Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. How fast is a (void) loop?

How fast is a (void) loop?

Scheduled Pinned Locked Moved Development
4 Posts 4 Posters 1.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Meister_Petz
    wrote on last edited by
    #1

    Hi,

    I would like to include a Temp Sensor into a Relay with Button Actuator.

    Of course, sending the Relay to sleep (like it is in the Temp Sketch) is not the most useful thing, So I thought I just put a counter into the loop and the temp reading is sent every x time and then the counter is set to 0. So my question would be, how long it takes to run a loop? Aproximately! I would be happy if the Temp is transmitted every 5-10 Minutes.

    Many Thanks

    Petz

    AWIA petewillP 2 Replies Last reply
    0
    • M Meister_Petz

      Hi,

      I would like to include a Temp Sensor into a Relay with Button Actuator.

      Of course, sending the Relay to sleep (like it is in the Temp Sketch) is not the most useful thing, So I thought I just put a counter into the loop and the temp reading is sent every x time and then the counter is set to 0. So my question would be, how long it takes to run a loop? Aproximately! I would be happy if the Temp is transmitted every 5-10 Minutes.

      Many Thanks

      Petz

      AWIA Offline
      AWIA Offline
      AWI
      Hero Member
      wrote on last edited by
      #2

      @Meister_Petz Hi, the best way is to take time as reference. Take a look at the sketch http://www.mysensors.org/build/display. This shows a flexible way of doing things "once in a while"

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dirk_H
        Contest Winner
        wrote on last edited by
        #3

        Hi,

        it would also be possible to just use a Timer and Interrupt. This might be not as flexible as using the time as reference but you dont have to deal with getting the RTC from the gateway etc.

        For an example have a look at:
        http://playground.arduino.cc/Deutsch/HalloWeltMitInterruptUndTimerlibrary

        regards
        Dirk_H

        1 Reply Last reply
        0
        • M Meister_Petz

          Hi,

          I would like to include a Temp Sensor into a Relay with Button Actuator.

          Of course, sending the Relay to sleep (like it is in the Temp Sketch) is not the most useful thing, So I thought I just put a counter into the loop and the temp reading is sent every x time and then the counter is set to 0. So my question would be, how long it takes to run a loop? Aproximately! I would be happy if the Temp is transmitted every 5-10 Minutes.

          Many Thanks

          Petz

          petewillP Offline
          petewillP Offline
          petewill
          Admin
          wrote on last edited by
          #4

          @Meister_Petz I use millis() for this exact thing and it has been working great for me for months.
          Here is an example of what I do:

          unsigned long DHTPreviousMillis = 0; // last time update. 
          long DHTDelay = 120000; // interval at which to do something (milliseconds)
          
          //Delay temperature and humidity for the length of time of DHTDelay without stopping the whole program
          unsigned long DHTCurrentMillis = millis();
          if(DHTCurrentMillis - DHTPreviousMillis > DHTDelay) {
          DHTPreviousMillis = DHTCurrentMillis;  
          //do something here
          }
          

          See http://stackoverflow.com/questions/10773425/performing-a-function-after-x-time for more details on Millis delay

          Hope that helps.

          My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          15

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular