Best way to combine two sketches using interrupt and sleep time?



  • I want to combine the soil-moisture and the temp sketch into one. But they use different methods to sleep between redings. The soil-moisture-sketch uses interrupt and the temp sleeps for a specific time.

    What would be the best way to combine those two to be able to save as much battery power as possible? If I would be fine with them both reading the sensor-values for example every 5 min, can I just copy the loop block from the moisture sketch into the bottom of the loop of the temp sensor sketch?


  • Hardware Contributor

    You can actually combine both I think. Search for sleep. There is a sleep function

    bool sleep(int interrupt, int mode, unsigned long ms=0);
    

    that both listenes to an interrupt and wakes up after a certain time. The return boolean value indicates which one.


Log in to reply
 

Suggested Topics

  • 4
  • 17
  • 15
  • 4
  • 20
  • 2

11
Online

11.4k
Users

11.1k
Topics

112.7k
Posts