Home/Support/Support Forum/Modbus data to iDigi
New and improved user forum site going live on 12/6 (All users will need to reset their password when the new forum is active)
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Modbus data to iDigi

0 votes
Has anyone connected a modbus rtu device to capture data in iDigi? Basically, I want to upload a power meter's data up through a Digi rs485 to zigbee adaptor into a connectport X4 gateway and have the data available in iDigi. I understand how to receive the data into the connectport, but need help on how to configure dia to send it up to iDigi.

Any suggestions would be appreciated.
asked Oct 15, 2009 in Device Manager by apineda Community Contributor (65 points)

Please log in or register to answer this question.

52 Answers

0 votes
I have complex experimental code which does some of this, but what piece are you actually needing? If you are already pulling Modbus data into the CP, how is that being done? Have you written Dia drivers before?

- Lynn
answered Oct 16, 2009 by lynnl Veteran of the Digi Community (1,047 points)
0 votes
What is the volume of data that you anticipate? In particular, at what frequency do you expect to obtain new samples? Is the most recent sample the only thing that is interesting to be available from iDigi, or is there a desire to support some form of change tracking directly from iDigi?

I'm curious how you hope to map the data to services that can be provided by iDigi.
answered Oct 16, 2009 by 52637p Community Contributor (59 points)
0 votes
To be more specific, I want to link up a Conzerv EM 6433 power meter using a Digi rs485 Adapter to the ConnectPort X4. I don't have any code yet, I was referring to the ModBus serial settings on the CX4 that already exist. It appears that the CX4 can map the ZigBee links to pass the ModBus registers through the serial port interface to a python driver that I have to write.

Ideally, I would like to get 5 second samples of certain registers, such as Voltage, Amps, and KwH at a minimum. I only plan to have the latest reading on iDigi. I can store the data elsewhere if I need to keep track of it over time. The end result is a sort of web virtual meter that gets updated by requesting the latest record from iDigi via the web service.
There is a Modbus Register mapping sample on the Wiki, but I would still have to write a DIA driver to poll the Meter, I presume, but have not written a driver from scratch.

So, I think what I need is a DIA driver that polls the meter via the RS485 adapter and retrieves the needed register data. That data becomes a "channel" like some of the examples that I can configure for the cws-exist upload.
answered Oct 17, 2009 by apineda Community Contributor (65 points)
0 votes
I see, I'll try to clean up one of my code samples to allow a serial Modbus poll (which returns a word array) to be parsed/chopped up into "Published Dia channels".

You are correct that the X4 can manage Modbus external to Python, however I'd probably 'de-couple' the poll. So on some schedule a driver would send a poll and time-stamp the send but not wait for a response, then any response which seemed to match the outstanding request could be parsed into published channels.

Do you desire allow a remote Modbus/TCP master to query the power meter freely "in parallel" to the Python? If yes, then we need to allow the Modbus engine to "own" the raw serial channel (end-point 232) out of the X4. Otherwise we can allow Python to manage that.
answered Oct 18, 2009 by lynnl Veteran of the Digi Community (1,047 points)
0 votes
Awesome! Sounds like you've done this before. Due to my lack of ModBus experience, I need to ask a question:
Can the Slave RTU (Meter) be set to just transmit the register values periodically? This would be a "push" rather than a "pull" via a poll. If so, then I would just have to send a command initially to set the push timing.

If not, then your suggestion sounds fine to allow the Python driver to send the poll based on a programmable schedule.

I was thinking of using RCI to set/get values from the slave device for diagnostics. Having direct remote Modbus TCP control sounds easier. Although I expect the meter to be passive, it has several features that would be nice to set/get remotely without having to write python code, I could then connect to the Cx4 via a ModBus program on my computer (seems to be many available) and have direct access to the meter. I think the iDigi TCP/IP mapping would allow me to do that correct?

What do you think is better from a flexibility standpoint, RCI or Remote Modbus?

Thanks again for all your help!
answered Oct 18, 2009 by apineda Community Contributor (65 points)
0 votes
Generally, Modbus 'server/slaves' can never create messages so must be polled by brute-force, for example every few seconds. Big users shift to DNP3 or BACNET or other newer protocols when 'report-by-exception' data comms are desired. Keep in mind there is no graceful way to mix push/pull on the same serial line - however some higher-end Ethernet-based devices can be both master and slave. Also, many users use small local "operator-panels" to both display the local device info polled by brute-force via Modbus, and also to push data up-stream by other protocols or as a Modbus master.

My code would start as read-only, writing to control systems can be a dangerous task & generally requires a direct write-then-readback in realtime which isn't so easy in widely dispursed, abstracted networks.

Personally I'd rather use iDigi to upload periodic data long-term in cyclic, less-than-realtime and use Modbus/TCP direct via cellular/DSL/broadband to "set" things in real-time & confirm the effect.
answered Oct 19, 2009 by lynnl Veteran of the Digi Community (1,047 points)
0 votes
Thank makes sense. Let me know when you have a version I can start testing.
answered Oct 19, 2009 by apineda Community Contributor (65 points)
0 votes
It is moving along - I have my code reading two Modbus/TCP (ethernet-based) servers from an X4 every few seconds, which creates float or int channels named things like motor01_current, or motor02_speed.

Since the Dia Code talks via the normal Digi Modbus bridge/engine, it will work with Modbus/TCP in TCP or UDP, plus Modbus/RTU or Modbus/ASCII in TCP, UDP, serial or Xbee.

I am gearing it more towards normal cellular (less at Xbee) since combined with my 'filter-device' it would make a great report-by-exception tool for waste-water, lift pumps etc - only moving changes and perhaps a daily 'refresh' via cellular.

(Should have sample code to share by Thu or Fri this week)
answered Oct 20, 2009 by lynnl Veteran of the Digi Community (1,047 points)
0 votes
Hi Lynn,

No hurry, just checking in on the code you mentioned. It would be great to be able to test this weekend :)

answered Oct 28, 2009 by apineda Community Contributor (65 points)
0 votes
Sorry - was distracted.

It's been running fine since last Friday importing some solar inverter data via Modbus/TCP into Dia for upload to iDigi (a remote host uses RCI to pull the data actually).

Open the ZIP and see if the readme and the file placement makes sense. Hopefully all the right files are there.

- Lynn
answered Oct 28, 2009 by lynnl Veteran of the Digi Community (1,047 points)