I am trying to change the spreading factor from SF10 to SF7 on an MKR WAN 1310,
but the gateway always receives my uplinks at SF10BW125.
Setup
Board: Arduino MKR WAN 1310, modem firmware ARD-078 1.2.3 (modem.version())
Library: MKRWAN 1.0.15 (1.1.2 is available but not installed; MKRWAN_v2 1.3.2 is installed but my sketch uses #include <MKRWAN.h>)
Region: AS923 (Japan), OTAA, The Things Stack Sandbox (au1)
Gateway: SenseCAP M2 (packet forwarder mode)
TTN device: LoRaWAN 1.0.3, RP001 Regional Parameters 1.0.3 revision A
What I tried
modem.setADR(false);
bool ok = modem.dataRate(5); // returns true
Serial.println(modem.getDataRate()); // prints 5
I tried this (a) before joinOTAA(), (b) right after joinOTAA(), and
(c) just before modem.beginPacket() on every uplink. I also tried dataRate(3).
In every case getDataRate() returns the value I set, but the TTN live data
always shows "Data rate: SF10BW125" for the uplinks (the join request is
also SF10).
With the default setADR(true) the uplinks are also always SF10BW125
(more than 1,600 uplinks on another unit with the same hardware and sketch).
Questions
Is dataRate() known to have no effect on uplinks with this library/firmware
combination in AS923, or is there another setting (for example dwell time
or channel configuration) that I should change?
Would updating MKRWAN to 1.1.2 change this behavior, or does it require
a newer modem firmware?
Would MKRWAN_v2 with firmware 1.3.x behave differently?
I can post a minimal sketch if that helps. Thank you!
First, the join request at SF10 is completely normal and not part of your problem - OTAA joins in AS923 always go out at the default join data rate regardless of your dataRate setting.
The key detail is that getDataRate() in the MKRWAN library only returns the value you stored locally; it does not read back the actual transmit data rate from the modem, so its output cannot prove the modem applied anything. In MKRWAN 1.0.15, dataRate() is known to have no real effect on the modem in many cases - the data rate handling was reworked in the 1.1.x releases, so I would update to 1.1.2 before testing anything else.
When you retest, call modem.dataRate() after modem.begin() but before joinOTAA(), keep ADR disabled during the test, and judge only by the live data on The Things Stack, not by what getDataRate() reports. If uplinks still arrive at SF10 with 1.1.2, try MKRWAN_v2 with the 1.3.x modem firmware, which uses a different command interface for the data rate.
Thank you very much for the detailed answer. I retested as you suggested.
Conditions
MKRWAN updated to 1.1.2 (modem firmware still ARD-078 1.2.3)
modem.setADR(false) and modem.dataRate(5) called right after modem.begin(AS923) and before joinOTAA()
No other setADR()/dataRate() calls anywhere in the sketch
Judged only by the live data on The Things Stack
Result
After a fresh join, the first two uplinks (the first two data uplinks after the join accept) still arrive at SF10BW125. I understand that the join request at SF10 is normal. Earlier I had also tried 1.1.2 with dataRate(5) called after joinOTAA(), with the same result.
If I want to go ahead with MKRWAN_v2 and modem firmware 1.3.x, what is the recommended procedure (which firmware update sketch, and which library version should it match)?
Is it possible to go back to the original firmware (ARD-078 1.2.3) if the update does not help or fails?
Does the sketch need other changes besides #include <MKRWAN_v2.h>? How should the data rate be set with MKRWAN_v2 for AS923?
Is there anything else I should check first (for example dwell time or channel settings in AS923) before updating the modem firmware?
I have two identical units in the field, so I will test on one unit only.
Thanks for the reply. The issue is only about the LoRa modem on the
MKR WAN 1310 (the spreading factor seen on The Things Stack). The sensors
(ultrasonic sensor, SHT31, DS18B20) are wired to the board's pins, but they
are not involved in the LoRaWAN data rate, so a wiring diagram would not add
information here.
Here is a simplified version of the LoRa part of my sketch (the real sketch
also reads the sensors, retries the join and sleeps between uplinks):
With MKRWAN 1.1.2 (modem firmware ARD-078 1.2.3), the uplinks still arrive
at SF10BW125 on The Things Stack. Please let me know if you need more
information.