kevinkk525 wrote: ↑Fri Feb 22, 2019 8:59 pm
time.ticks_ms is a method only available in micropython, not on your pi. on your pi you can use time.time() which returns seconds so you have to replace the 3000ms in my example with 3s.
Aha... now I understand, super explanation thanks, Kevin. The programme I am actually using to send the data to Adafruit is coded on the ESP8266 which I have successfully (
after some trials and tribulation) flashed with Micropython, and so for the eventual code I upload to there I will use your syntax. For the test on the Pi (or maybe on my Mac) I'll amend the code to use test.time().
kevinkk525 wrote: ↑Fri Feb 22, 2019 8:59 pm
I would not disconnect because this way you could keep track of whether the device is still connected or not. You probably need to configure a keepalive and last will message but I guess one step after the other.
The coding difference is, that you would need to connect before you publish anything, which is more difficult in my example as you would have to do it before every publish but also disconnect after every publish or keep track of the connection state... It makes the program complicated without a reason, that's all.
I was actually thinking about if there would be a way to monitor if my ESP8266 had lost connection to the net, but then I wondered how I would get it to send me a message somehow when it had no way of so doing!! I am curious (
and eager to learn) about how this would work?
As a side note... I have a not so normal set up at home re internet access. I don't have a broadband service - used to have Virgin Media when ex wife and kids were here, but that was 7 years ago and I no longer needed that level of internet access or speed, so I use my excellent mobile provider to give me WiFi from a hotspot on my phone when I am home. Super speeds sometimes up to 40MBPS, and never an issue. However... now that I am dabbling with IoT I do of course need an always-on internet connection at home, but I am not wanting to commit to a contract with one of the service providers. So, I've found a super mobile service called Smarty - no contract, various plans, even up to unlimited for £25 pm which is super. So, I am up and running with this second provider to determine how much bandwidth I need for the home network - started off with 4GB, will see how it goes. But I have a SONOFF TH10 controlling the CH and have started using the ESP8266 for other stuff. All good fun eh!
Thanks for your help thus far, Kevin, much appreciated.