SolarBridge: a Wemos Base bridge between GroWatt and Toon

Forum about Toon hardware, both versions 1 and 2 of Toon

Moderators: marcelr, Toonz, TheHogNL, TerrorSource

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby oepi-loepi » Mon Apr 13, 2020 7:22 pm

jozg wrote:Hello Oepi-loepi,

Before i build the optocoupler etc. i flashed my wemos with the sketch.
I managed to get the wemos working, and can fill in the wifi and growatt details.

For some reason it shows nothing:
Actual: 0.00 Watt
Today: Not Connected Yet
Month: Not Connected Yet

It also shows
Connection Posssible: Yes
1000 imp/kW

Is it possible that i have an other growatt the your program is expecting?
I used the same credentials i use in https://server.growatt.com

Maybe you can help me in the right direction.
Thanks.

Regards,


Connection is possible it says so indeed you have wifi available and you manage to receive the session cookies from the login page at Growatt. . Could you please check the Arduino Serial monitor? Normaly you get about 8 pulses when you start and after that you receive the data from Growatt. It is visible in the serial monitor.

You can also browse (with a normal browser) to http://server-api.growatt.com/index after login? I assume you only have 1 plant?
oepi-loepi
Member
Member
 
Posts: 72
Joined: February 2019

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby jozg » Tue Apr 14, 2020 6:51 am

Hello Oepi-Loepi,

Here a copy of the serial logging.
I marked out my credentials.
Maybe, for further investigation, i can deliver you my credentials in a PM, so you can test is out?

Also logging in via http://server-api.growatt.com/index is working ok.
I'm nog using a email address, but only a login name to enter the server dashboard.

Thanks for helping.


mounting FS...
mounted file system
reading config file
opened config file
{"GroWattName":"****","GroWattPass":"********","dhcp":false,"ip":"192.168.1.100","gateway":"192.168.1.1","subnet":"255.255.255.0"}
parsed json
Setting up wifi from Static IP config
Last known ip from config
192.168.1.100
*WM: Adding parameter
*WM: GroWattName
*WM: Adding parameter
*WM: GroWattPass
*WM: Adding parameter
*WM:
*WM: Adding parameter
*WM: dhcp
*WM: Adding parameter
*WM:
*WM: Adding parameter
*WM:
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Custom STA IP/GW/Subnet
*WM: 192.168.1.100
*WM: Status:
*WM: 6
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.1.100
connected...yeey :)
local ip
192.168.1.100
192.168.1.1
255.255.255.0
8.8.8.8
*WM: freeing allocated params!
PulsesGen.: 0 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 1 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 2 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 3 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 4 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 5 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 6 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 7 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0

parseObject() failed
PulsesGen.: 8 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 9 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 10 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 11 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 12 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 13 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 14 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 15 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 16 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0
PulsesGen.: 17 ** EnergyDay: 0 ** Act.Power: 0.00 ** N.Periods :0 ** PowerCorre.: 0.00 ** Corr.Power: 0.00 ** timebetw.pulses: 2000 ** newday: 0

parseObject() failed
jozg
Member
Member
 
Posts: 52
Joined: November 2017

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby oepi-loepi » Tue Apr 14, 2020 12:04 pm

jozg wrote:Hello Oepi-Loepi,

Here a copy of the serial logging.
I marked out my credentials.
Maybe, for further investigation, i can deliver you my credentials in a PM, so you can test is out?

parseObject() failed



All looks ok but it should get the data where it states parseObject() failed. Are you sure you filled in your credentials ok? Indeed maybe you could send them by PM so I can test them.... Of course I will use them confidentially.
oepi-loepi
Member
Member
 
Posts: 72
Joined: February 2019

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby jozg » Tue Apr 14, 2020 12:12 pm

Hello,

Check your PM.
Thanks for helping me out!.

Regards,
jozg
Member
Member
 
Posts: 52
Joined: November 2017

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby oepi-loepi » Tue Apr 14, 2020 5:48 pm

jozg wrote:Hello,

Check your PM.
Thanks for helping me out!.

