File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
libraries/MySensors/examples/DallasTemperatureSensor Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ void setup()
21
21
{
22
22
// Startup OneWire
23
23
sensors.begin ();
24
+ // requestTemperatures() will not block current thread
25
+ sensors.setWaitForConversion (false );
24
26
25
27
// Startup and initialize MySensors library. Set callback for incoming messages.
26
28
gw.begin ();
@@ -44,7 +46,12 @@ void loop()
44
46
gw.process ();
45
47
46
48
// Fetch temperatures from Dallas sensors
47
- sensors.requestTemperatures ();
49
+ sensors.requestTemperatures ();
50
+
51
+ // query conversion time and sleep until conversion completed
52
+ int16_t conversionTime = sensors.millisToWaitForConversion (sensors.getResolution ());
53
+ // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
54
+ gw.sleep (conversionTime);
48
55
49
56
// Read temperatures and send them to controller
50
57
for (int i=0 ; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
@@ -62,6 +69,3 @@ void loop()
62
69
}
63
70
gw.sleep (SLEEP_TIME);
64
71
}
65
-
66
-
67
-
You can’t perform that action at this time.
0 commit comments