Rissy wrote: ↑Wed Nov 16, 2022 2:03 pm
Thanks for your input. I think that's what i was looking for from someone. Basically just tell me where I'm wrong and present an alternative solution that WILL work.
I'll try out your solution tonight now! Thanks! (I wish everyone was as forthcoming with help and advice when I ask for a direct specific piece of help. For some people, it seems to be a sport of sorts to keep those who are still learning, stuck down low in the learning curve unnecessarily!?)
As for time stamping. That was actually my next manoeuvre actually. I was looking at this very subject a couple of weeks ago, but trying to get a proper time source into the Pico W via the internet, corrected to your required time-region seems to be a bit of headache. You're suggesting just importing time, but my understanding right now is that it is MUCH more complicated than this!?
Rissy, I'm happy to read that I may have helped you, but I do not concur with your remarks that some people are using you as 'sport' to keep you stuck down. On their behalf I find this attitude a bit offensive. Some advice may prove more beneficial than others but I'm sure any responder is simply trying to assist. It maybe they simply miss-judge your level of competence and ability to understand their response.
A final note if that I was thinking that your errorlog file was on a rpi and not a rpi-pico though mostly this sort of code will work on both. Just to be on the safe side I just ran the example on a rpi-pico and it all worked. I was using Thonny to run the code and I did note that, for whatever reason, the errorlog.txt file did not immediately show in the files list side panel. However a few more runs of the code did provoke it to be displayed and the results as as shown below:
(2022, 11, 16, 14, 52),SHT Error:,Bus error
(2022, 11, 16, 14, 55),SHT Error:,Bus error
(2022, 11, 16, 15, 17),SHT Error:,Bus error
As you can see the date/time format is YYYY,MM,DD,hh,mm. However, the date and time on the rpi-pico was correct because I was connect to it over Thonny via a usb connection. When the picoW is on its own then you can get the date and time via the wifi connection. You will need to look at ntptime. Alas this in in GMT and there are a few hoops to get BST which, judging from your remarks, you have come across. There are also other ways to extract and format the date time so I'm sure you can get it MUCH more complicate if you wish
But, I would not be writing the errorlog file to the rpi-pico. You are sending mqtt messages from the rpi-pico to and rpi so the best way IMHO is to send the error message as an mqtt message to the rpi and deal with logging any error messages to a file on the rpi itself (with the benefit of more easily getting the correct time). On the rpi you could also keep the last time that an mqtt message was received (e.g. a temperature reading from the pico) and have a periodic routine to check and create an alert if the the last message received time is greater than the expected time interval. The alert could be anything you wish, but an email, sms other something like that could be done and all of this sort of coding is probably better done on the rpi.
Have fun