This folder contains code running on Raspberry Pi
with DHT11
sensor.
The collected humidity
and temperature
are sent to piService
and shown in piClient
.
Theoretically, you can use any devices with any sensors.
The only thing you have to do is to send a PUT
request to your piService
instance.
Put
request URL:
http://localhost:31414/api/local-weather/<name>/<PI_API>
Payload:
{
"description": "<name>",
"temp": 25.2,
"humidity": 51.6
}
For hardware related information, please refer to Freenove DHT11 and Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi as it is used in my set up.
In principle, any DHT11 or even DHT22 shuold work with the script.
- Open the
.env
file inpiSensor
folder. - For now,
NAME
needs to behome
as it is hardcoded inpiClient
. - Specify the
PI_SERVICE_URL
to yourpiService
instance.- For example, via the nginx gateway
http://localhost:31414/api/
or directly tohttp://localhost:31415/
.
- For example, via the nginx gateway
- Specify the
PI_API
. ThePUT
request can only be made sucessfully with a correctPI_API
key.- It is the same key as the one in
.env
in the root folder when you executedocker compose
. - Keep this key secret as anyone with this key can update the weather data.
- It is the same key as the one in