davidkreidler / OpenCO2_Sensor

Arduino Repository for an E-Ink CO2 Sensor using ESP32 and SCD4X
https://www.tindie.com/products/davidkreidler/open-co2-sensor/
MIT License
97 stars 5 forks source link

Document how to extract current sensor values programmatically #21

Closed saviola777 closed 1 month ago

saviola777 commented 1 month ago

Hello,

this is probably trivial to figure out if one knows anything about Prometheus/Grafana, but maybe it would be useful to document how to use curl / wget or similar to extract current sensor values from the device over WiFi in a machine-readable format.

The website is cool and all, but I would prefer to integrate the information directly into my system to e.g. remind me to open/close the windows depending on sensor values and inside/outside temperatures.

davidkreidler commented 1 month ago

Hey @saviola777 thanks for reaching out. Great suggestion to add a quick how to get values instructions.

First please find out the IP of the sensor in your home network via the ui of your router or on the sensor itself via the button under Menu -> Info .

Then insert the IP here and use wget -S -O - [IP]:9925/metrics

Or wget [IP]:9925/metrics && cat metrics

Or via curl example

curl 10.0.0.101:9925/metrics

# HELP rco2 CO2 value, in ppm
# TYPE rco2 gauge
rco2{id="Open CO2 Sensor",mac="7C:DF:A1:96:B9:72"}571
# HELP atmp Temperature, in degrees Celsius
# TYPE atmp gauge
atmp{id="Open CO2 Sensor",mac="7C:DF:A1:96:B9:72"}25.37
# HELP rhum Relative humidity, in percent
# TYPE rhum gauge
rhum{id="Open CO2 Sensor",mac="7C:DF:A1:96:B9:72"}55.15

Hope this helps, I will add it to the README

David

saviola777 commented 1 month ago

Perfect! Thanks.