emma controller code in production board v1
Dependencies: ADE7758_v1 Crypto DHT11 MQTT MbedJSONValueEmma SDFileSystem TFT_ILI9341 SWSPI SetRTC TFT_fonts Touch W5500Interface mbed-rtos mbed-src SoftSerial
Fork of emma_controller_energy by
Diff: emmaCode.cpp
- Revision:
- 16:3c8d0142bf63
- Parent:
- 15:136526c28afb
- Child:
- 17:b3ced0e67916
--- a/emmaCode.cpp Wed Jul 15 02:36:24 2015 +0000 +++ b/emmaCode.cpp Wed Jul 15 11:44:33 2015 +0000 @@ -967,7 +967,8 @@ ADE.write16bits(BVAG, 0); ADE.write16bits(CVAG, 0); - ADE.AWhLSB = 0.000001192;//0.00006025556; + //ADE.AWhLSB = 0.000001192;//0.00006025556; + ADE.AWhLSB = 0.00002109; ADE.BWhLSB = 0.25075167; ADE.CWhLSB = 0.25075167; @@ -1117,7 +1118,7 @@ strftime(q, 32, "%Y-%m-%d %H:%M:%S\r\n",localtime(&seconds)); sprintf(s,"{\"uid\":\"%s\",\"hmac\":\"%s\",\"time\":\"%s\",\"energy\":%.2f,\"voltage\":%.2f,\"power\":%.2f}", emmaUID.c_str(),hmac.c_str(),q,XWattHr,XVrms,XWatt); - //DBG.printf("dataEnergy:%s\r\n",s); + DBG.printf("dataEnergy:%s\r\n",s); rest.post(r,s); wait(2); if(rxBuf.find("\"status\":\"success\"") != std::string::npos) { @@ -1533,7 +1534,6 @@ //osDelay(5000); //calculate energy - /* DBG.printf("energyThread-start\r\n"); float period = 0; AWattHrSum = 0; @@ -1546,14 +1546,14 @@ BWattHrSum += BWattHrValue; CWattHrSum += CWattHrValue; } - AWattHr = AWattHrSum;// * ADE.AWhLSB; + AWattHr = AWattHrSum * ADE.AWhLSB; BWattHr = BWattHrSum * ADE.BWhLSB; CWattHr = CWattHrSum * ADE.CWhLSB; DBG.printf("energyThread-finish\r\n"); - */ //testing + /* DBG.printf("thread called\r\n"); Timer t; t.start(); @@ -1562,6 +1562,7 @@ t.reset(); } DBG.printf("thread ended\r\n"); + */ } } void checkVoltagePower() {