Integrate RTC chip #16

Merged
W1CDN merged 5 commits from add-rtc into main 2023-09-03 11:00:47 -05:00
Owner

To keep track of time while the ESP32 is unpowered, add a DS3231 RTC chip with its own battery.

Update the time automatically when the webform is submitted.

To keep track of time while the ESP32 is unpowered, add a DS3231 RTC chip with its own battery. Update the time automatically when the webform is submitted.
W1CDN added 1 commit 2023-09-02 18:52:27 -05:00
Author
Owner

I have the RTC module talking to the ESP32 and a way to fill in the unix timestamp in the webform, but the timestamp is from when the page was loaded, not when it was submitted.

  • get js timestamp on form submit, not page load
  • update RTC time from webform timestamp

I think we can do time with onsubmit: https://stackoverflow.com/a/33102497/2152245

var putDate = function(form) {
  form.date.value = new Date().toString();
};

<form name="test" method="post" action="B" onsubmit="putDate(this);">
  <input name="text" type="text" />
  <input name="date" type="hidden" />
  <input type="submit" value="Submit">
</form>
I have the RTC module talking to the ESP32 and a way to fill in the unix timestamp in the webform, but the timestamp is from when the page was loaded, not when it was submitted. - [x] get js timestamp on form submit, not page load - [x] update RTC time from webform timestamp I think we can do time with `onsubmit`: https://stackoverflow.com/a/33102497/2152245 ``` var putDate = function(form) { form.date.value = new Date().toString(); }; <form name="test" method="post" action="B" onsubmit="putDate(this);"> <input name="text" type="text" /> <input name="date" type="hidden" /> <input type="submit" value="Submit"> </form> ```
mattbk added 1 commit 2023-09-02 20:03:03 -05:00
Author
Owner

Trying to convert from string to long, it should work with new build flag but it's not.

Trying to convert from string to long, it should work with new build flag but it's not.
Author
Owner

I thought the issue was string conversion, but what has been causing the crash is
rtc.adjust(DateTime();, no matter what value is in it (or empty).

Functions in RTClib I can use: https://adafruit.github.io/RTClib/html/class_r_t_c___d_s3231.html

I thought the issue was string conversion, but what has been causing the crash is `rtc.adjust(DateTime();`, no matter what value is in it (or empty). Functions in RTClib I can use: https://adafruit.github.io/RTClib/html/class_r_t_c___d_s3231.html
Author
Owner

Calling RTClib as a dependency as the GitHub url in platformio.ini file. It is a newer version (2.1.2) than the library in PlatformIO/VSCode.

Calling RTClib as a dependency as the GitHub url in `platformio.ini` file. It is a newer version (2.1.2) than the library in PlatformIO/VSCode.
Author
Owner

That seems to work.

  • why does it seem like webform files are being written twice? Javascript? not doing it anymore
  • make it clear that this is UTC time!
  • get the time back to show it on the web page
    • started, will test tomorrow
That seems to work. - ~~why does it seem like webform files are being written twice? Javascript?~~ not doing it anymore - [x] make it clear that this is UTC time! - [x] get the time back to show it on the web page - started, will test tomorrow
mattbk added 1 commit 2023-09-02 22:11:56 -05:00
mattbk added 1 commit 2023-09-02 22:13:15 -05:00
Author
Owner

This makes it crash:
rtc.now().toString("DDD, DD MMM YYYY hh:mm:ss");

This makes it crash: `rtc.now().toString("DDD, DD MMM YYYY hh:mm:ss");`
Author
Owner

Had to use rtc.now().timestamp() to get string rather than char. 🙄

Had to use `rtc.now().timestamp()` to get string rather than char. 🙄
mattbk added 1 commit 2023-09-03 10:57:00 -05:00
W1CDN merged commit 48db6bc4c9 into main 2023-09-03 11:00:47 -05:00
W1CDN deleted branch add-rtc 2023-09-03 11:00:53 -05:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: W1CDN/vulpes#16
No description provided.