Browse Source

Added prefix to driver variables

fastled
Xose Pérez 8 years ago
parent
commit
cada976436
5 changed files with 31 additions and 22 deletions
  1. +10
    -10
      code/html/index.html
  2. +3
    -3
      code/src/dht.ino
  3. +12
    -3
      code/src/emon.ino
  4. +1
    -1
      code/src/webserver.ino
  5. +5
    -5
      code/src/websockets.ino

+ 10
- 10
code/html/index.html View File

@ -113,18 +113,18 @@
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4" for="temperature">Temperature (ºC)</label>
<input class="pure-u-1 pure-u-sm-3-4" type="text" name="temperature" readonly />
<label class="pure-u-1 pure-u-sm-1-4" for="dhtTmp">Temperature (ºC)</label>
<input class="pure-u-1 pure-u-sm-3-4" type="text" name="dhtTmp" readonly />
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4" for="humidity">Humidity (%)</label>
<input class="pure-u-1 pure-u-sm-3-4" type="text" name="humidity" readonly />
<label class="pure-u-1 pure-u-sm-1-4" for="dhtHum">Humidity (%)</label>
<input class="pure-u-1 pure-u-sm-3-4" type="text" name="dhtHum" readonly />
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4" for="power">Power (W)</label>
<input class="pure-u-1 pure-u-sm-3-4" type="text" name="power" readonly />
<label class="pure-u-1 pure-u-sm-1-4" for="emonPower">Power (W)</label>
<input class="pure-u-1 pure-u-sm-3-4" type="text" name="emonPower" readonly />
</div> </div>
<div class="pure-g"> <div class="pure-g">
@ -287,9 +287,9 @@
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1"> <div class="pure-u-1">
<label class="form-label" for="pwMainsVoltage">AC RMS Voltage</label>
<label class="form-label" for="emonMains">AC RMS Voltage</label>
<div class="hint">This is your house nominal voltage, you probably know this or you wont be playing with this device...</div> <div class="hint">This is your house nominal voltage, you probably know this or you wont be playing with this device...</div>
<select name="pwMainsVoltage" class="pure-u-1-4" tabindex="40">
<select name="emonMains" class="pure-u-1-4" tabindex="40">
<option value="125">125</a> <option value="125">125</a>
<option value="220">220</a> <option value="220">220</a>
<option value="230">230</a> <option value="230">230</a>
@ -298,9 +298,9 @@
</div> </div>
<div class="pure-u-1"> <div class="pure-u-1">
<label class="form-label" for="pwCurrentRatio">Current Ratio</label>
<label class="form-label" for="emonRatio">Current Ratio</label>
<div class="hint">This is the value in amps for a 1V output for your sensor. Some current sensors like the YHDC SCT-013-030 have it written in the enclosure: 30A 1V. If you are using a current sensor that outputs a current (no built in burden resistor) it will depend on the turns ratio between the primary and secondary coils in the sensor and the burden resistor you use. Check about this constant in the <a href="https://openenergymonitor.org/emon/buildingblocks/calibration" target="_blank">post about calibration</a> in the Open Energy Monitor site.</div> <div class="hint">This is the value in amps for a 1V output for your sensor. Some current sensors like the YHDC SCT-013-030 have it written in the enclosure: 30A 1V. If you are using a current sensor that outputs a current (no built in burden resistor) it will depend on the turns ratio between the primary and secondary coils in the sensor and the burden resistor you use. Check about this constant in the <a href="https://openenergymonitor.org/emon/buildingblocks/calibration" target="_blank">post about calibration</a> in the Open Energy Monitor site.</div>
<input name="pwCurrentRatio" type="text" class="pure-u-1-4" value="" size="8" tabindex="41" placeholder="0">
<input name="emonRatio" type="text" class="pure-u-1-4" value="" size="8" tabindex="41" placeholder="0">
</div> </div>
</div> </div>


+ 3
- 3
code/src/dht.ino View File

@ -59,12 +59,12 @@ void dhtLoop() {
DEBUG_MSG("[DHT] Humidity: %s\n", humidity); DEBUG_MSG("[DHT] Humidity: %s\n", humidity);
// Send MQTT messages // Send MQTT messages
mqttSend((char *) getSetting("dhtTemperatureTopic", DHT_TEMPERATURE_TOPIC).c_str(), temperature);
mqttSend((char *) getSetting("dhtHumidityTopic", DHT_HUMIDITY_TOPIC).c_str(), humidity);
mqttSend((char *) getSetting("dhtTmpTopic", DHT_TEMPERATURE_TOPIC).c_str(), temperature);
mqttSend((char *) getSetting("dhtHumTopic", DHT_HUMIDITY_TOPIC).c_str(), humidity);
// Update websocket clients // Update websocket clients
char buffer[20]; char buffer[20];
sprintf_P(buffer, PSTR("{\"temperature\": %s, \"humidity\": %s}"), temperature, humidity);
sprintf_P(buffer, PSTR("{\"dhtTmp\": %s, \"dhtHum\": %s}"), temperature, humidity);
webSocketSend(buffer); webSocketSend(buffer);
} }


