Created
December 1, 2019 19:53
-
-
Save valentt/9d44c63d7645de5196e91a7aa00b6bbb to your computer and use it in GitHub Desktop.
send_metrics.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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