Expert Thermocouple & RTD &Temperature Sensor Manufacturer.

+86 13816377866    |

Thermocouple head

build a apple homekit temperature sensor (dht22) device using a raspberrypi and a dht22

by:JVTIA     2020-10-28
I\'m looking for a low cost temperature/humidity sensor that I can use to monitor what\'s going on in my crawl space as I find this spring to be very wet and wet.
So I am looking for a sensor that is reasonably priced and I can put it there and monitor it remotely.
Dug up some locally available things online and showed after working with Raspberry PI and NodeMCU (
More will be introduced later).
I decided to use the DHT22 sensor.
Cheap price with temperature and humidity and local.
Update April 2019-
A few years after using the pigpiod library, I have switched to the bcm2835 library and posted new instructions here.
December 2016 -
After a few months of operation, I found that the accuracy of the humidity sensors varies greatly over time, and I no longer believe that these sensors can provide reasonable and accurate humidity information.
I am replacing all my equipment with a Bosch BME280 temperature/humidity/air pressure sensor.
So I created a new structure that shows how to connect this sensor to the RaspberryPI (
Temperature to connect RaspberryPI BME280 and NodeMCU/ESP8266 (Homebridge-MCUIOT ).
So I went to the local parts store and bought one
1-dht22/am230 temperature/humidity sensor4.
7K resistance 4 pin female head (Sensor side )
Female head of 5 Needles (RPI Side )
The heat shrink tube is narrow, wideOld serial mouse connects the sensor to the PI, and I use the cable of an old serial mouse I lay down.
Any used cable can be used as long as there are 3 wires.
The one I use has a few wires, but I keep it simple in red, yellow and black.
Then I welded the pin to my wire.
My pins are curled, but I can\'t get them to curl properly, so I switched to welding instead.
After welding the pins, I inserted them into the 5-pin female connector, red in 1, yellow in 4, and black in 5.
RPI connections like this are wired> 5 needles-> Description -
> Wire color 1-> 1 -> 3. 3 VDC Power -> Red 7 -> 4 -> GPIO4 -> Yellow 9 -> 5 -> Ground -
> At this end we use 4 pin female connector, resistance and heat shrink tube.
Weld the red and yellow wires to a pin and place the resistance between them.
Also cover these with heat shrink so you won\'t be short.
Then weld the black wire to a pin.
Follow these steps to insert the pin into the 4 pin head-Red2 -Yellow3 -Empty4 -
Then cover the wire with a larger heat shrink tube.
After turning off the RPI power supply, carefully connect the 5-pin mother to the GPIO connection, and the red line in pin 1 is aligned with pin 1 on the GPIO connector.
The head should cover only the first 5 odd GPU pins.
For the sensor side, align the pins on the sensor with the connector and ensure pin 1 of the sensor (
On the left)
, Connected to pin 1 of the title (
Red Line).
I can\'t see the color of the wire anymore after turning on the heat shrink, so I marked it with sharpie.
Since they are many other guides for setting up Raspberry pi, I\'m not going to repeat this here, but I\'m assuming you set up RPI using Node with raspberry Jessie.
JS is installed and homebridge is running.
They already have a lot of getting started guides on home bridges to cover this. 1.
Install homebridge-
Dht installed using command sudo npm-g homebridge-dht2.
Update your configuration. ~ Json file in.
Family Bridge 1 with the following functions.
Install pigpiod Library sudo apt through these commands-
Get update sudo apt-
Get python to install pypio-pigpio python3-pigpio2.
Copy dht22 to local/bin/dht22 and execute.
After installing on my RPI, it is located in/usr/lib/node_modules/homebridge-dht.
Your installation may place it in a different location.
Please check.
Dht/dh22sudo cp/usr/lib/node_modules/homebridge-
Dht/dht22/usr/local/bin/dht22 sudo chmod a x/usr/local/bin/dht22.
At this point, you should be able to test the DHT22 sensor using the command DHT22, which should respond at 0 18. 4 C 51.
0% this is an optional step that allows you to remotely monitor the temperature of the Raspberry pi cpu. 1.
Create a file in/usr/local/bin/cpu temp container 2.
Set the file exectuablechmod to x/usr/local/bin/cpu 3.
Update your configuration. ~ Json file in.
Home bridge, replace the attachment section with the following: start home bridge, your log file should be like this [
9:37:31 in the afternoon
Loading plugin: homebridge-dht [
9:37:31 in the afternoon
Registered attachment \'homebridge-dht. Dht\'[
9:37:31 in the afternoon---[
9:37:31 in the afternoonLoaded config.
Json with 2 attachments and 0 platforms. [
9:37:31 in the afternoon---[
9:37:32 in the afternoon
0 platform loading. . . [
9:37:32 in the afternoon
2 accessories. . . [
9:37:32 in the afternoon[cputemp]
Initialize the accessories for Dht. . . [
9:37:32 in the afternoon[cputemp]INIT: cputemp[
9:37:32 in the afternoon[
Temperature/humidity sensor
Initialize the accessories for Dht. . . [
9:37:32 in the afternoon[
Temperature/humidity sensor
INIT: Temp/humidity sensors scan this code on iOS devices using the HomeKit app paired with Homebridge:45-
154 [
9:37:32 in the afternoon
Homebridge is running on port 51826.
Start your favorite homekit client and pair it with your new accessory.
You should then see the new temperature/humidity sensor.
If you have a question, please ask a question on GitHubAfter after several people have asked. I think I will include the notes needed to add a second sensor.
For wiring, take a look at the image in the attachment, which is the image of the second sensor I shared with hector305.
This is config for the updated profile. json for that.
Custom message
Chat Online 编辑模式下无法使用
Chat Online inputting...