This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

modbus config
#1
I have bought a multisensor from a chinese company and connected it to the modbus. I have managed to add a device in the reactor. The rtu settings are

RTU enabled
Port /dev/485
Baud rate 4800
Parity None, stop bit 1
Half duplex



The result of the rtu scan says slave 1 already mapped:



And the RTU read test with Device address 1, Function Holding register #3, address 0, read length 7 gives a result of 189,220,0,0,0,0,108



According to the manual attached the first number is the temperature, and the second is humidity, then there are some zero values and that should be ok since there are data only in register 0,1 and 6. A mystery is that the values according to the manual are HEX, so that translated into decimal values it should be 393, 544 and 264.

This should be 39,3 degrees, 54,4%humidity, and 264 lux. It is absolutely not 39 degrees in that room, and 54,4% RH is plausible, but this is winter and humidity is normally much lower. It could of course be that it is 18,9 degrees, 22%RH. The lux is ok I think for an inside room with no windows and just a small 9W LED lamp of 650lumen. Does the reactor translate HEX values into DEC?

The reason I am here with this info is that this is the rtu scan. I want to read these values with a script or some other way if that is possible?

The script that I have been looking at is like this

require('luamodbus')
mb = luamodbus.rtu()
mb:close()
mb:open('/dev/RS485', 4800, 8, "NONE", 1)
mb:connect()


-- Lux
value = mb:readregisters()
if value <=  then
  dosomething()
else
  dosomethingelse()
end

mb:close()


I am not sure what to do here, but my guess is that the mb:readregister should contain (startaddress, data length) in some way?

Attached Files
.doc   Transmitter Instructions.doc (Size: 523.5 KB / Downloads: 33)
Reply
#2
RTU read test value are decimal. To read 7 registers starting from 0 use mb:readregisters(0, 7).
You can also create a profile for this device (save as .json file and upload into Profiles in Modbus tab):
Code:
{
  "manufacturer": "RS",
  "description": "GZWS-N01",
  "mapping": [
    {
      "name": "Temperature",
      "bus_datatype": "float16",
      "datatype": "int16",
      "type": "register",
      "address": 0,
      "value_multiplier": 0.1
    },
    {
      "name": "Humidity",
      "bus_datatype": "float16",
      "datatype": "uint16",
      "type": "register",
      "address": 1,
      "value_multiplier": 0.1
    },
    {
      "name": "Illumination",
      "bus_datatype": "uint16",
      "datatype": "uint16",
      "type": "register",
      "address": 6
    }
  ]
}
Reply
#3
(08.01.2018, 07:52)admin Wrote: RTU read test value are decimal. To read 7 registers starting from 0 use mb:readregisters(0, 7).
You can also create a profile for this device (save as .json file and upload into Profiles in Modbus tab):
Code:
{
 "manufacturer": "RS",
 "description": "GZWS-N01",
 "mapping": [
   {
     "name": "Temperature",
     "bus_datatype": "float16",
     "datatype": "int16",
     "type": "register",
     "address": 0,
     "value_multiplier": 0.1
   },
   {
     "name": "Humidity",
     "bus_datatype": "float16",
     "datatype": "uint16",
     "type": "register",
     "address": 1,
     "value_multiplier": 0.1
   },
   {
     "name": "Illumination",
     "bus_datatype": "uint16",
     "datatype": "uint16",
     "type": "register",
     "address": 6
   }
 ]
}

Managed to create a profile, and have added a device with the name of multi. Found by accident the objects from the profile in the mapping section for the modbus device. Linked those to virtual KNX objects, but not sure if this is necessary. Maybe it is possible to access thos mapping objects directly from a script?

Anyway, made a simple script that read a value from the virtual objectand turned on and off some lights just to test. Worked like a charm
Reply


Forum Jump: