kidsIOT Mainboard×1 |
Motor×1 |
Temperature and Humidity Sensor×1 |
Wire×2 |
Battery Holder×1 |
Fan×1 |
USB Cable×1 |
Temperature and Humidity System LEGO Pieces×1 |
AA Battery(Not provide)×6 |
Process 1:
Process 2:
Process 3:
Process 4:
Complete:
Module |
kidsIOT Mainboard |
---|---|
Temperature and Humidity Sensor |
No.6 port(control pin is io23) |
Motor |
No.9 port(IN+control pin is io18,IN-control pin is io19) |
Connect the kidsIOT mainboard to your computer via USB cable, connect the external power supply and turn the DIP switch on the mainboard to ON end.
This block is used to initialize the OLED’s width, height and an I2C address.
This is a command block for drawing a straight line from the initial position x0:0 y0:0 to the final position x1:32 y1:16. The number in the block can be changed.
This is a command block that draws a recta with a width of 32 and a height of 16 from the initial position x:0 y:0, the numbers can be changed.
This is a command block that draws a rectangle with a width of 32 and a height of 16 from the initial position x:0 y:0, the numbers can be changed.
This is the command block that draws a circle with a radius of 8 starting from the initial position x:16 y:16.
This is the command block that fills a circle with a radius of 8 starting at an initial position of x:16 y:16.
This is the command block that draws a round rectangle with width 32, height 16, and radius 4 starting from an initial position of x:16 y:16.
This is the command block that fills a round rectangle with width 32, height 16 and radius 4 starting from initial position x:16 y:16.
This is the command block to draw a triangle from three positions x0:0 y0:0, x1:16 y1:0 and x2:8 y2:16.
This is the command block that fills the triangle between the three positions x0:0 y0:0, x1:16 y1:0 and x2:8 y2:16.
This is a command block for setting text size and color and background color.
This is the command block that sets the cursor position.
This is a command block for setting the way of printing strings on the OLED screen. “warp” means newline printing, “no-warp” means no newline printing.
This is the command block to set the OLED display pattern.
This is the command block to clear the OLED screen.
This is the command block to refresh the OLED screen and display the next content.
This is a command block that sets strings to start scrolling in a certain direction.
This is the command block to set stop scrolling.
① Initialize the OLED with width 128, height 64 and I2C address 0x78 (0x3c).
② Set the text size displayed on the OLED to 6x8, the text color to white and the background color to black.
③ OLED displays straight lines.
④ The OLED displays the straight line and delays 1 second.
⑤ The OLED displays rectangle and delays 1 second.
⑥ The OLED displays fill rectangle and delays 1 second.
⑦ The OLED displays circle and delays 1 second.
⑧ The OLED displays fill circle and delays 1 second.
⑨ The OLED displays round rectangle and delays 1 second.
⑩ The OLED displays fill round rectangle and delays 1 second.
⑪ The OLED displays triangle and delays 1 second.
⑫ The OLED displays fill triangle and delays 1 second.
⑬ The OLED displays smile face and delays 1 second.
⑭The OLED displays angry face and delays 1 second.
⑮ The OLED displays cry face and delays 1 second.
⑯ The OLED displays “↑” and delays 1 second.
⑰ The OLED displays “↓” and delays 1 second.
⑱ The OLED displays “←” and delays 1 second.
⑲ The OLED displays “→” and delays 1 second.
⑳ The OLED displays “❤” and delays 1 second.
㉑ Set the cursor position of the OLED to display the “Hello, KidsBlock” string at x:0 y:30 with a delay of 1 second.
㉒ Complete Program
Click to upload the above complete code to the kidsIOT motherboard. After powering up via the external power supply, the OLED display on the kidsIOT board displays various patterns and English letters.
Tap , click the “Actuator” module in the “Extension” , then select “DC Motor for esp32” and click to return to the programming interface.
Set the high and low level states of the motor INA pin and INB pin.
Set the high and low level status of the motor INA pin and the analog output value of the INB pin in certain channels. If the INA pin is in a high-level state, the smaller the INB analog output value, the faster the fan rotates; and if the INA pin is in a low-level state, the larger the INB analog output value, the faster the fan rotates.
① The pin INA of the motor module is IO18, the level is low, the INB pin is IO19, the channel is CH0 (LT0), and the analog output value is 0, then the motor does not rotate.
② Set the motor pin INA to low level and the analog output value of the INB pin to different values, then the motor rotates clockwise at different speeds.
③ Set the motor to stop rotating for 3 seconds.
④ Set the motor pin INA to high level and the analog output value of the INB pin to different values, then the motor rotates anticlockwise at different speeds.
⑤ Set the motor to stop rotating for 3 seconds.
⑥ Complete Program
Click to upload the above complete code to the kidsIOT motherboard. After powering up via the external power supply, the motor rotates clockwise at different speeds and stops for 3 seconds, and then rotates counterclockwise at different speeds and stops for 3 seconds.
Tap , click the “Sensor” module in the “Extension” , then select “DHT sensor for esp32” and click to return to the programming interface.
Initialize the pin and mode of the temperature and humidity sensor (dht11, dht21 or dht22).
Read the temperature and humidity from the temperature and humidity sensor.
① Set the baud rate to 15200.
② Initialize pin IO23 of the temperature and humidity sensor, and select the dht11 mode.
③ The serial port prints the read temperature and humidity in the current environment every 1 second.
④ Complete Program
Click to upload the above complete code to the kidsIOT mainboard. After powering up via the USB cable, click in the serial monitor and set the baud rate to 15200. Then the serial port prints the temperature and humidity in the current environment.
①Initialize pin IO23 of the temperature and humidity sensor, and select the dht11 mode.
② Initialize the width, height, I2C address, text size and color as well as background color of the OLED display.
③ Set the strings “Temper:” and “Humid:” to be displayed on the OLED.
④ Define variables “temperature” and “humidity”.
⑤ Store the read temperature data into the “temperature” variable. The read humidity data is stored in the “humidity” variable.
⑥ Display temperature data and humidity data at the corresponding position on the OLED.
⑦ Determine the temperature and humidity value in the environment detected by the temperature and humidity sensor. When the temperature is greater than 29°C, or the humidity is greater than 80%RH, the fan will be turned on.
⑧ Complete Program
Click to upload the above complete code to the kidsIOT mainboard. After powering up via the external power, the OLED displays the temperature and humidity in the current environment.
When the temperature reaches 29°C or the humidity reaches 80%RH, the motor will turn on to dissipate heat or dehumidify (the fan simulates heat dissipation and dehumidification, and the heat dissipation and dehumidification effect is average); otherwise, the motor will turn off to achieve automatic farm temperature and humidity control effect.
A: The sensor detects the temperature and humidity in the air, which is not waterproof. Please do not put the module into water.