AM2315 not responding

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
weathernick
 
Posts: 12
Joined: Wed Mar 12, 2014 7:52 pm

AM2315 not responding

Post by weathernick »

Just got my order of the Raspberry Pi, breadboard and the AM2315. I used http://sopwith.ismellsmoke.net/wp-conte ... AM2315.pdf as a guide to wire it up and everything looks good. Voltages are where they should be with using the 10k resistors but the i2cdetect -y 1 command (enter twice back to back) doesn't show the device. Is it possible my sensor is dead? I also read the datasheet http://www.adafruit.com/datasheets/AM2315.pdf

Advice?

Loving the Raspberry pi just need to get some sensors attached.

Thank,

Nickolas

User avatar
weathernick
 
Posts: 12
Joined: Wed Mar 12, 2014 7:52 pm

Re: AM2315 not responding

Post by weathernick »

Well I have tried the i2cdetect command a few times now and it seems to be responding. I will install the rest of the code from the instructions and see if I can get a value from her.

Thanks,

User avatar
weathernick
 
Posts: 12
Joined: Wed Mar 12, 2014 7:52 pm

Re: AM2315 not responding

Post by weathernick »

Got the rest of the code up...but now I can't even detect it any more. It seems to be randomly working. Should it be working this way?

Thanks,

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: AM2315 not responding

Post by adafruit_support_mike »

The AM3215 uses a nonstandard version of I2C.

It spends most of its time asleep because self-heating in the chip could cause errors in the humidity reading, so you have to poll it twice to get any information. The first connection attempt wakes it up, and as soon as it wakes up it takes a reading. It doesn't emit an ACK like a normal I2C device would do at that point though. The second command tells the AM2315 to send the data from its last reading, and needs to be sent before the device goes to sleep again. The window for timing is about two seconds.

That isn't hard to do if you're bit-banging the connection, but I2C libraries have a tendency to hide all the basic signal control behind startTransaction() and endTransaction() methods. Those work fine for stanard I2C devices, but cause problems when trying to work with the AM2315.

This PDF has a good description of one hacker's effort to get the thing working with a RasPi: http://sopwith.ismellsmoke.net/wp-conte ... AM2315.pdf

User avatar
weathernick
 
Posts: 12
Joined: Wed Mar 12, 2014 7:52 pm

Re: AM2315 not responding

Post by weathernick »

Yea I followed all those guides. The sensor showed up once after doing the double command trick... but never again. Since it doesn't show up on I2C no other commands will work. I don't know why it only responded a few times.. I didn't change my connections after I saw it come up but could never get it to show back up.

I just got done installing the BMP180 pressure sensor via I2C and while it doesn't do the whole sleep thing it does come up so I know my I2C slot is working...

Any other ideas? Some people have trouble with this sensor but the double command trick usually fixes it.

Thanks,

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: AM2315 not responding

Post by adafruit_support_mike »

Sounds like a timing thing.. what delay are you using between the two command bytes?

User avatar
weathernick
 
Posts: 12
Joined: Wed Mar 12, 2014 7:52 pm

Re: AM2315 not responding

Post by weathernick »

That is what I thought originally. So I varied issuing the I2cdetect commands. First I tried super fast.. one right after the other. then I varied it by a second... two seconds... etc. Any variation I did resulted in nothing. And even when I got it to detect the one time I couldn't duplicate it.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: AM2315 not responding

Post by adafruit_support_mike »

The datasheet specifies a 2-second window after the wakeup pulse, but a 1-second delay should have done it.

Let's try a new module: send a note to [email protected] with a link to this thread and the folks there will get you a replacement.

Sopwith
 
Posts: 14
Joined: Wed Mar 19, 2014 9:50 pm

Re: AM2315 not responding

Post by Sopwith »

Hello Weathernick,

It is highly unlikely your device is defective. 9 out of 10 times, the reason you cannot 'see' the device on the i2c bus is due to incorrect wiring. Also, be sure you run i2cdetect with the correct parameter depending on the Pi version you have.
sudo i2cdetect -y 0 (if you are using a version 1 Raspberry Pi)
sudo i2cdetect -y 1 (if you are using a version 2 Raspberry Pi)

