2.2 Sensors
This exercise builds upon the hardware setup from the previous, but now we add a temperature and humidity sensor to the ensemble.
Last updated
Was this helpful?
This exercise builds upon the hardware setup from the previous, but now we add a temperature and humidity sensor to the ensemble.
Last updated
Was this helpful?
Again, we start easy. After the website button is pressed, read the temperature sensor information every five seconds and print it to the console!
Possible solution:
Now also print the humidity sensor value to the console. Let the user know which value is currently printed, including a short sentence with the correct unit.
Possible solution:
We slowly become familiar with the sensors. Let’s try to light up the LED in red when the temperature exceeds a threshold - say 30° Celsius. Let the user enter the threshold.
Optional: Add a permanent display area for the temperature that changes its background color from green to red as the threshold exceeds the limit.
Possible solution:
Possible solution:
Possible solution:
Possible solution:
Build upon the result of , but now also make the button blink slowly in white color when the threshold exceeds a limit. This is to indicate that we need some user interaction to fix the situation.
Build upon the result of and turn the light off again when the hardware button is pressed. The button should stop blinking, too. Make sure that the LED only turns red again when the temperature falls below the threshold and exceeds it again afterwards. When the temperature stays > 30° C and the hardware button was already pressed, the LED should not turn red again.
Now, instead of turning red, make the LED light up in green (OK), yellow (WARNING), and red (CRITICAL) depending on the temperature. Find useful ranges for the thresholds and assign the colors accordingly. The human interaction from should only be prompted when the critical threshold is exceeded!