|
Forum Index : Microcontroller and PC projects : WebMite reconnect
| Author | Message | ||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2031 |
I am using a WebMite for my outdoor weather station, it sends data to the indoor unit using HC-12 modules and it is also connected to the web so that I can get the information on my phone or PC. Problem is the outdoor weather unit runs off a UPS so that I don't lose rain data in a power outage, in a power outage however my Modem drops out and I lose the connection to the outdoor unit. When power is restored the WebMite does not auto reconnect to my WiFi. Is there any way I can test to see if I have lost the connection and restart the CPU. Edit. I wrote the code for sending to my phone with the help of TBS member Luc's web tutorial. Here Edited 2026-02-14 09:12 by palcal "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 3006 |
Having the code below in the main loop works for me. As you want your outdoor unit to keep recording it might be best if it is in a Sub that the main loop only calls every few minutes or longer. Or perhaps via a long tick interrupt. If MM.Info(ip address) = "0.0.0.0" Then 'test for WiFi link Print "WiFi not found"; Pause 8000 Print "...Rebooting now" CPU restart 'endless re-boot until WiFi found EndIf After the WiFi is back up you may need to wait for your ISP to restore the internet connection before sending over that. I wait for the Pico Date$ to be restored by a NTP server. This will need modifying to suit your application. Sub Internet 'TZ+DS = time zone (10) and daylight saving (0 or 1) Do While Date$ = "01-01-2024" 'test internet connection, wait for date$ to update. On error skip WEB NTP TZ+DS, "203.12.160.2" 'Second choice is 0.au.pool.ntp.org or 1.au.pool.ntp.org Inc n : Print n; " tries", DateTime$(now), Pause 2000 If n=15 Then Exit Sub 'give up! Loop End Sub Edited 2026-02-14 10:08 by phil99 |
||||
palcal![]() Guru Joined: 12/10/2011 Location: AustraliaPosts: 2031 |
Thanks Phil, I'm not using WEB NTP for time, a bit unreliable, I am using an RTC. Checking MM.Info(ip address) will work. Thanks for that. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |