This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:practical:hardware:sut:stm32:emb4_1 [2024/04/22 17:40] – [Prerequisites] ktokarz | en:iot-open:practical:hardware:sut:stm32:emb4_1 [2024/04/22 17:56] (current) – [Result validation] ktokarz | ||
|---|---|---|---|
| Line 38: | Line 38: | ||
| #include < | #include < | ||
| </ | </ | ||
| - | <note important> | + | <note important> |
| === 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 | + | #define ONE_WIRE_BUS |
| static OneWire oneWire(ONE_WIRE_BUS); | static OneWire oneWire(ONE_WIRE_BUS); | ||
| static DallasTemperature sensors(& | static DallasTemperature sensors(& | ||
| Line 55: | Line 55: | ||
| sensors.begin(); | sensors.begin(); | ||
| </ | </ | ||
| - | |||
| === Step 4 === | === Step 4 === | ||
| Read the data: | Read the data: | ||
| <code c> | <code c> | ||
| + | sensors.requestTemperatures(); | ||
| if (sensors.getDeviceCount()> | if (sensors.getDeviceCount()> | ||
| { | { | ||
| tempDS = sensors.getTempCByIndex(0); | tempDS = sensors.getTempCByIndex(0); | ||
| - | } | ||
| - | else | ||
| - | { | ||
| - | // Sensors not present (broken?) or 1-wire bus error | ||
| } | } | ||
| </ | </ | ||
| Line 75: | Line 71: | ||
| * '' | * '' | ||
| - | The library can make non-blocking calls, which can also be implemented using timers, as presented in the scenario [[en: | ||
| ==== 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 '' | ||
| <WRAP noprint> | <WRAP noprint> | ||