diy solar

diy solar

RS485 Developer Needed

ncsolarelectric

Engineering Support CEO
Joined
May 24, 2022
Messages
756
Location
Statesville NC
I'm looking for someone who can create an app that reads a WattNode meter, and controls turning on and off the battery charger when exporting, or the inverter when importing energy to/from the grid. I have the setup, have no idea how to do the app or what microcontroller to use. I want something more reliable than an Arduino.

PM me please if interested.
 
Hi, I'm going to open source a tool doing this in the coming days. I did not intend to implement support for that meter, but it should not be a big deal to add it to my list. According to what I just read in a doc probably applying, the power value can be access in registers 1155 and 1156 in floating point format, or register 1209 in integer format.

Are you tied to this WattNode device? What is the exact reference. Have you the correct/matching register map in some document?

Ping me in a few days in case I forget to update you when I disclose my software.

NOTE: Be sure of what you're doing, or it can be dangerous... Playing on/off with such high currents is usually very damaging. Maybe good to clarify your intents, or wait to see my soft+doc to possibly detect risks.
 
Unfortunately, yes these microinverters are married to that particular meter. Here is the documentation I have.

Thank you.
 

Attachments

  • WND-WR-Modbus-Brochure.pdf
    481.9 KB · Views: 3
  • WND-WR-MB-Meter-Datasheet.pdf
    398.9 KB · Views: 2
  • WND-WR-MB-Ref-Manual-1.01.pdf
    1 MB · Views: 2
  • Technical Note-Hoymiles Export Management_0124.pdf
    10.8 MB · Views: 4
At a glance, the manual contains the information I need.
So, two good news for you:
- It should be easy to integrate this in my software.
- Your device supports the SunSpec standard, which is relevant to integrate in my software.

I'm on holiday but busy in the coming days. I'll have a look at this not before end of week, and more probably next week before I go back to work.
Since I have no device of that kind, I can't test. So, I may prepare some code for you to test. However I can't afford to spend much time on it...

Have you a Raspberry or some computer that runs linux? Do you feel fine with command line, if I give you some instructions?
=> If yes, then I'll prepare a custom version to test and will ask you to have a try and provide the feedback.

In order to test, I'll need to check that my software reads the correct values. So, we need a reference load/production or possibly a monitoring device to compare the value I read with the value displayed in that monitoring tool.

Would it be ok for you?
 
I don't have a Raspberry pi, but I do have an Arduino MEGA and a Ada Fruit "Tiny" that I have barely used. I don't have a linux computer either. Ideally, I want an embedded microcontroller to do the work, not a PC.

I know some Linux command line. What I don't know is the code structure for RS485 or what software to program it in. I'm a hardware guy, but if given a program template and the necessary editor, I can get things done.

Thanks! Much appreciated.
 
Ok, let's do it that way then. Here after a few theory, then you'll see if it still fits your time frame and possible efforts.
Since you're a hardware guy, you certainly have an oscilloscope available, it may be necessary later on.
I also consider you're familiar with UART and asynchronous serial communications, which apply to RS485, from a logical point of view.

In your project, that's not only RS485, it is Modbus over RS485, or Modbus RTU for the correct naming. This is a Master-Slave communication model, where the meter is the slave and the master must be unique (in your case and most of the time, but it's possible to build multi-master ;-)).

So, only one master on the line, in the context of your application. And here we hit a first problem/question: If you have a meter installed, probably it is already used, thus there is already a master on the line... You cannot interfere with it, especially by adding your own master!
No worries, since you intent to act on low level, then you still can spy silently what is going on the line without acting yourself as a master. Just spy, recognize the frame that is of interest for you, and you're (nearly) done!
Well, recognizing the frame is just detecting the start/end according to the correct framing, check the CRC checksum, recompose the bytes in the correct order to finally get the power expressed as a multi-bytes floating point or integer value. (No worries, all this will look simpler once you'll see the simple structure of frames.)

But if the meter is there just because you had to buy it and is not used, for example you have no monitoring of the power flow using it, no export limit or the like that uses the RS485 line, then you have to play the role of master from your microcontroller. It means you have to formulate the requests to the slave (meter), so that the slave can reply to you, then you process the reply. There is probably some Arduino library available to do a part of the Modbus job. (By opposition to spying, where you'll need to go low level yourself, since no library can be relevant there.)
The request structure is very simple too, the most difficult is just the CRC calculation, but there again you'll certainly find some Arduino library, it is a common CRC calculation.

That's all for the theoretical/simple principle, now some of the many subtleties, per level...

RS485 lines are, in theory, quite simple. This is just a twisted pair, differential, and you may/should/have to add or not add some resistors (pull-up, pull-down, terminator) to both balance the line and ensure that relative levels are in the range of the RS485 specification. Seems ok, right? Well, indeed when you reach that stable state where everything if fine, RS485 can bring your signal on long distances... Not your interest here, but just to mention that it CAN be strong, if properly tuned.
In practice, especially for DIY stuff, it's often a nightmare to setup, depending on the line, devices, resistors, environment and, most important than all others, a common valid reference. It must be common to both ends, or you necessarily get out of the valid RS485 ranges at some point, possibly randomly. => This is where the oscilloscope may help you to check if the signal is clean or not.

Modbus is not really a concern once RS485 is stable. It is just a "standard" way of communicating on top of RS485 (or another media). That way of communicating is based on "registers" that are "mapped" and can be either read-only or read-write. Typically, in your project you want to know which register you have to read to get the active power. This is documented in the "manual" document you shared. There, you'll find the map of registers, that is what information you can find in which register address. Also, the WattNode implements both its own register map and also another one, standardized as "SunSpec". Typically you'll find the "active power" is spread on 1 or 2 registers, depending which format you want.
If your are the master, just send a request for that registers to the meter, it will then send you the content of those registers. You'll just have to order the bytes appropriately to get the active power value.
Ok, how to formulate the request? If you use a library, look at "read holding register" (function 0x03) in its documentation. If you write your own code to build and send that request, than the typical format is:
<slave address>[1 byte] <function code>[1 byte] <first register address>[2 bytes] <count of registers>[1 byte] <CRC>[2 bytes]


NOTE: The master as "no address", because it doesn't need one, since it is the only one allowed to request something. The slaves reply with their address, for convenience and redundant check.

So, with this you have a global view. Now the deal will be different according to what library you can find to accomplish a part of the job. And if you do everything on your own, well it may take time but yes it is "funny".

I hope to publish my C++/linux software tomorrow evening (CET timezone), I'll share the link here when available. You'll find some reference code that may help you do the same or similar with an Arduino.
 
Last edited:
Back
Top