0

AM2315 + Teensy. Bad Data
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

AM2315 + Teensy. Bad Data

by easternstargeek on Wed May 22, 2013 5:56 pm

Hi,
Just tried using my new AM2315 Humidity/Temperature sensor with a Teensy 2.0, and I am getting bad data.

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 it for days with an Arduino Uno, with no difficulty.

I am currently using the Teensyduino 1.02 IDE.

Any clues will be most appreciated!

easternstargeek
 
Posts: 344
Joined: Mon Dec 13, 2010 1:39 pm
Location: Upper Eastern Tennessee

Re: AM2315 + Teensy. Bad Data

by adafruit_support_mike on Thu May 23, 2013 6:42 pm

First, have you been able to get good readings from the sensor by hooking it up to an Arduino again? If so, the problem isn't completely messing up the sensor (which is good).

Second, does the garbage input always occur after the 11th reading when you use the Teensy? If so, it sounds like a timing or memory issue.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 58797
Joined: Thu Feb 11, 2010 2:51 pm

Re: AM2315 + Teensy. Bad Data

by easternstargeek on Thu May 23, 2013 9:43 pm

Yes, and yes.

Thanks for the tip- that's what I was thinking, but then again- how could it be a memory problem with such a tiny sketct?

Also, as far as timing issues go, what can be done? I'm not familiar with the intricacies of the Wire library and how it works.

Still looking for whatever help is out there. Anyone else have Tennsy 2.0 and I2C problems?

easternstargeek
 
Posts: 344
Joined: Mon Dec 13, 2010 1:39 pm
Location: Upper Eastern Tennessee

Re: AM2315 + Teensy. Bad Data

by adafruit_support_mike on Fri May 24, 2013 6:25 pm

WRT memory issues, it's hard to say, though the Arduino 'String' class is a common source of headaches. Post your code and we'll see if we can find anything.

WRT timing, reading the AM2315 datasheet is a linguistic adventure (http://www.adafruit.com/datasheets/AM2315.pdf) but it repeats the assertion that it sends the sensor to sleep to avoid self-heating in the sensor, since that would introduce errors. How often are you polling the sensor for readings?
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 58797
Joined: Thu Feb 11, 2010 2:51 pm

Re: AM2315 + Teensy. Bad Data

by easternstargeek on Fri May 24, 2013 8:26 pm

This is the code- should look familiar!

Code: Select all | TOGGLE FULL SIZE
#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);
}


The Board is a Teensy 2.0

easternstargeek
 
Posts: 344
Joined: Mon Dec 13, 2010 1:39 pm
Location: Upper Eastern Tennessee

Re: AM2315 + Teensy. Bad Data

by paulstoffregen on Sun May 26, 2013 3:29 pm


paulstoffregen
 
Posts: 434
Joined: Sun Oct 11, 2009 11:23 am
Location: Portland, Oregon, USA

Re: AM2315 + Teensy. Bad Data

by adafruit_support_mike on Wed May 29, 2013 1:20 am

Since I have the luxury of asking the authority on the Teensy:

Paul, am I correct in thinking the Teensy's clock runs at 16MHz? A difference in the prescaler between the Teensy clock and the Arduino clock is the closest thing I can think of in terms of a hardware issue.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 58797
Joined: Thu Feb 11, 2010 2:51 pm

Re: AM2315 + Teensy. Bad Data

by paulstoffregen on Wed May 29, 2013 7:29 am

adafruit_support_mike wrote:Paul, am I correct in thinking the Teensy's clock runs at 16MHz?


On Teensy 2.0 (AVR), the default setting is 16 MHz.

On Teensy 3.0 (ARM), the default setting is 96 MHz. However, there are multiple clocks inside that ARM chip. Most of the peripherals run from the "bus clock", which is 48 MHz when the CPU is at either 96 or 48 MHz.

A difference in the prescaler between the Teensy clock and the Arduino clock is the closest thing I can think of in terms of a hardware issue.


The Teensyduino installer adds a "USB Speed" sub-menu into Arduino's Tools menu. You can use that menu to select other speeds. On AVR, when you select the slower speeds, the prescaler is used, and all the code adapts so the Arduino timing stuff still works properly.

But if you suspect a timing issue, best to make sure the Tools > CPU Speed menu is set to 16 MHz.

paulstoffregen
 
Posts: 434
Joined: Sun Oct 11, 2009 11:23 am
Location: Portland, Oregon, USA

Re: AM2315 + Teensy. Bad Data

by kallie469 on Wed May 29, 2013 8:48 am

Hi, Sorry a bit of a deviation....

Can you Run the AM2315 and two aditional DS18B20 Temp probes using the
Adafruit Pi T-Cobbler Breakout Kit for Raspberry Pi?

So sensing 3 temps and 1 humidity?
kallie469
 
Posts: 13
Joined: Wed May 29, 2013 8:44 am

Re: AM2315 + Teensy. Bad Data

by easternstargeek on Wed May 29, 2013 9:20 am

Kallie-

Chances are, your enquiry will not get noticed on this thread. Please consider starting a new one, and moving it enquiry there.
This will also benefit others that may have the same issue as you.
Good luck on your project!

easternstargeek
 
Posts: 344
Joined: Mon Dec 13, 2010 1:39 pm
Location: Upper Eastern Tennessee

Please be positive and constructive with your questions and comments.