FIRST Robotics Competition is the ultimate Sport for the Mind as it combines the rigors of science and technology...
1. Screen: OLED, 1.3" Display SH1106, I2C white color ---- PID: 18283
2. Sensor: Digital Humidity and Temperature Sensor DHT22 ---- PID: 7375
4. Power: This cable can only connect with a computer USB port and the cable is also used for data transfer between the IDE and Arduino board. USB CABLE, A TO B, M/M, 0.5M (1.5FT) ---- PID: 29862
Or you can use this to power the board: 5V 2A AC/DC Adapter ---- PID: 10817.
The DHT22 sensor sends serial data to pin 2. So, connect the second pin from left, the "SDA" pin should be connected to pin 2.
For the SSH1106 display, it uses the analog pin to transmit. The circuitry of the screen will be "SCL" pin to Arduino's "A5" and "SDA" pin to Arduino's "A4". While the pixel position data is transmitting continuously, the display function in the program only triggers the command once every time it reads the data from the sensor.
Both the sensor and screen can use the 3.3V to power on Arduino as a DC power input. To power, we need to connect both the "VCC" pins to Arduino’s "3.3V". And the "GND" pins can be simply connected to the "GND" pin on the Arduino board.
Use the USB A to B cable, connect the Arudino to computer.
"u8glib" for SSH1106 screen from Olikraus.
"DHT sensor library" for DHT22 sensor from Adafruit. You should download the two libraries: DHT22 sensor library: https://github.com/adafruit/DHT-sensor-library
And use “manage library” in IDE to make them unzipped. Online instruction of managing libraries: https://github.com/adafruit/DHT-sensor-library
Test coe for DHT22 sensor serial port (which is inside the DHT22 library>>examples):
(You can skip this part.)
It just to test the DHT22 sensor reads data normally.
Then, initialize the pin circuitry for the Arduino board. Because the sensor library requires the data to declare the object.
And you can test the sensor's data by monitoring the output data through digital pin 2 by using the function called "Serial.print()". Because the frequency of data transmission is roughly 1 reading every 2 seconds (which is 0.5 Hz), when programmed in Arduino IDE, we need to set the delay inside the loop function to be more than 2 seconds. So there is a "delay(2000)" inside the loop function. This ensures the data will be refreshed frequently. In the function "draw", get the data from the serial data port and put them into to float numbers using the "readHumidity" and "readTemperature" functions.
Print out the humidity and temperature using the print function in the "u8glib" file. You can adjust the position by changing the number in the "setPrintPos" function. The print function can directly show the text and numbers.
To set up the hardware, give the serial port a 10 seconds delay. Then call the begin function for the sensor. According to my circuit, my screen was upside down. So I also included a "setRot180" function to rotate the display.
The loop function of the Arduino board is the main function. It keeps calling the draw function to display the text and data every time the sensor is refreshed.
The screen looks like this:
You can disconnect the Arduino UNO from your computer and power it using a 5V DC power adaptor connecting to its 2.1mm power jack. It stores the program inside its drive and can continuously run the program again after being powered.