Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

6

Disadvantages using /dev/mem for accessing the I²C hardware of the Raspberry Pi directly: It's not portable to other hardware platforms. It's not portable to additional USB I²C adapters. It's not portable to additional bitbanged I²C. You limit yourself to one-application at a time which may use the I²C, while the kernel serializes requests on /dev/i2c-nnn ...


4

In addition to @Janka's answer, more disadvantages: No useful interrupt or DMA processing with /dev/mem Whatever utility has the permission to interact with /dev/mem, can pretty much have complete control over the system. /dev/i2c would allow access only to I2C bus. Advantage of /dev/mem is that it can be used for very quick proof of concept, or as help ...


3

You can use a break-out board like the Black HAT Hacker or Pico HAT Hacker. Alternatively, connect another Pi Zero as a USB gadget and use the GPIO expander.


3

Question How to distinguish multiple GPIO Buttons? Answer Well, for a small number of buttons, say 8, you can use 8 GPIO pins, each of which entertains one button. But that is a big waste of GPIO pins. For more than 8 buttons, you can use GPIO extenders such as MCP23017, each of which adds 16 more GPIO pins, and greedy you can "easily" (see warning ...


3

While it is possible to connect multiple buttons to the Pi's GPIO and read them in a python loop the second that second "schematic" will not work. Note that ABCDE and FGHIJ columns are connected for each numbered row. Placing the buttons as shown will make it impossible to distinguish between the two buttons on each line. In this particular case one would ...


2

The above answer (goldilocks) is correct. I just wanted to add the steps without having to navigate to another site. In the Pi terminal: wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/adafruit-pitft.sh chmod +x adafruit-pitft.sh sudo ./adafruit-pitft.sh Choose your correct screen size Choose rotation (this can be ...


2

Make sure you have a common ground between the Pi, the LEDs and the power supply so that referenced voltages are consistent.


2

I have been using raspi-config always found it working. Sometimes my modules are not working. So I usually use two little test programs to check. One program is to repeatedly send out bytes and use a scope to make sure the waveform looks OK. The other test program is a loop back test. I connect MOSI to MISO, send a byte and read back. You might like ...


2

SPI is working. The needed modules are loaded (spidev, spi_bcm2835) and the needed devices are present (dev/spidev0.0 /dev/spidev0.1).


2

There are alternative usable pins on the compute module. There are no alternative hardware pins on the other Pis. I have bit banged serial using my pigpio library. Anything under 19k2 baud appears rock solid. Anything faster and you would need error checking. Bit banging the input side is trivial. sudo pigpiod # start the pigpio daemon pigs slro 23 ...


2

What you need is a button array. Example you have two rows of buttons a A b B c C d D e E a and A are connected to the same input GPOP b and B are connected to the same input GPIO and so on But they way you tell which button is being pressed is to Power all the capital buttons, check the inputs. Remove power from Capital buttons, power the lower case row, ...


2

To determine what your program is doing, you need to save the output of the program to a file. Use this type of call to start the program /path/to/script >> /path/to/log/file 2>&1 & This will start the program in the background, and send all output (both stdout and stderr) to a file of your choice. Keep in mind that if the script is long ...


1

I know you can do this with pigpio. I am not sure about the other Python modules. SDA=2 SCL=3 pi = pigpio.pi() if not pi.connected: exit() pi.write(SCL, 1) # automatically sets mode to WRITE pi.write(SDA, 0) # automatically sets mode to WRITE # read/write other GPIO pi.write(SCL, 0) pi.write(SDA, 1) # read/write other GPIO pi.set_mode(SDA, pigpio....


1

Question Usage of that python class will not work with my setup of one motor. I agree and I want to instead use the GPIO library to control the board controlling the motor. Example code I found: import RPi.GPIO as GPIO I do not know how to edit the code to work with my project.] but I am using IN1 on the controller board and GPIO2 from ...


1

I suggest you return to using gpiozero, but select a suitable class. We don't know anything about your robot (include detail in your question). I guess it has a single motor with forward/reverse so the following would be appropriate:- https://gpiozero.readthedocs.io/en/v1.2.0/api_output.html#motor


1

Question GPIO.setup(18,GPIO.OUT) # to Power the Sensor with 3.3 Volt Tried the 3.3 Volt Pin instead of Pin 18 and it did not help Answer I found that the Xinda water level detector uses the very common NPN BJT SS8050. Usually the a BJT is biased for a fixed voltage, say, 5V for Arduino. If you supply power Vcc = 3V3, then the BJT might not work ...


1

At least one of the comments on the linked product says they only work with 5V so you may well be correct. I suggest you power them from 5V and drop the output to a Pi safe 3V3 by using a resistor divider at the receiving GPIO.


1

If the relay pins are a simple contact closure (which seems likely, but no one can confirm - although it is easy to verify with a multimeter) then you can use any button code. See https://www.raspberrypi.org/blog/gpio-zero-a-friendly-python-api-for-physical-computing/ Specifically https://gpiozero.readthedocs.io/en/stable/recipes.html#button Connecting to ...


1

Question connected 5 V logic directly to Rx now it appears to have stopped functioning. Could I configure another pin as Rx? Be that via a config file, or setting, or kernel recompile? Answer You can use USB UART/TTL cables. Then you can have as many UARTs as you have USB/TTL cables. I have read others experimenting with software serial. But ...


1

After more testing I found out that there was still active code trying to access GPIO23. As GPIO23 is in use by the kernel, the declaration btn23 = Button(pin=23, pull_up=True) fails with RuntimeError: Failed to add edge detection, which apparently was silently caught in a try/except block. When an exception is thrown while declaring a Button, the cleanup ...


1

Question I have a 5V latch relay, and I have tested it manually, by hand and found everything OK. How to use one Rpi GPIO pin to do automatic (say python software) control? Answer No problem. Let us first begin with the latch relay features/operation/functional user guide/specification as display below. Now I have drawn a schematic showing 4 ...


1

Short answer: "Yes, there is a way to achieve this." That said, your question omits some details that are needed for a complete answer. But we'll start from what we know, or can reasonably assume, and go from there. One caveat: Your Raspberry Pi may be ruined if one of us makes a mistake: either I make a mistake in my instructions, or you make a mistake in ...


1

We have a Ribbon Cable here. Which according to Wikipedia could be color-coded to reduce the risk of reversed connections: To make it easier to identify individual conductors in a cable; ribbon-cable manufacturers introduced rainbow ribbon cable, which uses a repeating pattern of colors borrowed from the standard resistor color code (Brown is pin 1 or pin ...


1

gpio mode 18 out will not do anything, because there is no Wiring Pi pin 18 gpio -g mode 18 out or gpio mode 1 outwill work


1

The most likely explanation is your testing is faulty because the relay module is not suitable for the Pi (it may need more than a 3V3 GPIO to switch). To test the GPIO try (my) GPIO test or wiringPi's pintest. Nothing should be connected to the GPIO during either test.


1

My 2 cents: Similar to the Arduino (8 bit AVR based uC) recommendation I would look at the far more capable STM32 series from ST microelectronics. There are at least two good Arduino API ports here and here, Great support forum Inexpensive: ~$2 for the cheapest breakout boards - "Bluepill" and a reusable ST Link V2 clone programmer Plethora of ...


1

You can't use 5 V relay with signal from Raspberry Pi while Raspberry Pi signal is 3.3 V. So if you used Logic level converter to convert 3.3 V from Raspberry to 5 V then to relay in I think it may solve this issue. I don't know why most distributors say it should work with raspberry pi while the ideal one for Raspberry Pi is 3.3 ...


1

Seeed Studio has Grove Base Hat for Raspberry Pi which provides GPIO connectors.


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