The Raspberry Pico W is a cheap microcontroller (around €8) that can control sensors and access a WIFI network. With a bit of soldering and MicroPython, you can have it serving JSON data over your local network, then log it with a database and visualise it in a dashboard. Here I’m just going to briefly describe my setup as the basis for later blog articles.
The graphic above shows the overall setup. We’ve got:
- One or more Picos, with a sensor connected to each,
- A wifi connection from the Pico(s) to the router
- A Raspberry Pi
- The Pi runs Manjaro
- It has Docker installed
- The Ambient Data logger (a small Python application) runs inside a Docker container. It queries the Picos every 10 minutes and writes data to the Postgres DB
- The Postgres DB runs inside another Docker container, and this is where data is logged
- Yet another Docker container holds a Grafana installation, exposed on port 80 for access via the network. Grafana queries the Postgres DB regularly
- Anyone on the local network can log into Grafana (if they have an account) and see the visualised data
The Pico W
I soldered a sensor to each Pico W (A DHT-22 to one, and a BME280 to another) and wrote some MicroPython code to listen for requests over the network, take a reading, then respond to the request with JSON data.
I’ve got a Raspberry Pi running Manjaro Linux, which has Docker installed. As described above, a custom-written script to log and store the data is in one container, a Postgres database in another, and a Grafana installation in another.
I tried to keep the setup as modular as possible so that I can easily extend it and store the configuration in a Git repository. That way, if anything breaks I can recreate my setup relatively easily.
That’s it for now!