Based off https://www.circuits.dk/install-grafana-influxdb-raspberry/ & http://docs.grafana.org/installation/debian/
sudo apt-get install apt-transport-https curl && curl https://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
echo "deb https://dl.bintray.com/fg2it/deb-rpi-1b jessie main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
echo "deb https://dl.bintray.com/fg2it/deb jessie main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt-get update && sudo apt-get install -y grafana
sudo systemctl enable grafana-server.service && sudo service grafana-server start
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -source /etc/os-release
test $VERSION_ID="8" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install -y influxdb && sudo service influxdb start
influx
CREATE DATABASE officeTemps
sudo pip install influxdb
import time
import sys
import datetime
from influxdb import InfluxDBClient
from envirophat import weather
# Set this variables, influxDB should be localhost on Pi
host = "localhost"
port = 8086
user = "root"
password = "root"
dbname = "office"
client = InfluxDBClient(host, port, user, password, dbname)
# Sample period (s)
interval = 60
# Allow user to set session and runno via args otherwise auto-generate
if len(sys.argv) > 1:
if (len(sys.argv) < 2):
print "Must provide a desk number"
sys.exit()
else:
deskNo = sys.argv[1]
else:
deskNo = "3"
now = datetime.datetime.now()
# Run until keyboard out
try:
while True:
temp = weather.temperature()
press = weather.pressure()
iso = time.ctime()
json_body = [
{
"measurement": temperatures,
"tags": {
"desk": deskNo,
},
"time": iso,
"fields": {
"Degrees" : temp
"Pressure" : press
}
}
]
# Write JSON to InfluxDB
client.write_points(json_body)
# Wait for next sample
time.sleep(interval)
except KeyboardInterrupt:
client.close()
select-editor
crontab -e
@reboot python /home/pi/code/envirophat/temperature_logger.py &
sudo reboot now