CO2 reader & logger - reads CO2 values from a sensor and creates a pretty plot out of them. Will also keep a file with latest sensor state.
Run as a service from systemd (recommended and easier) or trigger this script from udev.
For details on the supported devices, see: https://hackaday.io/project/5301-reverse-engineering-a-low-cost-usb-co-monitor
NB: This is written for a RapsberryPi. Other platforms might be slightly different. NB2: Paths in config files are for /home/pi/co2 and /dev/co2 - if your paths are different, you should change these files.
- Edit the run configuration @ co2reader.service
- Link co2reader.service to systemd's directory: sudo ln -s co2reader.service /etc/systemd/system
- Reload systemd: sudo systemctl daemon-reload
- Start the service: systemctl start co2reader
- If everything seems to work, enable the service so it'll be restarted on reboot: sudo systemctl enable co2reader
You may still want to install a udev rule to alias your device: this will enable a pretty name such as /dev/co2, instead of a pseudo-random /dev/hidraw0.
Use udev to automatically start this script whenever the sensor is plugged:
- Fix paths in 99-co2dev.rules
- Copy or link 99-co2dev.rules to /etc/udev/rules.d/
- udev restart might be necessary: sudo service udev restart
- Reload rules with sudo udevadm control --reload-rules && udevadm trigger
- Plug and unplug the sensor