letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.26k stars 2.21k forks source link

Senseair plugin default MODBUS address 0xFE is not good #1475

Open Grovkillen opened 6 years ago

Grovkillen commented 6 years ago

Current code use address 254 (0xFE) for communication. That address is a default MODBUS address only meant to used for test and should not be used in a MODBUS system since multiple units may respond to that address.

Default address is 104 (0x68) which will suit most users but it's possible to set the address to something else if needed. This is done with the Senseair application "UIP" but the plugin might be able to do this out of the box?

TD-er commented 6 years ago

The Senseair plugin should get a complete make-over. Have all Senseair sensors the same (default) modbus address? And if I remember correctly, it is possible to change it to allow more sensors on the same bus. Is this stored in the sensors flash, or in memory?

Grovkillen commented 6 years ago

It should be stored in memory and yes they all have the same default address.

Grovkillen commented 6 years ago

I realized that we use UART with current plugin, MODBUS would be good. So this issue is not a problem now.

Andrey2509 commented 5 years ago

Current code use address 254 (0xFE) for communication. That address is a default MODBUS address only meant to used for test and should not be used in a MODBUS system since multiple units may respond to that address.

Default address is 104 (0x68) which will suit most users but it's possible to set the address to something else if needed. This is done with the Senseair application "UIP" but the plugin might be able to do this out of the box?

Please tell me how to change modbus ID address of senseair S8 permanently. I need to use 4 sensors on one RS485 bus. I tried to change ID using software from senseair (UIP5), but after switch off power supply address modbus returned to 104.

Grovkillen commented 5 years ago

You probably need to write the settings to EEPROM, should be possible with UIP5 I think.

Andrey2509 commented 5 years ago

Please add calculate CRC cheksum of received bytes from senseair S8 (modbus). Bad answers should be ignored. I have numerous errors of data: I get CO2 ppm from 500 ppm to 10000 ppm quickly changed on distance 10m (utp cat5e). If distance is short (1 meter) - data is stable.

Andrey2509 commented 5 years ago

You probably need to write the settings to EEPROM, should be possible with UIP5 I think.

I tried to change ID using UIP5, but without success. It returned to 104 after power off. I don't know "how write the settings to EEPROM" permanently.

lirik90 commented 3 years ago

After listening to what UIP5 transmits, I found commands for getting and changing the Senseair S8 Modbus address. It is not standard Modbus function codes, 0x44 for read and 0x41 for write. Function data is 0x002001. For example for change sensor address to 85 (0x55 in hex) we send to sensor: fe 41 00 20 01 55 e9 af where 0xe9af is calculated CRC. For read current address we send: fe 44 00 20 01 c1 24 and answer can be: fe 44 01 55 b0 76 where 0x55 is address. When i close UIP5 address is reset to standard 104, but if i break physical connection without closing UIP5 app, address is stored. After write address command UIP5 send one another command, if think it's command means "Write the settings to EEPROM", command with function 0x41 data 0x00600102.

So for change S8 modbus address i use this command sequence:

stty 9600 -F /dev/ttyUSB0

# Change Modbus address to 0x55 (aka 85)
echo -n -e "\xfe\x41\x00\x20\x01\x55\xe9\xaf" > /dev/ttyUSB0

# Read current address (just in case)
echo -n -e "\xfe\x44\x00\x20\x01\xc1\x24" > /dev/ttyUSB0

# Store changes to EEPROM
echo -n -e "\xfe\x41\x00\x60\x01\x02\xa9\x85" > /dev/ttyUSB0
TD-er commented 3 years ago

Great! That would make it possible to have several SenseAir units on the same bus.

PerryHunt commented 1 month ago

Hi All, Yes I can confirm that saving settings to EEPROM is necessary. The assigned Address is one of the infrequently changed settings so it can live in EEPROM. Values that change often are in RAM. These sensors transfer the EEPROM contents into holding registers in RAM upon powerup. The process to change a setting is to power the sensor up, write the new value into the variable's holding register, then issue a save to EEPROM command. You can't write to EEPROM directly. These sensors must be power cycled after saving the settings to EEPROM before the new settings will take effect. EEPROM has a very limited number of write cycles, like 1000 max, so be aware of that. The holding register for the address in Sunrise is HR20 (0x13), but I could not find it for the S8. I'll try to put more information together for each of the sensors and post somewhere here. I'll try to come by here more often. Perry Hunt Sr Applications Engineer AKM Semiconductor & Senseair AB

PerryHunt commented 1 month ago

Writes to EEPROM take time, so be sure not to power the sensor down until the writes complete.