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.
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.
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>
```
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
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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.
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.
I think we can do time with
onsubmit: https://stackoverflow.com/a/33102497/2152245Trying to convert from string to long, it should work with new build flag but it's not.
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
Calling RTClib as a dependency as the GitHub url in
platformio.inifile. It is a newer version (2.1.2) than the library in PlatformIO/VSCode.That seems to work.
why does it seem like webform files are being written twice? Javascript?not doing it anymoreThis makes it crash:
rtc.now().toString("DDD, DD MMM YYYY hh:mm:ss");Had to use
rtc.now().timestamp()to get string rather than char. 🙄