kscheff / BlueBasic

BASIC interpreter for CC2540 and CC2541 Bluetooth LE chips
11 stars 9 forks source link

Can't read from i2c sensors #7

Closed 0xFACE closed 5 years ago

0xFACE commented 6 years ago

I'm trying to use I2C READ function to read from several i2c sensors (ie BMP180 barometric pressure sensor). But no luck so far.

The Wiki states following syntax for I2C reading: I2C READ <address>, <variable>[, ...]

As far as I know address value is the CHIP-ADDRESS. But how to pass DATA-REGISTER-ADDRESS value ?

Do I have to use this sequence: I2C WRITE 0XD0, 0X00, READ D taken from reading the DS3231 example.

Please explain.

kscheff commented 6 years ago

Yes, you have to use the the method to first write the chip address and sub register address before reading data. In this way BlueBasic issues a Restart. I don’t have actually tried this myself, it’s a good practice to use a scope to see how the bits are generated and if the BMP180 acknowledges the device address and data writes (sub address).

Am 14.01.2018 um 13:36 schrieb Piotr notifications@github.com:

I'm trying to use I2C READ function to read from several i2c sensors (ie BMP180 barometric pressure sensor). But no luck so far.

The Wiki states following syntax for I2C reading: I2C READ

, [, ...]

As far as I know address value is the CHIP-ADDRESS. But how to pass DATA-REGISTER-ADDRESS value ?

Do I have to use this sequence: I2C WRITE 0XD0, 0X00, READ D taken from reading the DS3231 example.

Please explain.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

kscheff commented 5 years ago

Since there is no further feedback I close the issue here.