Added option for measuring internal VCC

This commit is contained in:
battika
2016-05-14 23:40:14 +02:00
parent 3e576041e8
commit 4308e77d6e
3 changed files with 39 additions and 6 deletions
+18 -2
View File
@@ -72,7 +72,7 @@
// ********************************************************************************
// Set default configuration settings if you want (not mandatory)
// You can allways change these during runtime and save to eeprom
// You can always change these during runtime and save to eeprom
// After loading firmware, issue a 'reset' command to load the defaults.
#define DEFAULT_NAME "newdevice" // Enter your device friendly name
@@ -105,6 +105,12 @@
#define FEATURE_TIME true
#define FEATURE_SSDP true
// Enable FEATURE_ADC_VCC to measure supply voltage using the analog pin
// Please note that the TOUT pin has to be disconnected in this mode
// Use the "Analog Input" device to read the VCC value
#define FEATURE_ADC_VCC false
// ********************************************************************************
// DO NOT CHANGE ANYTHING BELOW THIS LINE
// ********************************************************************************
@@ -214,6 +220,9 @@ ESP8266HTTPUpdateServer httpUpdater(true);
#if ESP_CORE >= 210
#include <base64.h>
#endif
#if FEATURE_ADC_VCC
ADC_MODE(ADC_VCC);
#endif
#define LWIP_OPEN_SRC
#include "lwip/opt.h"
#include "lwip/udp.h"
@@ -432,6 +441,10 @@ byte cmd_within_mainloop = 0;
unsigned long connectionFailures;
unsigned long wdcounter = 0;
#if FEATURE_ADC_VCC
float vcc = -1.0;
#endif
boolean WebLoggedIn = false;
int WebLoggedInTimer = 300;
@@ -757,6 +770,9 @@ void runEach30Seconds()
#if FEATURE_SSDP
if (Settings.UseSSDP)
SSDP_update();
#endif
#if FEATURE_ADC_VCC
vcc = ESP.getVcc() / 1000.0;
#endif
loopCounterLast = loopCounter;
loopCounter = 0;
@@ -846,7 +862,7 @@ void SensorSendTask(byte TaskIndex)
if (success)
{
for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++)
{
{
if (ExtraTaskSettings.TaskDeviceFormula[varNr][0] != 0)
{
String spreValue = String(preValue[varNr]);
+6 -1
View File
@@ -401,7 +401,7 @@ void fileSystemCheck()
{
if (SPIFFS.begin())
{
String log = F("SPIFFS Mount succesfull");
String log = F("SPIFFS Mount successful");
addLog(LOG_LEVEL_INFO, log);
File f = SPIFFS.open("config.txt", "r");
if (!f)
@@ -1195,6 +1195,7 @@ String parseTemplate(String &tmpString, byte lineSize)
{
// here we know the task and value, so find the uservar
String value = toString(UserVar[y * VARS_PER_TASK + z], ExtraTaskSettings.TaskDeviceValueDecimals[z]);
if (valueFormat == "R")
{
int filler = lineSize - newString.length() - value.length() - tmpString.length() ;
@@ -1232,6 +1233,10 @@ String parseTemplate(String &tmpString, byte lineSize)
newString.replace("%uptime%", String(wdcounter / 2));
#if FEATURE_ADC_VCC
newString.replace("%vcc%", String(vcc));
#endif
IPAddress ip = WiFi.localIP();
char strIP[20];
sprintf_P(strIP, PSTR("%u.%u.%u.%u"), ip[0], ip[1], ip[2], ip[3]);
+15 -3
View File
@@ -21,6 +21,7 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
Device[deviceCount].ValueCount = 1;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].FormulaOption = true;
break;
}
@@ -39,16 +40,18 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[3];
String options[4];
options[0] = F("Uptime");
options[1] = F("Free RAM");
options[2] = F("Wifi RSSI");
int optionValues[3];
options[3] = F("Input VCC");
int optionValues[4];
optionValues[0] = 0;
optionValues[1] = 1;
optionValues[2] = 2;
optionValues[3] = 3;
string += F("<TR><TD>Indicator:<TD><select name='plugin_026'>");
for (byte x = 0; x < 3; x++)
for (byte x = 0; x < 4; x++)
{
string += F("<option value='");
string += optionValues[x];
@@ -93,6 +96,15 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
value = WiFi.RSSI();
break;
}
case 3:
{
#if FEATURE_ADC_VCC
value = vcc;
#else
value = -1.0;
#endif
break;
}
}
UserVar[event->BaseVarIndex] = value;
String log = F("SYS : ");