Coder Social home page Coder Social logo

Future Enhancement - MQTT about solar HOT 16 CLOSED

PhillyGilly avatar PhillyGilly commented on August 19, 2024
Future Enhancement - MQTT

from solar.

Comments (16)

RichardL64 avatar RichardL64 commented on August 19, 2024

Hi @PhillyGilly

I picked up this from Ebay UK - from a seller called Puretek.
They seem to be reasonably generic - the only gotcha being the silkscreen for the RS485 cables is marked back to front - so if it doesn’t work - swap the cables.

XY-017 3.3v 5v 12v RS485 TO TTL RS485 SP3485 RS-485 Breakout For Arduino RPi

https://www.ebay.co.uk/itm/274273632839

The Arduino seems more than cabable of relaying 1 second resolution across 10-12 attributes + even storing data locally to an SD (which I’ve not debugged as yet). Certainly plenty of oomph to integrate an MQTT library and post there.

I thought about home assistant - nothing wrong with it; but went this route for a few reasons:

  • The challenge - a little bit of coding
  • Arduino is slim - no O/S
  • Raspberry Pi is/was short on supply
  • Minimal software hardware stack - no cloud, less to break etc.

I’ve also found a thing called a Arduino Wemos D1 - which is a perfect client too this and can display simple red/amber/green lights + operate an external relay depending on solar availability.

I’m sure you could well do this with home assistant etc - I guess at the end of the day I preferred debugging a few hundred lines of code than configuration files :)

Regards;

from solar.

PhillyGilly avatar PhillyGilly commented on August 19, 2024

Hello @RichardL64. Thanks for the helpful reply.
I got the Puretek part thanks and am waiting on delivery of 50(!) sockets from China.
I like to do Fritzing sketches for all my Arduino projects and it it's any use here is one for this project (although I may have the TX to RX wrong bearing in mind your comment about the screen printing.)

ArduinoRS485_bb

My Solis inverter is a six month fix to non-availability of GivEnergy G2 kit, and it's there working away without either a dongle or meter/CT which I don't want to buy. So my only option to get data is to work locally with the RS485. As I've got HA up and running (RPi4 with SSD) with a lot of my energy consumption data it suits me best to get the inverter data in there too.

The coding approach I used for my Arduino energy meter was to use the MQTT pubsub.h then; 1. on initialisation publish a json file containing the HA auto-discovery data, and 2. periodically publish the json data to be read by HA. It looks like I can merge this approach into your code.

However before I get on with it, I am wondering about whether or not it will actually work without a meter/CT. So I think I'll probably knock up an exact copy of your project and If it doesn't produce the data I need, decide if I just use my Arduino MQTT energy or have fun adding the ADS115 adc as well as the MQTT. Happy days!

Cheers.

from solar.

RichardL64 avatar RichardL64 commented on August 19, 2024

from solar.

PhillyGilly avatar PhillyGilly commented on August 19, 2024

Hi Richard. I just got delivery from Alibaba of the plugs. When I tested the +5V on my inverter its dead. I'm assuming that's because it goes to sleep when there is no PV? Is that your experience? I'm not sure how I feel about my nano33 rebooting multiple times per day. Cheers. Phil

from solar.

RichardL64 avatar RichardL64 commented on August 19, 2024

from solar.

PhillyGilly avatar PhillyGilly commented on August 19, 2024

