I2C Sensor + Teensy 2.0. Bad Data

Status
Not open for further replies.
Hi,
Just tried using my new AM2315 Humidity/Temperature sensor with a Teensy 2.0, and I am getting bad data.
This is an I2C device available from Adafruit Industries:
http://www.adafruit.com/products/1293

Link to the library:
https://github.com/adafruit/Adafruit_AM2315

The code is an example included with the AM2315 Library:
Code:
    #include <Wire.h>
    #include <Adafruit_AM2315.h>

    /***************************************************
      This is an example for the AM2315 Humidity + Temp sensor

      Designed specifically to work with the Adafruit BMP085 Breakout
      ----> https://www.adafruit.com/products/1293

      These displays use I2C to communicate, 2 pins are required to 
      interface
      Adafruit invests time and resources providing this open source code,
      please support Adafruit and open-source hardware by purchasing
      products from Adafruit!

      Written by Limor Fried/Ladyada for Adafruit Industries. 
      BSD license, all text above must be included in any redistribution
    ****************************************************/

    // Connect RED of the AM2315 sensor to 5.0V
    // Connect BLACK to Ground
    // Connect WHITE to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5
    // Connect YELLOW to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4

    Adafruit_AM2315 am2315;

    void setup() {
      Serial.begin(9600);
      Serial.println("AM2315 Test!");

      if (! am2315.begin()) {
         Serial.println("Sensor not found, check wiring & pullups!");
         while (1);
      }
    }

    void loop() {
      Serial.print("Hum: "); Serial.println(am2315.readHumidity());
      Serial.print("Temp: "); Serial.println(am2315.readTemperature());

      delay(1000);
    }

Everything is wired the normal way, using a pair of 10K pullups to Vcc. I have made many successful gadgets using I2C in the past.

When I first start the system, the first 11 readings were normal at 24degC and 55.4%rh (close to a DHT-22 I also have running on a different system), but then the numbers went all weird- the Temperature value stuck at 3331.80 and the Humidity at 22.00 with minor variation (+/- 0.02% or so).

I tried disconnecting the USB, waiting 15 seconds, then plugged it in. Same thing.

The software is an un-modified (except for deleting an extraneous "}" at the end) example sketch that came with the Adafruit AM2315 library.

I ran exactly the same code for days with an Arduino Uno, with no difficulty.

I am currently using the Teensyduino 1.02 IDE.

Any clues will be most appreciated!

I posted this topic on the Adafruit board as well:
http://forums.adafruit.com/viewtopic.php?f=19&t=40118
but have not received much helpful information yet.

Thank you!
 
That library code is so very simple, it really ought to work.

Inside the library, there is a commented line which would print the raw data from the sensor. It's in this part:

Code:
  Wire.requestFrom(AM2315_I2CADDR, 8);
  for (uint8_t i=0; i<8; i++) {
    reply[i] = Wire.read();
    //Serial.println(reply[i], HEX);
  }

Could you uncomment that line and give it another try? Perhaps seeing if (and how) the raw data changes might help in understanding the problem?
 
That library code is so very simple, it really ought to work.

Inside the library, there is a commented line which would print the raw data from the sensor. It's in this part:

Code:
  Wire.requestFrom(AM2315_I2CADDR, 8);
  for (uint8_t i=0; i<8; i++) {
    reply[i] = Wire.read();
    //Serial.println(reply[i], HEX);
  }

Could you uncomment that line and give it another try? Perhaps seeing if (and how) the raw data changes might help in understanding the problem?

Sure, I'd be happy to, but won't have an opportunity for at least two weeks. I guess the thing that is bothering me so much is that the Arduino UNO seemed to work so well. What do you suppose the variables could be when comparing the two platforms?

Thanks for your quick reply, BTW.
 
Of course, can always be a wonky sensor, as well- It's worth noting that I never had a lick of trouble with Teensy 2.0 I2C communications until now...
 
This really should work. The I2C hardware on Teensy 2.0 is pretty much identical to Arduino Uno.

Without more info or the actual hardware to test, I really can't offer any useful opinions.
 
Status
Not open for further replies.
Back
Top