RFM69 library: readTemperature always return raw value of 0

Started by ducknoir, May 01, 2024, 02:36:36 AM

ducknoir

I've been tinkering with an RFM69 module with an Arduino Uno for a while, and I've come to the conclusion that the readTemperature method in the LowPowerLab RFM69 library always returns an uncorrected temperature value of 0.

uint8_t RFM69::readTemperature(uint8_t calFactor) // returns centigrade
{
  setMode(RF69_MODE_STANDBY);
  writeReg(REG_TEMP1, RF_TEMP1_MEAS_START);
  while ((readReg(REG_TEMP1) & RF_TEMP1_MEAS_RUNNING));
  return ~readReg(REG_TEMP2) + COURSE_TEMP_COEF + calFactor; // 'complement' corrects the slope, rising temp = rising val
} // COURSE_TEMP_COEF puts reading in the ballpark, user can add additional correction


On a logic analyzer tracing the SPI bus, I can see that the first register read to RegTemp1 (0x4E) returns a raw hex value of 0x01, which masked out is interpreted as "ready". But it seems bit 2 (TempMeasRunning) never went to 1 to indicate the measurement was initiated. So when it immediately tries to read the temperature, it gets 0, not a valid temperature.

The RadioHead library has a similar function, and it works fine. It has a similar while loop, which polls the TempMeasRunning bit and gets 0x04 (running) four times, before it flips to 0x00 on the fifth pass, after which it reads RegTemp2 (0x4F) and gets a value that converts to a reasonable temperature.

My guess is, for some reason it's not in Standby mode when the code writes the initiate command, so it never enters running. I don't know why that would be yet, but I thought I would go ahead and start a conversation about it in case anyone can understand what's going on.

I'm attaching a screenshot of the logic analyzer to show what I'm seeing. And here's a link to the RFM69 datasheet for reference.

https://www.digikey.ca/htmldatasheets/production/1921186/0/0/1/rfm69hcw.html