jlab-sensing / soil-power-sensor-firmware

Firmware for STM32 and ESP32 microcontrollers on the Soil Power Sensor board
MIT License
0 stars 3 forks source link

Add RTC support with LoRaWAN time synchronization #67

Closed jmadden173 closed 2 months ago

jmadden173 commented 2 months ago

Name/Affiliation/Title N/A, maintainer

Purpose of the PR This PR enables the RTC to be used to get the current unix epoch rather than just seconds. It also enables clock synchronization with the LoRaWAN application server.

Development Environment Linux redwood 6.6.22-1-lts #1 SMP PREEMPT_DYNAMIC Sat, 16 Mar 2024 06:20:33 +0000 x86_64 GNU/Linux Debugger: ST-Link V3 PlatformIO Core, version 6.1.13

Pkg List

********************************************************************************
Obsolete PIO Core v6.1.13 is used (previous was 6.1.14)
Please remove multiple PIO Cores from a system:
https://docs.platformio.org/en/latest/core/installation/troubleshooting.html
********************************************************************************
Resolving stm32 dependencies...
Platform ststm32 @ 17.0.0+sha.7136ebc (required: git+https://github.com/jlab-sensing/platform-ststm32)
├── framework-stm32cubewl @ 1.26.2+sha.77fa61b (required: git+https://github.com/jlab-sensing/STM32CubeWL)
├── tool-dfuutil @ 1.11.0 (required: platformio/tool-dfuutil @ ~1.11.0)
├── tool-dfuutil-arduino @ 1.11.0 (required: platformio/tool-dfuutil-arduino @ ~1.11.0)
├── tool-ldscripts-ststm32 @ 0.2.0 (required: platformio/tool-ldscripts-ststm32 @ ~0.2.0)
├── tool-openocd @ 1.0.0+sha.0ecdfeb (required: git+https://github.com/jlab-sensing/tool-openocd.git)
├── tool-stm32duino @ 1.0.1 (required: platformio/tool-stm32duino @ ~1.0.1)
└── toolchain-gccarmnoneeabi @ 1.70201.0 (required: platformio/toolchain-gccarmnoneeabi @ >=1.60301.0,<1.80000.0)

Libraries
└── Soil Power Sensor Protocal Buffer @ 2.0.0 (required: symlink://../proto/c)

Resolving example_battery dependencies...
Platform ststm32 @ 17.0.0+sha.7136ebc (required: git+https://github.com/jlab-sensing/platform-ststm32)
├── framework-stm32cubewl @ 1.26.2+sha.77fa61b (required: git+https://github.com/jlab-sensing/STM32CubeWL)
├── tool-dfuutil @ 1.11.0 (required: platformio/tool-dfuutil @ ~1.11.0)
├── tool-dfuutil-arduino @ 1.11.0 (required: platformio/tool-dfuutil-arduino @ ~1.11.0)
├── tool-ldscripts-ststm32 @ 0.2.0 (required: platformio/tool-ldscripts-ststm32 @ ~0.2.0)
├── tool-openocd @ 1.0.0+sha.0ecdfeb (required: git+https://github.com/jlab-sensing/tool-openocd.git)
├── tool-stm32duino @ 1.0.1 (required: platformio/tool-stm32duino @ ~1.0.1)
└── toolchain-gccarmnoneeabi @ 1.70201.0 (required: platformio/toolchain-gccarmnoneeabi @ >=1.60301.0,<1.80000.0)

Libraries
└── Soil Power Sensor Protocal Buffer @ 2.0.0 (required: symlink://../proto/c)

Resolving example_adc dependencies...
Platform ststm32 @ 17.0.0+sha.7136ebc (required: git+https://github.com/jlab-sensing/platform-ststm32)
├── framework-stm32cubewl @ 1.26.2+sha.77fa61b (required: git+https://github.com/jlab-sensing/STM32CubeWL)
├── tool-dfuutil @ 1.11.0 (required: platformio/tool-dfuutil @ ~1.11.0)
├── tool-dfuutil-arduino @ 1.11.0 (required: platformio/tool-dfuutil-arduino @ ~1.11.0)
├── tool-ldscripts-ststm32 @ 0.2.0 (required: platformio/tool-ldscripts-ststm32 @ ~0.2.0)
├── tool-openocd @ 1.0.0+sha.0ecdfeb (required: git+https://github.com/jlab-sensing/tool-openocd.git)
├── tool-stm32duino @ 1.0.1 (required: platformio/tool-stm32duino @ ~1.0.1)
└── toolchain-gccarmnoneeabi @ 1.70201.0 (required: platformio/toolchain-gccarmnoneeabi @ >=1.60301.0,<1.80000.0)

Resolving tests dependencies...
Platform ststm32 @ 17.0.0+sha.7136ebc (required: git+https://github.com/jlab-sensing/platform-ststm32)
├── framework-stm32cubewl @ 1.26.2+sha.77fa61b (required: git+https://github.com/jlab-sensing/STM32CubeWL)
├── tool-dfuutil @ 1.11.0 (required: platformio/tool-dfuutil @ ~1.11.0)
├── tool-dfuutil-arduino @ 1.11.0 (required: platformio/tool-dfuutil-arduino @ ~1.11.0)
├── tool-ldscripts-ststm32 @ 0.2.0 (required: platformio/tool-ldscripts-ststm32 @ ~0.2.0)
├── tool-openocd @ 1.0.0+sha.0ecdfeb (required: git+https://github.com/jlab-sensing/tool-openocd.git)
├── tool-stm32duino @ 1.0.1 (required: platformio/tool-stm32duino @ ~1.0.1)
└── toolchain-gccarmnoneeabi @ 1.70201.0 (required: platformio/toolchain-gccarmnoneeabi @ >=1.60301.0,<1.80000.0)

Libraries
└── Soil Power Sensor Protocal Buffer @ 2.0.0 (required: symlink://../proto/c)

Test Procedure

Additional Context In the future we will need to add a way for the clock to be synced through the WiFi interface if LoRa is not available

Also I needed to update the cubewl framework to enable the RTC interface without OTA updates which were very difficult to configure. You will need to update the framework-stm32cubewl in your platformio installation.

Closes #48 Closes #57