AnsweredAssumed Answered

micropython informations

Question asked by dumaresq.jonathan on Feb 22, 2018
Latest reply on Mar 27, 2018 by Elio Cometti

HI,

I try to get my SPWF04SA working with micropython only. 

1) I want to be able to connect to my router and send information on MQTT when connected. 

I have set the console_enables=2 and python_script=myscript.py in my variables. 

 

Here my script to test:

from network import WLAN
from pyb import LED
w = WLAN(WLAN.STA)
l = LED(1)
l.off()
MySsid = 'MySSID'
print('INIT')
w.init(mode=WLAN.STA, ssid=MySsid, auth=(WLAN.WPA2, 'MYPassword'))
if w.isconnected():
     print("connected");
     l.on()
print(w.ifconfig())
print('END')

 

If I run this script with REPL, the connection is not working bu I see my traces. 

 

If I run the script with the GPIO8 HIGH and reset the board, I don't see any traces on the uart. Is it possible to have the traces on the uart with only the upython working ?

 

2) When I do a scan with the AT command, AT+S.SCAN=d, I see all the network available on the output. If I do the same thing in the python repl like this 

 

from network import WLAN
w = WLAN(WLAN.STA)
nets = w.scan()
for net in nets:
    print(net)

I don't see any networks. 

 

I don't know what i'm doing wrong, but it's not clear what thing I need to do to get this working. 

 

Here a sample of communication:

+WIND:1:Poweron:171117-0328fe3-SPWF04S
+WIND:13:Copyright (c) 2012-2017 STMicroelectronics, Inc.  All rights Reserved:SPWF04SA
+WIND:0:Console active
+WIND:3:Watchdog Running:20
+WIND:32:WiFi Hardware Started
+WIND:19:WiFi Join:AC:86:74:23:BF:FA
+WIND:25:WiFi Association successful:AP-SSID
+WIND:51:WPA Handshake Complete
+WIND:24:WiFi Up:0:10.255.248.175
+WIND:24:WiFi Up::fe80:0:0:0:280:e1ff:febf:ef63
+WIND:84:NTP Server delivery:2018.2.22:4:20.36.55
at+s.scan=d,
AT-S.Parsing Networks:11
1:       BSS AC:86:74:23:BF:FA CHAN: 05 RSSI: -42 SSID: 'AP-SSID' CAPS: 0431 WPA WPA2
2:       BSS AC:86:74:23:BF:FC CHAN: 05 RSSI: -43 SSID: 'AP-SSID-1' CAPS: 0431 WPA2
3:       BSS AC:86:74:23:BF:FB CHAN: 05 RSSI: -42 SSID: '' CAPS: 0431 WPA WPA2
4:       BSS 24:DE:C6:45:8E:81 CHAN: 06 RSSI: -46 SSID: 'AP-SSID-2' CAPS: 1431 WPA2
5:       BSS 24:DE:C6:45:8E:82 CHAN: 06 RSSI: -47 SSID: 'AP-SSID-3' CAPS: 1421
6:       BSS 24:DE:C6:45:8E:83 CHAN: 06 RSSI: -46 SSID: 'AP-SSID-4' CAPS: 1431 WPA2
7:       BSS 24:DE:C6:45:8E:84 CHAN: 06 RSSI: -47 SSID: 'AP-SSID-5' CAPS: 1431 WPA2
8:       BSS 24:DE:C6:45:8E:85 CHAN: 06 RSSI: -47 SSID: 'TestCP' CAPS: 1431 WPA2
9:       BSS 24:DE:C6:45:8E:80 CHAN: 06 RSSI: -47 SSID: '' CAPS: 1431 WPA2
10:      BSS AC:A3:1E:00:BB:84 CHAN: 06 RSSI: -87 SSID: 'AP-SSID-6' CAPS: 1431 WPA2
11:      BSS AC:A3:1E:00:BB:85 CHAN: 06 RSSI: -87 SSID: 'AP-SSID-7' CAPS: 1431 WPA2
AT-S.OK
at+s.python
AT-S.OK
MicroPython v1.8.7-149-g476c672 on 2017-02-22; SPWF04Sx with STM32F439
Type "help()" for more information.
>>> from network import WLAN
>>> w = WLAN()
>>> nets = w.scan()
>>> print(nets)
[]
>>>

 

Regards

Jonathan

Outcomes