PV Inverter - monit...
 
Notifications
Clear all

PV Inverter - monitoring and control using Modbus & RS485

20 Posts
5 Users
14 Likes
420 Views
Majordennisbloodnok
(@majordennisbloodnok)
Noble Member Member
3854 kWhs
Joined: 2 years ago
Posts: 348
Topic starter  

Posted by: @cathoderay

@majordennisbloodnok - I'm not in the business of telling anyone they must do something a particular way,

...

No, you're not; I quite agree. I do, however, get the feeling your suggestions contain more than a modicum of your personal biases based on your situation. I could, of course, be interpreting your language incorrectly but my recommendation to anyone else is to approach all the options with an open mind. I doubt you would disagree, especially as I've seen you write as much several times.

Posted by: @cathoderay

...

HA does have a lot of modules/add-ons, but they are not always easy to configure; the scripts, on the other hand, are so simple that once you have got the hang of them, they are easy to configure.

...

The key there is "once you have got the hang of them". Until that point a newcomer is in the same position either way; an obstreperous module or some coding they've never done before. That's a learning curve whichever way you jump. Of course, many HA integrations are easy to configure and that has to be factored in too.

Posted by: @cathoderay

...

Not everyone (and that includes me) has everything in their home (including that smart chip in their left buttock) hooked into their home network... I also think if someone rules out an option, then it is very useful to know why they ruled it out (so the reader can make their own assessment of whether the reason also applies to them).

...

I agree, but you only need to look at the success of the major smart home offerings of Google, Amazon, Apple and the like to see many people do indeed have at least a lot of different devices attached to their network, robotic gluteus maximus notwithstanding. If someone wants to add some intelligence to their heating and solar PV system and keep that separate from the rest of their home automation that's not a problem. If they already have a home automation system and want to bring their heating and solar PV into the fold then the home-grown python scripts may well not cut it, nor if they want to start with heating and solar PV but know in advance they'll want to extend to other smart devices. Once again, horses for courses.

On a tangent, btw, doesn't a "chip in their left buttock" make someone de facto a smart arse? 😎 

Posted by: @cathoderay

...

By the bye, another advantage of using python scripts I forgot to mention is they allow you to store the data in csv files, while HA uses sqlite or in some cases full blown relational databases to store the data. This immediately makes the data less accessible, and furthermore, in my experience, HA can randomly corrupt its database, causing major headaches. Short of over-writing the file, it is very difficult to corrupt a csv file, and if by chance corruption does occur (has yet to happen to my Midea monitoring system), the file can be opened in a text editor to see what happened, and what can be recovered. Another relatively recent discovery is a program called 'q text as data', an absolutely brilliant bit of software that allows you to run sql queries on multiple csv (and tab separated) files, including the use of joins. It's available for most operating systems, and can be found here. That way you get the best of both worlds, the simplicity of csv files, plus the sophistication of sql queries.

...

That's whole other world and probably best left to another thread to cover in more detail. However, there are a few key things I'd pick up on here.

  • On one hand you're giving the "need to become a network engineer" to perform a minor config change to an RS485 to Ethernet converter as a level of complexity to be avoided if possible (which many people would get done by asking a friend - we almost all have someone with some skill in that area and if all else fails we could ask our children/grandchildren since it's often almost second nature to them) yet on the other hand you're happily recommending people getting into SQL. To me, knowing both disciplines, that's quite a leap. That's not, by the way, a suggestion SQL is too complex but most people wanting to analyse data will stick with Excel and create some graphs.
  • SQLite already is a full blown relational database.
  • There are many reasons for using databases in preference to text files and I could lecture for hours on the reasons. Nonetheless, the only real barrier to accessibility is knowing what to install to connect and type in your commands (or click around). In order to program in Python you have the same issue; you can't create an executable python script without somewhere to type the code into and something running on your computer that will read those commands and act on them.
  • Instead of connecting to and using a ready-installed relational database you're suggesting installing something else that will turn multiple text files into a relational database but without the query planning benefits a relational database provides by design. I don't doubt Q - Text as Data is useful for ad-hoc times when you want to query some text files but why abandon a relational database only to suggest a less efficient alternative?

