Continue to try Wifi Connection indefinitely, and go back to the connection/reboot if a try fails.
-
Hi All,
Have built a simple Micropython app for my M5Stack. It relies on the Wifi Connection and pinging the router to get some information. However; I need the device to continue to try and connect to Wifi, and if it cannot ping the router, to exit main.py go back to this wifi connection.
Has anyone successfully done this or would know where to look?
Thanks and Regards,
Fox. -
@foxhound said in Continue to try Wifi Connection indefinitely, and go back to the connection/reboot if a try fails.:
i
In main.py, add Wi-Fi ping router in your loop code, if ping fail, reconnect
-
@foxhound Have you thought about adding something like
if False: pass else: pass
In order to create a time out function?
You could then use theelse: pass
function to get the program to exit and return to the wifi select function. -
@heybin said in Continue to try Wifi Connection indefinitely, and go back to the connection/reboot if a try fails.:
@foxhound said in Continue to try Wifi Connection indefinitely, and go back to the connection/reboot if a try fails.:
i
In main.py, add Wi-Fi ping router in your loop code, if ping fail, reconnect
@ajb2k3 said in Continue to try Wifi Connection indefinitely, and go back to the connection/reboot if a try fails.:
@foxhound Have you thought about adding something like
if False: pass else: pass
In order to create a time out function?
You could then use theelse: pass
function to get the program to exit and return to the wifi select function.Hi Everyone, thanks for your replies. I'm a little bit confused, and I may be using the wrong firmware.
What's the difference between m5go and m5cloud? I'm using m5cloud-psram-20180323-v0.3.8.bin as my firmware.
Are they related?My boot.py is very different from the only boot.py I can find, inside M5GO.
# This file is executed on every boot (including wake-boot from deepsleep) import sys sys.path[1] = '/flash/lib' from m5stack import lcd, speaker, buttonA, buttonB, buttonC # ---------- M5Cloud ------------ if True: if buttonB.isPressed(): lcd.println('On: OFF-LINE Mode', color=lcd.ORANGE) else: import wifisetup import m5cloud
I cannot find that m5cloud anywhere. Also not sure where it calls main.py from so I can exit out of it.
If that's the same wifisetup.py in M5GO, I should be able to modify that to continue to try connecting. -
@foxhound said in Continue to try Wifi Connection indefinitely, and go back to the connection/reboot if a try fails.:
@heybin said in Continue to try Wifi Connection indefinitely, and go back to the connection/reboot if a try fails.:
@foxhound said in Continue to try Wifi Connection indefinitely, and go back to the connection/reboot if a try fails.:
i
In main.py, add Wi-Fi ping router in your loop code, if ping fail, reconnect
@ajb2k3 said in Continue to try Wifi Connection indefinitely, and go back to the connection/reboot if a try fails.:
@foxhound Have you thought about adding something like
if False: pass else: pass
In order to create a time out function?
You could then use theelse: pass
function to get the program to exit and return to the wifi select function.Hi Everyone, thanks for your replies. I'm a little bit confused, and I may be using the wrong firmware.
What's the difference between m5go and m5cloud? I'm using m5cloud-psram-20180323-v0.3.8.bin as my firmware.
Are they related?My boot.py is very different from the only boot.py I can find, inside M5GO.
# This file is executed on every boot (including wake-boot from deepsleep) import sys sys.path[1] = '/flash/lib' from m5stack import lcd, speaker, buttonA, buttonB, buttonC # ---------- M5Cloud ------------ if True: if buttonB.isPressed(): lcd.println('On: OFF-LINE Mode', color=lcd.ORANGE) else: import wifisetup import m5cloud
I cannot find that m5cloud anywhere. Also not sure where it calls main.py from so I can exit out of it.
If that's the same wifisetup.py in M5GO, I should be able to modify that to continue to try connecting.
My understanding is that M5cloud is depreciated and M5Go/uiflow is the current firmware.
I haven't delved too far into Micropython yet but I'm read that main.py is always the first python called. -
Perfect, thanks for getting back to me on this. I'm not going to get to my comptuer for another 24hours give or take, but I'll flash the new firmware then and go from there.
-
@foxhound no worries i’m In and out of the forum most of the time and try to help out when I can.
-
Hey mate, been a little caught up sorry. I flashed the latest m5Go Image/firmware from here. Obviously I can no longer see it in the cloud interface. How can I upload my code and make modifications to the Wifi? It's puzzling me a bit.
THe M5Cloud image was fine besides the font size wouldn't change, and on top of that, I couldn't find the Wifi to modify.
Thanks again for your help.
Adam -
@foxhound Did you remember to change the ID code of the the M5go after flashing?
UIFlow has been a bit buggy lately and several members have reported issue with connections dropping out between UIFlow and the M5stacks and M5Sticks.. -
Sorry mate, Change the ID code?
-
I feel I am missing something. I have written most of my code using M5Cloud. I have two issues, the fonts won't change (I need larger text), and I need to modify the Wifi Setup so I can keep trying if it doesn't boot. I am using an M5 Stack Fire.
I need to know which image I should be using (there seems to be a lot), and what is the best/proper way for me to put my code on it.
-
@foxhound the current firmware in 1.2.3 en for the M5Stack Fire.
I wasn’t aware the M5Cloud still works.
UIFlow is the current IDE and has a blocky and Micropython. -
Interesting, mind throwing me a link to that firmware.
FWIW, what I'm currently using, I setup Wifi and then get to here, where nothing happens (besides io.m5stack.com/#/<id> opening) when I scan it
-
@foxhound on the computer or phone connect to the new M5Stack network and type in the address. This open a page on the M5Stacks internal micro server that allows you to set the M5Stack into station mode connected to your network. Select your network and insert the password and it should connect and restart disconnecting the M5Stack’s internal network. A new page should show up giving The M5Stack’s is code.
In the UIFlow tutorial section is a link to my documents that have a guide to setup, there is an issue with enterprise networks -
Thanks mate, I've followed this; however this is where it lands me after I've connected it to a network (and it's disconnected the M5Stack's internal network). I never get the ID code. DO you have a link to the 1.2.3 firmware you mentioned?
I suspect there is an issue with the firmware I am using. I will look for your guide now. Have you got a link to it?
Thankyou so much for your help, I really appreciate it.
-
@foxhound https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/software/M5Burner_MacOS.zip
or
https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/software/M5Burner.zipwhen the downloader fully fils the black circle, wait 20 seconds then press the red button on the m5 stack to reset it then press button C to access setup.
Strange that yours isn't showing the ID code as I've just updated mine and they worked properly. -
-
@foxhound Did you get the connection Successful message when trying to connect?
-
Woohoo!! Thanks so much mate, finally in and have placed my code into the UI Flow Python Editor and have started running it :)
Couple of questions related to my original question regarding wifi.
- How do I permenantly save the code to my device. I can run it, but I when I reboot it doesn't boot into my code again.
- Secondly, how on boot can I edit it so it automatically tries to reconnect if the Wifi isn't found.
Thanks so much for your help, really appreciate it.
-
In the top right hand corner is an icon with 3 horizontal lines, click on that then click on "Download" to permanently save to the M5Go.
I do believe that you use
import wifisetup wifisetup.auto_connect()
at the beginning of the file above the
from m5stack import * from m5ui import *
Alternatively, save the file as main.py and copy it to the M5Stack using ampy.