Case 05: Water Temperature Detection
Contents
7. Case 05: Water Temperature Detection#
7.1. Introduction#
Fishes are poikilotherm whose body temperature changes as the ambient water temperature changes, thus, the water temperature plays a vital role in the growth of fishes.
7.2. Function#
Dectect the water temperature with the DS18B20 sensor and display them on OLED screen.
7.3. Products Link#
7.4. Picture#
7.5. Hardware Connection#
Connect DS18B20 to P1 and the OLED to IIC on IoT:bit.
7.6. Software Programming#
Click “Advanced” in the MakeCode to see more choices.
For programming, we need to add a package: click “Extensions” at the bottom of the MakeCode drawer and search with “iot-environment-kit” in the dialogue box to download it.
Notice: If you met a tip indicating that some codebases would be deleted due to incompatibility, you may continue as the tips say or create a new project in the menu.
7.7. Program#
Initialize the OLED screen as 128×64.
Set DS18B20 sensor to connect to P1 and save the returned value as variable “Temp”.
Clear the OLED screen and display the water temperature.
7.8. Result#
The OLED displays the water temperature and refreshes every 5 seconds.