Skip to content

Commit

Permalink
Update to 2.7.2
Browse files Browse the repository at this point in the history
+ changed LATITUDE / LONGITUDE format from float to char - #49
+ fixed broadcasting unwanted open wifi network - #47
  • Loading branch information
bfaliszek committed Oct 4, 2019
1 parent 9a8bd53 commit 838b7cd
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 130 deletions.
20 changes: 11 additions & 9 deletions Smogomierz.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>
#include <SoftwareSerial.h>
#elif defined ARDUINO_ARCH_ESP32 // Arduino core for the ESP32 - 1.0.3-rc2 or later
#elif defined ARDUINO_ARCH_ESP32 // Arduino core for the ESP32 - 1.0.4-rc1 or later // at 1.0.3 autoupdate doesn't work !!!
#include <WiFi.h>
#include <WiFiClient.h>
#include <ESPmDNS.h>
Expand All @@ -30,19 +30,20 @@
/*
ESP8266 - NodeMCU 1.0 - 1M SPIFFS
Szkic używa 526596 bajtów (50%) pamięci programu. Maksimum to 1044464 bajtów.
Zmienne globalne używają 53096 bajtów (64%) pamięci dynamicznej, pozostawiając 28824 bajtów dla zmiennych lokalnych. Maksimum to 81920 bajtów.
Szkic używa 527448 bajtów (50%) pamięci programu. Maksimum to 1044464 bajtów.
Zmienne globalne używają 54108 bajtów (66%) pamięci dynamicznej, pozostawiając 27812 bajtów dla zmiennych lokalnych. Maksimum to 81920 bajtów.
Szkic używa 527300 bajtów (50%) pamięci programu. Maksimum to 1044464 bajtów.
Zmienne globalne używają 53688 bajtów (65%) pamięci dynamicznej, pozostawiając 28232 bajtów dla zmiennych lokalnych. Maksimum to 81920 bajtów.
Szkic używa 527548 bajtów (50%) pamięci programu. Maksimum to 1044464 bajtów.
Zmienne globalne używają 54216 bajtów (66%) pamięci dynamicznej, pozostawiając 27704 bajtów dla zmiennych lokalnych. Maksimum to 81920 bajtów.
ESP32 Dev Module - 1.9MB APP with OTA - 190KB SPIFFS
Szkic używa 1245330 bajtów (63%) pamięci programu. Maksimum to 1966080 bajtów.
Zmienne globalne używają 61084 bajtów (18%) pamięci dynamicznej, pozostawiając 266596 bajtów dla zmiennych lokalnych. Maksimum to 327680 bajtów.
Szkic używa 1247990 bajtów (63%) pamięci programu. Maksimum to 1966080 bajtów.
Zmienne globalne używają 62236 bajtów (18%) pamięci dynamicznej, pozostawiając 265444 bajtów dla zmiennych lokalnych. Maksimum to 327680 bajtów.
Szkic używa 1251682 bajtów (63%) pamięci programu. Maksimum to 1966080 bajtów.
Zmienne globalne używają 62776 bajtów (19%) pamięci dynamicznej, pozostawiając 264904 bajtów dla zmiennych lokalnych. Maksimum to 327680 bajtów.
Szkic używa 1247598 bajtów (63%) pamięci programu. Maksimum to 1966080 bajtów.
Zmienne globalne używają 62172 bajtów (18%) pamięci dynamicznej, pozostawiając 265508 bajtów dla zmiennych lokalnych. Maksimum to 327680 bajtów.
*/

