wifi antenna default
-
https://docs.pycom.io/firmwareapi/pycom/network/wlan/ says pycom modules default to the internal antenna for wifi but when I run
from network import WLAN wlan=WLAN(mode=WLAN.STA) print('antenna', wlan.antenna())
I get
antenna 2
since 0=internal & 1=external, 2 seems a tad ambiguous. I'm wondering if I need to run
Pin('P12', mode=Pin.OUT); wlan.antenna(WLAN.INT_ANT)
just to be sure?
-
I will add an entry to the documentation and a micropython constant for
MAN_ANT
to make this more clear, thanks!
-
@Gijs understood, thnx
-
Okay I looked into it in more detail and was able to reproduce it (I accidentally set it in a previous applications, and did not power off in between)
so, antenna = 2 refers to
ANTENNA_TYPE_MANUAL
if you did not use its keyword argument inwlan= WLAN()
orwlan.init(...)
or the functionwlan.antenna(..)
, meaning you can select the antenna manually by setting pin P12. In most cases, this defaults to the use of the internal antenna, as P12 is not asserted by default. To be sure, you should set the antenna type, but it is not necessaryGijs
-
@Gijs tried it on 3 different devices
(sysname='LoPy4', nodename='LoPy4', release='1.20.0.rc13', version='v1.9.4-94bb382 on 2019-08-22', machine='LoPy4 with ESP32', lorawan='1.0.2', sigfox='1.0.1') (sysname='LoPy4', nodename='LoPy4', release='1.18.2.r1', version='v1.8.6-849-e0fb68e on 2018-11-26', machine='LoPy4 with ESP32', lorawan='1.0.2', sigfox='1.0.1') (sysname='GPy', nodename='GPy', release='1.20.1.r1', version='15b6d69 on 2019-11-02', machine='GPy with ESP32')
all give 2 as the result, no pybytes.
-
That is quite odd, as when I run the same code on my device:
>>> from network import WLAN >>> wlan=WLAN(mode=WLAN.STA) >>> print('antenna', wlan.antenna()) antenna 0
Refering to the internal antenna. Which firmware version are you running and are you perhaps using pybytes on boot?
Gijs