mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-23 09:30:53 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
398407350c | ||
|
|
5e33a15e85 | ||
|
|
7f51534e91 | ||
|
|
0f5af6b274 | ||
|
|
7886ce668e |
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -20,7 +20,6 @@ jobs:
|
|||||||
GITHUB_REF: ${{ github.ref }}
|
GITHUB_REF: ${{ github.ref }}
|
||||||
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
|
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
|
||||||
- name: Get release version for code
|
- name: Get release version for code
|
||||||
id: release_tag
|
|
||||||
env:
|
env:
|
||||||
GITHUB_REF: ${{ github.ref }}
|
GITHUB_REF: ${{ github.ref }}
|
||||||
run: echo ::set-env name=GITHUB_TAG::$(echo ${GITHUB_REF##*/})
|
run: echo ::set-env name=GITHUB_TAG::$(echo ${GITHUB_REF##*/})
|
||||||
|
|||||||
@@ -71,18 +71,10 @@ void setup() {
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(config.hasConfig()) {
|
if(config.hasConfig() && config.isDebugSerial()) {
|
||||||
if(config.getAuthSecurity() > 0) {
|
|
||||||
Debug.setPassword(config.getAuthPassword());
|
|
||||||
}
|
|
||||||
Debug.setSerialEnabled(config.isDebugSerial());
|
Debug.setSerialEnabled(config.isDebugSerial());
|
||||||
Debug.begin(config.getWifiHostname(), (uint8_t) config.getDebugLevel());
|
|
||||||
if(!config.isDebugTelnet()) {
|
|
||||||
Debug.stop();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
#if DEBUG_MODE
|
#if DEBUG_MODE
|
||||||
Debug.begin("localhost", RemoteDebug::DEBUG);
|
|
||||||
Debug.setSerialEnabled(true);
|
Debug.setSerialEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -94,13 +86,15 @@ void setup() {
|
|||||||
debugI("Voltage: %.2fV", vcc);
|
debugI("Voltage: %.2fV", vcc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vcc > 0 && vcc < 3.25) {
|
#if SELF_POWERED
|
||||||
|
if (vcc > 2.5 && vcc < 3.25) { // Only sleep if voltage is realistic and too low
|
||||||
if(Debug.isActive(RemoteDebug::INFO)) {
|
if(Debug.isActive(RemoteDebug::INFO)) {
|
||||||
debugI("Votltage is too low, sleeping");
|
debugI("Votltage is too low, sleeping");
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
}
|
}
|
||||||
ESP.deepSleep(10000000); //Deep sleep to allow output cap to charge up
|
ESP.deepSleep(10000000); //Deep sleep to allow output cap to charge up
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_RGB_LED
|
#if HAS_RGB_LED
|
||||||
// Initialize RGB LED pins
|
// Initialize RGB LED pins
|
||||||
@@ -117,7 +111,16 @@ void setup() {
|
|||||||
WiFi.softAPdisconnect(true);
|
WiFi.softAPdisconnect(true);
|
||||||
WiFi.mode(WIFI_OFF);
|
WiFi.mode(WIFI_OFF);
|
||||||
|
|
||||||
if(SPIFFS.begin()) {
|
bool spiffs = false;
|
||||||
|
#if defined(ESP32)
|
||||||
|
debugD("ESP32 SPIFFS");
|
||||||
|
spiffs = SPIFFS.begin(true);
|
||||||
|
#else
|
||||||
|
debugD("ESP8266 SPIFFS");
|
||||||
|
spiffs = SPIFFS.begin();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(spiffs) {
|
||||||
bool flashed = false;
|
bool flashed = false;
|
||||||
if(SPIFFS.exists("/firmware.bin")) {
|
if(SPIFFS.exists("/firmware.bin")) {
|
||||||
if(Debug.isActive(RemoteDebug::INFO)) debugI("Found firmware");
|
if(Debug.isActive(RemoteDebug::INFO)) debugI("Found firmware");
|
||||||
@@ -295,10 +298,18 @@ void loop() {
|
|||||||
|
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
wifiConnected = false;
|
wifiConnected = false;
|
||||||
|
Debug.stop();
|
||||||
WiFi_connect();
|
WiFi_connect();
|
||||||
} else {
|
} else {
|
||||||
if(!wifiConnected) {
|
if(!wifiConnected) {
|
||||||
wifiConnected = true;
|
wifiConnected = true;
|
||||||
|
if(config.getAuthSecurity() > 0) {
|
||||||
|
Debug.setPassword(config.getAuthPassword());
|
||||||
|
}
|
||||||
|
Debug.begin(config.getWifiHostname(), (uint8_t) config.getDebugLevel());
|
||||||
|
if(!config.isDebugTelnet()) {
|
||||||
|
Debug.stop();
|
||||||
|
}
|
||||||
if(Debug.isActive(RemoteDebug::INFO)) {
|
if(Debug.isActive(RemoteDebug::INFO)) {
|
||||||
debugI("Successfully connected to WiFi!");
|
debugI("Successfully connected to WiFi!");
|
||||||
debugI("IP: %s", WiFi.localIP().toString().c_str());
|
debugI("IP: %s", WiFi.localIP().toString().c_str());
|
||||||
@@ -696,7 +707,7 @@ void sendSystemStatusToMqtt() {
|
|||||||
}
|
}
|
||||||
mqtt.publish(config.getMqttPublishTopic() + "/rssi", String(hw.getWifiRssi()));
|
mqtt.publish(config.getMqttPublishTopic() + "/rssi", String(hw.getWifiRssi()));
|
||||||
if(temperature != DEVICE_DISCONNECTED_C) {
|
if(temperature != DEVICE_DISCONNECTED_C) {
|
||||||
mqtt.publish(config.getMqttPublishTopic() + "/vcc", String(temperature, 2));
|
mqtt.publish(config.getMqttPublishTopic() + "/temperature", String(temperature, 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
#include "HwTools.h"
|
#include "HwTools.h"
|
||||||
|
|
||||||
double HwTools::getVcc() {
|
double HwTools::getVcc() {
|
||||||
|
double volts = 0.0;
|
||||||
#if defined(ARDUINO_ESP8266_WEMOS_D1MINI)
|
#if defined(ARDUINO_ESP8266_WEMOS_D1MINI)
|
||||||
return (((double) ESP.getVcc()) / 900); // This board has a voltage divider on VCC. Yes, 900 is correct
|
volts = (((double) ESP.getVcc()) / 900.0); // This board has a voltage divider on VCC.
|
||||||
|
#elif defined(ARDUINO_LOLIN_D32)
|
||||||
|
volts = (analogRead(GPIO_NUM_35) / 4095.0) * 3.3 * 2.25; // We are actually reading battery voltage here
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
#if defined(ESP_VCC_CALIB_FACTOR)
|
volts = ((double) ESP.getVcc()) / 1024.0;
|
||||||
return ((double) ESP.getVcc()) / 1024 * ESP_VCC_CALIB_FACTOR;
|
#endif
|
||||||
#else
|
|
||||||
return ((double) ESP.getVcc()) / 1024;
|
#if defined(ESP_VCC_CALIB_FACTOR)
|
||||||
#endif
|
return volts * ESP_VCC_CALIB_FACTOR;
|
||||||
|
#else
|
||||||
|
return volts;
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double HwTools::getTemperature() {
|
double HwTools::getTemperature() {
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ public:
|
|||||||
int getWifiRssi();
|
int getWifiRssi();
|
||||||
|
|
||||||
HwTools() {
|
HwTools() {
|
||||||
|
#if defined(ARDUINO_LOLIN_D32)
|
||||||
|
pinMode(GPIO_NUM_35, INPUT);
|
||||||
|
#endif
|
||||||
oneWire = new OneWire(TEMP_SENSOR_PIN);
|
oneWire = new OneWire(TEMP_SENSOR_PIN);
|
||||||
tempSensor = new DallasTemperature(this->oneWire);
|
tempSensor = new DallasTemperature(this->oneWire);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>AMS reader - Meter configuration</title>
|
<title>AMS reader - Restarting, please wait</title>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<link rel="stylesheet" type="text/css" href="boot.css"/>
|
<link rel="stylesheet" type="text/css" href="boot.css"/>
|
||||||
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user