Bad temperature readings with Arduino Micro and BMP085
Moderators: adafruit_support_bill, adafruit

Bad temperature readings with Arduino Micro and BMP085

by sim on Sat Mar 09, 2013 2:57 pm

I have an Arduino Micro that I bought from Adafruit and I hooked this up to a BMP085 sensor I have. I believe I've hooked it up correctly as I am indeed getting data back. It's just that the data is consistently way off. I'm using the Adafruit BMP085 library. For example, these are the readings I currently get:

Temperature = -94.43 *C
Pressure = 163217 Pa

Obviously way off right? To test if this is the result of a bad sensor, I hooked everything up to my Raspberry Pi and followed the instructions from learn.adafruit.com. Here's what I got (using the BMP085 python code):

Temperature: 22.70 C
Pressure: 1016.13 hPa
Altitude: -23.95

Obviously much, much better (I haven't verified the pressure and altitude readings, but the temp at least is fairly accurate). So am I missing something here? Is there something special that needs to be done when using the Arduino Micro? I'm thinking I2C bus speed or something? I'll dig in to the specs for that microcontroller again, but if anyone can lend a hand here it will be much appreciated.
sim
 
Posts: 3
Joined: Sun Sep 02, 2012 8:30 am

Re: Bad temperature readings with Arduino Micro and BMP085

by sim on Sat Mar 09, 2013 3:07 pm

Forgot to mention something else! During some debugging of the Arduino BMP085 library, I found a weird anomaly. It's in this section of code:

uint16_t Adafruit_BMP085::readRawTemperature(void) {
write8(BMP085_CONTROL, BMP085_READTEMPCMD);
_delay_ms(5);
#if BMP085_DEBUG == 1
Serial.print("Raw temp: ");
read16(BMP085_TEMPDATA);
read16(BMP085_TEMPDATA);
#endif
return read16(BMP085_TEMPDATA);
}

If I add another call to read16, magically the temperature result changes! So for example if I change the code to this:

uint16_t Adafruit_BMP085::readRawTemperature(void) {
write8(BMP085_CONTROL, BMP085_READTEMPCMD);
_delay_ms(5);
#if BMP085_DEBUG == 1
Serial.print("Raw temp: ");
read16(BMP085_TEMPDATA);
read16(BMP085_TEMPDATA);
#endif
read16(BMP085_TEMPDATA);
return read16(BMP085_TEMPDATA);
}

Then all of a sudden the temp reported is 34.5 *C. The first call to read16, returns 0 from the register. So if I have just one call, the raw temp is 0. Doesn't seem to matter with 3 calls or more. Not sure if this is a hint to the underlying problem or not. Again, this is only happening with the Arduino Micro: http://arduino.cc/en/Main/ArduinoBoardMicro
sim
 
Posts: 3
Joined: Sun Sep 02, 2012 8:30 am

Re: Bad temperature readings with Arduino Micro and BMP085

by Zener on Sat Mar 09, 2013 3:43 pm

As far as your second post, I don't know. I am not an I2C expert (that should be in a code box BTW...)

However, the fact that you have a working system to compare to is a big plus usually. So that is a good thing.

Now, if I was handed this at work, and told to fix it, and I knew nothing about it (which is just about a daily occurrence at my job...) here is a basic test I would do first:

Put yoru fingers on the temp sensor and observe what happens to the readings. If something happens but it makes no sense, like the pressure number changes, or the numbers respond but in a crazyish way, then that would suggest that there is some communication with the I2C but it is getting corrupted somehow.

On the other hand, if nothing at all happens and the numbers just sit there, then that suggest the I2C link isn't working at all for some reason. The next thing I would do is put a scope on the data line and compare the good system with the bad, but I am guessing you don't have a scope so that test is out.

Do that test and report back and hopefully a really smart person comes along who can help you more. Good luck!
Last edited by Zener on Sat Mar 09, 2013 3:52 pm, edited 1 time in total.
Zener
 
Posts: 2572
Joined: Sat Feb 21, 2009 1:38 am

Re: Bad temperature readings with Arduino Micro and BMP085

by adafruit_support_rick on Sat Mar 09, 2013 3:45 pm

You may be seeing a logic-level issue. The Micro operates at 5V, while both the Pi and the BMP085 are 3.3V parts.
Are you using the Adafruit BMP085 breakout? Is it the 5V-ready version?
User avatar
adafruit_support_rick
 
Posts: 12130
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Bad temperature readings with Arduino Micro and BMP085

by sim on Sat Mar 09, 2013 9:33 pm

Ah... I think driverblock is right! I didn't buy the BMP085 from Adafruit and I just checked, it is 3.3v logic! Facepalm for not reading carefully! I wonder how much damage I've done to the sensor?
Zener,thanks also for your tips. I actually did try testing the sensor with a block of ice a few days ago. Temp did not change one bit, but I thought there was just a problem with the sensor. Hence the Raspberry Pi test. Also, I'll remember to use the code block for code from now on. Sorry about that.
Guess I'll track down a logic-level converter and try this thing again.
Thanks all for your help.
sim
 
Posts: 3
Joined: Sun Sep 02, 2012 8:30 am

Re: Bad temperature readings with Arduino Micro and BMP085

by adafruit_support_rick on Sun Mar 10, 2013 11:48 am

sim wrote:Guess I'll track down a logic-level converter and try this thing again.

Like this one?
User avatar
adafruit_support_rick
 
Posts: 12130
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Bad temperature readings with Arduino Micro and BMP085

by Static on Sun Mar 17, 2013 2:12 am

I'm having similar issues, but across the board and with my Raspberry Pi.

Last week I had great sensor readings with my BMP085, two TSL2561's, and a TMP102. I updated the I2C code and the BMP085 code to the most recent Adafruit releases. Now my readings are nutty, obviously wrong.

Are you sure this was a 3.3v issue?
Static
 
Posts: 180
Joined: Thu Dec 23, 2010 5:21 pm

Re: Bad temperature readings with Arduino Micro and BMP085

by adafruit_support_rick on Sun Mar 17, 2013 8:58 am

Static wrote:Are you sure this was a 3.3v issue?

OP was running an Arduino Micro, not a Pi, so you wouldn't be seeing the same problem.
Static wrote:I'm having similar issues, but across the board

Do you mean you're seeing a problem with all your devices, or just the BMP085?
User avatar
adafruit_support_rick
 
Posts: 12130
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Bad temperature readings with Arduino Micro and BMP085

by Static on Sun Mar 17, 2013 2:53 pm

It's all of the devices, on both devices.

Last night I tried successfully set the debug mode, but then I got... stuff. The numbers are coming through fine, and it's readable, I just don't know what the numbers are referring to (I'm sending the BMP085 data sheet to my phone, in case I get a chance to read this week at work... unlikely, but you never know).

I need to pull apart one of my other projects and get my other Raspberry Pi out. I'll pull the card and try running it on that one. It's going to take a couple of days for me to do that.

Don't spend too much skull sweat on it, please. I put the post out to see if others were having similar issues. Looking at the code, it looks like it should work.

There is one thing, and I don't know how to send a comment through GitHub (Learning GitHub is high on my priority list of things to work on, but it's a really long list).
In the most recent release of the Adafruit_I2C it allows the user to pass which I2C bus they are using. The Adafruit_BMP085 code builds on this, but doesn't appear to allow the user to pass which bus is being used. I think there needs to be a variable in the __init__ function for the Adafruit_BMP085. It's not broken as long as the user is only using the "normal" bus on their Raspberry Pi (The new code examines which version of the Pi you are using and can automatically configure which bus it looks at). If the user is using the other bus, or both buses at the same time, they're going to get some frustrating results. I think.

If anyone else is following this thread with the similar issues, I'll be posting over to the relevant thread as soon as I can sit down and look at it. I guess I should also start a thread here about "Raspberry Pi and BMP085: funky data". I'll look at that on Wednesday when I get home.

driverblock, I don't know if this is a complement or not. When I was poking at this the other day, I did say to myself "What would driverblock do?", given the assistance you gave me in my other endeavors. Thanks again for all of your help on here.
Static
 
Posts: 180
Joined: Thu Dec 23, 2010 5:21 pm

Re: Bad temperature readings with Arduino Micro and BMP085

by adafruit_support_rick on Sun Mar 17, 2013 3:00 pm

Try the I2C devices one-at-a-time. Could be one bad one screwing up the bus.

As for GitHub, you want to find the 'Issues' tab on the top bar - to the right of 'Code', 'Network', etc. Click that, and you'll see a button for 'New Issue" at the upper left.

ps - thanks for the kudos! :D
User avatar
adafruit_support_rick
 
Posts: 12130
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY