ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Trouble accessing Raspberry pi 2 GPIO with python

asked 2016-03-18 02:22:58 -0500

nishthapa gravatar image

I have a scenario in which i have to take readings from a DHT11 Temperatute & Humidity sensor and publish it to a topic (I am using python so suggestions keeping python in mind would be helpful). The problem is that i need to do sudo to assess the GPIO but again rosrun is not found when in sudo. What should i do ?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2016-03-18 02:42:02 -0500

gvdhoorn gravatar image

Please try to use the search next time (or Google: $searchterms site:answers.ros.org fi), this has been asked (and answered) many times before. See Raspberry Pi 2, ROS and GPIO access for a recent one.

edit flag offensive delete link more

Comments

But that case uses the WiringPI Library for C++. I am trying to do this with Python.

nishthapa gravatar image nishthapa  ( 2016-03-18 02:48:22 -0500 )edit

The question I linked as an example. There are many more, and also dealing with Python.

gvdhoorn gravatar image gvdhoorn  ( 2016-03-18 03:05:31 -0500 )edit
gvdhoorn gravatar image gvdhoorn  ( 2016-03-18 03:07:08 -0500 )edit

Wiringpi2 says its deprecated and wiringpi still requires sudo. What should i do ?

nishthapa gravatar image nishthapa  ( 2016-03-21 01:15:04 -0500 )edit

From _wiringpi2/README.txt:

This package has been deprecated in favour of using the name "WiringPi" which provides the same exact functionality.

It's just a name change.

gvdhoorn gravatar image gvdhoorn  ( 2016-03-21 02:33:16 -0500 )edit
0

answered 2016-03-18 02:51:16 -0500

MarkyMark2012 gravatar image

I would suggest updating your raspberry Pi distro (Jessie) https://www.raspberrypi.org/blog/raspbian-jessie-is-here/. The latest version does not require SUDO access to control the GPIO ports

Mark

Quote

"Python users used to have to launch Python with sudo in order to allow access to the GPIO lines – Python can now access GPIOs as a standard user."

edit flag offensive delete link more

Comments

I am using Latest Raspbian Jessie. But still sudo is required it seems.

nishthapa gravatar image nishthapa  ( 2016-03-18 02:54:01 -0500 )edit

Shouldn't do - what happens if you just run a basic python script to control the IO without ROS?

MarkyMark2012 gravatar image MarkyMark2012  ( 2016-03-18 03:46:23 -0500 )edit

Sudo is still required even in a basic script.

nishthapa gravatar image nishthapa  ( 2016-03-21 03:28:08 -0500 )edit

Drop your basic script here and I'll have a look later see if I can replicate

MarkyMark2012 gravatar image MarkyMark2012  ( 2016-03-21 04:43:47 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-18 02:22:58 -0500

Seen: 597 times

Last updated: Mar 18 '16