About the address range

Currently I purchased a humidity and temperature sensor which is called AM2320 with I2C technology.
The problem is that the address of this slave is 0xB8 and I cannot use it though the built in I2C directly.
However, I found that the beaglebone black is only supporting address range from 0x03 to 0x77.
Am a understanding wrong or other things else?

Could anyone give suggestion on how to configure and use the IC AM2320?
Is that possible to build the bus by myself using other port?
I am new hand and hope someone can teach me.

I2C addresses are confusing, as they are really only 7-bit and the extra bit
is the Read/Write bit. So to read a value from a unit with address 7 you
use "address" 0x0e, to write it 0x0f.

So your AM2320 has an address of 0x5c which fits within the range 0-0x7f
which is the allowed range.

Having said that, quite where you get the idea the there is an additional
restriction I have no idea - I have never seen such a restriction - please
provide a reference.

I am also unsure where you get the idea that the AM2320 is an I2C device.
From all I can find in the datasheet although it is a single wire device, it is
not either 1-wire or I2C compatible. You will need to take the arduino code
which controls a GPIO line and convert it to use the BBB GPIO interface.
Remember also that the arduino code relies on being able to do precise
timing, and unless you are writing your own device driver or using the PRU
that is going to be difficult with linux which might go off and do some
housekeeping at an inopertune moment.

David

Hi,

I have some experience with the AM2302 / DHT22 and I can confirm that it uses a custom serial protocol. It is not i2c. It is a bit finicky in regards to timing and attempting to take measurements too fast will result in inaccuracies. I believe that Adafruit has a decent Arduino lib for this sensor. I’d imagine that porting the code would require some work. As David mentions, one thing that will most likely be an issue with the BBB is attempting to use this sensor with standard GPIO. As I mentioned the timing this device requires is pretty tight. I’d be very surprised if you could get it to work reliably without employing the PRU. It may just be easier to use something like an ATTiny (along with the Adafruit lib) in between the sensor and the BBB and dump the data using a UART. My two cents… FWIW.

Thanks,
Skip

http://item.taobao.com/item.htm?spm=a1z09.2.9.329.RgcLAh&id=40173284096&_u=djrk34rc500

The above link is the AM2320 that I purchased from taobao.com.
The manufacturer sent me the 8051 I2C library C source code for me and also datasheet. It is a real I2C device.
However, I 'm planned to use JAVA and no idea how to implement this…
Is that possible to use UART port on Beaglebone Black with 4.7kohm as pull up resistor and build a library by myself(like 8051)?

http://item.taobao.com/item.htm?spm=a1z09.2.9.329.RgcLAh&id=40173284096&_u=d
jrk34rc500

The above link is the AM2320 that I purchased from taobao.com.
The manufacturer sent me the 8051 I2C library C source code for me and also
datasheet. It is a real I2C device.

Well unless I2C means something different in Chinese every other source on the
net including respected people like AdaFruit say this is not what everyone
else means by I2C (and the BBB implements).

However, I 'm planned to use JAVA and no idea how to implement this...

If you look on the AdaFruit site you will find an Arduino library which works,
but which points out how messy the protocol (not I2C) is. You could port
that but as it is very timing dependant it is unlikely to work as a user space
app - you would need to write a device driver or PRU code. You can not use
Java in either environment.

Is that possible to use UART port on Beaglebone Black with 4.7kohm as pull
up resistor and build a library by myself(like 8051)?

No, UARTS and one wire solutions like this are totally different.

David

Thanks for your reply and suggestion.
In my experience, I tried to implement I2C in AT89S51 so is that possible to implement I2C in some pin in BBB and build a library by myself like in AT89S51?
The AM2320 I bought have SCL and SDA so it should not be serial in one wire.
I still have no any idea to control the device til now =.=
Anyway, thanks for your attention :slight_smile:

searching on the net I think I may have found what you are using. It is not
an AM2320, but rather an AM2321. This DOES have an I2C interface unlike
the AM2320.

On GitHub you will find a library for talking to the AM2321,but it is written
in C and using the wiring library so it is not directly usable on a BBB, but
it confirms the address you gave and shows the sequence of bytes you
need to send to get back the temperature and humidity. I suggest you
read up on Linux support of I2C. To access this from Java you will need
JNA (which is packaged for Debian), and you will find some useful tips
if you read:-

http://www.raspberrypi.org/forums/viewtopic.php?p=187073#p187073

Don't be put off by it being for the Raspberry Pi, Linux is Linux what
ever the hardware it is running on.

David

David Goodenough <david.goodenough@...> writes:

searching on the net I think I may have found what you are using. It is not
an AM2320, but rather an AM2321. This DOES have an I2C interface unlike
the AM2320.

According to sellers who offer AM2320 (e.g. on AliExoress), it supports
both, I2C and Aosong's proprietary single wire protocol. This claim is also
backed by this datasheet:
http://akizukidenshi.com/download/ds/aosong/AM2320.pdf .

The only difference between AM2320 and AM2321 seems to be the orientantion
of the pins (bottom side vs. back side).

But unfortunately the datasheet gives no information about changing the I2C
device address, which I would also be interested in, so that I can put
multiple sensors onto a single I2C bus.