cancel
Showing results for 
Search instead for 
Did you mean: 

Custom external RTC DS3231 implementation in LoRaWan Wio E5 project

user_01
Associate II

I am using Seeed Studio LoRaWan Project for Wio E5 Mini(STM32WLE5JC6). By default the project is using internal RTC, but I want to use an external RTC DS3231 alarm for my application to send data because it would be run through the power line and when there is a power cut I don't want the alarm to be colliding with other such devices because all other similar devices will be sending data one after the other with no collision. How can I modify the project in lora_app.c such that the DS3231 SQW/INT pin wakes up the MCU from sleep, transmit and then go to sleep, and so on. I have issues using the SQW/INT interrupt pin to check for the alarm and then transmit data. 

2 REPLIES 2

@user_01 wrote:

 I have issues using the SQW/INT interrupt pin to check for the alarm and then transmit data. 


What issues, exactly?

 


@user_01 wrote:

I want to use an external RTC DS3231 alarm for my application to send data because it would be run through the power line and when there is a power cut I don't want the alarm to be colliding with other such devices because all other similar devices will be sending data one after the other . 


I don't follow the logic here - how does an external (rather than internal)  RTC make any difference in that situation?

1) The INT pin works fine when I tested the DS3231 in a blank project(i.e it is active high and goes low when an alarm is generated), but behaves weirdly when I put it in the LoRa project in place of the internal timer code which is it either stays still or goes toggles whenever the alarm is generated. I've modified and added my external RTC set alarm (which might definitely not be right) and without interrupt I polled for the alarm with every 10th sec alarm match. To make sure I know that an alarm was generated I made the alarm event to toggle an external LED which it does correctly every minute (LoRa interval is 60 sec). The weird thing is the alarm is not set at the 10th sec but is really random all the time which means the alarm is not triggering the LoRa transmission but the internal RTC is. If my external LED alarm event happens every minute accurately and even if I set the external alarm to a particular minute meaning an alarm every hour it transmits the data every minute with alarm triggering every minute. For sure I have not correctly replaced all the internal util timer code in lora_app.c. I would like to know which lines I need to exactly replace.

 

2) External RTC with battery backup provision would run incase of a power cut but since we have no plans for a separate external battery for the line powered MCU so internal RTC just stops running incase of a power cut. The internal RTC does not allow me to configure it to any BCD mode (else the program breaks all together) which makes it possible for me to set alarms at exact seconds every minute or exact minutes every hour so that the different devices for my application don't collide during transmission.