sunflowerseastar / weather-station

Nerves + Raspberry Pi to Phoenix & Grafana

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weather Station

This is an Elixir Nerves project running on a Raspberry Pi. It is from the book Build a Weather Station with Elixir and Nerves: Visualize Your Sensor Data with Phoenix and Grafana, by Alexander Koutmos, Bruce A. Tate, and Frank Hunleth.

The Pi collects data via sensors and POSTs it to a Phoenix server. Data is visualized with Grafana.

# docker
cd weather_tracker
docker-compose up # visit localhost:3000 admin/admin

# phoenix (separate terminal)
cd weather_tracker
mix phx.server # API on localhost:4000

# to inspect/debug the device
ssh hub.local
RingLogger.attach()
exit()

The devices I have are slightly different from the ones used in the book:

deviceminebook
ambient light sensorVCNL4040VEML6030
atmospheric sensorBME280BME680
air qualityCCS811SGP30

Interfacing with the Pi

Getting values from sensors:

ssh hub.local

VCNL4040.start_link()
VCNL4040.get_measurement()

alias SensorHub.Sensor
gas = Sensor.new(Ccs811)
environment = Sensor.new(BMP280)
Sensor.measure(gas)
Sensor.measure(environment)

Update the Pi:

export MIX_TARGET=rpi4
cd sensor_hub
mix deps.get
mix firmware
mix upload hub.local

mix burn # for when it's hard-wired, not ssh

Components

CCS811 air quality / BME280 atmospheric sensor - https://www.sparkfun.com/products/14348

VEML6030 light sensor - https://www.sparkfun.com/products/15436

About

Nerves + Raspberry Pi to Phoenix & Grafana


Languages

Language:Elixir 97.8%Language:HTML 2.2%