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.
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.