Hi @RichardL64 . I tested my inverter with a voltmeter across the pins (Blue: pin4 = 1.6v, Yellow: pin3 = 3.2v) and it definitely powers the RS485 down if the sun isn't shining so I'll probably keep the nano USB powered for the time being.
I also finally got delivery from China of the Exceedconn plugs and sockets. (I have put the remainder on sale on eBay http://ebay.co.uk/itm/195464332269 although I don't expect to make money on it, somebody else might want/need these parts).
Before attempting any serious coding, I got the example ModbusRTUClientKitchenSink sketch from the IDE, cut out all the calls apart from requestFrom, and compiled it to the nano. It runs and returns 1 to ModbusRTUClient.begin(9600), but the requestFrom fails with an error "Connection timeout" whatever register address used and for both combinations of AB inputs. I'm really scratching my head, but there's no point in going any further until I can get the underlying comms working. I have ordered a USB/RS485 plug to test the comms directly from my laptop. But meanwhile, any ideas however basic would be appreciated. TIA.

from solar.

RichardL64 avatar RichardL64 commented on August 19, 2024

from solar.

PhillyGilly avatar PhillyGilly commented on August 19, 2024

Agreed, the display is also off when not generating. I will re-check the 5V line tonight, but when I "commissioned" it, I worked in the evening to minimise DC risks. After it was all set up, I closed the MCB and turned on the AC isolator and nothing happened. I was convinced I'd made a mistake, but the next morning when I tried again it was working. I guess that Standard Stick is designed to power down and then power up?

from solar.

PhillyGilly avatar PhillyGilly commented on August 19, 2024

It's a configurable option in the Advanced settings. 24H Switch. Default is Disabled, but if you Enable it the inverter doesn't go to sleep.

from solar.

RichardL64 avatar RichardL64 commented on August 19, 2024

from solar.

PhillyGilly avatar PhillyGilly commented on August 19, 2024

Mixed result.....
image

It looks like enabling the inverter gets it to draw 60 W when the inverter isn't generating (that's the drop off in the raw purple line). It could be a bit less as my Arduino CT doesn't know about the power factor, but I can't match it exactly to the smart meter out put as both are on 10sec samples but not aligned.

So enabling the inverter overnight could use up to 1kWh which is the opposite of what I want to achieve.

I'll get the basic 485 working next week and then devise a strategy to deal with the inverter going to sleep...

from solar.

PhillyGilly avatar PhillyGilly commented on August 19, 2024

I had the rx-tx wires crossed. Here is my revised Fritzing sketch.
image
The example is running although I am having to offset the address by one, which I don't know if you are doing.

from solar.

RichardL64 avatar RichardL64 commented on August 19, 2024

from solar.

PhillyGilly avatar PhillyGilly commented on August 19, 2024

Hi @RichardL64, I thought I'd give you a quick update:

  1. Up and running!
    image
  2. In the end my code isn't that similar to yours, because:
    a) I'm not a very good coder, and b) the arduino just posts out the modbus data by mqtt as soon as it reads it, so there isn't any need to hold it locally. I just keep it in global variables.
  3. If your interested I can share it with you via Github. I haven't really tried to make the functions efficient as I don't need to, so I'm not going to hold it up as an example of how to do it.
  4. My inverter S6 uses different modbus addresses from your hybrid inverter. So if I want to know what is at address 3000, I have to interrogate address 2999. This is what I meant by offsetting the address.
  5. I solved the "inverter asleep at night" problem by working on the idea that if the modbus stopped communicating it meant the inverter had powered down. When that is detected "dynamic" values are set to 0 and "integrated" values are set to their last known value. That seems to placate my Home Assistant.
  6. As the arduino is in my loft next to the inverter which is five flights of stairs up from my office, so I use OTA and don't bother with any serial print for error traps. If I do want to know what's happening, I publish a mqtt message.
  7. I still need to work out how to write into the modbus time registers as I need to synchronise times so that "daily" values are for the same 24hrs. I have no idea how to take the time values as strings and convert the right bits into unsigned-16 but I'm sure that somebody somewhere has cracked it already.
    Cheers and thank you!

from solar.

RichardL64 avatar RichardL64 commented on August 19, 2024

from solar.

PhillyGilly avatar PhillyGilly commented on August 19, 2024

Here is my first attempt at a repository
https://github.com/PhillyGilly/SolarisS6ArduinoMqtt
I am going to have to work on formatting my reade.md and adding pictures.

OTA is part of #include <ArduinoOTA.h>
It's really simple and works well on the IDE v2.

from solar.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.