I suggest you wire you wire up the sensor on a small breadboard for testing. The Adafruit Pi cobbler is very handy for this.
https://learn.adafruit.com/adafruit-pi-cobbler-kit

I used two 10k ohm resistors and wire up my AM2315 exactly the same way shown in my 'How-To' document in Figure-11 on page 10.
http://sopwith.ismellsmoke.net/wp-conte ... AM2315.pdf

After thoroughly checking your wiring, let me know if you are still having problems.

Sopwith

User avatar
weathernick
 
Posts: 12
Joined: Wed Mar 12, 2014 7:52 pm

Re: AM2315 not responding

Post by weathernick »

Thank you all for your help. I received the new sensor and it worked straight out of the gate. I am now able to view temperature and humidity using the instructions on Sopwith.

Must have been a bad sensor as it should have responded with the two back to back i2cdetect -y 1 commands (ver 2 RPi)

Now on to some coding.

You can see how the sensor will be used by visiting http://www.wxforum.net/index.php?topic= ... icseen#new

Thanks again for all your help.

Sopwith
 
Posts: 14
Joined: Wed Mar 19, 2014 9:50 pm

Re: AM2315 not responding

Post by Sopwith »

Weathernick,

Good to hear you are back in business. I posted a new Python class today that wraps the functions of the AM2315.
http://sopwith.ismellsmoke.net/?p=104

You may want to consider using it to get your sensor up and running quickly.

Sopwith

User avatar
weathernick
 
Posts: 12
Joined: Wed Mar 12, 2014 7:52 pm

Re: AM2315 not responding

Post by weathernick »

Nice more code!!! I see it is in Python 3, is that just how this sensor is going to roll? No support for Python2?

How does this code different from what you have in your original instructions?

Finally you say the device is accurate, do you have any data on how accurate?

Thanks again for your contribution as without your documentation the AM2315 would be dead in the water.

Sopwith
 
Posts: 14
Joined: Wed Mar 19, 2014 9:50 pm

Re: AM2315 not responding

Post by Sopwith »

"I see it is in Python 3, is that just how this sensor is going to roll? No support for Python2?"
-My Python class uses the quick2wire library that only runs in Python3

"How does this code different from what you have in your original instructions?"
-My "How-To" document uses the am2315-python-api written by Joehrg Ehrsam. The code is poorly formatted, not documented, and has a timing issue that returns -bogus data occasionally. So I wrote a new class that does not suffer from the timing issue.

"Finally you say the device is accurate, do you have any data on how accurate?"
- Anecdotal only by comparing to other sensors that I have.

If you really want to use my OASONG_AM2315 Python3 class with legacy code written in Python2.x, it can be done. I have written a tiny Python3 script that you can call from legacy 2.x code. It uses the subprocess module and returns the AM2315 sensor readings to your legacy code. This allows you to use the code you already have for your weather station relieving the pain of porting it to Python3 just to get the AM2315 sensor data.

Send me an email request to sopwith(atsign)ismellsmoke.net and I will send you the code.

Sopwith

User avatar
weathernick
 
Posts: 12
Joined: Wed Mar 12, 2014 7:52 pm

Re: AM2315 not responding

Post by weathernick »

Message sent.

I will be adding your code to my station. I haven't gotten to the recording stage of my project so I haven't seen the sporadic reading. Thanks for saving me and I am sure others time.

User avatar
Bennard
 
Posts: 2
Joined: Fri Jul 04, 2014 1:44 am

Re: AM2315 not responding

Post by Bennard »

Sopwith, thanks for sharing your code. Ive been using my AM2315 for a few months with your code and it works great. Thank you.

I have worked out a solution that does not use Python3. I'm currently reading the AM2315 with Python2.x. I'm not a coder, but I am good at brute force getting stuff to work for what I need. So I would love to share my code and have someone else clean it up and make it usable by everyone. Because I don't know any proper coding etiquette. Any takers?

b

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”