The OSOYOO Magic I/O Shield for Arduino is a powerful board for the beginners. With this Magic board, we can easily connect various sensors and actuators much easier than before.
In this project, we will show how to program OSOYOO Basic Board for Arduino, DHT11 sensor and 1602 I2C LCD module and make them work to together to display environment temperature and humidity.
OSOYOO Basic Board for Arduino (Fully compatible with Arduino UNO rev.3) x 1
OSOYOO Magic I/O Shield for Arduino x1
DHT11 Sensor x 1
I2C LCD 1602 x 1
OSOYOO 3-Pin PNP Cable x 1
OSOYOO 4-Pin PNP Cable x 1
USB Cable x 1
PC x 1
First, please plug Osoyoo Magic I/O shield into UNO board:
Then connect the modules to the ports of the Magic I/O shield (please move the switch on the board to 5V) with a 4-pin PNP cable and a 3-pin PNP cable as below:
I2C LCD 1602 Display – I2C
DHT11 – D3
More information about I2C LCD 1602 Display, please see Lesson14.
Notice: Shut off your battery or Unplug your power adapter when upload sketch code to OSOYOO Basic Board for Arduino.
After above operations are completed, connect the OSOYOO Basic Board for Arduino to your computer using the USB cable. The green power LED (labelled PWR) should go on.
Open the Graphical Programming softwareMixly, if Mixly is not English, you should change the language first:
You can download the code directly, then click “Open” in Mixly to choose the code you download:
Add the I2C 1602 LCD block and type the corresponding I2C address on it:
Click “Control” block;
Drag “Setup” to the blank space;
Click “Monitor” block;
Drag the “setup LCD” under “Setup” block, fit the two blocks;
Click “Monitor” block, drag the “LCD mylcd clear” under “setup LCD” block, fit the two blocks;
Click “Monitor” block, drag the “LCD mylcd print line” under “LCD mylcd clear” block, fit the two blocks;
For “LCD mylcd print line” block, edit “print line1” to “Humidity & temp”.
Click “Control” block;
Drag the “Delay” under “LCD mylcd print line” block, fit the two blocks and edit the parameter to “3000”;
Then right click to duplicate the last three blocks:
Display the temperature and humidity data on the i2c LCD.
Click “Monitor” block;
Drag “LCD mylcd clear” to the blank space;
Click “Control” block;
Drag the “Delay” under “LCD mylcd Clear” block, fit the two blocks and edit the parameter to “500”;
Click “Monitor” block;
Drag the “LCD mylcd row” under “Delay” block, fit the two blocks.
Then right click to duplicate the “LCD mylcd row” block five times, and edit the rows to “1 1 1 2 2 2”, columns to “1 10 15 1 10 15”.
Please edit the first text after “print” to “Temp : “, the third text to “C”, the fourth text to “Humidity : “, the sixth text to “%”.
Right click the second and fifth text block after “print” to delete the blocks:
Click “Sensor” block;
Drag the “DHT11 Pin” to fit the deleted block after “print” as the picture shows;
Edit the DHT11 Pin to “3“, and edit the second DHT11 parameter to “getHumidity“.
Click “Control” block;
Drag the “Delay” under “LCD mylcd row” block, fit the two blocks and edit the parameter to “2000”.
The whole program blocks are as following:
After above operations are completed, do as follows:
Click Save after programming is done.
Select the board type and serial port before uploading. For instause an UNO board, just select Arduino/Genuino Uno: if you use a Mega2560, select Arduino/Genuino Mega or Mega2560.
Select the serial device of the OSOYOO Basic Board for Arduino from the COM menu. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can disconnect your OSOYOO Basic Board for Arduino and re-open the menu; the entry that disappears should be the OSOYOO Basic Board for Arduino. Reconnect the board and select that serial port.
Next,upload the code. If the uploading fails, check and correct the code according to the prompts.
Finally, the status will change to ‘Upload success!’.
A few seconds after the upload finishes, you should now see the value of current humidity and temperature displayed on the LCD.