Access variables from Neuron (MervisOS)
I was wondering how I can access the data on my Neuron M203. It's running on the latest version of Mervis.
We have a very simple setup:
The Neuron M203, which hosts a web panel
A Raspbery Pi with raspbian connected directly to the Neuron with an ethernet cable. We use this one to display the webpanel.
Both devices are not connected to the internet.
We want to store a few parameters of the PLC in an InfluxDB on our regular Raspberry Pi. How can we get the data from the PLC? I've seen a few things about TCP/Modbus, but I have never used Modbus before. So I'd need some extra help with that.
Thanks in advance,
I'll start from the end - the RaspberryPi running an InfluxDB. I can only guess - and correct me if I am wrong - but you have only SD card with the Raspbian in your RaspberryPi, right? The SD cards are quite fragile regarding the number of data you can write on them. That's the reason why we switch the filesystem in MervisOS to read-only. So generally, running a database on the SD card is not-so-good idea.
Now to the part how to access Mervis variables from outside. Currently the most straightforward method is via Modbus. If you haven't use Modbus before, please take a look on the protocol itself: physical layers, addressing, datatypes,... The Wikipedia article is a good (a bit too complicated) start.
Then check our tutorial how to setup ModbusTCP server (slave) in Mervis: https://kb.unipi.technology/en:sw:01-mervis:setting-modbus-server-hidden
And to put it together check this Python Gist how to poll data from ModbusRTU slave into InfluxDB: https://gist.github.com/sansal54/bea2526ab8e968351a85db3410cc9f65
There's a lot of information you need to grasp from the beginning to get it working. Feel free to ask more.
Thank you for the wonderfull answer Martin!
Currently the RaspberryPi only has the SD card as memory space indeed, but it would be possible to attach an external drive.
After creating the Modbus Server Channel, I was instantly able to view all the values that I wanted. Now I can experiment with how we want to store our data.
But first we're going to see if we can attach it to the internet so we can use the MervisDB.
Thanks for the info!