logo

Full-stack Developer Portfolio | Hubert Pawlak

DS18B20 Remote Sensor

This is a simple program to periodically read temperatures from 1-Wire sensors and send them to a specified endpoint. Easy to run as a systemd service. Below is my systemd unit configuration file.

[Unit]
Description=sending temperature readings
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/home/pi/ds18b20-remote-sensor/ds18b20-remote-sensor start
WorkingDirectory=/home/pi/ds18b20-remote-sensor
Restart=on-failure
User=pi
Group=pi

[Install]
WantedBy=default.target
screenshot with CLI usage of ds18b20-remote-sensor server

The code is written and tested with Go. It works flawlessly 24/7. I chose to send JSON using HTTP POST requests to fit both standard and serverless architecture.

screenshot of the program running in verbose mode showing serialized readings and the HTTP response codes

I personally run it on a cheap Raspberry Pi Zero W in a dusty environment. There are probably cheaper solutions as you only need a way to get readings from the sensors and send those values.

photo of a plugged in Raspberry Pi Zero W hanging on the wall with wires attached to the GPIO header