Overview The purpose of this experiment is to make a project involving switches and sensors with arduino.
Materials 1 Arduino development board 2 temperature and humidity sensor 3 resistor 4 switch 5 Jumper wires
Circuit connection method We used ThinkerCAD to create the circuit diagram.
Circuit simulation after running the code.
Production process Connect the switch and DHT11 temperature and humidity sensor to the Arduino as per the next diagram.
First, install the library: DHT and upload the sample code.
1 Including DHT library: 2 Define the pin of the DHT sensor connection, connected to digital pin 2. 3 Define the DHT sensor type: DHT11. 4 Initialize a dht object named DHT using the pin and the previously defined type. 5 In setup (), initialize the serial monitor at a baud rate of 9600 for debugging. 6 Use the.begin () method to initialize the DHT sensor. 7 At the beginning of loop (), there is a 2-second delay. This delay is needed to give the sensor enough time to take a reading. 8 Use the readHumidity () method on dht objects to save the humidity in the h variable. 9 Read the temperature using the readTemperature () method. 10 All readings are displayed on the serial monitor.
Achievement display When the switch is pressed, the temperature and humidity are read and the results are displayed on the serial monitor.
Summary: Through this experiment, we successfully learned how to use the switch and sensor, and we can get the relevant information we want through the sensor.
Experiment 6-Environmental monitor
Overview The purpose is to build an environment monitor with arduino.
Materials 1 Arduino development board 2 temperature and humidity sensor 3 LDR 4 resistor 5 Jumper wires
Circuit connection method We used ThinkerCAD to create the circuit diagram.
Production process Use Arduino Uno to drive the DHT11 temperature/humidity module and photoresistor. After the program is run, the sensor will display the temperature, humidity and light intensity of the sensing test through the serial port monitor of the Arduino IDE.
Achievement display When the switch is pressed, the light intensity and temperature/humidity are read and the results are displayed on the serial monitor.
Summary Through this experiment, we have successfully learned how to use photoresistor and temperature/humidity sensor to build environmental monitoring equipment, and we can obtain the relevant information we want through the environmental monitoring equipment built.