connect IR sensor to BBB

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jaleb
 
Posts: 27
Joined: Thu Jan 21, 2016 5:18 pm

connect IR sensor to BBB

Post by jaleb »

I've bought an IR sensor like this http://goo.gl/o3JCtN
My problem is to connect it to BBB.
This sensor has 3 wires:
white: power (5-30V)
brown: ground
yellow: V_out (0-3V)
BBB ha 1.8V analog in so I cannot read directly it and I need to measure temperature until to about 700 °C.
So I've two possibilties 1) using a volt converter circuit 2) using something to convert signal in digital.
What do you suggest me to control this sensor?

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

Re: connect IR sensor to BBB

Post by adafruit_support_mike »

You can't convert the signal digitally until you get it into the BBB, and connecting 3v to the ADC will kill it.

Use a 1k-1k voltage divider to drop the 0v-3v output to 0v-1.5v

User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: connect IR sensor to BBB

Post by drewfustini »

Check out the voltage divider info in this tutorial:
Measuring Light with a BeagleBone Black
beaglebone_voltage_divider.png
beaglebone_voltage_divider.png (104.41 KiB) Viewed 607 times

User avatar
jaleb
 
Posts: 27
Joined: Thu Jan 21, 2016 5:18 pm

Re: connect IR sensor to BBB

Post by jaleb »

drewfustini wrote:Check out the voltage divider info in this tutorial:
Measuring Light with a BeagleBone Black
beaglebone_voltage_divider.png
Ok! Thanks. I've done something similar as in the image.
Image
From the moment that I enter with 5V and I've to enter in BBB with <1.8V, my calculation gives R1=634 and R2=324.
Could be correct in this way?
Anyway I cannot read ADC values in pyhton. After import Adafruit_BBIO.ADC as ADC, I get error launching ADC.setup().
My kernel i 4.1.16-bone18. Could be it the problem?

User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: connect IR sensor to BBB

Post by drewfustini »

Could you please paste the error?

Please paste the output off these commands, too:

Code: Select all

# check what capes are loaded
cat sys/devices/bone_capemgr.*/slots

# check the version of Adafruit_BBIO installed
sudo cat /usr/lib*/python*/site-packages/Adafruit_BBIO*.egg-info/PKG-INFO |head

# print current pin mux states
sudo cat /sys/kernel/debug/pinctrl/*pinmux/pins

# check what Debian image is running
cat /etc/dogtag

# check which kernel is running
uname -a

# check which version of Debian
lsb_release -a
You could also try the latest recommended Wheezy image from beagleboard.org:
Debian 7.9 ( 4GB SD) 2015-11-12

User avatar
jaleb
 
Posts: 27
Joined: Thu Jan 21, 2016 5:18 pm

Re: connect IR sensor to BBB

Post by jaleb »

drewfustini wrote:Could you please paste the error?

Please paste the output off these commands, too:

Code: Select all

# check what capes are loaded
cat sys/devices/bone_capemgr.*/slots

# check the version of Adafruit_BBIO installed
sudo cat /usr/lib*/python*/site-packages/Adafruit_BBIO*.egg-info/PKG-INFO |head

