With the advent of the smart home era, IoT devices for temperature and humidity monitoring and related services are overflowing. However, from a developer's point of view, there are a few things that are disappointing. Most services collect data in 1-minute or 1-hour increments, and this data collection cycle may not be sufficient in situations where sophisticated monitoring is required.
We decided to work on this project to solve this problem. We are trying to manage the smart home environment more efficiently through more detailed data collection and real-time notifications. And let's implement this using our product Watab.
Part 1: Project OverviewIt's a good idea to read it first.
In this article, I want to set up a basic data collection environment by setting up the Raspberry Pi hardware and connecting a temperature and humidity sensor.
If connecting to the router is difficult, Angry IP Scanner (https://angryip.org/You can also find out the Raspberry Pi's IP by searching for IPs with port 22 (SSH) enabled using a tool such as).
Even if you do the above, if the IP is unknown, you can directly view the Raspberry Pi console screen by connecting the HDMI port to a monitor and connecting a USB keyboard to check for wireless LAN connection errors, etc.
The Raspberry Pi has a header with 40 pins. Since the Zero series is not equipped with a pin header as standard, soldering the pin header is required.
Those who have trouble soldering can also use the basic series 2, 3, 4, and 5. The arrangement of pin headers in the Raspberry Pi product series is generally similar; for example, GPIO pin 4 is in the same position as the Zero series and other series.
Connect the top 3 pins to the sensor via a cable.
For the DHT22 sensor, the pin arrangement (from left) is shown below.
The case of a module soldered to a PCB is as follows.
The module soldered to the PCB has a pull-up resistor (pull-up resistor) connected to the board. The pull-up resistor keeps the input pin high (high voltage) by default to keep the logic data transmitted through the DATA line stable. Generally, resistance values of 4.7 kΩ to 10 kΩ are used. To reduce errors during communication with the temperature sensor, it is recommended to use a module with a pull-up resistor.
Raspberry Pi pin sensor pin (module) Pin 1 - DC 3.3vPin 1 - vccPin 7 - GPIO4pin 2 - DataPin 9 - groundPin 3 - GND
Once the 3 wires are connected to each other as above, the hardware is all ready.
Connect to Raspberry Pi with ssh and update the OS.
To use GPIO pins on Linux-based devices such as the Raspberry Pi, an additional installation is required.
Each project uses a virtual environment to manage different library versions and dependencies independently. This allows you to implement an isolated environment for each project without touching the global Python environment.
Let's write basic code to obtain data from the DHT22 sensor using python. adafruit_dht (https://docs.circuitpython.org/projects/dht/en/latest/) A library was used, and only a message was output when a sensor communication error occurred.
Write stable code that can be used in actual operation.
Write code to collect data from sensors and return results as json. It makes up to 5 attempts, and records the presence or absence of errors only in the json data without outputting an error message.
In Part 3, we'll look at how to send collected temperature and humidity data to the Watap monitoring system. We'll cover the process of configuring the WhATap dashboard and notifications by setting up WhaTap Focus and implementing data transmission. We'll see you in the next episode!
Part 1: Project Overview (link)
Part 2: Hardware configuration (this article)
Part 3: Watap integration
Part 4: Mobile app development