Hi All,
I bought a RS-WS-N01-8 Modbus Temperature and Humidity sensor a few weeks ago and I did the integration to OpenHAB. There is a Youtube video describing how the sensor works and how to set it up:
Link for the modbus setup utility to change the station ID and baud (explained in the video):
https://drive.google.com/file/d/0Bw1XOPtMPlsNUi1SWEZ4OGdGVUU/view?usp=sharing
Link for the image explaining the use of the above utility:
https://drive.google.com/file/d/0Bw1XOPtMPlsNMkFZZ3VnSUJXY0E/view?usp=sharing
To communicate with the sensor, add the modbus binding to your OpenHAB installation.
These are my settings in openhab.cfg to configure the modbus communication:
modbus:serial.rswstemp.connection=/dev/ttyUSB0:9600:8:none:1:rtu
modbus:serial.rswstemp.type=holding
modbus:serial.rswstemp.valuetype=int16
modbus:serial.rswstemp.length=2
modbus:serial.rswstemp.start=0
modbus:serial.rswstemp.id=50
The only thing to change in the above config is the station ID and communication details for your particular device.
The device sends the humidity and temperature values in 0.1% and 0.1C format. So the value needs to be divided by 10. Since there is no transformation for the modbus binding, I am reading the values to a temporary items, dividing them and posting the actual values to the final items using rules.
Let’s see the item configuration first:
// RS-WS-N01-8 Temperature and Humidity sensor
Number RSWShumidity_temp "Humidity [%d]" <rain> {modbus="rswstemp:0"}
Number RSWStemperature_temp "Temperature [%d]" <temperature> {modbus="rswstemp:1"}
Number RSWShumidity "Humidity [%.1f %%]" <rain> (rswstemp)
Number RSWStemperature "Temperature [%.1f C]" <temperature> (rswstemp)
Sitemap itself is very simple, there is no surprise there. Obviously only the final values as added to the sitemap:
Text label="RS-WS Temperature and Humidity" icon="energy" {
Text item=RSWStemperature
Text item=RSWShumidity
And finally the rules which takes care of the conversion:
import org.openhab.core.library.types.*
rule "Convert Temperature value"
when
Item RSWStemperature_temp received update
then
postUpdate(RSWStemperature, Float::parseFloat(RSWStemperature_temp.state.toString()) / 10)
end
rule "Convert Humidity value"
when
Item RSWShumidity_temp received update
then
postUpdate(RSWShumidity, Float::parseFloat(RSWShumidity_temp.state.toString()) / 10)
end
I hope you like find this write-up useful. I certainly like this sensor and it is definitely a reasonable price for a temperature and humidity sensor. As far as I can tell, the actual sensor used is a reasonable good one, it does responds to changes very rapidly.