Closed jwillemsen closed 7 years ago
Closing, looks the datarate is for this already
I'm a little confused by your change. According to the RN2483 and RN2903 datasheets I have there is no mac set sf sfX
command. I also do not see the reason for adding this to this library. Spreading factor (SF) is a LoRa physical layer concept. In LoRaWAN land we talk about data rate (DR). Data rate is a term for a spreading factor and channel width pair.
setDR is on: https://github.com/jpmeijers/RN2483-Arduino-Library/blob/master/src/rn2xx3.cpp#L522
I just saw you closed this PR while I was busy typing this.
Yes, found the DR, want to experiment with a different SF to see whether I get coverage from home
Currently implementing a cycling of DR for each transmit to see what happens
Still on my todo list to add this to the binary coordinate examples too.
void loop()
{
SerialUSB.println("Waiting for GPS fix");
unsigned long startTime = millis();
while(millis()-startTime<10000)
{
digitalWrite(LED_GREEN, LOW);
sodaq_gps.scan();
digitalWrite(LED_GREEN, HIGH);
}
// while(sodaq_gps.getLat()==0.0)
// {
// digitalWrite(LED_RED, LOW);
// sodaq_gps.scan();
// digitalWrite(LED_RED, HIGH);
// }
LatitudeBinary = ((sodaq_gps.getLat() + 90) / 180) * 16777215;
LongitudeBinary = ((sodaq_gps.getLon() + 180) / 360) * 16777215;
txBuffer[0] = ( LatitudeBinary >> 16 ) & 0xFF;
txBuffer[1] = ( LatitudeBinary >> 8 ) & 0xFF;
txBuffer[2] = LatitudeBinary & 0xFF;
txBuffer[3] = ( LongitudeBinary >> 16 ) & 0xFF;
txBuffer[4] = ( LongitudeBinary >> 8 ) & 0xFF;
txBuffer[5] = LongitudeBinary & 0xFF;
altitudeGps = sodaq_gps.getAlt();
txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
txBuffer[7] = altitudeGps & 0xFF;
hdopGps = sodaq_gps.getHDOP()*10;
txBuffer[8] = hdopGps & 0xFF;
toLog = "";
for(int i = 0; i<sizeof(txBuffer); i++)
{
char buffer[3];
sprintf(buffer, "%02x", txBuffer[i]);
toLog = toLog + String(buffer);
}
SerialUSB.println(toLog);
digitalWrite(LED_BLUE, LOW);
myLora.txBytes(txBuffer, sizeof(txBuffer));
digitalWrite(LED_BLUE, HIGH);
SerialUSB.println("TX done");
myLora.setDR(datarate);
datarate = (datarate + 1)%6;
}
Yes, was just adding this to the binary example, expect a new PR soon ;-)
Cycling DR shows that I can even transmit on SF11/SF12 from within my house and get data on TTN, will cleanup my code and extend the logging a little bit before I make a new PR
Add support to set the spreading factor as supported by the RN2483, section 2.5.4.5 of the module command reference user guide