SOLVED - BMP180 Temperature Errors

Does anyone know of a way to handle sensor errors?

I've added a picture of the serial monitor.

Those erroneous readings going from 41.00 down to 2 are not actually occuring. It should just read 41.00. Temperature changes are gradual and slow for the thing I am measuring.

I have the sensor connected using I2C and I am using the Adafruit_BMP085 library. I am just using bmp.readTemperature() to get the temperature from the sensor, and then simple mean averaging 30 readings - nothing special.

One thing to note is that this had worked for some time, many months. Its just lately the readings are very erroneous as you can see. I wantes to introduce some code or some I2C error handling to ensure sensor readings are accurate.

Ignore big deltas.

1 Like

Could be a problem with your unseen code or unknown MCU board?

I will try get a good portion of my temperature code up when I get back to the PC.

I think it might be something with the I2C bus, as when these erros occur, the RTC clock goes mad... random time changes etc.

I was more wondering if there was a way to handle I2C errors, or see them when they occur to fault find what is going on.

I could try and add a big delta ignore code, but Id like to understand what is going wrong.

Me too.

You should output the raw temperature data and see what the actual renegade value is.

Oops... warning: when multiple problems are observed, start looking for loose wiring, bad power, interference: cellphone nearby? Fluorescent lightning? Bad AC grounding, poor wall-wart.

30 readings for averaging seems an overkill. I usually use a rolling average of 10 (or less) values. For things you know will not change fast, you can compare raw with average and toss the value if too far off... be careful to implement a max time to toss!

Hi,

Did you just find this problem after writing a mass of code?

If you wrote you code in stages, you should have a piece of code that JUST reads the 085 and puts the results on the IDE monitor.

If you haven't, then forget your master code for the present, and write some code, or use the library examples, to establish if you are communicating properly with the device.

This is called getting back to basics in troubleshooting and developing code in stages, each stage needing to work correctly before combining with other code stages.

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:
PS, For the moment do not cut your existing master code back, write fresh code for the 085.

Hi Tom,

No not after writing any code.

I wrote the code about a year ago, and I am just starting to get problems now.

I have made a pcb for the project, and everything is connected fine.

I'm wondering now if the RTC module is causing problems, potentially if the battery is low?

Hi,
Do you have a schematic?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Ive realised that I dont have pullup resistors on the SCL & SDA lines. Could this be my issue do people think?

Absolutely.

If you're using modules as distinct from raw chips, don't the modules have pullups on them? If so, I think there's a chance that if they both have resistors, and you now have 2 sets in parallel, the resulting value is unsuitable.

So just to confirm, a year ago it was ok?

void getTemperature(){

  currentTemp = bmp.readTemperature();

  total = total - readings[readNum];
                                              
  readings[readNum] = currentTemp;
                                 
  total = total + readings[readNum];
                                             
  readNum = readNum + 1;   
                                                      
  if (readNum >= numReadings) {
    readNum = 0;                                                                  
  }
  
  averageTemp = total / numReadings;                                      
  
  currentTempAverage = averageTemp;
  //Serial.print("AverageTemp:");       //DEBUGGING.
  //Serial.println(currentTempAverage);            //DEBUGGING.
}

Ive just disabled the temperature sensor, and just the rtc is doing weird stuff. I think the battery may just be dead or a bad module. I will replace and get back...

I see some garbage on the line. My guess is that its resetting and the average is restarting with all zeros, hence the low & increasing numbers.

Yeah definately.

I think the rtc module might be hogging, or draghing down the scl sda lines, causing the bmp180 to loose connection and report 0 back or an error (not sure).

That is a good point!

I will check the module boards to see if they have their own resistors.

Edit: And yes, a year ago it worked fine.

Both modules have pullup resistors.

I will remove them from the ds3231.

I do not think this has anything to do with the I2C.

I am seeing the same issue on serial write:
image

void loop() {
  //getTemperature();
  //tempSwitch();
  DateTime now = rtc.now();
  setInputFlags();
  resolveInputFlags();
  setCathodePoisonFlag();
  if (cathodePoisonFlag == HIGH){
    cathodePoisonPrevention();
    cathodePoisonFlag = LOW;
  }
  else{
  writeHours(now.hour());
  writeMinutes(now.minute());
  Serial.print("Hour: ");
  Serial.print(now.hour());
  Serial.print(" ");
  Serial.print("Minutes: ");
  Serial.println(now.minute());
  }
}

Oh yeah, its a Nixie clock. Cathode Poison occurs every 30mins and looks like this:
image

The common fault that occurs after this error, is that the Arduino Nano freezes. The serial monitor freezes, the clock freezes etc.

I am wondering if something is locking up.

I have replaced the Arduino Nano.