Add speed & AuxAmp to GPRS data
Signed-off-by: Martin Kolací <martin.kolaci@lmc.eu>
This commit is contained in:
27
evDash.ino
27
evDash.ino
@@ -412,6 +412,8 @@ bool sim800lSetup() {
|
|||||||
SoftwareSerial* serial = new SoftwareSerial(SIM800L_RX, SIM800L_TX);
|
SoftwareSerial* serial = new SoftwareSerial(SIM800L_RX, SIM800L_TX);
|
||||||
serial->begin(9600);
|
serial->begin(9600);
|
||||||
sim800l = new SIM800L((Stream *)serial, SIM800L_RST, 512 , 512);
|
sim800l = new SIM800L((Stream *)serial, SIM800L_RST, 512 , 512);
|
||||||
|
// SIM800L DebugMode:
|
||||||
|
//sim800l = new SIM800L((Stream *)serial, SIM800L_RST, 512 , 512, (Stream *)&Serial);
|
||||||
|
|
||||||
bool sim800l_ready = sim800l->isReady();
|
bool sim800l_ready = sim800l->isReady();
|
||||||
for (uint8_t i = 0; i < 5 && !sim800l_ready; i++) {
|
for (uint8_t i = 0; i < 5 && !sim800l_ready; i++) {
|
||||||
@@ -430,16 +432,16 @@ bool sim800lSetup() {
|
|||||||
|
|
||||||
bool sim800l_gprs = sim800l->setupGPRS(liveData->settings.gprsApn);
|
bool sim800l_gprs = sim800l->setupGPRS(liveData->settings.gprsApn);
|
||||||
for (uint8_t i = 0; i < 5 && !sim800l_gprs; i++) {
|
for (uint8_t i = 0; i < 5 && !sim800l_gprs; i++) {
|
||||||
Serial.println("Problem to set GPRS connection, retry in 1 sec");
|
Serial.println("Problem to set GPRS APN, retry in 1 sec");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
sim800l_gprs = sim800l->setupGPRS(liveData->settings.gprsApn);
|
sim800l_gprs = sim800l->setupGPRS(liveData->settings.gprsApn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sim800l_gprs) {
|
if (sim800l_gprs) {
|
||||||
liveData->params.sim800l_enabled = true;
|
liveData->params.sim800l_enabled = true;
|
||||||
Serial.println("GPRS OK");
|
Serial.println("GPRS APN set OK");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("Problem to set GPRS");
|
Serial.println("Problem to set GPRS APN");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,27 +453,32 @@ bool sendDataViaGPRS() {
|
|||||||
|
|
||||||
NetworkRegistration network = sim800l->getRegistrationStatus();
|
NetworkRegistration network = sim800l->getRegistrationStatus();
|
||||||
if (network != REGISTERED_HOME && network != REGISTERED_ROAMING) {
|
if (network != REGISTERED_HOME && network != REGISTERED_ROAMING) {
|
||||||
Serial.println("SIM800L module not connected to network!");
|
Serial.println("SIM800L module not connected to network, skipping data send");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!sim800l->isConnectedGPRS()) {
|
||||||
|
Serial.println("GPRS not connected... Connecting");
|
||||||
bool connected = sim800l->connectGPRS();
|
bool connected = sim800l->connectGPRS();
|
||||||
for (uint8_t i = 0; i < 5 && !connected; i++) {
|
for (uint8_t i = 0; i < 5 && !connected; i++) {
|
||||||
|
Serial.println("Problem to connect GPRS, retry in 1 sec");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
connected = sim800l->connectGPRS();
|
connected = sim800l->connectGPRS();
|
||||||
}
|
}
|
||||||
|
if(connected) {
|
||||||
if (!connected) {
|
Serial.println("GPRS connected!");
|
||||||
|
} else {
|
||||||
Serial.println("GPRS not connected! Reseting SIM800L module!");
|
Serial.println("GPRS not connected! Reseting SIM800L module!");
|
||||||
sim800l->reset();
|
sim800l->reset();
|
||||||
sim800lSetup();
|
sim800lSetup();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Serial.println("Start HTTP POST...");
|
Serial.println("Start HTTP POST...");
|
||||||
|
|
||||||
StaticJsonDocument<450> jsonData;
|
StaticJsonDocument<512> jsonData;
|
||||||
|
|
||||||
jsonData["apikey"] = liveData->settings.remoteApiKey;
|
jsonData["apikey"] = liveData->settings.remoteApiKey;
|
||||||
jsonData["carType"] = liveData->settings.carType;
|
jsonData["carType"] = liveData->settings.carType;
|
||||||
@@ -481,14 +488,16 @@ bool sendDataViaGPRS() {
|
|||||||
jsonData["batPowerAmp"] = liveData->params.batPowerAmp;
|
jsonData["batPowerAmp"] = liveData->params.batPowerAmp;
|
||||||
jsonData["batVoltage"] = liveData->params.batVoltage;
|
jsonData["batVoltage"] = liveData->params.batVoltage;
|
||||||
jsonData["auxVoltage"] = liveData->params.auxVoltage;
|
jsonData["auxVoltage"] = liveData->params.auxVoltage;
|
||||||
|
jsonData["auxAmp"] = liveData->params.auxCurrentAmp;
|
||||||
jsonData["batMinC"] = liveData->params.batMinC;
|
jsonData["batMinC"] = liveData->params.batMinC;
|
||||||
jsonData["batMaxC"] = liveData->params.batMaxC;
|
jsonData["batMaxC"] = liveData->params.batMaxC;
|
||||||
jsonData["batInletC"] = liveData->params.batInletC;
|
jsonData["batInletC"] = liveData->params.batInletC;
|
||||||
jsonData["batFanStatus"] = liveData->params.batFanStatus;
|
jsonData["batFanStatus"] = liveData->params.batFanStatus;
|
||||||
|
jsonData["speedKmh"] = liveData->params.speedKmh;
|
||||||
jsonData["cumulativeEnergyChargedKWh"] = liveData->params.cumulativeEnergyChargedKWh;
|
jsonData["cumulativeEnergyChargedKWh"] = liveData->params.cumulativeEnergyChargedKWh;
|
||||||
jsonData["cumulativeEnergyDischargedKWh"] = liveData->params.cumulativeEnergyDischargedKWh;
|
jsonData["cumulativeEnergyDischargedKWh"] = liveData->params.cumulativeEnergyDischargedKWh;
|
||||||
|
|
||||||
char payload[450];
|
char payload[512];
|
||||||
serializeJson(jsonData, payload);
|
serializeJson(jsonData, payload);
|
||||||
|
|
||||||
Serial.print("Sending payload: ");
|
Serial.print("Sending payload: ");
|
||||||
@@ -506,8 +515,6 @@ bool sendDataViaGPRS() {
|
|||||||
Serial.println(rc);
|
Serial.println(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
sim800l->disconnectGPRS();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif //SIM800L_ENABLED
|
#endif //SIM800L_ENABLED
|
||||||
|
|||||||
Reference in New Issue
Block a user