RadMon support
This commit is contained in:
@@ -46,6 +46,7 @@ reload configuration and voilà!
|
||||
|
||||
### RadMon integration
|
||||
- Create account on https://radmon.org/
|
||||
- Login, go to **Control Panel** -> fill form to add sensor
|
||||
|
||||
### J3x5 Tube specification
|
||||
| Property | J3x5 |
|
||||
|
||||
@@ -241,6 +241,36 @@ void radmonUpload(int cpm) {
|
||||
}
|
||||
}
|
||||
|
||||
void gmcUpload() {
|
||||
Serial.print("[HTTP] begin...\n");
|
||||
GMCMap_Request = GMCMap_Request_payload + "?AID=" + gmcAccountID + "&GID=" + gmcDeviceID + "&CPM=" + buf + "&ACPM=" + buf + "&uSV=" + buf2;
|
||||
Serial.println(GMCMap_Request);
|
||||
HTTPClient http;
|
||||
if (http.begin(espClient2, GMCMap_Request)) { // HTTP
|
||||
Serial.print("[HTTP] GET...\n");
|
||||
int httpCode = http.GET();
|
||||
if (httpCode > 0) {
|
||||
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
|
||||
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
|
||||
String payload = http.getString();
|
||||
Serial.println(payload);
|
||||
if (payload.indexOf("ERR0") > 0) GMCMap = "OK";
|
||||
if (payload.indexOf("ERR1") > 0) GMCMap = "Error! User is not found";
|
||||
if (payload.indexOf("ERR2") > 0) GMCMap = "Error! Geiger Counter is not found";
|
||||
if (payload.indexOf("Warning") > 0) GMCMap = "Warning! The Geiger Counter location changed, please confirm the location";
|
||||
Serial.println(GMCMap);
|
||||
}
|
||||
} else {
|
||||
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
|
||||
GMCMap = http.errorToString(httpCode).c_str();
|
||||
}
|
||||
http.end();
|
||||
} else {
|
||||
Serial.println("[HTTP] Unable to connect");
|
||||
GMCMap = "Unable to connect";
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// it is a good practice to make sure your code sets wifi mode how you want it.
|
||||
@@ -251,7 +281,7 @@ void setup() {
|
||||
initLittleFS();
|
||||
|
||||
display.begin(i2c_Address, true);
|
||||
|
||||
display.setContrast (0);
|
||||
lcdPrint("Geiger Interace");
|
||||
|
||||
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
|
||||
@@ -334,6 +364,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Double Reset Detection
|
||||
drd->loop();
|
||||
|
||||
// if MQTT server provided
|
||||
@@ -342,12 +373,6 @@ void loop() {
|
||||
reconnect();
|
||||
}
|
||||
|
||||
if(millis() >= time_now + 5000){
|
||||
time_now += 5000;
|
||||
client.publish("esp32/heartbeat", "PING");
|
||||
}
|
||||
|
||||
|
||||
if (millis() >= mold + 60000) {
|
||||
ltoa(GeigerCounts, buf, 10);
|
||||
dtostrf(GeigerCounts*TUBE_FACTOR, -4, 2, buf2);
|
||||
@@ -358,45 +383,34 @@ void loop() {
|
||||
lcdUpdate();
|
||||
}
|
||||
client.loop();
|
||||
|
||||
//if(millis() >= time_now + 5000){
|
||||
// time_now += 5000;
|
||||
// client.publish("esp32/heartbeat", "PING");
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
// Update time on LCD
|
||||
getLocalTime(&timeinfo);
|
||||
if (timeinfo.tm_sec == 0){
|
||||
lcdUpdate();
|
||||
}
|
||||
|
||||
// if GMC IDs provided
|
||||
if (String(gmcAccountID) != "") {
|
||||
// Sending HTTP requests in every 10 minutes
|
||||
currentMillis = millis();
|
||||
if (currentMillis - previousMillis_10m >= interval_10m) {
|
||||
previousMillis_10m = currentMillis;
|
||||
Serial.print("[HTTP] begin...\n");
|
||||
GMCMap_Request = GMCMap_Request_payload + "?AID=" + gmcAccountID + "&GID=" + gmcDeviceID + "&CPM=" + buf + "&ACPM=" + buf + "&uSV=" + buf2;
|
||||
Serial.println(GMCMap_Request);
|
||||
HTTPClient http;
|
||||
if (http.begin(espClient2, GMCMap_Request)) { // HTTP
|
||||
Serial.print("[HTTP] GET...\n");
|
||||
int httpCode = http.GET();
|
||||
if (httpCode > 0) {
|
||||
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
|
||||
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
|
||||
String payload = http.getString();
|
||||
Serial.println(payload);
|
||||
if (payload.indexOf("ERR0") > 0) GMCMap = "OK";
|
||||
if (payload.indexOf("ERR1") > 0) GMCMap = "Error! User is not found";
|
||||
if (payload.indexOf("ERR2") > 0) GMCMap = "Error! Geiger Counter is not found";
|
||||
if (payload.indexOf("Warning") > 0) GMCMap = "Warning! The Geiger Counter location changed, please confirm the location";
|
||||
Serial.println(GMCMap);
|
||||
}
|
||||
} else {
|
||||
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
|
||||
GMCMap = http.errorToString(httpCode).c_str();
|
||||
}
|
||||
http.end();
|
||||
} else {
|
||||
Serial.println("[HTTP] Unable to connect");
|
||||
GMCMap = "Unable to connect";
|
||||
|
||||
// if RadMon username provided
|
||||
if (String(rmUser) != "") {
|
||||
radmonUpload(atoi(buf));
|
||||
}
|
||||
|
||||
// if GMC IDs provided
|
||||
if (String(gmcAccountID) != "") {
|
||||
gmcUpload();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user