I was following the guide and program for a simple TTN node that Andreas Spiess presented a video. The program uses the LMIC library.
The program works fine and the packets show up in the TTN device console.
I added some of my own diagnostics, I read back the LoRa device registers after a packet send and display, frequency, bandwidth, spreading factor, coding rate and power level.
I had assumed the power level would be set for 14dBm/25mW, but LoRa device is reporting its set to 16dBm/40mW .
Now the appropriate register for power level is RegPaConfig and its set in radio.c
static void configPower () {
#ifdef CFG_sx1276_radio
// no boost used for now
s1_t pw = (s1_t)LMIC.txpow;
if(pw >= 17) {
pw = 15;
} else if(pw < 2) {
pw = 2;
}
// check board type for BOOST pin
writeReg(RegPaConfig, (u1_t)(0x80|(pw&0xf)));
writeReg(RegPaDac, readReg(RegPaDac)|0x4);
#elif CFG_sx1272_radio
// set PA config (2-17 dBm using PA_BOOST)
s1_t pw = (s1_t)LMIC.txpow;
if(pw > 17) {
pw = 17;
} else if(pw < 2) {
pw = 2;
}
writeReg(RegPaConfig, (u1_t)(0x80|(pw-2)));
#else
#error Missing CFG_sx1272_radio/CFG_sx1276_radio
#endif /* CFG_sx1272_radio */
}
I have CFG_sx1276_radio selected so the power level is set by;
writeReg(RegPaConfig, (u1_t)(0x80|(pw&0xf)));
Which writes the pw variable into the register.
Now if pw is 14 (for 14dBm) the power level of the device is according to the datasheet;
Pout=17-(15-OutputPower)
Now ‘OutputPower’ is what is written to bits 3-0 of RegPaConfig and if its 14 the actual power level selected appears to be;
Pout=17-(15-14) = 16dBm.
Which is in line with my diagnostic print, which suggested the power level is being set to 16dBm when 14dbm is expected.
Is it possible the LMIC code should be;
writeReg(RegPaConfig, (u1_t)(0x80|(pw&0xf)-2));
Or is there some deliberate compensation going on ?