OSError: no network card available after newest firmware update
-
Hello everyone,
I updated my latest firmware from the Pycom Lopy 4 (v.1.20.2.r4) and since ever then I can't send data over WiFi and I also can't change from protocol because it is for a task at the University.
This is my main code:
from machine import Pin from time import sleep_ms import time import urequests btn = Pin('P16', Pin.IN, Pin.PULL_UP) btn2 = Pin('P17', Pin.IN, Pin.PULL_UP) btn3 = Pin('P18', Pin.IN, Pin.PULL_UP) btn4 = Pin('P19', Pin.IN, Pin.PULL_UP) led = Pin('P20', Pin.OUT, Pin.PULL_DOWN) def irq_function_sad(self): if not btn.value(): led.value(1) print("ongelukkig") sleep_ms(500) send_sad("ongelukkig") else: led.value(0) def send_sad(sad): res = urequests.post('http://xxxxxx', json={"emotie": sad}) res.close() if (res.status_code - 200) < 100: # check that response code is in the 200 range print('done') else: print('there was some error') def main(): btn.callback(Pin.IRQ_FALLING, irq_function_sad) while True: print(btn.value()) time.sleep(2) if __name__ == "__main__": main()
My error:
Unhandled exception in callback handler Traceback (most recent call last): File "main.py", line 18, in irq_function_sad File "main.py", line 24, in send_sad File "/flash/lib/urequests.py", line 116, in post File "/flash/lib/urequests.py", line 56, in request OSError: Network card not available
Can someone help me please? Or did someone had the same problem?
Kind regards,
Zino
-
It seems you never instantiate a network. Perhaps in 1.18 you were using the
pycom.wifi_on_boot
(etc. from here: https://docs.pycom.io/firmwareapi/pycom/pycom/#pycomwifi_on_bootboolean) settings which might have been erased when you did the firmware update?
In any case, you should be able to add the example from here: https://docs.pycom.io/tutorials/networks/wlan/#connecting-to-a-router to your main() to resolve the issue.