Skip to content

Instantly share code, notes, and snippets.

@valentt
Created December 1, 2019 19:53
Show Gist options
  • Save valentt/9d44c63d7645de5196e91a7aa00b6bbb to your computer and use it in GitHub Desktop.
Save valentt/9d44c63d7645de5196e91a7aa00b6bbb to your computer and use it in GitHub Desktop.
send_metrics.sh
#! /bin/sh
power_raw=`cat /sys/bus/i2c/devices/2-0044/hwmon/hwmon1/power1_input`
voltage_raw=`cat /sys/bus/i2c/devices/2-0044/hwmon/hwmon1/in1_input`
temperature_raw=`cat /sys/devices/platform/soc/soc:i2c-gpio/i2c-2/2-0076/iio:device0/in_temp_input`
humidity_raw=`cat /sys/devices/platform/soc/soc:i2c-gpio/i2c-2/2-0076/iio:device0/in_humidityrelative_input`
pressure_raw=`cat /sys/devices/platform/soc/soc:i2c-gpio/i2c-2/2-0076/iio:device0/in_pressure_input`
power=`echo "scale=2; $power_raw / 1000000" | bc`
voltage=`echo "scale=2; $voltage_raw / 1000" | bc`
temperature=`echo "scale=2; $temperature_raw / 1000" | bc`
humidity=`echo "scale=2; $humidity_raw / 1000" | bc`
pressure=$(printf %.2f `echo "scale=2; $pressure_raw * 10" | bc`)
influx_password=osijek:PASSWORD
curl -i -XPOST 'http://SERVER:8086/write?db=DATABASE' -u $influx_password --data-binary "Osijek,lokacija=pekara1 power=$power,voltage=$voltage,temperature=$temperature,humidity=$humidity,pressure=$pressure"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment