Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:practical:hardware:sut:stm32:emb4_1 [2024/04/22 17:40] – [Prerequisites] ktokarzen:iot-open:practical:hardware:sut:stm32:emb4_1 [2024/04/22 17:56] (current) – [Result validation] ktokarz
Line 38: Line 38:
 #include <DallasTemperature.h> #include <DallasTemperature.h>
 </code> </code>
-<note important>Also, remember to add the LCD handling library, as present in the EMB9 scenario, unless you decide to use another output device.</note>+<note important>Also, remember to add the LCD handling library, as present in the STM_9 scenario, unless you decide to use another output device.</note>
  
 === Step 2 === === Step 2 ===
 Declare the 1-Wire GPIO bus pin, 1-Wire communication handling object, sensor proxy and a variable to store readings: Declare the 1-Wire GPIO bus pin, 1-Wire communication handling object, sensor proxy and a variable to store readings:
 <code c> <code c>
-#define ONE_WIRE_BUS 6+#define ONE_WIRE_BUS D0
 static OneWire oneWire(ONE_WIRE_BUS); static OneWire oneWire(ONE_WIRE_BUS);
 static DallasTemperature sensors(&oneWire); static DallasTemperature sensors(&oneWire);
Line 55: Line 55:
   sensors.begin();   sensors.begin();
 </code> </code>
- 
  
 === Step 4 === === Step 4 ===
 Read the data: Read the data:
 <code c> <code c>
 +  sensors.requestTemperatures();  
   if (sensors.getDeviceCount()>0)   if (sensors.getDeviceCount()>0)
   {   {
     tempDS = sensors.getTempCByIndex(0);     tempDS = sensors.getTempCByIndex(0);
-  } 
-  else 
-  { 
-    // Sensors not present (broken?) or 1-wire bus error 
   }   }
 </code>  </code> 
Line 75: Line 71:
   * ''sensors.getAddress(sensorAddress, index)'' - reads device address given by ''uint8_t index'' and stores it in ''DeviceAddress sensorAddress''.   * ''sensors.getAddress(sensorAddress, index)'' - reads device address given by ''uint8_t index'' and stores it in ''DeviceAddress sensorAddress''.
  
-The library can make non-blocking calls, which can also be implemented using timers, as presented in the scenario [[en:iot-open:practical:hardware:sut:esp32:adv1_1|]]. 
  
 ==== Result validation ==== ==== Result validation ====
 The observable temperature is usually within the range of 19-24C. If you find the temperature much higher, check your code, and if that is okay, please contact our administrator to inform us about the faulty AC. The observable temperature is usually within the range of 19-24C. If you find the temperature much higher, check your code, and if that is okay, please contact our administrator to inform us about the faulty AC.
  
 +===== FAQ ===== 
 +**I've got constant readings of value 85.0. What to do?**: Check if GPIO is OK (should be D0), check if you initialised controller class and call the function ''sensors.requestTemperatures();''. Give the OneWire bus and the sensor some recovery time (at least 250ms) between consecutive readings.
  
 <WRAP noprint> <WRAP noprint>
en/iot-open/practical/hardware/sut/stm32/emb4_1.1713807627.txt.gz · Last modified: 2024/04/22 17:40 by ktokarz
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0