Hmmmm…perhaps I haven’t had enough coffee yet this morning. Let me try this. Yes, I had very good success with Modbus TCP. I could not find any available code, so I downloaded a description of the Modbus protocol and wrote my own code to talk to the device.
The device I needed to talk to is a YSI water quality analyzer. It holds sensor readings (12 of them) in Modbus registers. Each sensor requires 8 registers and each register requires 2 bytes. The whole register scheme is standard. In the case of the YSI, the registers hold sensor data, as I mentioned.
Two aspects (at least) make this a bit tricky: the data is stored as floating point numbers in big-Endian format, whereas the Photon is little-Endian. I believe (I don’t have the docs with me) this is the standard format for Modbus register data. The other aspect is the command to read the device is a bit tricky–it’s a 12 byte array that indicates the READ command, the starting address and how many registers to read.
Basically, I used the TCPclient class to instantiate an object I could use to open port 502 (the standard Modbus TCP port) to the YSI meter’s IP address. I then issued a command to request the desired number of bytes starting with register 1 (address 0). As the sensor readings come back, I convert them from big-Endian to little-Endian format using a union structure (dealer’s choice) and the build a string to push the data to the cloud service (Grovestreams in my case).
I hope this at least partially answers your question.
By the way, I found a free simulator (somewhere) which I used to debug the program, since there was only 1 YSI analyzer available and it was in production. The simulator was a huge benefit, since I knew exactly what data I should be reading.