Scheduling A&X data
It feels like this statement has been a long time in coming, but (knock wood) everything finally seems to be scanning, storing, displaying and uploading as it was designed to do… that means I can take another look at the clock/calendar chip, and get my data uploads to push on the hour instead of spamming out 2-3 times per minute (every time it passes through the programming loop)
As an aside, while reading up on the DS3231-RTC module I’m using, I found it has its own (built in) temperature sensor and, more impressively, a 24C32 EEPROM… which is basically a Memory/storage upgrade. Once that sunk in and registered, my first thought was that I might need to use that if when I get the point where I’m able to play midi files/alerts, as I’ve read they can use up a lot of resources.
As my code for the NodeMCU (Master) goes, it is currently routing the A data goes to the LCD, and the X data automatically gets posted to the spreadsheet as soon as it is detected. I’ve decided that it will be easier (and tidier) for me to work a scheduler into NodeMCU, where A data is copied to X on the hour and then uploaded. I could then add an X button to the Uno, just for the purpose of creating a one-off (manual) data upload, which I think would be ideal for things like the TDS sensor or other things you might only need to check for daily and/or need to prepare special samples for.
6 hours later I see that was a bad idea.
Yet again this NodeMCU is incompatible with another component/library/process.
First it was the TDS sensor, followed by the i2c communications debacle, and now the scheduler.
Its not even like the scheduler kinda works… something in one of the associated libraries is outright preventing the NodeMCU from even booting properly… it just loops an error message that there isn’t a lot of information on, online. (You know you’re in trouble when you search for something and google informs you that there aren’t a lot of results)
Here and now, these seem to be my options:
revert to my original plan where the Uno drives the scheduling
trying to reinvent the wheel
Give up on the scheduler
So, what did I decide on?
Heh heh heh, I opted for the infamous “one last thing” (that is never the last thing), and started digging.
I had the idea that I’d just remove the libraries one at a time to see which one(s) were causing the problem. The first one I tested was the alternate “but fully compatible” clock/calendar library that an “expert” from a forum post indicated would be required, because the actual library for the chip I was using was allegedly not compatible with the code…
Funny thing… using the proper library for the RTC allowed the NodeMCU to boot AND display my A data on the LCD… Not sure on the data upload.
I’m going to need to work some kind of timestamp into my serial display in order to confirm if the data didn’t upload because the NodeMCU doesn’t like the code, or if it didn’t upload because the time is wrong.
OK… The timestamp was placed in the code, and all that allowed me to do was watch all my alarm points drift by while the NodeMCU continued to display on the LCD and ignore the spreadsheet.
Not wanting to give up after already spending around 8hours on this today, I moved onto dropping the scheduler code into the Uno’s commands to see if that might work any better (given the codes/libraries were designed to work on the thing) and achieved similar results. I have a feeling this scheduler code only works if it doesn’t have anything else to do… if the computer is computing and misses the exact moment / second it had a task scheduled for the window is closed until the following day.
I’m back on the idea of needing to set up a call and response system, where the NodeMCU asks the Uno for fresh data at the start of the loop…
I need to make sure that if I have some Xdata to send to the NodeMCU, that it is not overwritten with Adata until its is processed by the NodeMCU… probably meaning needing to set up some kind of Xdata flag/check… or put some kind of wait for response command in the Uno’s Xdata creation, and include an acknowledgement as part of my spreadsheet upload script.
Wait a tic… if the Uno is going to paused/waiting for a response when Xdata is sent, I technicallly won’t NEED to worry about sending a refresh data command from the NodeMCU… it would be a lot more efficient if I did, but I don’t think its absolutely necessary.