New answers tagged

1

In one of your comments you said: if i use a simple on/off switch code it turn on and off Did your code include corresponding print statements when switching? Does the following work for you? import RPi.GPIO as GPIO import time GPIO_IN = 21 GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(GPIO_IN, GPIO.OUT) while True: print('relay off') ...


0

Ah, so have the relay always on problem, which is the Rpi relay newbies' constant (well, 12 years) sorrow. The very sad story began in the good old happy days, when we hobbyists played with only 5V Arduino and all logical levels are sort of 5V TTL, life was easy. It is only when 3V3 Raspberry Pi came along, and later also 3V3 Arduino (Pro Mini 328 3V3 8MHz),...


2

Most relay modules are active LOW and you need to set the pin HIGH to turn the relay off


2

I found an online simulator here, but you can't modify the hardware: https://create.withcode.uk/python/A3 https://fritzing.org/ has hardware and code, but I have not tried the coding yet. It costs about $9 but is worth it in my opinion. They also have the option to create and upload your schematics and will send you a PCB board (for a fee).


0

Using the following wiring diagram: https://gpiozero.readthedocs.io/en/stable/recipes.html?highlight=distance#distance-sensor With the code from https://github.com/makertut/raspberry-hc-sr04 : (NOTE: code requires TRIG and ECHO to be swapped to match circuit) import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) TRIG = 24 ECHO = 23 print "...


0

You appear to be asking us to debug some random tutorial you found on the internet which you may or may not have followed correctly. Try https://gpiozero.readthedocs.io/en/stable/recipes.html?highlight=distance#distance-sensor If this doesn't work you need to post details of your setup.


0

GPIO4 is the default pin for the 1-Wire interface. Make sure 1-Wire is disabled in Raspberry Pi Configuration, Interfaces.


0

You can buy these USB power switches for Rpi 1 to 3 and a USB-C type for Rpi4. I have one on each of my Pis. Around 3 to 5 UK pounds or equivalent. They often have an LED to show when power is on.


0

To avoid having to fiddle the USB plug out of the Pi each time you want to reboot it or switch it off, you can also unplug the power adapter. This is far less likely to cause any damage. Alternatively, buy an extension cord with a switch to power the Pi. I use one that shuts off all my lab equipment from mains at once.


1

You can reboot with a button connected to pin 5. See raspberrypi.stackexchange.com/a/19754/8697 You can also reboot most models by pulling the RUN pin LOW. The latest models with PMIC chips (basically Pi3 on) can be rebooted by pulling GLOBAL_EN low. See https://raspberrypi.stackexchange.com/a/100234/8697


1

That seems to be odd behaviour. Can't help with the spidev module. Perhaps use a different library. My pigpio, lgpio, and rgpio Python modules will work okay. pigpio (own SPI driver) import pigpio tx1 = [0xCA, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ...


4

When your custom user fails to play the audio, are you also logged to the system as the pi user? audio group is tricky, it allows users in that group to get exclusive access to audio HW, preventing other users from using it: Adding users to the audio group allows direct access to devices. Keep in mind, that this allows applications to exclusively reserve ...


2

Caveat: I know nothing about aplay or espeak. However, I can sometimes read & comprehend a man page. Simon's answer may be generally correct in that your "other-user" needs to be added to the group audio, but I don't believe you can add a user to a group with the command he's given: sudo useradd -G audio. To be completely fair, group and user ...


-1

You need to add your user into the 'audio' group to allow them access to audio devices and resources. sudo useradd -G audio <Your username>


Top 50 recent answers are included