The project objectives were to create a way to remotely monitor countryside house temperature with Raspberry Pi and sensors like DS18B20, and to automate the control of emergency heating with relays and GPIOs, to protect water pipes in the winter. The POC was ready in under two weeks, however later on I decided to push the project further and use it as a sandbox to broaden my skill set.
- [GitHub] bartoszadamczyk/weather-station-cloud
- /app - frontend React App that displays live
readings. Tech stack:
Netlify
,TypeScript
,React
,Immer
,WebSockets
,i18next
,antd
,Sentry
,Jest
,ESLint
,GitHub Actions
- /serverless - serverless API bundled with
Serverless and hosted on AWS Lambda. Tech stack:
Serverless
,TypeScript
,DynamoDB
,SQS
,AWS API Gateway (with WebSockets)
,AJV
,Sentry
,Mocha
,Chai
,Sinon
,ESLint
,GitHub Actions
- /terraform - Tech stack:
Terraform
,TFLint
,GitHub Actions
- /app - frontend React App that displays live
readings. Tech stack:
- [GitHub] bartoszadamczyk/weather-station-rpi - raspberry Pi worker
deployed with balena.io. Tech stack:
Raspberry Pi
,Linux
,balena.io
,Docker
,Python
,AsyncIO
,SQS
,Mypy
,Black
,Flake8
,Sentry
andGitHub Actions
Fast, accurate, and cheap temperature sensor. You can't go wrong with that one. It is available standalone as well as a pre-wired waterproof version.
- Depending on the housing and cable used it can measure a temperature from -55°C to +125° with a decent accuracy of ±0.5°C.
- Each sensor has a unique device ID.
- It can work with both 3.3v and 5v.
- Sensor is using 1-Wire protocol that can support multiple sensors connected to one GPIO.
GPIO 4
is used by default, you can connect all your sensors to one GPIO.- Especially for longer cables pull up resistor of 4.7k-10k ohm is required.
You can get it on The PiHut , Adafruit or Amazon.
A basic sensor that is quite slow and buggy. On paper, you can get a reading every two seconds however protocol that is used by this sensor is quite often crashing, hence in practice, you can the readings only a few times per minute. Because of the errors in the protocol, the reading is sometimes incorrect. If you need just a temperature sensor, go for DS18B20. If you got some extra budget go for the BME280 or BME680.
- Temperature readings in the range of -40 to 80°C with ±0.5°C accuracy.
- Humidity readings in the range of 0-100% with ±2-5% accuracy.
- It can work with both 3.3v and 5v.
- It requires one GPIO per one sensor together with the pull-up resistor.
- This project suggests using
GPIO 17
,GPIO 27
,GPIO 22
,GPIO 23
andGPIO 24
. - No unique id, GPIO number is used as an ID.
- Pull up resistor of 4.7k-10k ohm is required.
You can get it on The PiHut , Adafruit, or Amazon.
Overall very nice sensor, accurate, stable and versatile. On board chip is from Bosch, supports temperature, humidity, pressure, altitude and gas, although the last two require calibration.
You can get it on The PiHut and Pimoroni
You can use GPIOs as an output for your alarms. This can be used to control relays or other devices. Remember to protect your GPIOs! Don't connect relays directly to your Raspberry Pi. This is going to break your board! You need some transistors, diodes, resistors and preferably an optocoupler to protect your device. If you don't want to build it yourself, buy a ready-made relay board. Just remember to pick one compatible with Raspberry Pi 3v3 GPIOs, like the one from WaveShare.
- WaveShare Relay board is using
GPIO 26
,GPIO 20
,GPIO 21
. - You can also use
GPIO 19
,GPIO 16
,GPIO 13
,GPIO 6
,GPIO 12
andGPIO 5
.
You can get it on The PiHut or Amazon.
- If you want to use the dashboard, follow the steps
in Cloud API. You need
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
,AWS_DEFAULT_REGION
andAWS_SQS_DATA
from there. - Create a free balena.io account (10 devices are for free!).
- Create your first
balena application
. Flash your device, connect to the internet and turn it on. - Fork and clone this repository. You can deploy code to balena with:
- Github actions
- Edit deploy workflows to match your setup:
- Use correct docker file for your device (for rpi2 you can use rpi3)
- In your
Repository
->Settings
->Actions secrets
add:BALENA_API_TOKEN
BALENA_APPLICATION_NAME_RPI_2
or any other vars you want to use
- Edit deploy workflows to match your setup:
- Or manually with git push
- Copy correct
Dockerfile
from docker/ directory into yourroot dir
- Git push to balena
- Copy correct
- Github actions
- In balenaCloud, in
Device Configuration
setDefine DT overlays
to"w1-gpio"
. - Great! Your Weather Station should work and already detect DS18B20 Temperature sensors!
- Now, have a look at the Device Configuration below to enable more features.
You can configure more features with Device service variables
:
Feature | ENV VARIABLES |
Format |
---|---|---|
Override BALENA_DEVICE_UUID |
DEVICE_ID |
string |
Enable Sentry | SENTRY_DSN , SENTRY_ENVIRONMENT |
string |
Enable DHT22 sensors | DHT22_PINS |
[17] |
Enable BME680 sensor | ENABLE_BME680 |
True |
Enable Relays | RELAY_PINS |
[26,20,21] |
Enable LiveSQSConsumer | AWS_ACCESS_KEY_ID ,AWS_SECRET_ACCESS_KEY , AWS_DEFAULT_REGION and AWS_SQS_DATA |
string |
- Raspberry Pi 2 (armv7hf and up)
- Raspberry Pi 3
- Raspberry Pi 4
pip install -r requirements.txt
pip freeze > requirements.txt
./lint.sh
./test.sh