#include <PubSubClient.h>
Expand Down Expand Up @@ -392,6 +393,7 @@ void setup() {
if (wifiManager.autoConnect(device_name)) {
Serial.println("connected...yeey :)");
//wifiManager.setConfigPortalBlocking(false);
WiFi.mode(WIFI_STA); // https://github.com/hackerspace-silesia/Smogomierz/issues/47#issue-496810438
} else {
Serial.println("Configportal running");
wifiManager.setConfigPortalBlocking(false);
Expand Down
6 changes: 3 additions & 3 deletions defaultConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ bool SMOGLIST_ON = true;

bool AIRMONITOR_ON = false;
bool AIRMONITOR_GRAPH_ON = true;
float LATITUDE = 50.2639;
float LONGITUDE = 18.9957;
float MYALTITUDE = 271.00;
char LATITUDE[255] = "50.263911";
char LONGITUDE[255] = "18.995711";
int MYALTITUDE = 271;

bool THINGSPEAK_ON = false;
bool THINGSPEAK_GRAPH_ON = false;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 8 additions & 5 deletions src/airmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void sendJson(JsonObject& json) {
return;
}

delay(100);
delay(100);

client.println("POST /api HTTP/1.1");
client.println("Content-Type: application/json");
Expand All @@ -48,8 +48,8 @@ void sendDUSTData(int averagePM1, int averagePM25, int averagePM10) {
if (strcmp(DUST_MODEL, "Non")) {
StaticJsonDocument<400> jsonBuffer;
JsonObject json = jsonBuffer.to<JsonObject>();
json["lat"] = String(LATITUDE, 6);
json["long"] = String(LONGITUDE, 6);
json["lat"] = String(LATITUDE);
json["long"] = String(LONGITUDE);
json["pm1"] = averagePM1;
json["pm25"] = averagePM25;
json["pm10"] = averagePM10;
Expand All @@ -73,8 +73,8 @@ void sendTHPData(float currentTemperature, float currentPressure, float currentH
if (strcmp(THP_MODEL, "Non")) {
StaticJsonDocument<400> jsonBuffer;
JsonObject json = jsonBuffer.to<JsonObject>();
json["lat"] = String(LATITUDE, 6);
json["long"] = String(LONGITUDE, 6);
json["lat"] = String(LATITUDE);
json["long"] = String(LONGITUDE);
if (!strcmp(THP_MODEL, "BME280")) {
json["pressure"] = currentPressure;
json["temperature"] = currentTemperature;
Expand Down Expand Up @@ -109,3 +109,6 @@ void sendDataToAirMonitor(float currentTemperature, float currentPressure, float
sendDUSTData(averagePM1, averagePM25, averagePM10);
sendTHPData(currentTemperature, currentPressure, currentHumidity);
}



18 changes: 9 additions & 9 deletions src/autoupdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ bool checkUpdate(int checkUpdateSW) {
// Reading data over SSL may be slow, use an adequate timeout
client.setTimeout(12000);
#endif

HTTPClient http;

#if defined(ARDUINO_ARCH_ESP8266)
String latestJSONlink = "http://smogomierz.hs-silesia.pl/firmware/latest_esp8266.json";
#elif defined(ARDUINO_ARCH_ESP32)
Expand All @@ -113,17 +113,17 @@ bool checkUpdate(int checkUpdateSW) {
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
String payload = http.getString();
delay(10);

/*
/*
Serial.println(payload);
Serial.println(PMSENSORVERSION);
Serial.println(checkUpdateSW);
*/

StaticJsonDocument<400> jsonBuffer;
deserializeJson(jsonBuffer, payload);
JsonObject json = jsonBuffer.as<JsonObject>();

if (checkUpdateSW == 0) {
ServerSW = json[PMSENSORVERSION];
} else if (checkUpdateSW == 1) {
Expand Down Expand Up @@ -205,7 +205,7 @@ void doUpdate(int doUpdateSW) {
// Reading data over SSL may be slow, use an adequate timeout
client.setTimeout(12000);
#endif

if (checkUpdate(doUpdateSW)) {
if (DEBUG) {
Serial.println("Starting firmware upgrade...\n");
Expand Down Expand Up @@ -260,15 +260,15 @@ void doUpdate(int doUpdateSW) {
#elif defined(ARDUINO_ARCH_ESP32)
t_httpUpdate_return ret = httpUpdate.update(client, BinURL);
#endif

if (DEBUG) {
switch (ret) {
case HTTP_UPDATE_FAILED:
#if defined(ARDUINO_ARCH_ESP8266)
Serial.printf("Updated FAILED (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
#elif defined(ARDUINO_ARCH_ESP32)
Serial.printf("Updated FAILED (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
#endif
#endif
break;
case HTTP_UPDATE_NO_UPDATES:
Serial.println("No update needed!");
Expand Down
12 changes: 6 additions & 6 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ extern bool SMOGLIST_ON;

extern bool AIRMONITOR_ON;
extern bool AIRMONITOR_GRAPH_ON;
extern float LATITUDE;
extern float LONGITUDE;
extern float MYALTITUDE;
extern char LATITUDE[255];
extern char LONGITUDE[255];
extern int MYALTITUDE;

extern bool THINGSPEAK_ON;
extern bool THINGSPEAK_GRAPH_ON;
Expand Down Expand Up @@ -57,9 +57,9 @@ const char PMSENSORVERSION[] = "PMS";
extern char SERVERSOFTWAREVERSION[255];
extern char CURRENTSOFTWAREVERSION[255];
#if defined(ARDUINO_ARCH_ESP8266)
const char SOFTWAREVERSION[] = "2.7.1 build " __TIME__ " " __DATE__;
const char SOFTWAREVERSION[] = "2.7.2 build " __TIME__ " " __DATE__;
const char HARDWAREVERSION[] = "1.0 - ESP8266";
#elif defined(ARDUINO_ARCH_ESP32)
const char SOFTWAREVERSION[40] PROGMEM = "2.7.1 build " __TIME__ " " __DATE__;
const char SOFTWAREVERSION[40] PROGMEM = "2.7.2 build " __TIME__ " " __DATE__;
const char HARDWAREVERSION[40] PROGMEM = "2.0 - ESP32";
#endif
#endif
4 changes: 2 additions & 2 deletions src/luftdaten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,10 @@ void sendTHPDatatoMadavide(float currentTemperature, float currentPressure, floa
void sendDataToLuftdaten(float currentTemperature, float currentPressure, float currentHumidity, int averagePM1, int averagePM25, int averagePM4, int averagePM10) {
if (!(LUFTDATEN_ON)) {
return;
}
}
sendDUSTDatatoLuftdaten(averagePM1, averagePM25, averagePM10);
sendTHPDatatoLuftdaten(currentTemperature, currentPressure, currentHumidity);
delay(10);
sendDUSTDatatoMadavide(averagePM1, averagePM25, averagePM10);
sendTHPDatatoMadavide(currentTemperature, currentPressure, currentHumidity);
}
}
33 changes: 17 additions & 16 deletions src/smoglist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const char *SmoglistServerName = "api.smoglist.pl"; // api.smoglist.pl:8090/post
const uint16_t SmoglistPort = 8090;

void sendSmoglistJson(JsonObject& json) {

WiFiClient client;
client.setTimeout(12000);
Serial.print("\nconnecting to ");
Expand All @@ -24,7 +24,7 @@ void sendSmoglistJson(JsonObject& json) {
delay(3000);
return;
}
delay(100);
delay(100);

client.println("POST /postjson HTTP/1.1");
client.println("Content-Type: application/json");
Expand All @@ -40,13 +40,13 @@ void sendSmoglistJson(JsonObject& json) {
Serial.println(line);
}
client.stop();

}

void sendSmoglistData(float currentTemperature, float currentPressure, float currentHumidity, int averagePM1, int averagePM25, int averagePM4, int averagePM10) {
StaticJsonDocument<1000> jsonBuffer;
JsonObject json = jsonBuffer.to<JsonObject>();

#ifdef ARDUINO_ARCH_ESP8266
json["CHIPID"] = "Smogomierz-" + String(ESP.getChipId());
#elif defined ARDUINO_ARCH_ESP32
Expand All @@ -55,35 +55,36 @@ void sendSmoglistData(float currentTemperature, float currentPressure, float cur
json["SOFTWAREVERSION"] = SOFTWAREVERSION;
json["HARDWAREVERSION"] = HARDWAREVERSION; // "1.0 - ESP8266" or "2.0 - ESP32"
json["PMSENSORVERSION"] = PMSENSORVERSION; // PMS, SDS, HPMA115S0 ora SPS30

json["FREQUENTMEASUREMENT"] = FREQUENTMEASUREMENT; // frequent measurements - True or False
json["DISPLAY_PM1"] = DISPLAY_PM1; // True or False

json["DUST_TIME"] = DUST_TIME; // frequency of PM measurements; default - 1
json["NUMBEROFMEASUREMENTS"] = NUMBEROFMEASUREMENTS; // default - 10

json["SENDING_FREQUENCY"] = SENDING_FREQUENCY; // default - 2
json["SENDING_DB_FREQUENCY"] = SENDING_DB_FREQUENCY; // default - 2

json["LUFTDATEN_ON"] = LUFTDATEN_ON; // True or False

json["AIRMONITOR_ON"] = AIRMONITOR_ON; // True or False
json["AIRMONITOR_GRAPH_ON"] = AIRMONITOR_GRAPH_ON; // True or False

json["THINGSPEAK_ON"] = THINGSPEAK_ON; // True or False
json["THINGSPEAK_GRAPH_ON"] = THINGSPEAK_GRAPH_ON; // True or False

json["INFLUXDB_ON"] = INFLUXDB_ON; // True or False
json["MQTT_ON"] = MQTT_ON; // True or False

json["DEEPSLEEP_ON"] = DEEPSLEEP_ON; // True or False
json["AUTOUPDATE_ON"] = AUTOUPDATE_ON; // True or False
json["MODEL"] = MODEL; // default "white" - automatic calibration, "red" - without calibration

json["LATITUDE"] = String(LATITUDE); // default - 50.2639
json["LONGITUDE"] = String(LONGITUDE); // default - 18.9957

json["LATITUDE"] = String(LATITUDE, 6); // default - 50.2639
json["LONGITUDE"] = String(LONGITUDE, 6); // default - 18.9957
json["MYALTITUDE"] = MYALTITUDE; // int; default - 271.00

//PM data
if (!strcmp(DUST_MODEL, "PMS7003")) {
json["DUST_MODEL"] = "PMS5003/7003";
Expand All @@ -104,7 +105,7 @@ void sendSmoglistData(float currentTemperature, float currentPressure, float cur
json["PM25"] = averagePM25;
json["PM4"] = averagePM4;
json["PM10"] = averagePM10;

// Temp/Humi/Pressure data
if (strcmp(THP_MODEL, "Non")) {
if (!strcmp(THP_MODEL, "BME280")) {
Expand Down
Loading

0 comments on commit 838b7cd

Please sign in to comment.