Ive been playing around with _thread in a picow
I have a function which sets up wifi and then gets some information from another pi using the wifi connection.
If I run this normally , that is not using any threads , all works correctly.
If I introduce a simple count and print function and run it in core1, the wifi setup code runs and sets up the correct IP address (indicated by print statements) but the wifi connection has not been created .. pinging the picow fails.
If I swop the two functions .. the counter in core0 and the wifi function in core1 I get the same result.
Any ideas?
I use thonny as my method for programming the picow
The code to connect to wifi is ..
I have a function which sets up wifi and then gets some information from another pi using the wifi connection.
If I run this normally , that is not using any threads , all works correctly.
If I introduce a simple count and print function and run it in core1, the wifi setup code runs and sets up the correct IP address (indicated by print statements) but the wifi connection has not been created .. pinging the picow fails.
If I swop the two functions .. the counter in core0 and the wifi function in core1 I get the same result.
Any ideas?
I use thonny as my method for programming the picow
The code to connect to wifi is ..
Code:
def start_wifi(): # Set up wifi with static ip-address lan_errors={0:"IDLE",1:"CONNECTING",-3:"WRONG PASSWORD",-2:"NO AP FOUND", -1:"CONNECT FAIL",3:"GOT IP"} lan=WLAN(STA_IF) lan.active(True) lan.ifconfig((this_ip, '255.255.255.0',gateway, dhcp)) count = 0 print("LanStatus = "+str(lan_errors[lan.status()])) lan.connect(ssid, password) while not lan.status() >= 3 : print('waiting to connect #'+str(count)) sleep(3.0) lan.connect(ssid, password) count+=1 print("LanStatus = "+str(lan_errors[lan.status()])) lan.ifconfig((this_ip, '255.255.255.0',gateway, dhcp)) print("LAN Config = "+str(lan.ifconfig())+"\n")Statistics: Posted by Hcgrant — Sat Jul 12, 2025 10:56 am