diff --git a/.github/workflows/airohr-firmware.yml b/.github/workflows/airohr-firmware.yml index 526efcb7..d4380dfb 100644 --- a/.github/workflows/airohr-firmware.yml +++ b/.github/workflows/airohr-firmware.yml @@ -27,6 +27,21 @@ jobs: key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- + + - name: Load cached ~/.platformio + uses: actions/cache@v2 + with: + path: ~/.platformio + key: platformio-${{ hashFiles('**/platformio.ini') }} + restore-keys: platformio- + + - name: Load cached ./.pio + uses: actions/cache@v2 + with: + path: ./.pio + key: pio-${{ hashFiles('**/platformio.ini') }} + restore-keys: pio- + - name: Install dependencies run: | python3 -m pip install --upgrade pip diff --git a/airrohr-firmware/Readme.md b/airrohr-firmware/Readme.md index 5e392d22..0eb7f1af 100644 --- a/airrohr-firmware/Readme.md +++ b/airrohr-firmware/Readme.md @@ -13,6 +13,14 @@ Please refer to [Contributing README](./Contributing.md) for details. +## ESP32 support + +The support is still experimental. Run the following to complile the code for the [ES32 WROOM board](https://docs.platformio.org/en/latest/boards/espressif32/denky32.html): + +``` +pio run --environment esp32 +``` + ## WiFi configuration For German Version see: [Konfiguration der Sensoren](https://github.com/opendata-stuttgart/meta/wiki/Konfiguration-der-Sensoren) diff --git a/airrohr-firmware/airrohr-firmware.ino b/airrohr-firmware/airrohr-firmware.ino index 7150d4ad..dde5784f 100644 --- a/airrohr-firmware/airrohr-firmware.ino +++ b/airrohr-firmware/airrohr-firmware.ino @@ -58,7 +58,7 @@ #include // increment on change -#define SOFTWARE_VERSION_STR "NRZ-2024-136-B1" +#define SOFTWARE_VERSION_STR "NRZ-2024-136-B2" String SOFTWARE_VERSION(SOFTWARE_VERSION_STR); /***************************************************************** @@ -87,7 +87,11 @@ String SOFTWARE_VERSION(SOFTWARE_VERSION_STR); #include #include #include -#include +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL (4, 4, 0) + #include +#else + #include +#endif #include #include #endif @@ -2917,7 +2921,9 @@ static void waitForWifiToConnect(int maxRetries) * WiFi auto connecting script * *****************************************************************/ +#if defined(ESP8266) static WiFiEventHandler disconnectEventHandler; +#endif static void connectWifi() { @@ -5391,7 +5397,10 @@ static void init_display() // modifying the I2C speed to 400k, which overwhelms some of the // sensors. Wire.setClock(100000); + +#if defined(ESP8266) Wire.setClockStretchLimit(150000); +#endif } /***************************************************************** diff --git a/airrohr-firmware/defines.h b/airrohr-firmware/defines.h index 8294be79..a329a7dc 100644 --- a/airrohr-firmware/defines.h +++ b/airrohr-firmware/defines.h @@ -1,3 +1,5 @@ +#include + #if defined(ESP8266) #define SENSOR_BASENAME "esp8266-" #define OTA_BASENAME "/airrohr" diff --git a/airrohr-firmware/platformio.ini b/airrohr-firmware/platformio.ini index e347d116..87bd2346 100644 --- a/airrohr-firmware/platformio.ini +++ b/airrohr-firmware/platformio.ini @@ -45,7 +45,7 @@ board_build.f_cpu = 160000000L ; (like OneWire, LiquidCrystal_I2C and TinyGPSPlus) lib_deps_external = - paulstoffregen/OneWire@2.3.5 + paulstoffregen/OneWire@2.3.8 marcoschwartz/LiquidCrystal_I2C@1.1.4 adafruit/Adafruit BMP085 Library@1.0.1 adafruit/Adafruit HTU21DF Library@1.1.2 @@ -55,6 +55,8 @@ lib_deps_external = bblanchon/ArduinoJson@6.18.3 ThingPulse/ESP8266 and ESP32 OLED driver for SSD1306 displays @ ^4.3.0 mikalhart/TinyGPSPlus@1.0.2 + ArduinoBearSSL@1.7.4 ; https://registry.platformio.org/libraries/arduino-libraries/ArduinoBearSSL + arduino-libraries/ArduinoECCX08@^1.3.8 ; system libraries from platform -> no version number lib_deps_esp8266_platform = @@ -89,7 +91,7 @@ extra_scripts = platformio_script.py # needs to be adjusted to the matching version from # https://github.com/platformio/platform-espressif8266/releases platform_version = espressif8266@2.6.2 -platform_version_esp32 = espressif32@1.11.1 ; using Arduino core 1.0.4 +platform_version_esp32 = espressif32@6.9.0 [env] build_unflags = -Os @@ -468,3 +470,18 @@ board_build.filesystem = ${common.board_build.filesystem} build_flags = ${common.build_flags} -DINTL_UA lib_deps = ${common.lib_deps_esp8266} extra_scripts = ${common.extra_scripts} + +[env:esp32] +lang = en +platform = ${common.platform_version_esp32} +framework = arduino +board = upesy_wroom ; https://docs.platformio.org/en/latest/boards/espressif32/upesy_wroom.html +board_build.ldscript = ${common.board_build.ldscript} +board_build.filesystem = ${common.board_build.filesystem} +build_flags = ${common.build_flags_esp32_release} '-DINTL_EN' '-DESP32_WROOM_MODULE' +lib_deps = ${common.lib_deps_esp32} +extra_scripts = ${common.extra_scripts} +; change microcontroller +board_build.mcu = esp32 +; change MCU frequency +board_build.f_cpu = 240000000 \ No newline at end of file diff --git a/airrohr-firmware/utils.cpp b/airrohr-firmware/utils.cpp index 6171e417..2dc096fb 100644 --- a/airrohr-firmware/utils.cpp +++ b/airrohr-firmware/utils.cpp @@ -217,7 +217,13 @@ bool launchUpdateLoader(const String& md5) { *****************************************************************/ String check_display_value(double value, double undef, uint8_t len, uint8_t str_len) { RESERVE_STRING(s, 15); - s = (value != undef ? String(value, len) : String("-")); + +#if defined(ESP8266) + s = (value != undef ? String(value, len) : String("-")); +#endif +#if defined(ESP32) + s = (value != undef ? String(value, (unsigned int) len) : String("-")); +#endif while (s.length() < str_len) { s = " " + s; } diff --git a/airrohr-firmware/utils.h b/airrohr-firmware/utils.h index 3bc8c5ff..9c21872d 100644 --- a/airrohr-firmware/utils.h +++ b/airrohr-firmware/utils.h @@ -39,7 +39,11 @@ #include #include #include -#include +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL (4, 4, 0) + #include +#else + #include +#endif #include #endif @@ -95,6 +99,7 @@ extern SoftwareSerial serialIPS; #define serialIPS (Serial1) #endif + enum class PmSensorCmd { Start, Stop,