Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: VS6048 Solar CC Wifi Monitoring System Post ReplyPost New Topic
<< Prev Page of 3
Author
Message << Prev Topic | Next Topic >>
azhaque
Newbie
Newbie


Joined: 21 February 2017
Location: Pakistan
Online Status: Offline
Posts: 26
Posted: 16 October 2018 at 4:21pm | IP Logged Quote azhaque

Hello everyone,

Progress to report, of the last 2-3 days.

Got the ESP8266 to run a webserver displaying dummy data, on my home network. This Network runs on an old Linksys router (pic below).





The Arduino/ESP8266 code is given below



#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

// Replace with your network credentials
const char* ssid = "TeenZaitoon";
const char* password = "OliveGrove2018";

ESP8266WebServer server(80);   //instantiate server at port 80 (http port)

String page = "";
double Adata; 
double data48A; 
double data48B; 

void setup(void){

  pinMode(A0, INPUT);
  
  delay(100);
  Serial.begin(115200);
  WiFi.begin(ssid, password); //begin WiFi connection
  Serial.println("");
  
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(50);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  server.on("/", [](){
    page = "<h1>Olive-Grove Solar Power Stats</h1><h3>Analogue: "+String(Adata)+"</h3><h4>ChargeCont-A: "+String(data48A)+"</h4><h5>ChargeCont-B: "+String(data48B)+"</h5>";
    server.send(200, "text/html", page);
  });
  
  server.begin();
}
 
void loop(void){
  Adata = analogRead(A0)-5;
  data48A += 3;
  data48B += 7;
  delay(150);
  server.handleClient();
}
ar Power Stats</h1><h3>Analogue: "+String(Adata)+"</h3><h4>ChargeCont-A: "+String(data48A)+"</h4><h5>ChargeCont-B: "+String(data48B)+"</h5>";
    server.send(200, "text/html", page);
  });
  
  server.begin();
}
 
void loop(void){
  Adata = analogRead(A0);
  data48A += 3;
  data48B += 7;
  delay(150);
  server.handleClient();
}


Picture of the data on my Chrome browser






Perusal of the Code would show that the output is essentially dummy data. This would be substituted by the actual data from the MODBUS outputs of the Charge Controllers. The photo below shows the simulated output voltage (0- 5 VDC) from the ACS758 that will indicate battery current, both charging and discharging.





Next step is to test out the MODBUS system and write its software.

Regards all round.

azhaque





Edited by azhaque on 16 October 2018 at 4:36pm



Back to Top View azhaque's Profile Search for other posts by azhaque
 
azhaque
Newbie
Newbie


Joined: 21 February 2017
Location: Pakistan
Online Status: Offline
Posts: 26
Posted: 19 October 2018 at 10:29pm | IP Logged Quote azhaque

Hi there,

Further progress to report.

Got the SoftwareSerial library system for ESP8266 up and running.

This Library allows one to emulate an extra UART on the 8266. I need the extra UART to connect to the channel for the second CC. O/P video on Youtube.

https://www.youtube.com/watch?v=xfXNs84Q56I


azhaque



Edited by azhaque on 19 October 2018 at 10:30pm
Back to Top View azhaque's Profile Search for other posts by azhaque
 
azhaque
Newbie
Newbie


Joined: 21 February 2017
Location: Pakistan
Online Status: Offline
Posts: 26
Posted: 24 October 2018 at 9:00pm | IP Logged Quote azhaque

Progress slow due to time constraints.
Had to mount Arduino mega board with the 8266 veroboard. This is because I can't risk connecting the prototype to the CC for the fear that the CC maybe damaged during testing plunging the home into darkness.
Now Arduino would run the modbus slave sketch for testing.
Last week spent on making a new mounting. Pic below
azhaque
Back to Top View azhaque's Profile Search for other posts by azhaque
 
azhaque
Newbie
Newbie


Joined: 21 February 2017
Location: Pakistan
Online Status: Offline
Posts: 26
Posted: 06 November 2018 at 6:19pm | IP Logged Quote azhaque

Sorry all for the delay in posting an update.

I now have the circuit working which collects VS6048 Charge Controller data via MODBUS. The microcontroller is an ESP8266-12E used in a NodeMCU development board.

Youtube video attached here

Next step is to put the data on the home network using the built in wifi in the ESP.

Regards

azhaque
Back to Top View azhaque's Profile Search for other posts by azhaque
 
lizby
Guru
Guru


Joined: 17 May 2016
Location: United States
Online Status: Offline
Posts: 306
Posted: 06 November 2018 at 10:42pm | IP Logged Quote lizby

