Jump to content

How do I connect an ADS1115 to OPI Lite?


pastito

Recommended Posts

 

Hi,

I am having doubts on how to use I2C ADS1115 unit on Orange Pi Lite. I already have I2C module and tools installed (see below).

Thing is, where do I get the Phyton library to make use of it? Are there any examples?

 

The other question is about wiring.

 

When I connect to twi0 I cannot see the I2C device:

 

root@orangepilite:~# i2cdetect -y twi0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

 

But when I connect to twi1 a 48 appears (I believe that is the device address)


root@orangepilite:~# i2cdetect -y twi1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  

 

How do you read that? As i2cget returns 0x00

 

root@orangepilite:~# i2cget -y twi1 0x48
0x00

 

 

Thanks and

Regards

 

Link to comment
Share on other sites

You won't be able to communicate using i2cget, this chip  has several register that need to be initialized in order to get analog conversion done.

Googling reveal to me that maybe this library could help you : https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/ads1015-slash-ads1115

This tutorial could help too : http://www.piettes.com/solar-panel-datalogging-with-raspberry-pi-and-ads1115/

 

Link to comment
Share on other sites

It works nicely, thank you!

Here is a hygrometer connected to port 2

root@orangepilite:~/Adafruit_Python_ADS1x15/examples# ./test.py 
Reading ADS1x15 values, press Ctrl-C to quit...
|      0 |      1 |      2 |      3 |
-------------------------------------
|   5460 |   4780 |  25822 |  25822 |
|   5716 |   4770 |  25823 |   6356 |

 

Now I wonder why I can only use I2C bus 1 (twi1 --GPIO pins PA19 and PA18--) and not 0 (twi0 --PA11 and PA12--)

I also tested this on Raspberry Pi 3 rev B and works nicely too.

 

Thanks and regards

Link to comment
Share on other sites

The fact that you get a "UU" when attached on TWI0 mean that it is detected by a kernel driver, most probably ads1015.ko.

You can check that while been connected on TWI0 if this driver is loaded by looking at "lsmod".

If Yes, then you can't talk directly to the chip, you need to talk to the driver, most probably from /sys/class/hwmon/hwmon0/device.

This is a bit explained here : http://www.jumpnowtek.com/rpi/Using-ads1115-ADCs-with-Raspberry-Pis.html

 

Link to comment
Share on other sites

Thank you for the information. Now I was trying to set that up, but I cannot seem to find /boot/config.txt in Armbian

there is only /boot/armbianEnv.txt

 

I added the following lines:

 

dtparam=i2c_arm=on
dtoverlay=ads1115
dtparam=cha_enable
dtparam=chb_enable
dtparam=chc_enable
dtparam=chd_enable
dtparam=cha_enable,cha_cfg=0A

 

Then I compiled with

mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
 

And rebooted, but still no luck. It does not work.

 

I see the following error in dmesg

 

[   82.263791] sunxi_i2c_do_xfer()985 - [i2c0] incomplete xfer (status: 0x20, dev addr: 0x76)
[   82.264134] sunxi_i2c_do_xfer()985 - [i2c0] incomplete xfer (status: 0x20, dev addr: 0x77)

 

 

Any ideas?

 

Thanks!

Link to comment
Share on other sites

Of course, the link I've provided was just for generic reference, because it is specific to RaspberryPi, not for Armbian.

You will need first to create an overlay from scratch and place it in /boot/dtb/overlay, then add its name into armbianEnv.txt.

Here some hints, but still not cooked solution, about this overlay :

https://www.kernel.org/doc/Documentation/devicetree/bindings/hwmon/ads1015.txt

https://github.com/modmaker/BeBoPr/wiki/Better-Analog-Inputs

https://dev.seemoo.tu-darmstadt.de/bcm/bcm-rpi3/blob/041eec392e9a2e63d94d5b53059718425703f8f7/kernel/arch/arm/boot/dts/overlays/ads1015-overlay.dts

 

 

Link to comment
Share on other sites

Thank you guys for your answers! I am a very seasoned linux sysadmin (been working on it since 1995).

It does not seem to be worth the effort to create an overlay to make the bus work since twi1 is working.

I will investigate overlays though... when I have a few spare cycles.

 

So far I was able to port everything that I had running on the raspberry pi into the orange pi with Armbian.

That is a DS18B0 digital thermometer, a 4 channel optically coupled relay board, an LDR with a 1uF to check

light levels and the ADS1115 with 4 hygrometers. Everything is working great.

Plus I was able to install apache / PHP / rrdtool and it is generating beautiful graphics on a ramdisk and sync'in the

data once a day (in order not to burn the flash quickly).

 

My experience has been very pleasant thanks to you. I was afraid of buying the orange pi as everybody on the

internet is talking that it has poor support and that it is hard to do some things on it. Well in my experience

y only took a few hours to make it work and it is a great value.

 

I will probably buy a few more powerful ones to create other projects... my gardening setup is almost ready

for deployment! I am waiting for the solenoid water valves and need to write some watering code based on 

humidity statistics!

 

 

Thanks and regards

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines