Author Topic: Node-Red to Classic Modbus for beginners  (Read 751 times)

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1926
Node-Red to Classic Modbus for beginners
« on: June 21, 2018, 11:31:28 AM »
This is to show the steps I am taking to setup  modbus reading on Node-Red.
I am not going to show how to set up Node-Red on a device because there are plenty of other tutorials on that.
I am using Windows 10 .
I am using serial data cable from Classic - see my post in Arduino section for how I set up the connections for that.
Also make sure you don't loose a day and have a lot of frustration by hooking up a connector on your test cable like I did ! Sometimes late night soldering is not good - ha ha .
I am using a usb to serial adapter now to get the data to my computer. In the future I may install Node-Red on a Raspberry Pi and connect the serial data on there using appropriate RS-232 to ttl converters as needed.

Back to Node-Red - I installed the Modbus package for Node-Red
This shows how to do that
 https://flows.nodered.org/node/node-red-contrib-modbus

Attached are some screen shots .
I have three temperature values displaying in the debug . Next step is to add the node red blocks to divide by ten and display them on the UI screen ( not shown yet )
I have shown the setup screens for the Classic using the Modbus Read block .
I am a total beginner at this !


Larry



system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1926
Re: Node-Red to Classic Modbus for beginners
« Reply #1 on: June 21, 2018, 11:39:41 AM »
This shows the UI screen  view of previous
I have three flows
First is Sonoff Basic Switch
Second is Sonoff POW switch
Third is the Text block from the Classic above .
So my next step is to figure out how to display these temperatures some nice way .


Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

ricardo

  • Jr. Member
  • **
  • Posts: 55
Re: Node-Red to Classic Modbus for beginners
« Reply #2 on: June 22, 2018, 11:29:04 AM »
has anyone made a KID serial data to modbus node-red flow? ..

i know others made scripts to go from serial to modbus .. 

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1926
Re: Node-Red to Classic Modbus for beginners
« Reply #3 on: June 22, 2018, 02:30:32 PM »
has anyone made a KID serial data to modbus node-red flow? ..

i know others made scripts to go from serial to modbus ..

I don't believe that the Kid uses Modbus

Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

Vic

  • Hero Member
  • *****
  • Posts: 2036
Re: Node-Red to Classic Modbus for beginners
« Reply #4 on: June 22, 2018, 07:59:56 PM »
Larry,    it looks like you are making some good progress!

I have yet to dip any toes in this water,   but hope to get to it fairly soon.

Thanks  for helping get the rest of us started.    73,   Vic
Off Grid - Two systems -- 4 SW+ 5548s, Surrette 4KS25 1280 AH X2@48V, 11.1 KW STC PV, 3X MidNite Classic 150 w/ WBjrs, Beta KID on S-530s, MX-60s, MN Bkrs/Boxes.  Thanks MN for Great Products/Service/Support!

ricardo

  • Jr. Member
  • **
  • Posts: 55
Re: Node-Red to Classic Modbus for beginners
« Reply #5 on: June 22, 2018, 09:36:53 PM »
has anyone made a KID serial data to modbus node-red flow? ..

i know others made scripts to go from serial to modbus ..

I don't believe that the Kid uses Modbus

Larry

It doesn't -- i was thinking of using a raspberry pi as a "modbus-bridge" .. i wonder if that is even useful?


ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1926
Re: Node-Red to Classic Modbus for beginners
« Reply #6 on: June 22, 2018, 09:42:47 PM »
I guess I don't understand what would be the use of using modbus as a bridge  ? 
You can already get the data from the Kid so why add modbus ?

Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

ricardo

  • Jr. Member
  • **
  • Posts: 55
Re: Node-Red to Classic Modbus for beginners
« Reply #7 on: June 22, 2018, 09:51:35 PM »
I guess I don't understand what would be the use of using modbus as a bridge  ? 
You can already get the data from the Kid so why add modbus ?

Larry

thats what i mean by "is it even useful" .. other than having the midnite local app work with a KID, or other modbus apps.

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1926
Re: Node-Red to Classic Modbus for beginners
« Reply #8 on: June 22, 2018, 10:06:08 PM »
I guess I don't understand what would be the use of using modbus as a bridge  ? 
You can already get the data from the Kid so why add modbus ?

Larry
thats what i mean by "is it even useful" .. other than having the midnite local app work with a KID, or other modbus apps.
Ricardo
Interesting idea but way too complicated for me.
The Local App uses Adobe Air - they chose that since it works on all platforms.  But the Node-Red does also and would be highly user configurable.
Making a Kid App on Node-Red would be better and probably a lot easier than trying to get Kid data converted to Modbus. I say that partly because I am just now starting to get Modbus stuff figured out !
If I win the lottery next time I will buy you a Classic so you can design Node-Red for it and save me a lot of learning and trouble ! ha ha .
Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1926
Re: Node-Red to Classic Modbus for beginners
« Reply #9 on: June 22, 2018, 10:06:56 PM »
Here is my Node -Red flow code so far.

