155

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 ...


54

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 ...


26

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/...


24

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 ...


22

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 ...


14

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

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

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 ...


12

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)


12

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. ...


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

The best solution to this is probably to go for a 'port expander'. There is an expander kit available from HobbyTronics in the UK: http://www.hobbytronics.co.uk/mcp23017-port-expander-board For a general briefing on port expanders, here's a page on Wikipedia: http://en.wikipedia.org/wiki/Port_expander


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

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.


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 ...


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

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)


6

After following the advice from okertanov, I discovered that you can't actually use RPi.GPIO in a python CGI script as it requires root access. I worked around the problem by calling out to the gpio command line app which is included as part of WiringPi, this can be called from a non-root account. # Read the GPIO pin using the gpio application import ...


6

You may try to add before 'import RPi.GPIO': import sys sys.stderr = sys.stdout try: import RPi.GPIO as GPIO except Exception as e: print e It may help to diagnose an error. And add these lines before your html output: print "Content-Type: text/html" # HTML is following print # blank line, end of headers See ...


6

It is possible to expand up to 64 additional GPIO ports using some MCP23008 chips connected via I2C interface. Each adds 8 GPIOs and up to eight can be connected through I2C. As you need 75, I suppose you go with the big brother of MCP23008 the MCP23017 which has 16 GPIO ports. It's not possible to mix both and get over 128 as the limit of 8 on the I2C-Bus ...


6

Restart your Pi, and then use this code to clean up the GPIO pins when your program exits: GPIO.cleanup() The next time your program runs it should work.


6

The reason is contact bounce - any mechanical switch will have contact bounce. See the link for possible solutions https://raspberrypi.stackexchange.com/a/10338/8697 The code fragment you posted is very poor code. The Pi will devote most of its resources to a tight loop. You should explore interrupts or callbacks.


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