Regards,


Please download version 2.2. Problem has been solved. Thanks for yor help.
oepi-loepi
Member
Member
 
Posts: 72
Joined: February 2019

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby jerver » Tue May 26, 2020 5:45 pm

Thanks for this info. Based on this infomation I was able to connect my solar system to "Toonopzon".
My solution is based on the script I use to upload solardata to PVoutput. Each 5 minutes a script started by a cronjob is parsing the Solaredge data and uploads it to PVoutput. In this script the energy produced in the last 5 minutes is easy to calculate as well as the time.
WIth a few extra python commands I send the produced energy in the previous 5 minutes and the time (to prevent double entries) via a serial connection to a connected arduino. The arduino converts this energy in pulses for the upcoming 5 minutes and drives a led which frequency is measured by the "meteradapter".
It is not the most accurate solution and there is a time delay of 10 minutes but the totals seems to be allright. Anyway it serves its goal to give my family more insight in energy and its costs.
The arduino code is:
Code: Select all
/******************************************************************************************
* deze sketch verwacht input op de COM poort met waarden 20200520/12:30/123\n
* 20200520 = datum (wordt niet gebruikt
* 12:30 = tijdstip
* 123 = Aantal Wh in de meet periode (hier 5 minuten)
* \n = newline karakter
* Vervolgens wordt aantal Wh omgerekend naar het aantal pulsen en dit aantal wordt opgeteld bij het resterend aantal
*/

int led = 8; //internal led
unsigned long PulsesGenerated = 0;  //pulses generated in the periods from last change  (when blink, PulsesGenerated++ and reset after calculation of correction)
unsigned long DayTotalPulses = 0;
int PulsesPerWh = 10; // 10 pulses per Wh
long PulseInterval;
long TimeInterval = 300000; //300000 is 5 minuten
String Time = "none";
String PrevTime = "none";
long Energy = 0;
long NewPulses = 0;
long Pulses = 0;
unsigned long startMillis;  //some global variables available anywhere in the program
unsigned long currentMillis;
unsigned long startMillis2;  //some global variables available anywhere in the program
unsigned long currentMillis2;
String sdata="";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(led, OUTPUT);
  startMillis = millis();  //initial start time
  startMillis2 = millis();  //initial start time
  delay(1000);
  getdata();

}


void getdata(){
    Time = sdata.substring(9,14);
    Energy = sdata.substring(15).toInt();
   
    if (Time != PrevTime) { //nieuwe input 
         NewPulses = Energy * PulsesPerWh;
         Pulses = NewPulses + Pulses - PulsesGenerated;
      PulsesGenerated = 0;
         if (Pulses > 0)
           PulseInterval = floor(TimeInterval / Pulses);
      else
        PulseInterval = 999999999;
      PrevTime =Time;
    }
                               
}


void blinkled() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);               // wait for some time
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
}



void loop() {

//check of er input op de seriele poort is
  byte ch;

   if (Serial.available()) {
      ch = Serial.read();
      sdata += (char)ch; 
      if (ch=='\n') {  // Command recevied and ready.
         sdata.trim();
         // Process command in sdata.
         getdata();
         sdata = ""; // Clear the string ready for the next command.
      }
   }
   
//check of er een pulse verstuurd moet worden 
  currentMillis = millis();  //get the current "time" (actually the number of milliseconds since the program started)
  if (currentMillis - startMillis >= PulseInterval && PulsesGenerated < Pulses) { //test whether the pulsetime has eleapsed
    blinkled();
    PulsesGenerated++;
    startMillis = currentMillis;  //IMPORTANT to save the start time of the current LED state.
    //Serial.print("Pulses: ");
    //Serial.print(PulsesGenerated);
    //Serial.print(" van ");
    //Serial.println(Pulses);
  }
}


An example python script whit parameters on commandline for testing
Code: Select all
#!/usr/bin/python
import serial, time, sys
command = sys.argv[1]
port = '/dev/ttyACM1'
arduino = serial.Serial(port,115200,timeout=5)
arduino.flush()
time.sleep(.1)
arduino.write(str.encode(command +"\n"))
#arduino.write("20200524/15:40/1000\n")


