An Apple HomeKit accessory for the SCD4x CO2 (Carbon Dioxide), temperature and humidity sensor running on a Raspberry Pi.
- Go - this accessory is written in Go
- HomeControl - to expose climate readings from the Enviro+ as an Apple HomeKit accessory
- SCD4x exporter for ESP32 - to read the SCD4x sensor and export it for scraping by Prometheus
Install this on a Raspberry Pi, or test it on macOS.
- Install Go >= 1.14 (useful Gist for Raspberry Pi)
- Clone this project:
git clone https://github.com/sighmon/homekit-scd4x
and thencd homekit-scd4x
- Install the Go dependencies:
go get
- Install and run the Climate Sensor exporter climate-sensor
- To build this accessory:
go build homekit-scd4x.go
- To cross-compile for Raspberry Pi on macOS:
env GOOS=linux GOARCH=arm GOARM=7 go build homekit-scd4x.go
- Execute the executable:
./homekit-scd4x
- Or run with the command:
go run homekit-scd4x.go
- sudo cp homekit-scd4x.service /lib/systemd/system/homekit-scd4x.service
- sudo systemctl daemon-reload
- sudo systemctl enable homekit-scd4x.service
- sudo systemctl start homekit-scd4x.service
The flag defaults can be overridden by handing them in at runtime:
-host=http://0.0.0.0
The host of your SCD4x sensor-port=1006
The port of your SCD4x sensor-sleep=5s
The time between updating the accessory with sensor readings (5s
equals five seconds)-dev
This turns on development mode to return a random temperature reading without needing to have a SCD4x
e.g. to override the port run: go run homekit-scd4x.go -port=8000
or ./homekit-scd4x -port=8000
If you uninstall this accessory from your Apple Home, you'll also need to delete the stored data for it to be able to be re-added.
- Delete the data in the folder created:
homekit-scd4x/SCD-41/
- Restart the executable
- Remove the persistent data:
rm -rf /var/lib/homekit-scd4x/data
- Restart the Raspberry Pi
This project uses the amazing work of Matthias. Please consider donating if you found this useful.