

Open KidsBlock and connect the board to computer. Choose File –> Load from your computer.

Choose path D:\Code\2.Code_kidsIOT and open 4.1Temperature detection.sb3.

Click
to connect to port and then
.

Q :After uploading the code, with temperature rises, the fan starts to work, yet the monitor stops outputting temperature values, with a prompt reading:

A :The power supply may be insufficient, so an external power supply may be required.


Code Blocks
|
Blocks |
Code block |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

Build blocks:
Click
to import libraries 18b20 and DC Motor for esp32.

Initialization
Initialize the serial monitor.


Main Code
Loop: DS18B20 sensor reads the temperature values and the serial monitor prints them. Then, it determines whether the value is greater than 30°C(this threshold is adjustable).
Temperature > 30: fan rotates to cool down.
Temperature < = 30: fan stops working.




