Can't get the EV3 touch sensor to work


#1

I am running the sample programs coming in /home/pi/Desktop directory of the Raspbian for Robots image, freshly downloaded and installed. I am using a Raspberry Pi 2 Model B and Python 2.7. Both the 8x battery pack and the USB power supply are connected.

Running EV3-Touch.py , the sensor is reading a value fluctuating between 980 and 1010 when the touch sensor is not pressed; when the sensor is pressed, I get the same in port 1 and 3, and values around 1022-1023 in port 2 and 4.

Running EV3-Touch_Debounce.py , with the sensor pressed I get mostly 1, and an occasional 0; with the sensor not pressed, I get something like

1
0
0
1
0
0
1
0
0
1
0
0
1
0
0
0
0

I am using the BrickPi for the first time, but I guess that is not the expected behavior.

Test programs that run motors and LEDs and read the battery voltage work fine.

Output of uname -a is

Linux dex 4.4.32-v7+ #924 SMP Tue Nov 15 18:11:28 GMT 2016 armv7l GNU/Linux

Note: I removed from this post the issue about ultrasound sensor, as it is resolved.

What can I try, or information I can collect for troubleshooting?

Thanks!


#2

It looks like your sensor is just tuned slightly different; the E3 touch sensor does an analog port read. You just need to modify this line:

if button_value > 1000:

To be where your analog sensor reading is coming back. It looks like 1021 value will work.


#3