170

I got the information below from here. The GPIO.BOARD option specifies that you are referring to the pins by the number of the pin the the plug - i.e the numbers printed on the board (e.g. P1) and in the middle of the diagrams below. The GPIO.BCM option means that you are referring to the pins by the "Broadcom SOC channel" number, these are the numbers ...


56

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, intended for industrial application. You cannot use the words Raspberry Pi to promote your product without permission. Raspberry Pi is trademarked. You will have ...


28

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 Linux kernel is started and if device tree is enabled (likely) then it will reconfigure the GPIOs according to the device tree settings. Modules loaded from /etc/...


25

Not sure if this is helpful, but under the latest copy of Raspbian I was able to install RPi.GPIO directly from the main repositories using apt-get as follows: sudo apt-get update sudo apt-get -y install python-rpi.gpio If you're running Python 3 (idle3 on the command line) instead of Python 2 (python on the command line) you need to install the RPi.GPIO ...


25

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 ask is that you include the words “Powered by Raspberry Pi” somewhere on your packaging. If your business is successful, we’d be very grateful if you could ...


16

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 directory named "RPi". In that folder, put an empty text file named __init__.py. This lets python know the folder "RPi" is a package. Also in that folder put a ...


15

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 OEM. "Better" as in price, availability, quantity, security and specific functionality. Price - $30 dollar a pop might not be much for a couple of devices, ...


13

What you are looking for in that case is a LED matrix. You could control this matrix from the GPIO pins, but that still limits the amount of LEDs you can connect (the size of the matrix) and it might also start to draw too much current if you're not careful. A better option is to connect a LED matrix to the I2C bus, using one or multiple I2C I/O extenders. ...


13

You can't read an output. Just store the state of the pin in a variable. import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) LED = 17 ledState = False GPIO.setup(LED,GPIO.OUT) ledState = not ledState GPIO.output(LED, ledState)


13

Another option would be to use a port expander to get additional I/O ports. For example, the MCP23008 can connect via I²C (only uses two pins) and gives you eight I/O ports. Since it uses I²C, up to eight of them can be connected to the same two I²C pins to give you up to 64 I/O pins. Adafruit has a tutorial about how to use the MCP23008 (or MCP23016, the ...


13

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 its power leads to a 5V pin and a ground pin. It will be on all the time as you can't switch the 5V pins on or off. Do not try powering the fans from a gpio. ...


12

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 What is the power on state of the GPIOs? and GPIO state after boot.


11

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) # output rf # Initial state for LEDs: print("Testing RF out, Press CTRL+C to exit") try: print("set GIOP high") GPIO.output(6, GPIO.HIGH) time.sleep(...


11

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 be changed you can use an I2C multiplexor chip to typically connect 8 devices to the same I2C bus. You send a command to the multiplexor to specify the device ...


10

The short answer No, you (almost) don't. It's actually the other way around - you have to set them up not to be GPIO but to serve their special purpose. The only exception are UART pins. Also and I²C pins somehow special. UART pins UART pins are used by the kernel for the console. You will have to configure the system not to use them if you want them to ...


10

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 install RPi.GPIO for Python 3


10

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.


10

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, like Panasonic Viera Link. But it all uses the same standard just some TV's implement more, some less but the basics should be there. Like turn TV on or off, ...


10

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 one of them at any one time. So potentially there are 5 accessible UARTs at any one time. You can enable each of the UARTs on the Pi4B by making appropriate ...


9

Discovered the problem: Some guides online instruct you do download version 0.1.0 of the GPIO library which does not have the setup function. You must use a more recent version of the library. RPi.GPIO-0.1.0.tar.gz I have downloaded version 0.5.x and it works correctly. RPi.GPIO-0.5.3a.tar.gz Download from here https://pypi.python.org/pypi/RPi.GPIO ...


9

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 suspect the figures won't be that far off). The code used is available here in C and the author gives the following pseudocode equivalent: // Pseudocode for (;;) { ...


9

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 function which accepts a single mandatory parameter (with as many optional parameters as you like). If the function accepts a single mandatory parameter, the ...


8

The component you are looking for to read the level of light is a light dependent resistor. As you rightly stated in the question; the Raspberry Pi only has digital input. Therefore you can create an RC Charging Circuit. I advise reading this tutorial regarding RC charging circuits. This blog post explains in detail how you can check light level using an ...


8

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 GPIO.output(LED_red, GPIO.HIGH) #set Pin LED_red = HIGH (ON) GPIO.input(LED_red) returns 1


8

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 you think you will be typing gpio 7000 times. In my opinion the clarity of gpio is much more important than the 3 characters you are saving each time. As for ...


8

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 add the apache user (www-data normally) to the gpio group then the web server will be able to access the GPIOs without requiring root access. You can do that ...


8

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.


8

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 output and thus most likely damages the Pi, there is nothing wrong with using one GND pin on the GPIO header for multiple GPIO pins. As you notice there are ...


8

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) ## set output GPIO.setup(green, GPIO.OUT)


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