AM2315 supply voltage

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tom_hvacsp
 
Posts: 6
Joined: Mon Dec 02, 2013 9:52 pm

AM2315 supply voltage

Post by tom_hvacsp »

I'm setting up a wireless temperature and humidity device to push data to the cloud. For some unknown reason, I thought the AM2315 could handle voltages beyond the 3.5-5 mentioned on the product page. I'm connecting it to an Electric Imp with a 12VDC supply to April board. Can it operate at the 3.3 VDC provided by the April onboard voltage regulator or should I change my power supply to a max of 5VDC? I almost tried to power it with the 12VDC and I'm guessing I would have smoked it. Whew!

User avatar
tom_hvacsp
 
Posts: 6
Joined: Mon Dec 02, 2013 9:52 pm

Re: AM2315 supply voltage

Post by tom_hvacsp »

I ended up using a 5VDC power supply to the board and everything worked fine--for about 20 hours. Now it seems the Electric Imp is not able to read from the device any longer.

The code is based upon a posting at Electric Imp and as I said, it worked fine for quite some time. Here's the code:
function phex(s) {
local h = "";
for(local i=0;i<s.len();i++) h+=format("%02x", s);
return h;
}


//imp.configure("AM2315 Sensor", [], []);

local i2c = 0x5c<<1;

hardware.configure(I2C_89);
hardware.i2c89.configure(CLOCK_SPEED_100_KHZ);

function bigLoop() {
hardware.i2c89.write(i2c, "\x00"); // Needed to wake up the bus
hardware.i2c89.write(i2c, "\x03\x00\x04");

imp.sleep(0.15);

reply <- hardware.i2c89.read(i2c, "\x03", 6);
server.log("reply = "+reply);
if ( reply[0] == 0x03 && reply[1] == 0x04) {
local humidity = reply[2];
humidity *= 256;
humidity += reply[3];
humidity /= 10.0;

local temperature = reply[4];
temperature *= 256;
temperature += reply[5];
temperature /= 10.0;
temperature *= (9.0/5.0);
temperature += 32.0;
local gsArray = {};
gsArray.temp <- temperature;
gsArray.humidity <- humidity;
//server.log("gsArray.temp = "+gsArray.temp);
//server.log("gsArray.humidity = "+gsArray.humidity);
agent.send("sendToGS",gsArray);
//server.log(format("temperature=%.02f F, humidity=%.02f %%R.H.", temperature, humidity))
//server.show(format("%.02f F, %.02f %%R.H.", temperature, humidity))
}
else {
server.log("bad reply from i2c:" +phex(reply))
}
imp.wakeup(60, bigLoop); // sleep for 5 min.
}
bigLoop();

The errors I'm getting are:
2014-01-11 10:33:35 UTC-5: [Status] Device booting; 3.24% program storage used
2014-01-11 10:33:35 UTC-5: [Device] reply = (null : 0x0)
2014-01-11 10:33:35 UTC-5: [Device] ERROR: at bigLoop:23
2014-01-11 10:33:35 UTC-5: [Device] ERROR: the index '0' does not exist
2014-01-11 10:33:35 UTC-5: [Device] ERROR: from main:49

This makes me think the reply <- hardware.i2c89.read(i2c, "\x03", 6); statement is not getting any result from the read. Any thoughts on why this would top working?

Thanks!

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

Re: AM2315 supply voltage

Post by adafruit_support_mike »

As I read the errors, it looks like the problem has to do with this line:

Code: Select all

agent.send("sendToGS",gsArray);
Check to make sure the code is actually creating that array. You may have some kind of memory leak.

User avatar
tom_hvacsp
 
Posts: 6
Joined: Mon Dec 02, 2013 9:52 pm

Re: AM2315 supply voltage

Post by tom_hvacsp »

Well, that particular statement was fine. I took the device apart to check for loose connections and it started working, again. I've had it running now for 12 hours without a hitch. The wires were twisted quite a bit inside the device (not do to anything I did). I'm wondering if they might have been touching or ended up touching after I handled it a bit. In any case, it's once again working and I hope it's solid. I've had another in production for a couple of months. If it fails again, I may request a replacement.

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

Re: AM2315 supply voltage

Post by adafruit_support_mike »

There could have been a loose connection or some interference between the wires. Glad to hear it's working.

User avatar
tom_hvacsp
 
Posts: 6
Joined: Mon Dec 02, 2013 9:52 pm

Re: AM2315 supply voltage

Post by tom_hvacsp »

I found the Aosong AM2315 pdf (I believe from the Adafruit site, but it was a circuitous route). It appears the supply voltage is officially 3.5-5.5, so my 5.1 should not be an issue--whew! Although 5v is "recommended", I think that's simply to keep users away from 3.3 and well below the 5.5. I've had the device working now for 24 hours without a hitch. I believe the problem was due to twisted wires inside the device--possibly causing a short between two of the leads. I can't recreate the issue and simply hope the wiring was the root cause of the problem.

I am a bit confused as to why the official documentation indicates sensors all have the address 0xb8 whereas the code from the electric imp forum shows 0x5c<<1 (which results in the same value). Any thoughts on why this would be utilized? My only guess is that they're trying to indicate that the LSB is "0" for "write" and 1 for "read". But that's just a guess. I'll post there, too.

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

Re: AM2315 supply voltage

Post by adafruit_support_mike »

All I2C devices have a 7-bit address. When the bus master wants to talk to a device, it sends a 'control byte' which contains the address of the device it wants to talk to, plus a bit that says whether the master wants to read or write information. The target device's address lives in the seven most significant bits of the control byte, and the read/write bit is the least significant bit.

The upshot is that you multiply the device address by two, then add 1 if you want to issue a READ command.

Offically, the AM2315's address is 0x5c. The command bytes you actually send on the bus will be 0xb8 and 0xb9.

User avatar
tom_hvacsp
 
Posts: 6
Joined: Mon Dec 02, 2013 9:52 pm

Re: AM2315 supply voltage

Post by tom_hvacsp »

I need a replacement, please. The device appears to have had an internal wiring problem. On a couple of occasions, the device would not talk to the Electric Imp. I've opened the device twice, relaxed the wires (they came quite twisted) and it seemed to resolve the problem on two occasions. The device reported temperature and humidity fine for 12 hours and is now reporting humidity as either 1% or 99% (without any other changes). The temperature is still being reported accurately. How do I go about getting a replacement?

BTW, I have had another one of these in production for a few months without issue and I have already ordered a "spare" which appears I'll now have to use as a replacement as soon as it arrives. That being said, I do feel I should be entitled to a replacement for this device since it's been a problem from the start. Thanks!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: AM2315 supply voltage

Post by adafruit_support_bill »

If you contact [email protected] with a link to this thread we can send out a replacement for you.

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

Return to “Other Arduino products from Adafruit”