The assignment for this week is to add a sensor to a board that we designed and then measure sometihng. However, due to fablab closure, I worked with an Arduino Uno to read the sensor data. Also, the group assignment was not possible to do for the same reasons mentioned above.
I connected my Arduino UNO with DHT11 - a humidity and temperature sensor
Single-bus data format is used for communication and synchronization between MCU and
DHT11 sensor. One communication process is about 4ms.
this means that the sensor uses only 1 pin to deliver data in addition to the 5V and GND pins. Convenientyl, the pin that was used has a built-in pull-up resistor so there was no need to add a resistor.
from the datasheet, we can find that the sensor sends 40bit for a complete data transmission in the following format:
8bit integral RH data + 8bit decimal RH data + 8bit integral T data + 8bit decimal T
data + 8bit check sum.
The sensor was inserted into a breadboard and the pins were connected to their corresponding pins on the Arduino. The sensor data pin was connected to Pin 7.
Code and library
To help with reading the data from the sensor, DHT library was downloaded in Arduino IDE (Sketch >> include Library >> Manage Libraries)
Then by going to File >> Examples >> DHT Sesnor Library >> DHTtester , then running the example code. The reading is then displayed ont the serial monitor.
To make things look nicer, I decided to add an LCD display for the sensor data. I will not go through the fine details of connecting an I2C lcd to the arduino since it's beyond the scope of this assignment. But the main steps were: install liquidcrystal_I2C library , then type the following in the example shown earlier:
Then in the setup section of the code we need to initiate the lcd by typing the following:
Finally, in the code Serial.print() should be replaced by the following: