emonTH pulse counting firmware error

I’m not sure that even the sensor knows that! I think it will come either from incorrect use, i.e. the sensor is powered and then read without being asked to do a reading (85 is the converted power-up value of 0x0550) or not enough time being allowed for it to make the reading (which amounts to the same thing). It might be the case that we have to choose between running the risk of falsely trapping that one or missing the error. I think I’ve written elsewhere that using a value that converts to an in-range temperature for a power-up value seems short-sighted (or historical? - it’s the top end of the ±0.5°C accuracy band).

But looking just now at the data sheet, it may well be that the checksum is not calculated at power-up, in which case your fix covers both errors - barring the checksum being accidentally correct. This needs proving.

No such luck!

int get_temperature(byte sensor)
{
  float temp=(sensors.getTempC(allAddress[sensor]));
  return(temp*10);
}

Taking all the tests out as above, I can provoke a “-127 °C” by making the data line intermittent, I can provoke a “85 °C” by making the power line intermittent, and I can provoke either by making the ground line intermittent. Had the checksum been a random value at power-up, then I would have expected a checksum failure instead of the 85 °C reading, but it doesn’t.

And I’ve made MartinR’s sketch produce much the same result but with “300.00” instead of “-127”. That confirms that the checksum is correct at power-up and there’s no obvious way to detect the “85 °C” condition.

Heigh Ho.

EDIT =============================

I have updated the Building Blocks article with the above information about the error values.

Sorry for the delay. I Can confirm I can replicate the issue with humidity reading being affected by the pulse count, interestingly the temperature reading from the DHT22 is not affected.

I will try your changes and report back

@digbyt would it be possible for you to submit a GitHub pull request with your proposed changes to the sleep function? I’ve just taken a look at your code and there are quite a few changes. I just want to make sure I test the changes as you intended, there is no better way than a pull-request.

Thanks,