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:
- 11:2311b2d5157d
- Parent:
- 10:1dc69e0ce7fd
- Child:
- 12:96f637ed37f9
diff -r 1dc69e0ce7fd -r 2311b2d5157d emmaCode.cpp --- a/emmaCode.cpp Mon Jul 13 06:25:58 2015 +0000 +++ b/emmaCode.cpp Mon Jul 13 13:29:25 2015 +0000 @@ -157,12 +157,12 @@ for(int i=0; i<2; i++) { if(jsonValue.hasMember(parameter[i])) { string val = jsonValue[parameter[i]].get<std::string>(); - //int st = writeSetting(parameter[i],val.c_str()); - //if(st) { - // DBG.printf("%s is saved\r\n",parameter[i]); - //} else { - // DBG.printf("%s is not saved\r\n",parameter[i]); - //} + int st = writeSetting(parameter[i],val.c_str()); + if(st) { + DBG.printf("%s is saved\r\n",parameter[i]); + } else { + DBG.printf("%s is not saved\r\n",parameter[i]); + } } } } @@ -735,11 +735,8 @@ sprintf(mqttClientId,"emma/%s",emmaUID.c_str()); if(mqtt.begin(mqttClientId, platformKEY.c_str(), platformSECRET.c_str(), 120, 1)) { - //mqtt.lwt("/lwt", "offline", 0, 0); mqtt.connectedCb.attach(&mqttConnected); mqtt.disconnectedCb.attach(&mqttDisconnected); - //mqtt.publishedCb.attach(&mqttPublished); - //mqtt.dataCb.attach(&mqttData); mqtt.connect(MQTT_HOST,MQTT_PORT,false); DBG.printf("emma: success to setup mqtt\r\n"); } @@ -1265,9 +1262,9 @@ //DBG.printf("checkVoltagePower-start\r\n"); - AVrms = ADE.VRMS(PHASE_A) * 2*0.000158; //constants are from calculateVRMS function - BVrms = ADE.VRMS(PHASE_B) * 2*0.000157; - CVrms = ADE.VRMS(PHASE_C) * 2*0.000156; + AVrms = ADE.VRMS(PHASE_A) * 0.000128; //0.000158; //constants are from calculateVRMS function + BVrms = ADE.VRMS(PHASE_B) * 0.000127; //0.000157; + CVrms = ADE.VRMS(PHASE_C) * 0.000126; //0.000156; AIrms = ADE.IRMS(PHASE_A) * 0.0000125; //constants are from calculateIRMS function BIrms = ADE.IRMS(PHASE_B) * 0.0000123;