I am trying to connect my SenseAir S8 CO2 meter to Nymea using the Modbus protocol. Here are the steps I have taken so far:
- Tested the interface: I ran a Python script (found at http://co2meters.com/Documentation/AppNotes/AN168-S8-raspberry-pi-uart.pdf) to test the interface between the SenseAir S8 and my Raspberry Pi. The script worked and output CO2 readings from the sensor.
- Installed the Modbus plugin and created a Modbus RTU master: I installed the Modbus plugin in Nymea and created a Modbus RTU master. The master shows ‘connected’ in the interface.
- Added an input register: I tried adding an input register for the SenseAir S8 to Nymea, using multiple slave addresses and register addresses that I found in the documentation (https://www.driesen-kern.de/downloads/ba-senseair-s8-modbus.pdf). For example, I tried using slave address 2 and register address 68, as well as slave address 0 and register address 44. However, the input register remains in the “Thing is not connected” state.
Do you have any ideas on how to fix this issue and successfully connect the SenseAir S8 to the Nymea system using Modbus?
I’m not sure if I understood correctly what you did in steps 2 and 3, but let me try to sum up what I believe the steps to get this working should be:
- Set up a modbus RTU master in Main Menu → System Settings → Modbus RTU. Use a baud rate of 9600, 8 Bits, No parity bit and 1 stop bit as per documentation in
2.1. Byte format. If it shows connected it means that it could at least open the Serial Port properly. Unfortunately Modbus RTU doesn’t have any mechanism in place to verify if the serial port settings are correct and communication is working properly without actually giving a slave ID and register to read.
- So the next step would be to install the
nymea-plugin-modbuscommander. I believe that’s what you mean when you say you installed the modbus plugin. If not, install that one.
- Then go to Main Menu → Configure things and click the + to add a new thing. Select the
Modbus RTU client to connect to the bus created by the Modbus RTU master you’ve created in step 1.
- Add another thing, this time a
Input register. Use slave address 254 and register address 3, at least that’s how I understand the documentation. I’ve obtained those values from page 13 in the section
CO2 read sequence.
Thank you! This actually seems to work
I see values in the nymea app now. Any idea why the graph stays at 0?
Right… States are not logged by default to spare some data in the log db. nymea:core does support configuring this per state but the app does not implement that setting at this point.
However, what I’d suggest you to do would be to install
nymea-plugin-genericsensors and add a generic co2 sensor thing. Then create a script (in magic) that maps the value from the modbus register to the sensor value. Something like this:
thingId: "...." // the input register thing id, use autocompletion in the script editor
thingId: "..." // the generic co2 sensor thing id
value: modbusRegister.value / 2000 // the input of the generic co2 sensor thing expects input of 0 - 1, within a range of 0-2000ppm. Adjust this if you change the max in the thing settings.
Given this is a really simple device and nymea has a modbus tool for generating modbus based plugins in place, I’ve added a proper plugin for this device: New plugin: Senseair S8 by mzanetti · Pull Request #104 · nymea/nymea-plugins-modbus · GitHub
It’s in the experimental repository now.
Installing that would allow removing all the stuff you did (except the RTU master which is still needed) and just add one thing and everything should work as expected
Please be so kind and set up an experimental installation and give this a test so we can include it in the next release.
I will give it a try and let you know the result!
I installed the plugin from the experimental repo. But when searching for it in ‘configure things’ it does not show up in the list. Also a reboot didn’t solve this.
The plugin API version changed in experimental. You’d need to install the entire nymea stack from experimental as the older stable nymead can’t load the newer plugins yet.
Ok I updated fully to experimental. The sensor seems to work even though it shows it is disconnected.
Thanks for testing. The issue with the connected state should be fixed now.
Yes it shows connected now in the new version!
Thanks for creating the plugin and have a good new year!