[{"id":"7814d43b.054044","type":"debug","z":"5b05eee9.d07c08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":550,"y":160,"wires":[]},{"id":"ac01c59a.753dd8","type":"modbus-read","z":"5b05eee9.d07c08","name":"Midnite Classic ","topic":"","showStatusActivities":false,"showErrors":false,"unitid":"10","dataType":"HoldingRegister","adr":"4131","quantity":"3","rate":"2","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"61de09d5.6be308","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":140,"y":140,"wires":[["48c2d857.b4cda"],["48c2d857.b4cda"]]},{"id":"dfd82617.a6187","type":"ui_text","z":"5b05eee9.d07c08","group":"92929de4.bc8b58","order":0,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"col-center","x":530,"y":240,"wires":[]},{"id":"603eab2c.3b8b24","type":"range","z":"5b05eee9.d07c08","minin":"0","maxin":"1000","minout":"0","maxout":"100","action":"scale","round":false,"property":"payload","name":"Scale ","x":350,"y":140,"wires":[["14547405.4ad87c","dfd82617.a6187"]]},{"id":"48c2d857.b4cda","type":"split","z":"5b05eee9.d07c08","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":260,"y":240,"wires":[["603eab2c.3b8b24"]]},{"id":"14547405.4ad87c","type":"debug","z":"5b05eee9.d07c08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":500,"y":340,"wires":[]},{"id":"61de09d5.6be308","type":"modbus-client","z":"","name":"Classic ","clienttype":"simpleser","bufferCommands":false,"stateLogEnabled":false,"tcpHost":"192.168.3.21","tcpPort":"502","tcpType":"TPC-RTU-BUFFERED","serialPort":"COM3","serialType":"RTU","serialBaudrate":"19200","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"10","commandDelay":"1","clientTimeout":"1000","reconnectTimeout":"2000"},{"id":"92929de4.bc8b58","type":"ui_group","z":"","name":"Outputs","tab":"74f42c08.0cd0ac","order":1,"disp":true,"width":"6"},{"id":"74f42c08.0cd0ac","type":"ui_tab","z":"","name":"Office","icon":"dashboard","order":1}]
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1926
Re: Node-Red to Classic Modbus for beginners
« Reply #10 on: June 24, 2018, 12:24:19 PM »


Ricardo ,
The first line below are my temps I want,
the second line { data: array[3], buffer: buffer[6]    seems to mess up the CSV
I think I need to use a function to strip those out
How do I do that ?
Thanks for any help .
Larry

6/24/2018, 11:13:33 AMnode: 14547405.4ad87cmsg.payload : array[3]
[ 195, 554, 540 ]
6/24/2018, 11:13:33 AMnode: 14547405.4ad87cmsg.payload : Object
{ data: array[3], buffer: buffer[6] }
6/24/2018, 11:13:35 AMnode: 14547405.4ad87cmsg.payload : array[3]
[ 196, 553, 540 ]
6/24/2018, 11:13:35 AMnode: 14547405.4ad87cmsg.payload : Object
{ data: array[3], buffer: buffer[6] }
6/24/2018, 11:13:37 AMnode: 14547405.4ad87cmsg.payload : array[3]
[ 196, 553, 540 ]
« Last Edit: June 24, 2018, 12:25:56 PM by ClassicCrazy »
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1926
Re: Node-Red to Classic Modbus for beginners
« Reply #11 on: June 24, 2018, 01:02:21 PM »
I figured out how to just get the numbers - I unhooked the bottom wire from the Modbus module and just use the top one. Now to split up the data into more than one line.

Larry
« Last Edit: June 24, 2018, 01:06:38 PM by ClassicCrazy »
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

jedon

  • Newby
  • *
  • Posts: 11
Re: Node-Red to Classic Modbus for beginners
« Reply #12 on: July 30, 2018, 01:08:15 PM »
I've had my Classic hooked to an RPi then to an Odroid C2 for years now, my Node-RED flows are... very complicated but powerful, auto start-stops the generator, voice control via Alexa, logging, remote monitoring etc. I have a wifi range extender bridged to the house from the solar shed and the Classic hooked to that via ethernet cable.
-Jedon

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1926
Re: Node-Red to Classic Modbus for beginners
« Reply #13 on: July 30, 2018, 02:02:30 PM »
I've had my Classic hooked to an RPi then to an Odroid C2 for years now, my Node-RED flows are... very complicated but powerful, auto start-stops the generator, voice control via Alexa, logging, remote monitoring etc. I have a wifi range extender bridged to the house from the solar shed and the Classic hooked to that via ethernet cable.
-Jedon
Jedon ,
That sounds like a great setup you have created.
Any chance you could share your flows or parts of them ? I have not gotten much farther than what I have posted above. 

Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

David

  • Jr. Member
  • **
  • Posts: 64
Re: Node-Red to Classic Modbus for beginners
« Reply #14 on: October 03, 2018, 05:35:47 PM »
Has someone gotten this to work over ethernet?  I have Node-Red running.  I have the client node using the IP# of the Classic as it appears from my router.  I can ping the Classic and within Node-Red have a ModBus-read node using  port 502, type TCP, and DEFAULT TCP Type.  It keeps displaying "Error: Modbus exception 1" and wondering what I am doing wrong.
« Last Edit: October 03, 2018, 05:38:19 PM by David »