You dont want your Arduino to reset when the com port opens/closes. You can prevent this by adding a 10 μF capacitor from ground to reset.
jerver
Starting Member
Starting Member
 
Posts: 10
Joined: February 2019

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby mvdbr4nd » Thu Sep 03, 2020 1:57 pm

Hello Oepi-loepi,

I have build your sketch yesterday and well its was my first Arduino project so I had to get used to the IDE etc. Somethings that I noticed while compiling is that you need to select the right versions of the libraries. F.e. Json you need to use version 5.x not 6.x (or you have to convert the code to be compatible not a big deal if your comfortable with coding C). SO not a big thing but I guess its not that obvious when compiling the first time. Also the Core of Arduino and the WIFI manager are a thing to keep in mind. Do not choose the recent core because there are isues compiling the sketch with WifiManager not being compatible.

I guess noting the correct version in the README makes sence in my case I came up with:

ArduinoJson 5.13.5
AdaFruit ESP8266 1.0.1
WifiManager 0.15.0
ArduinoCore 2.5.2 (board esp8266)

Some other things I noticed:

The MeterAdapter from Eneco:
There are different versions in the field. For This use you need the adapter that has 2 Jacks (3.5mm) and has 3 symbols on top of them instead of 2. I can confirm that version 6500-1300-7200 (with 2 icons) will not work. As in: Toon will not recognise this adapter to contain a solar analog input. (but KWh and Gas only). Which is wierd since they are there so its prob. a SW issue in the adapter.

The reset doenst work for me. As in it seems it does not remove the config.json file from the SD. (when invoked from the webpage). I will try to see why this file is not removed and old settings are used and the WEMOS does not go back into AP mode. I bypassed this issue by hardcoding some settings to overrrule the existing config file.
What I see is that the reset does not clear the config file (but from the code i see nothing strange) - I will look into it.

Anyways cool idea! and lets see if we can get the data more directly from the "omvormer" instead of the 5 min. resolution growatt server (that would be a nice improvement).
mvdbr4nd
Starting Member
Starting Member
 
Posts: 11
Joined: June 2019

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby mvdbr4nd » Sun Sep 06, 2020 9:20 am

For those that struggle to compile the sketch please use:

* Library versions
* ESP board (core version) 2.5.2
* ArduinoJson 5.13.5
* WifiManager 0.15.0

Otherwise you will end up with redecleration header issues due to the wifimanager. Also note that this sketch uses the (old) style ArduinoJson lib.

I can confirm that this setup works great. But please note that not all MeterAdapter will be able to act as a solar analalog input next to P1 measurements. You can recognise the compatible adapters with 3 icons above the jack inputs instead of 2 icons.
mvdbr4nd
Starting Member
Starting Member
 
Posts: 11
Joined: June 2019

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby oepi-loepi » Wed Sep 09, 2020 10:40 pm

Thank you for your comments on this post. I am sure this will help others to get it all working.
oepi-loepi
Member
Member
 
Posts: 72
Joined: February 2019

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby mvdbr4nd » Tue Sep 15, 2020 5:26 pm

I created a fork for solaredge users
I have a growatt myself but someone asked me if it could be done for solaredge as well.

https://github.com/mvdbr4nd/solarbridge-solaredge

Its basicly the same code with some changes for solaredge. This API does not require cookies but different ssl (fingerprint). and the parsing is a little bit different.
I also removed the custom wifi params because those appear to be broken in the lib (wifimanager) this is a known issues apparently. I will look into creating a settings page of something else if the custom params are not addressed. For now you will have to put the APIkey and SiteID in the ino file to make it work.

As for the rest of this bridge, I created a nice print for the LED and the optocoupler everything is running fine for over a week.
mvdbr4nd
Starting Member
Starting Member
 
Posts: 11
Joined: June 2019

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby TheHogNL » Tue Sep 15, 2020 5:53 pm

