phrrngtn / federated-data-logging

MIT License
0 stars 0 forks source link

get sensor data logging to MQTT #1

Open phrrngtn opened 2 years ago

phrrngtn commented 2 years ago

get data from JFC's sensor HAT on the Pi logging to MQTT (and thence to influxdb and grafana)

jfculhane commented 2 years ago

Here is some python for the hat. This just shows the basic weather. Just noticed there is a file called mqtt-all.py in the example directory but it doesn't run. The hat I have is just indoor while some of the examples are for the outdoor hat with particulate sensors.

`import time from bme280 import BME280

try: from smbus2 import SMBus except ImportError: from smbus import SMBus

import logging

logging.basicConfig( format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s', level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S')

logging.info("""weather.py - Print readings from the BME280 weather sensor.

Press Ctrl+C to exit!

""")

bus = SMBus(1) bme280 = BME280(i2c_dev=bus)

while True: temperature = bme280.get_temperature() pressure = bme280.get_pressure() humidity = bme280.get_humidity() logging.info("""Temperature: {:05.2f} *C Pressure: {:05.2f} hPa Relative humidity: {:05.2f} % """.format(temperature, pressure, humidity)) time.sleep(1) `

jfculhane commented 2 years ago

Would be great to get this to write to influxdb.

jfculhane commented 2 years ago

Actually here is the github for the pimoroni hat. https://github.com/pimoroni/enviroplus-python

jfculhane commented 2 years ago

Really clear walkthrough on Grafana, Telegraf and InfluxDB on the PI. Managed to get InfluxDB running but had a huge package issue with installing Telegraf on the PI. "E: unable to locate package telegraf".
https://www.youtube.com/watch?v=-zMWWCzFiH0

jfculhane commented 2 years ago

I managed to get the pimoroni live sensor data working through to grafana via influxdb and telegraf. Had to reinstall influx. Just have this odd issue in the grafana dashboard where it's not in sync to current time. It's 4 hours off no matter how I set the time zone preferences. It's all UTC out of influxDB which seems fine. Also playing around with VNC and works pretty well to ipad and android over wifi. Need to try the VNC server at some point to see it beyond my LAN. https://photos.app.goo.gl/YD7Hd3MFDxYvRiYM9

I'll post the python. Maybe set it up as a separate project. I want to try and add the light sensor into this also. Just letting it run all night for the first time.