we are working on a project in which we have to acquire data from rs 485 port of energy meter and transmit it to our web server.
as of now we have successfully imported data from meter and post it to web server using http client.
now what we want is to store data of connectivity with server is lost and trasmit all the data as the conectivity goes up.
we got 200 as response after succesful hit. so this is our method to make sure that hit has been made successfully.
we want to make use of flash memory of node or we can use extenal card if required.
please suggest your ideas for coding.. here is my sample code.
#include <SDM.h> //import SDM template library
#define ASCII_ESC 27
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#define USE_SERIAL Serial
ESP8266WiFiMulti WiFiMulti;
char bufout[10];
float v,a,p,fre,pf,tu;
SDM<2400, 13, 12> sdm; //SDM120T baud, rx pin, tx pin
//SDM<4800, 12, 13> sdm; //SDM220T baud, rx pin, tx pin
//SDM<9600, 12, 13> sdm; //SDM630 baud, rx pin, tx pin
//or without parameters (default from SDM.h will be used):
//SDM<> sdm;
void setup() {
Serial.begin(115200);
USE_SERIAL.begin(115200);//initialize serial
USE_SERIAL.flush();
WiFiMulti.addAP("Spectrum", "silex@123");
sdm.begin(); //initalize SDM220 communication baudrate
}
void loop() {
//sprintf(bufout,"%c[1;0H",ASCII_ESC);
// Serial.print(bufout);
v=(sdm.readVal(SDM120C_VOLTAGE)); //display voltage
delay(10);
a=(sdm.readVal(SDM120C_CURRENT )); //display current
delay(10);
p=(sdm.readVal(SDM120C_POWER)); //display power
delay(10);
fre=(sdm.readVal(SDM120C_FREQUENCY )); //display frequency
delay(10);
pf=(sdm.readVal(SDM120C_POWER_FACTOR )); //display frequency
delay(10);
tu=(sdm.readVal(SDM120C_TOTAL_ACTIVE_ENERGY )); //display frequency
Serial.print("Volts:");Serial.println(v);
Serial.print("current:");Serial.println(a);
Serial.print("Power:");Serial.println(p);
Serial.print("Frequency:");Serial.println(fre);
Serial.print("Power factor:");Serial.println(pf);
Serial.print("Total Energy:");Serial.println(tu);
Serial.println(String("http://web*******.com/DataApp/GetValues.aspx?Value=") + String(v) + "," + String(a) + "," + String(p) +"," + String(fre) + "," + String(pf) +"," + String(tu)+"," + "dummy");
delay(5000); //wait a while before next loop
if((WiFiMulti.run() == WL_CONNECTED)) {
HTTPClient http;
http.begin(String("http://web*********.com/DataApp/GetValues.aspx?Value=") + String(v) + "," + String(a) + "," + String(p) +"," + String(fre) + "," + String(pf) +"," + String(tu)+"," + "dummy");
int httpCode = http.GET();
http.end();
}
}