mvdbr4nd wrote:I created a fork for solaredge users
I have a growatt myself but someone asked me if it could be done for solaredge as well.

https://github.com/mvdbr4nd/solarbridge-solaredge

Its basicly the same code with some changes for solaredge. This API does not require cookies but different ssl (fingerprint). and the parsing is a little bit different.
I also removed the custom wifi params because those appear to be broken in the lib (wifimanager) this is a known issues apparently. I will look into creating a settings page of something else if the custom params are not addressed. For now you will have to put the APIkey and SiteID in the ino file to make it work.

As for the rest of this bridge, I created a nice print for the LED and the optocoupler everything is running fine for over a week.



Nice work!
Minor remarkt though... "Data from the website (from the convertor) is used to generate pulses (1 pulse / watt) "

It doesn't create 1 pulse/watt. For example, if the solar is doing 3000 watt. Is it then sending 3000 pulses? :-)
No, it generates pulses per specific amoung of watthour produced.
Member of the Toon Software Collective
User avatar
TheHogNL
Forum Moderator
Forum Moderator
 
Posts: 1621
Joined: August 2017

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby TheHogNL » Tue Sep 15, 2020 5:59 pm

Do you have that growatt version also online?
Member of the Toon Software Collective
User avatar
TheHogNL
Forum Moderator
Forum Moderator
 
Posts: 1621
Joined: August 2017

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby gert848 » Tue Sep 15, 2020 6:53 pm

mvdbr4nd wrote:I created a fork for solaredge users
I have a growatt myself but someone asked me if it could be done for solaredge as well.

https://github.com/mvdbr4nd/solarbridge-solaredge

Its basicly the same code with some changes for solaredge. This API does not require cookies but different ssl (fingerprint). and the parsing is a little bit different.
I also removed the custom wifi params because those appear to be broken in the lib (wifimanager) this is a known issues apparently. I will look into creating a settings page of something else if the custom params are not addressed. For now you will have to put the APIkey and SiteID in the ino file to make it work.

As for the rest of this bridge, I created a nice print for the LED and the optocoupler everything is running fine for over a week.

Thanks for the great job :)
gert848
Starting Member
Starting Member
 
Posts: 1
Joined: March 2020

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby oepi-loepi » Wed Sep 16, 2020 6:01 pm

Super thank you for taking your time and effort to create this. In the near future i will create a .bin file which includes all libs also or i will create a folder in the git containing the libs needed.

Again, thank you for this and maybe it is a good idea to start a new topic for this solaredge to attrack more solaredge users to this piece of software and the nice solaredge interface solution.
oepi-loepi
Member
Member
 
Posts: 72
Joined: February 2019

Re: SolarBridge: a Wemos Base bridge between GroWatt and Toon

Postby mvdbr4nd » Fri Sep 18, 2020 2:20 pm

Hi,

As i said previously I would look into some issues regarding - Custom wifi parameters and the JSON parser update. Also improving some minor things i noticed like the power keeping at 10W in the night. First this is my first arduino project so I got a bit frustrated with the Arduino IDE and moved over to PlatformIO. I converted both solarbridges to use PlatformIO which is a lot more dev friendly because this IDE will automaticly download required libraries + libraries are referenced by versions in the project file which means that by compiling the project from scratch you always have the right dependent libs downloaded and linked. Its a lot more friendly + a lot better IDE if you ask me.

So I migrated to Platform IO and managed to get everyhing compiled and running with the latests Core / ArduinoJSON6 and WifiManager also fixing the issues above. It also seems the Power goed to 0W in the night (which was a nice +) no idea why could be a core version which is now more recent.

Here are the sources: if you are intrested in platformio (using VisualStudio Code)
https://github.com/mvdbr4nd/solarbridge-solaredge
https://github.com/mvdbr4nd/solarbridge-growatt

I can also mention we have the first live installation working with solarbridge for solaredge! ;-)
mvdbr4nd
Starting Member
Starting Member
 
Posts: 11
Joined: June 2019

PreviousNext

Return to Toon Hardware

Who is online

Users browsing this forum: No registered users and 1 guest

cron