timmbogner / Farm-Data-Relay-System

A system that uses ESP-NOW, LoRa, and other protocols to transport sensor data in remote areas without relying on WiFi.
MIT License
485 stars 108 forks source link

Persistent data storage with RadioLib >= 6.2.0 (arduino-esp32, esp32-s2, esp32, ESPNOW) #190

Closed shaffenmeister closed 6 months ago

shaffenmeister commented 6 months ago

Observation

Environment

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/lolin_s2_mini.html PLATFORM: Espressif 32 (2023.11.1) > WEMOS LOLIN S2 Mini HARDWARE: ESP32S2 240MHz, 320KB RAM, 4MB Flash DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa) PACKAGES:

Dependency Graph |-- WiFi @ 2.0.0 |-- SPI @ 2.0.0 |-- Farm-Data-Relay-System @ 2.0.1 |-- RadioLib @ 6.3.0 |-- ArduinoJson @ 6.21.3`

The sketch uses ESPNOW as a controller and not LoRa.

Workaround

Caveats

Implications

timmbogner commented 6 months ago

Hey, thanks for this detailed report. Here is the first red flag that I see:

The sketch uses ESPNOW as a controller and not LoRa.

This isn't expected behavior to me. Under Arduino, if USE_LORA is not enabled, then RadioLib is never even included. I don't use PlatformIO except occasional testing, so I'm not totally fluent in its workings. I will have time to set up a matching setup to yours on the weekend. The issue doesn't seem to present in the Arduino IDE.

That confusion aside, it seems like this could be a bit of a RadioLib hiccup. @jgromes is adding LoRaWAN support to RadioLib, which is why the persistent storage stuff is being included. If needed, I think I can add in the workaround for the appropriate chips to FDRS. Having LoRaWAN within RadioLib will open the door to a LoRaWAN front-end in FDRS, which will be pretty cool 😎

jgromes commented 6 months ago

Hello everyone,

@shaffenmeister

This is expected as ESP32 and ESP32-S2 do not provide EEPROM memory.

That's not actually true. ESP32 provides EEPROM library, which emulates EEPROM in ESP32 flash. Which arduino-esp32 version are you using, maybe it's outdated?

shaffenmeister commented 6 months ago

Hello everyone,

@shaffenmeister

This is expected as ESP32 and ESP32-S2 do not provide EEPROM memory.

That's not actually true. ESP32 provides EEPROM library, which emulates EEPROM in ESP32 flash. Which arduino-esp32 version are you using, maybe it's outdated?

Hi, I know about the emulation layer, works like a charm. Platformio provides framework-arduinoespressif32 @ 2.0.14.

Will check and Report Back.

shaffenmeister commented 6 months ago

Okay, this is well-defined behaviour of the dependency resolver in platformio:

When not using -D RADIOLIB_EEPROM_UNSUPPORTED=1 but #include <EEPROM.h> instead in the main Arduino code file the library is compiled in: Dependency Graph (new) |-- WiFi @ 2.0.0 |-- SPI @ 2.0.0 |-- Farm-Data-Relay-System @ 2.0.1 |-- RadioLib @ 6.3.0 |-- ArduinoJson @ 6.21.3 |-- EEPROM @ 2.0.0

Manually specifying lib_deps = EEPROM in platformio.ini resolves the problem as well.

I would have expected the underlying library to pull-in its dependencies on its own using library.json and the like.