2022 Developer Survey is open! Take survey.
58 votes
Accepted

Can I use Raspberry Pi in commercial production?

You can embed the Raspberry Pi in any end-product you want. For mass production, the Compute Module may be a better choice. The Compute Module is a Raspberry Pi in a more flexible form factor, ...
user avatar
  • 66.3k
29 votes
Accepted

Why are some GPIO pins HIGH when the Raspberry Pi boots up?

At powerup the GPIOs are pulled either high or low through the internal resistors. Whether the pull is high or low for a particular GPIO is detailed on page 102 of BCM2835 ARM Peripherals. As the ...
user avatar
  • 66.3k
26 votes

Can I use Raspberry Pi in commercial production?

and I quote from Raspberry Pi's blog If, like Brian, you’re making a product which requires a Raspberry Pi to run, we don’t ask you to buy special permission or licences from us to use it. All we ...
user avatar
20 votes

gpio library on windows while developing

If you are just looking to test the whole code and not worry about the actual pins (as windows machines don't have GPIO), then you can fake it. First, in your main python source directory, create a ...
user avatar
  • 331
16 votes

Can I use Raspberry Pi in commercial production?

It depends how you define "mass" in "mass production". If you're talking hundreds, the Pi is probably a good choice. If you're talking thousands, there might be "better" solutions available through ...
user avatar
  • 1,651
15 votes
Accepted

GPIO: Warning Channel already in use

This code helped me get rid of the warning (the "finally" part at the end): import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme GPIO.setup(6, GPIO.OUT) # ...
user avatar
13 votes
Accepted

Plug a 5 V fan to GPIO 1 and 2

The diagram does not show pin numbers. Neither can I find anything on the diagram labelled 1. The diagram does appear to correctly label the ground and 5V pins. You can power a 5V fan by connecting ...
user avatar
  • 66.3k
13 votes

Can we use other GPIO pins as I2C

The whole point of I2C is it is a bus. You can therefore connect multiple I2C devices to the same GPIO provided they have different I2C device addresses. If the devices share an address which can't ...
user avatar
  • 66.3k
12 votes

Why are some GPIO pins HIGH when the Raspberry Pi boots up?

When the Raspberry Pi boots the GPIO lines are reset to the chip default, then the OS is loaded and resets them to the OS default. There is no way to "remember" the settings across a reboot. See also ...
user avatar
  • 906
11 votes

How to correctly install the python RPi.GPIO library

Assuming you have pip, the python package index installer, which is installed on the latest versions of Raspbian by default You can use: sudo pip install RPi.GPIO for Python 2 and sudo pip-3.2 ...
user avatar
11 votes
Accepted

How fast can GPIO pins toggle?

There are some benchmarks from Henner Zeller's repository on GitHub which claimed that directly outputting data to the GPIO could achieve up to 65.8 MHz on a Raspberry Pi 3 (not B+, mind, but I ...
user avatar
  • 6,158
11 votes

gpiozero Button.when_pressed

It is possible to use parameters with callback functions. See e.g. Documentation for button.when_pressed This can be set to a function which accepts no (mandatory) parameters, or a Python ...
user avatar
  • 3,302
10 votes
Accepted

What hardware do I need to turn Raspberry Pi into a TV remote controller?

I have tried this one, it connects into the USB port, can record and play back the IR codes, supported by LiRC. I have even tried to plug it into my Android phone and it works there as well.
user avatar
  • 11.4k
10 votes

What hardware do I need to turn Raspberry Pi into a TV remote controller?

As an alternative to Infrared, you could use HDMI, if your TV has HDMI 2.0, it will support some kind of CEC (Consumer Electronics Control) implemenatation Each TV brand calls this something else, ...
user avatar
  • 17.1k
10 votes
Accepted

Where are the uarts on the raspberry pi 4?

The preliminary Pi4 datasheet shows there are 6 UARTs. UART GPIO 0 14/15 1 14/15 2 0/1 3 4/5 4 8/9 5 12/13 Given that UART 0/1 are both connected to the same GPIO you can only use ...
user avatar
  • 66.3k
9 votes

Webserver & GPIO python script (No access to /dev/mem. Try running as root!)

You don't so much need root access as permission to access the gpio device. Raspbian has a user group 'gpio' to enable this. By default the 'pi' user is in the gpio group and can access GPIOs. If you ...
user avatar
  • 481
9 votes

Is there any built in LED connected with GPIO pin?

Yes, it is possible to control the built-in leds. Green LED is easier. According to here, though it is probably Pi 3 specific, since it didn't work for my Pi 4: In the terminal: sudo echo 1 > ...
user avatar
  • 1,574
8 votes

Toggling a GPIO pin set as output

Although stated elsewhere, you CAN read an output by just inputting the same GPIO pin and get the value returned you just set out before: GPIO.setup(LED_red, GPIO.OUT) #set Pin LED_red as aoutput ...
user avatar
8 votes

Importing RPi.GPIO

To answer your main question, no there is nothing syntactically wrong with writing: import RPi.GPIO as g g.setmode(GPIO.BCM) #etc... However, I would seriously evaluate what you are trying to do if ...
user avatar
8 votes
Accepted

Is there documentation for RPi.GPIO

The official documentation is http://sourceforge.net/p/raspberry-gpio-python/wiki/Examples/ It doesn't seem to have a traditional API style of documentation.
user avatar
  • 66.3k
8 votes
Accepted

Can you connect multiple GPIO pins, to one ground pin?

Setting aside the ill-phrased part of the question (connecting multiple GPIO pins (which to my knowledge are 3 volts), to one ground pin) - which indeed short circuits the GPIO pins if they are set to ...
user avatar
  • 15.5k
8 votes

I can't get three LED lights to turn off and on in an order

You need to set the pin as an output before you use it. To do that add the following line: GPIO.setup(red, GPIO.OUT) below the matching lines for green and yellow: GPIO.setup(yellow, GPIO.OUT) ...
user avatar
8 votes

Debouncing buttons with RPi.GPIO -- too many events detected?

As @joan points out, the bouncetime parameter in RPi.GPIO does almost exactly the wrong thing: it means when your switch bounces, you'll get the very first event, but that may not actually be ...
user avatar
  • 646
8 votes
Accepted

Error installing RPi.GPIO in virtual environment

It looks like the latest release does not support Python 3.9 but the alpha releases do: https://www.piwheels.org/project/RPi.GPIO/ You can install the alpha version with: pip install rpi-gpio --pre
user avatar
  • 2,361
7 votes

RPi.GPIO not found in virtual environment

The problem is that you don't have the GPIO module installed in your virtual environment. To correct this, run the following from within your virtual environment: for Python 2 pip install RPi.GPIO ...
user avatar
7 votes
Accepted

Is the gpio readall command compatible with RPi 4?

As far as I am aware it should work provided you download and install the latest version of wiringPi. http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/ cd /tmp wget https://...
user avatar
  • 66.3k
7 votes

Is there any built in LED connected with GPIO pin?

though it is probably Pi 3 specific, since it didn't work for my Pi 4 It works on the 4 as well, you just need to set the right trigger. The instructions that you provided are not applicable to the 4 ...
user avatar
7 votes

Install GPIO problem

You can't install RPi.GPIO on Windows. If you want to mock GPIO calls on a PC, try gpiozero which has a mock pin interface: https://gpiozero.readthedocs.io/en/stable/api_pins.html
user avatar
  • 2,361
6 votes

How to correctly install the python RPi.GPIO library

Another potential cause could be because the RPi.GPIO library has C bindings and therefore need to have python-dev installed in order to compile correctly when installing. Make sure you've got the ...
user avatar
  • 161
6 votes

how to turn on and off an led with only a tactile button

You can also use interrupts, which are quite useful in many other settings as well. This way, you can have your script do other things while you play with the button and the LED. import RPi.GPIO as ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible