Raspberry Pi Weather Station with Secure Scuttlebutt

Rick Carlino
3 min readJan 4, 2021

Secure Scuttlebutt is a replicating, peer-to-peer log database.

It is unique because it is theoretically possible to create a mesh of replicating nodes that do not have internet access. Information is “gossiped” over local WiFi. When users move between wifi networks, the “gossip” moves with them, enabling friends (and friends-of-friends) to pass data along the social mesh. (See: SSB Protocol Guide)

Currently, SSB is used for social apps that revolve around chat, microblogging and file sharing. The most popular apps are Patchwork (desktop) and Manyverse (mobile), which can be thought of as peer-to-peer Twitter-analogs. SSB’s gossip makes it well suited for these types of apps.

I have not yet seen SSB used for remote sensor networks, and I think it is a good use case for it, given the protocol’s delay tolerance and ability to store immutable log data.

This month’s project creates a weather station that uses SSB as a replacement for internet connectivity. Weather logs are transmitted via data mule until they eventually find their way to a peer with internet connectivity, at which point the weather data reaches the global mesh of SSB users on the internet.

To put that in more practical terms:

  1. An always-offline box in a remote location collects data.
  2. A data mule connects to the weather station’s internal wifi network while Manyverse (mobile SSB client) is open on the data mule’s mobile phone. The network is only a LAN- there is no internet access at the remote site.
  3. Within a few seconds, the weather station perform UDP peer discovery and exchange gossip.
  4. The data mule goes home.
  5. When the data mule connects to an internet-enabled wifi network at home, the data is gossiped to the wider SSB community (known as the “Scuttleverse”).

If you want to see the weather logs for yourself, you can follow its identity on the Scuttlverse:

@siAx0bQUNVIS3IH2d++o44atOzn8h7BuoULySDiKrHc=.ed25519

It’s a custom NodeJS application with a few dependencies:

  • node-dht-sensor: For reading an attached temperature sensor.
  • ssb-client: For writing to an append-only SSB feed.

The application reads the temperature once per day as well as at startup time. The reading is written to the machine’s SSB log so that it can be gossiped and replicated later.

Parts List

  • Wooden case (custom built)
  • DHT-22
  • Realtime Clock
  • Raspberry Pi 3 (the pi0 was too slow)
  • RaspAP-GUI (to create a WiFi LAN for UDP peer discovery)
  • USB battery pack

Operation

At startup, systemd initiates two services:

  • ssb-server, which provides an HTTP-based API for reading and writing to SSB feeds.
  • The custom Node app detailed in the section above.

The services run in the background and poll for temperature updates at startup and once per 24 hour period.

The full source code can be found on Github.

Improvements

This was a hobby project. Like all hobby projects, it is neither perfect nor optimized for real world conditions. If we were to spend more time on this project (we probably won’t), I would:

  • Use deep sleep to conserve battery
  • Add a solar cell for better off-grid support (we placed it in a spot that had grid power)
  • Automate the build process (currently, setup is a manual process)
  • Build a viewer app instead of publishing messages as "type": "post". Some users view the weather reports as "noise" on Patchwork.

Originally published at https://rickcarlino.com.

--

--

Rick Carlino

Open source software developer covering topics relating to computer programming, computer history and personal productivity. Co-founder @ farm.bot / fox.build