# print current pin mux states
sudo cat /sys/kernel/debug/pinctrl/*pinmux/pins

# check what Debian image is running
cat /etc/dogtag

# check which kernel is running
uname -a

# check which version of Debian
lsb_release -a
You could also try the latest recommended Wheezy image from beagleboard.org:
Debian 7.9 ( 4GB SD) 2015-11-12
Nothing .
No such file or directory for almost all that commands.
Anyway:
BeagleBoard.org Debian Image 2015-12-07
Linux beaglebone 4.1.16-bone18 #1 Sun Jan 24 10:53:24 UTC 2016 armv7l GNU/Linux
Then I tried this http://beagleboard.narkive.com/GEDC8qik ... -1-3-ti-r6
and this https://github.com/adafruit/adafruit-be ... /issues/80.
And it worked yesterday! it has been hard.
I could have been able to read analog input...but this morning the analog input are all "0".
I hope not to have damaged analog input. I've used R1=634 and R2=324 (5%), considering VDD input at 5.32V.
My code to convert the temperature:

import Adafruit_BBIO.ADC as ADC
import time

sensor_pin = 'P9_40'

ADC.setup()

while True:
reading = ADC.read(sensor_pin)
millivolts = (reading/4096) * 1800 # 1.8V reference = 1800 mV
temp_c = (millivolts-500)/10
temp_f = (temp_c * 9/5) + 32
print('%d') %(reading)
print('mv=%d C=%d F=%d' % (millivolts, temp_c, temp_f))
time.sleep(1)

User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: connect IR sensor to BBB

Post by drewfustini »

ok, since you are running 4.1 kernel, then please run this command:

sudo cat /sys/devices/platform/bone_capemgr/slots

Also this command:
sudo cat /sys/kernel/debug/pinctrl/*pinmux/pins

User avatar
jaleb
 
Posts: 27
Joined: Thu Jan 21, 2016 5:18 pm

Re: connect IR sensor to BBB

Post by jaleb »

drewfustini wrote:ok, since you are running 4.1 kernel, then please run this command:

sudo cat /sys/devices/platform/bone_capemgr/slots

Also this command:
sudo cat /sys/kernel/debug/pinctrl/*pinmux/pins
Now it seems working.
For all users of 4.1.xxx with this problem, I suggest this post:
http://beagleboard.narkive.com/GEDC8qik ... -1-3-ti-r6
Here is:

0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
5: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-ADC
6: P-O-L- 1 Override Board Name,00A0,Override Manuf,BB-SPIDEV1
7: P-O-L- 2 Override Board Name,00A0,Override Manuf,BB-SPIDEV0

registered pins: 142
pin 0 (44e10800.0) 00000031 pinctrl-single
pin 1 (44e10804.0) 00000031 pinctrl-single
pin 2 (44e10808.0) 00000031 pinctrl-single
pin 3 (44e1080c.0) 00000031 pinctrl-single
pin 4 (44e10810.0) 00000031 pinctrl-single
pin 5 (44e10814.0) 00000031 pinctrl-single
pin 6 (44e10818.0) 00000031 pinctrl-single
pin 7 (44e1081c.0) 00000031 pinctrl-single
pin 8 (44e10820.0) 00000027 pinctrl-single
pin 9 (44e10824.0) 00000027 pinctrl-single
pin 10 (44e10828.0) 00000027 pinctrl-single
pin 11 (44e1082c.0) 00000027 pinctrl-single
pin 12 (44e10830.0) 00000027 pinctrl-single
pin 13 (44e10834.0) 00000027 pinctrl-single
pin 14 (44e10838.0) 00000027 pinctrl-single
pin 15 (44e1083c.0) 00000027 pinctrl-single
pin 16 (44e10840.0) 00000027 pinctrl-single
pin 17 (44e10844.0) 00000027 pinctrl-single
pin 18 (44e10848.0) 00000027 pinctrl-single
pin 19 (44e1084c.0) 00000027 pinctrl-single
pin 20 (44e10850.0) 00000027 pinctrl-single
pin 21 (44e10854.0) 00000007 pinctrl-single
pin 22 (44e10858.0) 00000017 pinctrl-single
pin 23 (44e1085c.0) 00000007 pinctrl-single
pin 24 (44e10860.0) 00000017 pinctrl-single
pin 25 (44e10864.0) 00000027 pinctrl-single
pin 26 (44e10868.0) 00000027 pinctrl-single
pin 27 (44e1086c.0) 00000027 pinctrl-single
pin 28 (44e10870.0) 00000037 pinctrl-single
pin 29 (44e10874.0) 00000037 pinctrl-single
pin 30 (44e10878.0) 00000037 pinctrl-single
pin 31 (44e1087c.0) 00000037 pinctrl-single
pin 32 (44e10880.0) 00000032 pinctrl-single
pin 33 (44e10884.0) 00000032 pinctrl-single
pin 34 (44e10888.0) 00000037 pinctrl-single
pin 35 (44e1088c.0) 00000027 pinctrl-single
pin 36 (44e10890.0) 00000037 pinctrl-single
pin 37 (44e10894.0) 00000037 pinctrl-single
pin 38 (44e10898.0) 00000037 pinctrl-single
pin 39 (44e1089c.0) 00000037 pinctrl-single
pin 40 (44e108a0.0) 0000002f pinctrl-single
pin 41 (44e108a4.0) 0000002f pinctrl-single
pin 42 (44e108a8.0) 0000002f pinctrl-single
pin 43 (44e108ac.0) 0000002f pinctrl-single
pin 44 (44e108b0.0) 0000002f pinctrl-single
pin 45 (44e108b4.0) 0000002f pinctrl-single
pin 46 (44e108b8.0) 0000002f pinctrl-single
pin 47 (44e108bc.0) 0000002f pinctrl-single
pin 48 (44e108c0.0) 0000002f pinctrl-single
pin 49 (44e108c4.0) 0000002f pinctrl-single
pin 50 (44e108c8.0) 0000002f pinctrl-single
pin 51 (44e108cc.0) 0000002f pinctrl-single
pin 52 (44e108d0.0) 0000002f pinctrl-single
pin 53 (44e108d4.0) 0000002f pinctrl-single
pin 54 (44e108d8.0) 0000002f pinctrl-single
pin 55 (44e108dc.0) 0000002f pinctrl-single
pin 56 (44e108e0.0) 00000027 pinctrl-single
pin 57 (44e108e4.0) 00000027 pinctrl-single
pin 58 (44e108e8.0) 00000027 pinctrl-single
pin 59 (44e108ec.0) 00000027 pinctrl-single
pin 60 (44e108f0.0) 00000030 pinctrl-single
pin 61 (44e108f4.0) 00000030 pinctrl-single
pin 62 (44e108f8.0) 00000030 pinctrl-single
pin 63 (44e108fc.0) 00000030 pinctrl-single
pin 64 (44e10900.0) 00000030 pinctrl-single
pin 65 (44e10904.0) 00000030 pinctrl-single
pin 66 (44e10908.0) 00000028 pinctrl-single
pin 67 (44e1090c.0) 00000028 pinctrl-single
pin 68 (44e10910.0) 00000030 pinctrl-single
pin 69 (44e10914.0) 00000000 pinctrl-single
pin 70 (44e10918.0) 00000030 pinctrl-single
pin 71 (44e1091c.0) 00000000 pinctrl-single
pin 72 (44e10920.0) 00000000 pinctrl-single
pin 73 (44e10924.0) 00000000 pinctrl-single
pin 74 (44e10928.0) 00000000 pinctrl-single
pin 75 (44e1092c.0) 00000030 pinctrl-single
pin 76 (44e10930.0) 00000030 pinctrl-single
pin 77 (44e10934.0) 00000030 pinctrl-single
pin 78 (44e10938.0) 00000030 pinctrl-single
pin 79 (44e1093c.0) 00000030 pinctrl-single
pin 80 (44e10940.0) 00000030 pinctrl-single
pin 81 (44e10944.0) 00000027 pinctrl-single
pin 82 (44e10948.0) 00000030 pinctrl-single
pin 83 (44e1094c.0) 00000010 pinctrl-single
pin 84 (44e10950.0) 00000037 pinctrl-single
pin 85 (44e10954.0) 00000037 pinctrl-single
pin 86 (44e10958.0) 00000037 pinctrl-single
pin 87 (44e1095c.0) 00000037 pinctrl-single
pin 88 (44e10960.0) 0000002f pinctrl-single
pin 89 (44e10964.0) 00000027 pinctrl-single
pin 90 (44e10968.0) 00000037 pinctrl-single
pin 91 (44e1096c.0) 00000037 pinctrl-single
pin 92 (44e10970.0) 00000030 pinctrl-single
pin 93 (44e10974.0) 00000000 pinctrl-single
pin 94 (44e10978.0) 00000033 pinctrl-single
pin 95 (44e1097c.0) 00000033 pinctrl-single
pin 96 (44e10980.0) 00000037 pinctrl-single
pin 97 (44e10984.0) 00000037 pinctrl-single
pin 98 (44e10988.0) 00000030 pinctrl-single
pin 99 (44e1098c.0) 00000030 pinctrl-single
pin 100 (44e10990.0) 00000033 pinctrl-single
pin 101 (44e10994.0) 00000033 pinctrl-single
pin 102 (44e10998.0) 00000013 pinctrl-single
pin 103 (44e1099c.0) 00000013 pinctrl-single
pin 104 (44e109a0.0) 00000024 pinctrl-single
pin 105 (44e109a4.0) 00000027 pinctrl-single
pin 106 (44e109a8.0) 00000027 pinctrl-single
pin 107 (44e109ac.0) 00000027 pinctrl-single
pin 108 (44e109b0.0) 00000023 pinctrl-single
pin 109 (44e109b4.0) 00000003 pinctrl-single
pin 110 (44e109b8.0) 00000030 pinctrl-single
pin 111 (44e109bc.0) 00000028 pinctrl-single
pin 112 (44e109c0.0) 00000030 pinctrl-single
pin 113 (44e109c4.0) 00000028 pinctrl-single
pin 114 (44e109c8.0) 00000028 pinctrl-single
pin 115 (44e109cc.0) 00000028 pinctrl-single
pin 116 (44e109d0.0) 00000030 pinctrl-single
pin 117 (44e109d4.0) 00000030 pinctrl-single
pin 118 (44e109d8.0) 00000030 pinctrl-single
pin 119 (44e109dc.0) 00000030 pinctrl-single
pin 120 (44e109e0.0) 00000020 pinctrl-single
pin 121 (44e109e4.0) 00000030 pinctrl-single
pin 122 (44e109e8.0) 00000030 pinctrl-single
pin 123 (44e109ec.0) 00000028 pinctrl-single
pin 124 (44e109f0.0) 00000028 pinctrl-single
pin 125 (44e109f4.0) 00000028 pinctrl-single
pin 126 (44e109f8.0) 00000030 pinctrl-single
pin 127 (44e109fc.0) 00000028 pinctrl-single
pin 128 (44e10a00.0) 00000028 pinctrl-single
pin 129 (44e10a04.0) 00000020 pinctrl-single
pin 130 (44e10a08.0) 00000028 pinctrl-single
pin 131 (44e10a0c.0) 00000028 pinctrl-single
pin 132 (44e10a10.0) 00000028 pinctrl-single
pin 133 (44e10a14.0) 00000028 pinctrl-single
pin 134 (44e10a18.0) 00000028 pinctrl-single
pin 135 (44e10a1c.0) 00000020 pinctrl-single
pin 136 (44e10a20.0) 00000028 pinctrl-single
pin 137 (44e10a24.0) 00000028 pinctrl-single
pin 138 (44e10a28.0) 00000028 pinctrl-single
pin 139 (44e10a2c.0) 00000028 pinctrl-single
pin 140 (44e10a30.0) 00000028 pinctrl-single
pin 141 (44e10a34.0) 00000020 pinctrl-single

User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: connect IR sensor to BBB

Post by drewfustini »

An update on using the ADC in Python with Adafruit_BBIO:
It seems that Adafruit_BBIO does not work correctly with newer Linux kernel such as 4.1.x. This is because the pathname for the the capemgr in /sys has changed. My work in progress is in a GitHub Gist. I will create a pull request on github once I have created a fix.

Workaround: Revert to Linux kernel 3.8 by installing the most recent 3.8 kernel:

sudo apt-get update
sudo apt-get install linux-image-3.8.13-bone79


Now change which kernel will boot:

sudo vi /boot/uEnv.txt


Comment out the 4.1 line and add 3.8 line:

#uname_r=4.1.15-ti-r40
uname_r=3.8.13-bone79


Finally reboot:

sudo reboot

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

Return to “Beagle Bone & Adafruit Beagle Bone products”