Raspberry Pi Weather Station with Secure Scuttlebutt
Published: 2021-03-10 23:39:24

---
title: Raspberry Pi Weather Station with Secure Scuttlebutt
published: true
date: 2019-04-06 14:33:00 UTC
tags: 
canonical_url: 
---

# A Secure Scuttlebutt Weather Station

[Secure Scuttlebutt](https://scuttlebot.io/more/protocols/secure-scuttlebutt.html) 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](https://ssbc.github.io/scuttlebutt-protocol-guide/))

Currently, SSB is used for social apps that revolve around chat, microblogging and file sharing. The most popular apps are [Patchwork](https://github.com/ssbc/patchwork) (desktop) and [Manyverse](https://www.manyver.se/) (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”).

# See It in Action

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

```
@siAx0bQUNVIS3IH2d++o44atOzn8h7BuoULySDiKrHc=.ed25519

```

![](https://rickcarlino.com/images/2019/weather_station/patchwork.png)

![](https://rickcarlino.com/images/2019/weather_station/enclosure.jpg)

# How We Built It

It’s a [custom NodeJS application](https://github.com/FoxDotBuild/WeatherStation) 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](https://github.com/billz/raspap-webgui) (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](https://github.com/FoxDotBuild/WeatherStation).

### 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.