pycom / pycom-micropython-sigfox

A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
MIT License
196 stars 167 forks source link

LoRa constructor does not set power_mode #178

Open campbellsinclair opened 5 years ago

campbellsinclair commented 5 years ago

lora = LoRa(mode=LoRa.LORA, region=LoRa.AU915, frequency=925500000, tx_power=5, bandwidth=LoRa.BW_500KHZ, sf=7, preamble=8, coding_rate=LoRa.CODING_4_5, tx_iq=False, rx_iq=False, public=False, power_mode=LoRa.SLEEP, )

*
  * With a multimeter connected in series with the 5V power supply, observe that the current is approximately 103 mA.
  * Invoke the following command:
```python
lora.power_mode(LoRa.SLEEP)

*

campbellsinclair commented 5 years ago

My guess is that during initialisation for the LoRa class, power_mode is set but then another command is called which changes power_mode.

campbellsinclair commented 5 years ago

I've found a similar issue. This issue is for the command lora.power_mode(LoRa.TX_ONLY). Note that this is not initialisation.

When the power_mode is TX_ONLY, I expect the radio to go to sleep when it is not transmitting. This is true after executing that command. But once you send something, the power mode appears to be LoRa.ALWAYS_ON.

This time I turned off WiFi to get more stable power readings:

from network import WLAN

wlan = WLAN(mode=WLAN.STA)
wlan.deinit()
campbellsinclair commented 5 years ago

Another issue: with bandwidth=BW_125KHZ and sf=12, it appears that the radio does not successfully send any data (because my other LoPy does not receive the data -- assumption: the error is with the transmitting LoPy).

If I continuously transmit data, the current is 60 mA for approximately 7 seconds. It then drops to 43 mA (which is the same as power_mode=ALWAYS_ON), even while attempting to transmit data.

robert-hh commented 5 years ago

Cannot confirm. I have sent & received data at SF12BW125 with two xxPy devices.

campbellsinclair commented 5 years ago

@robert-hh Try setting the coding rate to CODING_4_8 and send data which is 156 bytes or greater. It will send the first time, but if I send again it doesn't work.

Note that the LoPy v1 uses the SX1272 instead of the SX1276.

robert-hh commented 5 years ago

There is a maximum airtime, depending on the transmission parameters. At SF12BW125 (DR=0), this is 51 (or 59) bytes. Setting the coding rate to 4/8 will reduce that further. So what were you test parameters?

nevercast commented 5 years ago

Where is the maximum airtime defined, @robert-hh ? Do we have a millisecond hard limit for that?

Edit: As a developer using LoRa on the LoPy I would not want to miss information about hard limits with a high Spread Factor, and this information could easily be buried in this issue, the name of which is entirely unrelated. @campbellsinclair Do you mind creating another issue separate from this one regarding your SF12BW125-C48 with >155 bytes problem? It would serve people like myself better when I search for issues.

nevercast commented 5 years ago

The state machine certainly needs checking. The modem does not go to sleep when power_mode is set on the LoRa constructor. Can I help in any way? Some code to reproduce this issue?