I fully support your intention to show people there are alternatives to many approaches. However, it feels you are trying to twist and turn to avoid using a perfectly mainstream mature solution already available i.e. an off-the-shelf home automation system. I'm not arguing for Home Assistant itself - that was just my choice of system given my circumstances and set of skills - just making clear that a mainstream home automation system of any kind becomes mainstream only by being a good enough compromise of ease of use vs range of functionality to appeal to a wide audience. Yes, people can choose to do it themselves but that requires a learning curve too.

Posted by: @cathoderay

...

One of the great things about this forum is we get posts detailing different options, usually with comments on the pros and cons, and some practical details. That's exactly how I think a forum like this should be, a resource, and that is what I like to think we achieve with our post (our being all contributors, not just us two). 

Totally agree.

 

105 m2 bungalow in South East England
Mitsubishi Ecodan 8.5 kW air source heat pump
18 x 360W solar panels
1 x 6 kW GroWatt battery and inverter
Raised beds for home-grown veg and chickens for eggs

"Semper in excretia; suus solum profundum variat"


   
IanMK13 reacted
ReplyQuote
(@ianmk13)
Estimable Member Member
1026 kWhs
Joined: 1 year ago
Posts: 67
 

As a retired electronics engineer, could I add my perspective to this debate (sorry - we seem to be moving away from the Modbus topic).