Nice. Is that an RS-485 module on the right of your perfboard, connecting to the charge controller using the green ethernet cable (stripped at the perfboard end?

Or perhaps as you suggest, a MODBUS module (or are they the same?).


Edited by lizby on 06 November 2018 at 10:43pm
Back to Top View lizby's Profile Search for other posts by lizby
 
azhaque
Newbie
Newbie


Joined: 21 February 2017
Location: Pakistan
Online Status: Offline
Posts: 26
Posted: 07 November 2018 at 12:19pm | IP Logged Quote azhaque

lizby wrote:
Nice. Is that an RS-485 module on the right of your perfboard, connecting to the charge controller using the green ethernet cable (stripped at the perfboard end?

Or perhaps as you suggest, a MODBUS module (or are they the same?).



Hi Lizby,

You guessed it right. That is indeed the MODBUS module using a MAX485 IC. Very cheap of low quality but works for me. This is a link to similar units on Amazon.

I also attach the datasheet/writeup about the innards of the VS6048 CC, very graciously shared by EPEVER/EPSOLAR. Should be useful for those who would like to continue on this line of work.

Regards

azhaque

2018-11-07_121825_BSeriesControllerProtocolv2.4.zip
Back to Top View azhaque's Profile Search for other posts by azhaque
 
azhaque
Newbie
Newbie


Joined: 21 February 2017
Location: Pakistan
Online Status: Offline
Posts: 26
Posted: 08 November 2018 at 1:42pm | IP Logged Quote azhaque

Greetings all,

Update pls.

Got the software up and running.

Data from the Epsolar VS6048BN charge controller using MODBUS protocol is fed to the ESP8266. The ESP payloads it on a wifi system feeding into the home network.

The pic below shows the ESP circuit sitting on the stairs on a make shift arrangement, just outside the garage door. Initially tried it inside the garage but the system doesn't work because garage door is steel and grounds the wifi radio signal. The green cable is from the charge controller carrying the MODBUS data. It is over 3 meters long and there seems to be no issue in data transmission.






The image below is the Router sitting inside the lounge. The signal is easily received in all the rooms, including the basement.






A short Video about the live data on screen on the laptop.

Now to clean up/improve the ESP code and make proper weatherproof housing for the ESP for placement outside the garage, in the open.

Regards
Back to Top View azhaque's Profile Search for other posts by azhaque
 
akashh
Senior Member
Senior Member


Joined: 19 January 2014
Location: India
Online Status: Offline
Posts: 115
Posted: 08 November 2018 at 3:44pm | IP Logged Quote akashh

Hi,
Looks good. It reminds me of how I started Wattmon almost six years ago. I had worked with the same current sensor but opted for a Hall effect sensor that didn't require a physical wired connection after having some trouble with solder joints and just the general inconvenience of having to disconnect the cables every time it required a fix.
As for SoC I use the coulomb counting method which is not terribly accurate but usually gives a decent indication of charge, and can be further improved by setting the Peukert constant.
Please do not view this as an advertisement for the Wattmon but rather as an alternative to developing the system from scratch if it gets too much. If you wish to know more you can PM me or check out the website at www.wattmon.com

All the best
Akash
Back to Top View akashh's Profile Search for other posts by akashh
 
azhaque
Newbie
Newbie


Joined: 21 February 2017
Location: Pakistan
Online Status: Offline
Posts: 26
Posted: 10 November 2018 at 11:55am | IP Logged Quote azhaque

Akashh,

Namastay from Islamabad.

The wattmon is a real wow. However my system is a piddly copy of the wattmon.

Keep up the good work.

Aurangzeb Haque
Back to Top View azhaque's Profile Search for other posts by azhaque
 
azhaque
Newbie
Newbie


Joined: 21 February 2017
Location: Pakistan
Online Status: Offline
Posts: 26
Posted: 19 November 2018 at 2:42pm | IP Logged Quote azhaque

Hi everyone,
Seasons greetings.

The project is moving on albeit at a slow speed. Since my last post I have been able to improve the software further and put the data on THINGSPEAK, which maybe seen here.

The initial design was based on the ESP8266 running a web-server. The problem was that the server would run for two to three hours and then crash. After a power recycle it would start again but crash a couple of hours later. Research showed that it is caused by a problem in the software libraries, called 'memory leak'. Any way I have changed tack and rehashed the firmware to run the ESP in STATION mode. Now the ESP;
a. Collects the data from the VS6048 Charge Controller on MODBUS;
b. Processes it and hands the data over wifi to my modem/router (photo below)
c. The modem sends it thru the local mobile internet facility (called ZONG - a Chinese company (what else did you expect) to THINGSPEAK. The ESP code running the whole show is also copied below.

Next step is to modify the software to pick up the data from the second EPSolar VS6048 Charge Controller, also connected to the battery. The data would be consolidated and then sent over to the IOT Thingspeak for display.

I have also begun making a PCB for it on EASY-EDA. Hopefully I should get it finalized in the next week or so.



#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>
#include <ModbusMaster.h>

// Zong Wifi Credentials
const char *ssid = "ZONG MBB-E5573-E9A6";
const char *password = "************";

/*
Thingspeak keys
1. Write Key : ***************
2. Read Key : ****************
*/
const char *host = "api.thingspeak.com";
String apiKey = "**************";  //ENTER YOUR API KEY <<<<<<<<<<<


#define MAX485_DE       D2
#define MAX485_RE       D1

#define PANEL_VOLTS     0x00
#define PANEL_AMPS      0x01
#define PANEL_POWER_L   0x02
#define PANEL_POWER_H   0x03
#define BATT_VOLTS      0x04
#define BATT_AMPS       0x05
#define BATT_POWER_L    0x06
#define BATT_POWER_H    0x07

#define LOAD_VOLTS      0x0C
#define LOAD_AMPS       0x0D
#define LOAD_POWER_L    0x0E
#define LOAD_POWER_H    0x0F

#define BATT_TEMP       0x10
#define DEV_TEMP        0x11
#define BATT_SOC        0x12

#define TODAY_ENERGY_L  0x00
#define TODAY_ENERGY_H  0x01
#define MONTH_ENERGY_L  0x02
#define MONTH_ENERGY_H  0x03
#define YEAR_ENERGY_L   0x04
#define YEAR_ENERGY_H   0x05

int deviceID = 1;

float PV_VData;
String PV_VDataS;

float PV_IData;
String PV_IDataS;

float PV_PData;
String PV_PDataS;

float Batt_VData;
String Batt_VDataS;

float Batt_IData;
String Batt_IDataS;

float Batt_PData;
String Batt_PDataS;

float Load_VData;
String Load_VDataS;

float Load_IData;
String Load_IDataS;

float Load_PData;
String Load_PDataS;


float Energy_TData;
String Enery_TDataS;

float Energy_MData;
String Energy_MDataS;

float Energy_YData;
String Energy_YDataS;

float BattTemp;
int BattSOC;
float CCTemp;


int Caunter=10;

// instantiate ModbusMaster object
  ModbusMaster node;

void setup() {
    
  Serial.begin(115200);
  while (!Serial) {
    ;
  }
  
  pinMode(MAX485_RE, OUTPUT);
  pinMode(MAX485_DE, OUTPUT);
  
 // Init in receive mode
  digitalWrite(MAX485_RE, 0);
  digitalWrite(MAX485_DE, 0);
  
  node.begin(1, Serial); //deviceID = 1 selects the first Charge Controller.
  // Callbacks 
  
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);

  WiFi.mode(WIFI_STA);        // Setup as Station
  WiFi.begin(ssid, password); //Connect to your WiFi router
  //Serial.println("");

  //Serial.print("Connecting");
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(100);
    //Serial.print(".");
  }

}
                                                                                                                                                                                                                           

//=======================================================================
//                    Main Program Loop
//=======================================================================

void loop() 
{

  WiFiClient client;          
  const int httpPort = 80; //Port 80 is commonly used for www
 //---------------------------------------------------------------------
 //Connect to host, host(web site) is define at top
  
 if(!client.connect(host, httpPort)){
   //Serial.println("Connection Failed");
   delay(300);
   return; //Keep retrying until we get connected
 }

 ///////MODBUS - STARTS HERE//////////

uint8_t result;
 
  /////////////// Read 19 registers starting at 0x3100////////
  
  node.clearResponseBuffer();
  result = node.readInputRegisters(0x3100, 15);
  
  if (result == node.ku8MBSuccess)
  {
    PV_VData = node.getResponseBuffer(PANEL_VOLTS)/100.0f;
    PV_IData = node.getResponseBuffer(PANEL_AMPS)/100.0f;
    PV_PData = (((node.getResponseBuffer(PANEL_POWER_H)*65536) + (node.getResponseBuffer(PANEL_POWER_L)))/100.0f);
    
    Batt_VData = node.getResponseBuffer(BATT_VOLTS)/100.0f;
    Batt_IData = node.getResponseBuffer(BATT_AMPS)/100.0f;
    Batt_PData = (((node.getResponseBuffer(BATT_POWER_H)*65536) + (node.getResponseBuffer(BATT_POWER_L)))/100.0f);

    Load_VData = node.getResponseBuffer(LOAD_VOLTS)/100.0f;
    Load_IData = node.getResponseBuffer(LOAD_AMPS)/100.0f;
    Load_PData = (((node.getResponseBuffer(LOAD_POWER_H)*65536) + (node.getResponseBuffer(LOAD_POWER_L)))/100.0f);
             
    BattTemp = node.getResponseBuffer(BATT_TEMP)/100.0f;
    CCTemp = node.getResponseBuffer(DEV_TEMP)/100.0f;
    
    BattSOC = node.getResponseBuffer(BATT_SOC);
    
    /////////////// END  Read 19 registers starting at 0x3100 ////////
  
  } else {
    Serial.print("Miss read, ret val:");
    Serial.println(result, HEX);
  }

    /////////////// Read 6 registers starting at 0x330C////////
  
  node.clearResponseBuffer();
  result = node.readInputRegisters(0x330C, 6);
  if (result == node.ku8MBSuccess)
  {
  
  Energy_TData = (((node.getResponseBuffer(TODAY_ENERGY_H)*65536) + (node.getResponseBuffer(TODAY_ENERGY_L)))/100.0f);
  Energy_MData = (((node.getResponseBuffer(MONTH_ENERGY_H)*65536) + (node.getResponseBuffer(MONTH_ENERGY_L)))/100.0f);
  Energy_YData = (((node.getResponseBuffer(YEAR_ENERGY_H)*65536)  + (node.getResponseBuffer(YEAR_ENERGY_L)))/100.0f);
  
  } else {
    Serial.print("Miss read, ret val:");
    Serial.println(result, HEX);
  }
             

 ///////MODBUS-ENDS HERE//////////
 
/*/---------------------------------------------------------------------

  StringPVData[0] = String(PVData[0],1);
  StringPVData[1] = String(PVData[1],1);
  StringPVData[2] = String(PVData[2],1);
  StringPVData[3] = String(PVData[3],1);
  
  StringBattData[0]= String(BattData[0],1);
  StringBattData[1]= String(BattData[1],1);
  StringBattData[2]= String(BattData[2],1);
  StringBattData[3]= String(BattData[3],1);
  
  StringLoadData[0]= String(LoadData[0],1);
  StringLoadData[1]= String(LoadData[1],1);
  
  StringEnergyData[0]= String(EnergyData[0],1);
  StringEnergyData[1]= String(EnergyData[1],1);
  StringEnergyData[2]= String(EnergyData[2],1);
 */ 
   //Make GET request as pet HTTP GET Protocol format
  String ADCData;
  float adcvalue = analogRead(A0);  //Read Analog value of LDR
  ADCData = String(adcvalue);   //String to interger conversion
  
    
  //String Link="GET /update?api_key="+apiKey+"&field1="+ADCData+"&field2="+Rand+"&field3="+R2;"";  //Requeste webpage
    
    String Link ="GET  /update?api_key="+apiKey+"&field1="+String(PV_VData)+"&field2="+String(PV_IData)+"&field3="+String(Batt_VData)+"&field4= "+String(Batt_IData);"";  
   
  Link = Link + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n";                
  
  client.print(Link);
  delay(100);
  
//---------------------------------------------------------------------
 //Wait for server to respond with timeout of 5 Seconds
 int timeout=0;
 while((!client.available()) && (timeout < 1000))     //Wait 5 seconds for data
 {
   delay(10);  //Use this with time out
   timeout++;
 }

//---------------------------------------------------------------------
 //If data is available before time out read it.
 if(timeout < 500)
 {
     while(client.available()){
        Serial.println(client.readString()); //Response from ThingSpeak       
     }
 }
 else
 {
     Serial.println("Request timeout..");
 }

 delay(30000);  //Read Web Page every 5 seconds
}



void preTransmission()
{
  digitalWrite(MAX485_RE, 1);
  digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
  digitalWrite(MAX485_RE, 0);
  digitalWrite(MAX485_DE, 0);
}


The pdf file for the circuit schematic is also attached.2018-11-19_144017_Schematic_NodeMCU-based-EPSOLAR-VS6048-Charge-Controller-Monitoring-Project_Sheet-1_20181119093050.pdf

Regards all round and seasons greetings.

azhaque






Edited by azhaque on 19 November 2018 at 2:43pm
Back to Top View azhaque's Profile Search for other posts by azhaque
 
JohnS
Guru
Guru


Joined: 18 November 2011
Location: United Kingdom
Online Status: Offline
Posts: 1725
Posted: 19 November 2018 at 6:25pm | IP Logged Quote JohnS

Please describe the memory leak in detail.

(E.g. what caused it? Your bug or whose? How do you avoid it?)

John
Back to Top View JohnS's Profile Search for other posts by JohnS
 


If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Search the forums using Google.
<< Prev Page of 3
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1250 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.12