pulquero / dbus-i2c

Victron Venus D-Bus services for I2C devices
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Add support for Adafruit PMSA003I Air Quality Breakout - STEMMA QT / Qwiic #4

Open spatcho opened 12 months ago

spatcho commented 12 months ago

Link to the device description : https://www.adafruit.com/product/4632

I would like to add support for this device, I am available for coding the implementation.

pulquero commented 12 months ago

Download HEAD to your RPi and try running /data/dbus-i2c/pm25_test.py. If this works, or you have some other example code that works on Venus then we should be able to add it. The existing *_service.py should give you an idea of how to implement it if you want to have a go.

NB: I suggest using the service name com.victronenergy.airquality. There is no formal support for this type of sensor, so I doubt it will be visible in the remote console**. Hopefully, it can still be registered on dbus and exported over mqtt.

**It is possible to add UI components, e.g. the package manager, so it might yet be possible to mod the UI so it appears.

spatcho commented 11 months ago

Ok, thanks, I checked. I installed using "main" as branch on package editor. The smbus2 dependency failed because I had no device that needed it and so it wasn't installed at setup. I am getting raw data from the smbus calls. The test script failed with "[Errno 71] Protocol error". If I change "read_block_data" to "read_i2c_block_data" it still fail but with "Invalid PM2.5 header", which I think is better. Difference with Adafruit sample code using CircuitPython, I need to choose a register, maybe 0 is not what to set. Anyways I am not a python/i2c expert, so I am learning and it is still a work in progress.

spatcho commented 11 months ago

Ok, it work, I had to do bytearray(read_i2c_block_data(...)), then I got the output listing all the pmxxx levels : {'pm10 standard': ... }. Now I will see for the service and ui.

spatcho commented 11 months ago

I did a basic service. I didn't find out yet how to use another service type than "temperature" and to show paths other than "/Temperature" and "/Humidity" on the venus screen. But paths like "/PM03" are published on MQTT and I can monitor the air quality on my OpenHAB instance.

pulquero commented 11 months ago

Great, submit a PR, branch, whatever and I'll merge it into the codebase.

spatcho commented 11 months ago

I will submit. But It hang after sometimes, I want to fix that first, and clean it up.