I was 'repurposing' structured cabling and using ethernet-RS-485 adapters a scarily-long time ago (I've just realised over 20 years ago). These 'hacks' came in very useful in many prestigious projects. My software skills were founded on machine code and assembler, moving onto Basic, Excel macros, Visual Basic and the like. I was busy enough navigating many diverse technologies and specialisms without moving into mainstream software development.

One of my present small projects is to resurrect my intruder alarm, which hasn't worked since I moved into my home almost 9 years ago.  I discovered a microcontoller-based 'Smart' Intruder Alarm interface bein sold online which is intended to fit inside the existing indoor alarm unit and use the existing sensors and outdoor sounder. The user interface could be via a 3rd party 'cloud' interface - which I didn't want to have to rely on for several reasons - or a local Home Automation hub.  Since Home Assistant is a very popular Home Automation hub and it has an 'integration' for this particular device, as well as many useful 'bolt-on' features, I decided to try Home Assistant.  I originally installed on an old PC but now keep this as my 'development environment'.  I received a Home Assistant Green (similar to a Rasperry-Pi) for Christmas, which I use as my 'production environment'.

It took me a while to become familiar with Home Assistant.  It can be used at different 'skill levels' and seems to be underpinned by Python.  A disadvantage is that it can be a little buggy but it is supported by the more-capable user community, so updates can be annoyingly frequent.  It is, however, improving all the time.

I have looked at Python and appreciate that I should investigate more.  Unfortunately, I've still not managed to 'find a way in'. As @majordennisbloodnok suggests, "once you have got the hang of them" isn't a trivial issue. Although Python may be written in English, it all reads like Greek to me; its the syntax and structure which I find difficult to navigate.  The same is true for JSON for me, too.

 


   
ReplyQuote
Transparent
(@transparent)
Famed Member Moderator
8122 kWhs
Veteran Expert
Joined: 2 years ago
Posts: 1354
 

I'm picking up the point made above by @majordennisbloodnok about the need for practical basic advice in this topic.

May I submit the following basic guidance:

RS485 and Modbus are separate concepts, but frequently encountered simultaneously.

 

RS485 is a communications standard, just as are the more common RS432 serial port and USB standards.
The Standard stipulates voltage levels (-7v to +12v) and speeds across a pair of wires labelled A and B.

However, RS485 doesn't have a defined connector associated with it.
Some devices simply provide an RS485 port via screw-terminals for each wire, and others use a common connector (eg an RJ45) which is normally associated with a different type of communication, such as ethernet.

RS485wiring

A device with an RS485 port will have a connection for A & B, and (usually) an earth.

All As are connected together, and all Bs similarly.
There must be a single main connection wire (bus) running along all the devices in a chain, with no side-branches.

Devices which offer an RS485 port can be varied within the same bus.
You can buy noise-level sensors, liquid level sensors, gravity/magnetometers (if you're so inclined) and converters to other standards, such as USB.

image

Each device on an RS485 bus is assigned its own unique address between 1 and 247.

 

Modbus is a defined set of commands which can be sent across an RS485 bus, and also across other types of communication network.

There is a Modbus Organisation which defines the standard, but doesn't enforce it.

Consequently many devices are available which use derivatives or sub-sets of the Modbus standard.
You need to consult the device manufacturers' documentation to see what commands are supported.

image
This post was modified 2 months ago 2 times by Transparent

Save energy... recycle electrons!


   
ReplyQuote
cathodeRay
(@cathoderay)
Famed Member Moderator
6810 kWhs
Joined: 2 years ago
Posts: 1383
 

Posted by: @majordennisbloodnok

I do, however, get the feeling your suggestions contain more than a modicum of your personal biases based on your situation

And why not: this is a forum, and forums are places for debate, and debate means two or more parties putting their case on the table. I'm not trying to write the ultimate impartial guide, I am instead giving an account of my experiences, what decisions I made, and why I came to those decisions. For example, I decided HA is not for me, because I find it awkward and cumbersome. Equally, I decided python scripts were for me, because without too much effort I could write scripts that did exactly what I wanted them to do. I chose csv files over a relational database because they are simple and robust, and are more than adequate for my normal everyday use, and then I discovered that very conveniently I can also run sql type queries on csv files, for those rare occasions where I wanted to do something a bit more esoteric, like merging two similar but not identical format data sets. This gives me the best of both worlds. Of course I have a personal bias in favour of what I have chosen! The key point is that this being a forum, it behoves me to say why I have the bias I do.

Likewise, you have a bias towards HA. That's fine, and you have I think given your reasons: you have a very smart home and possibly an even smarter arse 😎 and it makes sense to you to hook up these many smart things to a central home automation system that has many modules add-ons that can talk to your smart devices. It makes perfectly good sense to me, and if that is the way you want to go, great.

At this point, others are more than capable of seeing there are different options, and providing we do them the courtesy of telling them why we have chosen the options we have, they are more than capable of considering what choices they want to make. Furthermore, this being an open forum, they are free to make comments and ask questions. At the end of the day, threads like this one are a resource, loosely formatted for sure, but they contain information ('I chose X') and opinions (I chose X because...') that we post in the hope that it might be useful to someone else. 

Midea 14kW (for now...) ASHP heating both building and DHW


   
ReplyQuote
Majordennisbloodnok
(@majordennisbloodnok)
Noble Member Member
3854 kWhs
Joined: 2 years ago
Posts: 348
Topic starter  

Posted by: @cathoderay

...

Likewise, you have a bias towards HA.

...

As it happens, no. As I have got older I have found I tend to view software far more as a commodity than in times past and I'll happily chop and change between two solutions with equal utility to me. If future updates to OpenHAB change the balance away from HA I will have no compunction in switching. My use of HA at the moment are based on it providing more of the functionality I want but when it comes to evaluating that I'm about as platform agnostic as one can reasonably be.

Posted by: @cathoderay

...

That's fine, and you have I think given your reasons: you have a very smart home and possibly an even smarter arse 😎 and it makes sense to you to hook up these many smart things to a central home automation system that has many modules add-ons that can talk to your smart devices. It makes perfectly good sense to me, and if that is the way you want to go, great.

...

 

Even with a chip in it, there's no way I could claim to have a smart arse although I have certainly been guilty in the past of acting like one. Hey ho, lesson learned.

Those comments aside, your last post seems to me to sum things up really well. The consultant in me (from many years ago) focuses me on giving as balanced and impartial comments as I can and letting others make their own decisions. However, as you say if you have biases and make them clearly understood then that has just as much value in a forum like this and perhaps the contrast in presentations adds still more.

Posted by: @cathoderay

...but they contain information ('I chose X') and opinions (I chose X because...')...

Actually I chose not to use "X" even before Musk bought it 😉 

Badoom, tsh.

 

 

105 m2 bungalow in South East England
Mitsubishi Ecodan 8.5 kW air source heat pump
18 x 360W solar panels
1 x 6 kW GroWatt battery and inverter
Raised beds for home-grown veg and chickens for eggs

"Semper in excretia; suus solum profundum variat"


   
ReplyQuote
Majordennisbloodnok
(@majordennisbloodnok)
Noble Member Member
3854 kWhs
Joined: 2 years ago
Posts: 348
Topic starter  

Posted by: @editor

I’ve missed the boat now, but this autumn I’m going to try and figure out our monitoring and will be revisiting the related topics.  

@editor, whilst you might not have time to do anything about your monitoring at the moment, I would nonetheless still strongly suggest you start a bit of a list now; a list of things you want to achieve and a rating of essential or nice to have for each of them. Basically the longer you have time to crystalise your thoughts on what you want any solution to do for you, the better the position you'll be in to choose a path when you do start to have time to act.

 

105 m2 bungalow in South East England
Mitsubishi Ecodan 8.5 kW air source heat pump
18 x 360W solar panels
1 x 6 kW GroWatt battery and inverter
Raised beds for home-grown veg and chickens for eggs

"Semper in excretia; suus solum profundum variat"


   
Mars reacted
ReplyQuote



Transparent
(@transparent)
Famed Member Moderator
8122 kWhs
Veteran Expert
Joined: 2 years ago
Posts: 1354
 

To continue with my overview of practical advice....

RS485 is a slightly loose standard, which means it often works when you've made a mistake!
Nevertheless it's obviously best to try and get it right.

The A & B wires are a twisted pair.
But the size of the conductors and number of twists per metre aren't defined.

The twists limit the amount of interference which gets picked up through the air from nearby electronic devices.
Since a single RS485 bus can be over a kilometer long, this is an important point.
Without the twists, the wire would be acting as an aerial!

There can be up to 32 devices on a single RS485 bus.
That limit is imposed by the amount of power which can be delivered by the driver chips on each device.
(Note that I'm deliberately avoiding the maths and the characteristics of current/voltage delivered by these drivers. Look elsewhere online if you want that level of detail.)

RS485wires

Most devices with an RS485 port are supplied with the address set to 1.
Before connecting them together, you'll need to check that each device has a unique ID.

I never leave a device with an address of 1.
If it's urgent to do so, that enables me to replace a broken unit by taking a new one straight out the box and plugging it in.

Sometimes an address can be configured with on-board jumpers or links.
More commonly you configure the address by using a Modbus command.
That obviously requires you to connect it to a Modbus Master unit whose address isn't 1

Each end of the RS485 bus must be 'terminated' with a 120-ohm resistor across the A & B connections.

Some devices have a 120Ω resistor already on the board. You cut the pcb tracks with a knife if you don't require it.

Other devices, typically those which are used as Master controllers such as a Raspberry Pi Hat or an Arduino, will have an on-board jumper which you set to add the on-board resistor if it's needed.

RS485 120R

If you're simply connecting an RS485 board to a controller on the workbench to configure its address, then it will almost certainly work without a twisted pair of wires or either of the termination resistors. 🙂 

This post was modified 2 months ago 3 times by Transparent

Save energy... recycle electrons!


   
ReplyQuote
cathodeRay
(@cathoderay)
Famed Member Moderator
6810 kWhs
Joined: 2 years ago
Posts: 1383
 

Posted by: @majordennisbloodnok

As it happens, no.

OK, I got that wrong, but you do have a bias - towards

Posted by: @majordennisbloodnok

happily chop[ing] and chang[ing] between two solutions with equal utility to me

All I am saying is that in a forum we are not writing balanced impartial reports, we are discussing various options, and we all come from a particular place, that is as I see it how forums work. The key thing for me is reasons and practical experience, why something did or didn't work. That is what I am looking for when I read these sorts of threads.

I am afraid I am forever condemned to being a dumb arse, as the only time they will be able to chip me is when I am in a wooden box, core temp at room temp, at which time the chip can be as smart as it likes, the electronic lights may be on, but there'll be nobody at home.

Yes, very good general advice to get ahead of the game by thinking about what exactly you are trying to achieve, and how best to achieve it. It also takes time to determine exactly what you need (hardware and software), and where to get it.

For example, @transparent gives an excellent extended run down on RS-485 above, but it took me a while to realise I didn't need a dedicated (and relatively expensive) RS-485 twisted pair cable, because ordinary (and relatively cheap) shielded twisted pair Cat 5e network cable had not one but four twisted pairs, one used for the modbus connections, and one of the others to supply 5V (from the USB port) to any sensors that need 5V, leaving two redundant pairs. Total cost for 20 metres on ebay a year ago: £7.98, and it has worked without problems since I installed it.       

 

Midea 14kW (for now...) ASHP heating both building and DHW


   
Mars reacted
ReplyQuote
Page 2 / 2
Share:

Join Us!

Latest Posts

x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security