+ 12
- 3
code/src/emon.ino View File

@ -36,11 +36,20 @@ unsigned int currentCallback() {
} }
void powerMonitorSetup() { void powerMonitorSetup() {
// backwards compatibility
setSetting("emonMains", getSetting("pwMainsVoltage", EMON_MAINS_VOLTAGE));
setSetting("emonRatio", getSetting("pwCurrentRatio", EMON_CURRENT_RATIO));
setSetting("emonPowerTopic", getSetting("emonPowerTopic", EMON_POWER_TOPIC));
delSetting("pwMainsVoltage");
delSetting("pwCurrentRatio");
delSetting("emonPowerTopic");
emon.initCurrent( emon.initCurrent(
currentCallback, currentCallback,
EMON_ADC_BITS, EMON_ADC_BITS,
EMON_REFERENCE_VOLTAGE, EMON_REFERENCE_VOLTAGE,
getSetting("pwCurrentRatio", String(EMON_CURRENT_RATIO)).toFloat()
getSetting("emonRatio", String(EMON_CURRENT_RATIO)).toFloat()
); );
emon.setPrecision(EMON_CURRENT_PRECISION); emon.setPrecision(EMON_CURRENT_PRECISION);
} }
@ -81,13 +90,13 @@ void powerMonitorLoop() {
sum += current; sum += current;
++measurements; ++measurements;
float mainsVoltage = getSetting("pwMainsVoltage", String(EMON_MAINS_VOLTAGE)).toFloat();
float mainsVoltage = getSetting("emonMains", String(EMON_MAINS_VOLTAGE)).toFloat();
//DEBUG_MSG("[ENERGY] Power now: %dW\n", int(current * mainsVoltage)); //DEBUG_MSG("[ENERGY] Power now: %dW\n", int(current * mainsVoltage));
// Update websocket clients // Update websocket clients
char text[20]; char text[20];
sprintf_P(text, PSTR("{\"power\": %d}"), int(current * mainsVoltage));
sprintf_P(text, PSTR("{\"emonPower\": %d}"), int(current * mainsVoltage));
webSocketSend(text); webSocketSend(text);
// Send MQTT messages averaged every EMON_MEASUREMENTS // Send MQTT messages averaged every EMON_MEASUREMENTS


+ 1
- 1
code/src/webserver.ino View File

@ -117,7 +117,7 @@ void handleSave() {
#endif #endif
#if ENABLE_EMON #if ENABLE_EMON
setCurrentRatio(getSetting("pwCurrentRatio").toFloat());
setCurrentRatio(getSetting("emonRatio").toFloat());
#endif #endif
// Reconfigure networks // Reconfigure networks


+ 5
- 5
code/src/websockets.ino View File

@ -56,8 +56,8 @@ void webSocketStart(uint8_t num) {
root["relayMode"] = getSetting("relayMode", String(RELAY_MODE)); root["relayMode"] = getSetting("relayMode", String(RELAY_MODE));
#if ENABLE_DHT #if ENABLE_DHT
root["temperature"] = getTemperature();
root["humidity"] = getHumidity();
root["dhtTmp"] = getTemperature();
root["dhtHum"] = getHumidity();
#endif #endif
#if ENABLE_RF #if ENABLE_RF
@ -66,9 +66,9 @@ void webSocketStart(uint8_t num) {
#endif #endif
#if ENABLE_EMON #if ENABLE_EMON
root["power"] = getPower();
root["pwMainsVoltage"] = getSetting("pwMainsVoltage", String(EMON_MAINS_VOLTAGE));
root["pwCurrentRatio"] = getSetting("pwCurrentRatio", String(EMON_CURRENT_RATIO));
root["emonPower"] = getPower();
root["emonMains"] = getSetting("emonMains", String(EMON_MAINS_VOLTAGE));
root["emonRatio"] = getSetting("emonRatio", String(EMON_CURRENT_RATIO));
#endif #endif
JsonArray& wifi = root.createNestedArray("wifi"); JsonArray& wifi = root.createNestedArray("wifi");


Loading…
Cancel
Save