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 ...
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 ...
How to distinguish multiple GPIO Buttons?
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 ...
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 ...
The above answer (goldilocks) is correct. I just wanted to add the steps without having to navigate to another site.
In the Pi terminal:
chmod +x adafruit-pitft.sh
Choose your correct screen size
Choose rotation (this can be ...
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 ...
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 ...
What you need is a button array.
Example you have two rows of buttons
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, ...
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 ...
I know you can do this with pigpio. I am not sure about the other Python modules.
pi = pigpio.pi()
if not pi.connected:
pi.write(SCL, 1) # automatically sets mode to WRITE
pi.write(SDA, 0) # automatically sets mode to WRITE
# read/write other GPIO
# read/write other GPIO
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 ...
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:-
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
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 ...
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.
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.
Connecting to ...
connected 5 V logic directly to Rx now it appears to have stopped
Could I configure another pin as Rx? Be that via a config file, or
setting, or kernel recompile?
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 ...
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 ...
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?
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 ...
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 ...
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 ...
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.
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 ...
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 ...