instruction stringclasses 1
value | input stringlengths 81 29.2k | output stringlengths 30 23.3k |
|---|---|---|
Answer the following technical question about Raspberry Pi. | Title: How do I build a GCC 4.7 toolchain for cross-compiling?
Body: I already asked this question on Stack Overflow, but I would like to know if anyone managed to build a GCC 4.7 toolchain for ARM cross-compilation (for a x86/x86-64 Linux host). There are many instructions for building GCC from source and many available cross-compilers for pre-4.7 GCC versions, just not the latest one. Compiling on Rasp Pi itself works fine, but it's just a bit too slow for practical purposes. I am eager to get compiling and I would like to use the latest and the best tools. | I found these instructions How to build a cross compiler for your Raspberry Pi . It is a great walk through using a crosstool-ng tool which simplifies configuring a cross-compiler build A LOT (it has a nice curses-based interface) and it supports GCC 4.7. I've followed these steps and ended up with a successful build of a 4.7 cross-compiler. Prerequisites: The following packages are required: bison , flex , gperf , gawk , libtool , automake , g++ , ensure these are installed before proceeding. First download crosstool-ng from here (I used version 1.15.2). Unpack the distribution and do a ./configure / make / install Create a fresh directory somewhere in the file-system to build in and cd into it. Run ct-ng menuconfig . You will be presented with a nice set of menus to configure your build. Go into Paths and misc options. Enable Try features marked as EXPERIMENTAL. Choose a suitable Prefix directory . This is the directory that your compiler and libraries will get installed in (anything is fine basicallly, just make sure that the directory is empty). NOTE: It is also important that you have write access to the chosen folder Go to the Target options menu. Target architecture: arm Endianness: little endian Bitness: 32-bit You may also want to set floating point parameter to softfp (see this for more info), but hardfp is more appropriate for Raspbian. Go to Operating system menu and change Target OS to linux . Go to C compiler menu and choose gcc version 4.7.0 (the article recommends Linaro, but I managed to get it working with vanilla gcc). Also chose additional languages you want to be able to compile (C++, Fortran, ...) Go to C-library menu and chose one. The default is eglibc but that one didn't build fine for me, so I used glibc (the newest version). NOTE: during the build step 13. eglibc can fail to build if subversion is not installed, as the source can't be retrieved from the repository NOTE: eglibc is no longer a part of crosstool-ng as of version 1.21.0 due to its lack of development. See So long to eglibc . Use glibc as default. Exit the configuration tool while saving your changes. Run ct-ng build in the same directory. Wait a while (about 45 minutes in my case) and your cross compiler should be ready. Seems to work great! |
Answer the following technical question about Raspberry Pi. | Title: Running 1080p video from within XOrg smoothly
Body: The 1080p examples that work outside of X.Org run very smoothly on my Pi, but within X.Org they don't run very smoothly at all at the moment. Given that X.Org is currently not GPU-accelerated, this is understandable - but with the hardware limitations will running such video smoothly in X.Org ever be possible, or is this unlikely even if X.Org was running on the GPU? | You just need a video player that decodes the video using the GPU. The suggested (and currently the only known) player for the RPi that does this is OMXPlayer . |
Answer the following technical question about Raspberry Pi. | Title: connection failed in apt-get upgrade
Body: I am using Raspberry Pi 3 Model B, and installed raspbian-buster on it. sudo apt-get update works well. But sudo apt-get upgrade shows connection failed. Err:29 http://archive.raspberrypi.org/debian buster/main armhf arandr all 0.1.9-2+rpt4 Connection failed [IP: 93.93.128.230 80] Err:1 http://mirrors.ocf.berkeley.edu/raspbian/raspbian buster/main armhf cron armhf 3.0pl1-134 Connection failed [IP: 169.229.226.30 80] Err:30 http://archive.raspberrypi.org/debian buster/main armhf libraspberrypi-doc armhf 1.20190620+1-1 Connection failed [IP: 93.93.130.39 80] Err:2 http://mirrors.ocf.berkeley.edu/raspbian/raspbian buster/main armhf libk5crpyto3 armhf 1.17-3 Connection failed [IP: 169.229.226.30 80] Err:31 http://archive.raspberrypi.org/debian buster/main armhf libraspberrypi-dev armhf 1.20190620+1-1 Connection failed [IP: 93.93.130.104 80] .......... When I pinged to that IP addresses, there was no packet loss. I tried sudo apt-get clean , but the same problem still occurs. | As Milliways said, it seems because of the problem in the major release. After I downgrade to Stretch, the 'connection failed' problem does not occur. |
Answer the following technical question about Raspberry Pi. | Title: Bluetooth discoverable mode is automatically turned OFF
Body: I want to set up the Bluetooth on boot so I can connect to it whenever I want with a device which is not trusted by the Raspberry Pi Bluetooth. I set up the Bluetooth on boot on my Raspberry Pi this way. In /etc/rc.local, I added : sudo bluetoothctl <<EOF
power on
discoverable on
pairable on
EOF
sudo hciconfig hci0 sspmode 0
sudo bt-agent -c NoInputNoOutput -p /root/bluetooth.cfg & I use a Bluetooth configuration file to secure the Bluetooth connection, more information here The problem is, after some time (~3 minutes), the discoverable mode is automatically turned OFF and I cannot connect to Another problem is, after a device connect/disconnect, the discoverable mode is also turned OFF. Is this possible to keep the discoverable mode ON every time and even if some Bluetooth devices connect/disconnect to the Raspberry ? Edit: I'm using the Raspberry Pi Model B V1.2 | I continued my research and found an answer that works for me. There is a DiscoverableTimeout on /etc/bluetooth/main.conf which is, by default, set to 300s. I just add DiscoverableTimeout = 0 on this configuration files. |
Answer the following technical question about Raspberry Pi. | Title: How to start installing Raspbian using serial console?
Body: After finding out that I could redirect serial console output , I purchased a USB to Serial TTL PL2303HX (Prolific chipset) from eBay. Next step was to connect the serial adapter to the Pi. I have downloaded RPI Installer from http://www.raspbian.org/RaspbianInstaller , and copied the files onto my FAT formatted SDCard. I have tried connecting via Putty but I get a blank terminal screen. Question : What other steps do I need? | In the files extracted from the RPI Installer, I had to edit cmdline.txt and change this line: console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 to: console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=ttyAMA0,115200 After making that change, I could boot up my Pi and the console was showing in the putty session, allowing me to install Raspian. NOTE : To connect from windows: open device manager and find the COM port for the prolific USB-to-Serial Comm Port (e.g. COM14). open putty select serial as the Connection Type enter the comm port from windows device manager (e.g. COM14) in the Serial Line field set Speed to 115200. If you see a blank screen in Putty, press enter and you should see the setup screen. |
Answer the following technical question about Raspberry Pi. | Title: What sort of throughput is achievabe over the USB 3.0 port on the Pi-4?
Body: Looking to run a router application on the rPi-4, and was wondering if anyone has experience using usb 3.0 -> gigabit ethernet adapters on it - specifically what adapter/chipset worked with what driver, and also what speed was achieved, (would be particularly useful if it also tested the onboard Ethernet as a comparison simultaneously). P.S. - Yes, I know it has an ethernet port already, I need a 2nd one Also I expect significantly faster from previous models due to the 3.0 ports and that they aren't shared with the on-board ethernet anymore | I have a Pi 4 Model B/4GB serving a small office as a router/firewall/gateway with dnsmasq (DHCP+DNS), dnscrypt-proxy, chrony (NTP), and a few other odds and ends. It's fairly busy: up to 20 users at a time, lots of file uploads, three main VLANs (plus a management VLAN). There's minimal internal routing for the time being. I haven't really stress-tested it yet but it's handling all those service and a 500/35-rated connection without breaking a sweat. Speed test is like 590/40. I was worried about 802.1q performance but it hasn't seemed to be an issue. I'm using sch_fq_codel (no shaper) for now; trying to get sch_cake up and running before I take the training wheels off and start throwing tons of stuff at it. If you're planning to use the second ethernet connection as a WAN port, the problem you're going to run into is that USB NICs have no support for Byte Queue Limits (BQL) in the Linux kernel, and it doesn't appear likely to be added any time soon. This is going to severely hamper performance, and it renders sch_fq_codel, sch_cake, etc. nearly useless. The built-in NIC is attached directly to the SoC—as you've noted—and it uses the bcmgenet driver, which has BQL. To work around this, I'm actually passing the WAN connection through a managed switch (UniFi) and VLAN-tagging it before sending it to the Pi. This could be a security nightmare but I think I've got it fairly well isolated between a combination of switch settings and firewall rules. As far as performance goes, the easiest way to think about it is that Internet uploads and downloads have to share capacity on both the transmit and receive sides of the gigabit link, so I have a budget of roughly 300 Mbps on either side for the aforementioned services and other internal traffic. It's running Ubuntu Server arm64 (unofficial installer) with root on a USB 3.0 SATA SSD. For less than $100 all-in—including storage—it's far exceeded my expectations, and it should be fine until it makes sense to upgrade to something more substantial. It probably wasn't worth the cost savings on hardware once my time is factored in, but it's been a fun project! |
Answer the following technical question about Raspberry Pi. | Title: Does the PoE hat fit in the Raspberry Pi case?
Body: Does the Raspberry PoE hat fit inside the Raspberry Pi 3 Case ? And it might be too soon. But would the same PoE hat, on top of a Raspberry Pi 4 , inside a Raspberry Pi 4 Case also fit? And by "fit" I mean will the cover go on top of it as it naturally would. | I use it with standard RPi cases above on the 3+, the lid will fit but it gets hot in the office so the fan runs all the time, so I run it with the lid off as it is our main DNS box and I want it close to the centre of the network. The machines in the basement have the lid on them and run ok. Whilst the board has an extra layer on it, that layer doesn't extend past the USB sockets etc so the overall height is not larger. I have a 4 running sans case but new case should arrive tomorrow but I don't expect it to be different as the changes in the case are for the new side connectors. |
Answer the following technical question about Raspberry Pi. | Title: Led on before declaring it
Body: Hello I need some help with my leds, I have 2 leds one green and one red. What I want to do is just turn on the green led (and turn off the red) when I press a push button, that is to say all the time that I'm waiting, the red led will be on and the green off and when I push the button they will change their value. import cv2
import os
import time
import dlib
import RPi.GPIO as GPIO
# Raspberry settings
GPIO.setmode(GPIO.BCM)
btn, red_led, green_led, slider_on = 20, 26, 21, 19
GPIO.setup(slider_on, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(btn, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(red_led, GPIO.OUT)
GPIO.setup(green_led, GPIO.OUT)
# Main function
def main():
# Inicialize variables
cap = cv2.VideoCapture(0)
try:
while (True):
slider_true = GPIO.input(slider_on)
if slider_true == 1:
# Configure leds.
GPIO.output(green_led, GPIO.HIGH)
GPIO.output(red_led, GPIO.LOW)
# Wait until the button is pressed.
btn_press = not GPIO.input(btn)
if btn_press == True:
print('Btn pressed')
break
else:
GPIO.output(red_led, GPIO.HIGH)
GPIO.output(green_led, GPIO.LOW)
cv2.destroyAllWindows()
finally:
# To ending we clean GPIOS, close the windows and release resources.
GPIO.cleanup()
# Execute the main function
if __name__ == '__main__':
main() The problem is that, every time I run the program a few seconds the green led is on and the red is off and these seconds the green led turn off and the red turn on as it should be from the beginning. Why happens this? Thank you very much. | I guess the reason why you observe this behaviour in the first seconds is that you don't initialize the output state of the led pins. So, those gpios are in a default state (usually it's LOW, but it might be different for specific pins and depend on other configurations).
It will take a while until cap is initialized and that's the delay you see at the beginning of your program.
If I'm right, you just have to initialize the led pins to whatever state you want at the beginning. |
Answer the following technical question about Raspberry Pi. | Title: Creating an image file from an SD card
Body: I have a Raspberry Pi distribution on a bootable 32 GB SD card. What I would like to do, is the following: Shrink the partition to 4 GB (that's the size of the data on the card). Create an .img file from that SD card, so I can use it to create other bootable SD cards Any ideas? A newbie here. | There are some possibilities to shrink a partition but you may consider to create a complete new image file and copy your old installation to it. This way you are free to configure your new image as you like. You can modify the size of all partitions so just make the root partition 4 GB before copying. If you have made the image file you can just flash it to SD Cards as usual. Look at How to make an image file from scratch . |
Answer the following technical question about Raspberry Pi. | Title: Disable autologin on tty1 on stretch 9.9
Body: I found this answere but it doesnt work anymore. How does it work on the new version? | The autologin.conf file for tty1 must be deleted: sudo rm /etc/systemd/System/getty@tty1.service.d/autologin.conf . |
Answer the following technical question about Raspberry Pi. | Title: Raspbmc does not seem to do anything
Body: I have installed raspbmc and it seems to work. It has an IP address, I can ssh into it and ping the outside word from there, it updates the OS when it starts up, I can see the screen on the TV. I am hoping to use it to view sites like netflix and filmon. The problem is that I get a message telling me that the PVR manager has been enabled without any enabled PVR add-on. I have tried enabling several from the list in add-ons but then all I get is a message "clientname pvr client failed to connect to clientname backend. When I go to the home screen and select Live TV >TV channels nothing happens apart from a message that "no pvr clients have been started yet" There is something obvious and fundamental that I have missed :( | I was right, I did miss something fundamental :( It seems that very early in my RPi experience I ticked the box in the settings labelled "Live TV" as the main reason I want xbmc is to watch live UK TV via iPlayer or Filmon. This gave me an option of Live TV in the main menu. So that is where I went when I wanted to watch live TV and nothing happened. It is not very intuitive but what I must do is go to the main menu and select Videos then add-ons and click what I want (the right add-ons must already be installed). |
Answer the following technical question about Raspberry Pi. | Title: What Revision(s) does cat /proc/cpuinfo return on the new Pi 4 1/2/4GB?
Body: To enhance my bash script decoding the Revision returned by cat /proc/cpuinfo I'd like to know what the RaspBerry Pi 4 codes for ModelName,Processor and Memory are. (my own one is still underway) Sample sanitized output: LotPings@LegoBlack:~ $ ./pirevision.sh
Serial = 00000000a3123456
MAC-address(es) = b8:27:eb:12:34:56 b8:27:eb:ab:cd:ef
Revision = a020d3
PCBRevision = 3
ModelName = 3B+
Processor = BCM2837
Manufacturer = Sony UK
MemorySize = 1024 MB
EncodedFlag = revision is a bit field
WarrantyVoidOld = no
WarrantyVoidNew = no EDIT: The documentation was updated in the meantime, so the script should output official information now. #!/bin/bash
## resources:
## https://github.com/AndrewFromMelbourne/raspberry_pi_revision
## http://elinux.org/RPi_HardwareHistory#Board_Revision_History
## https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
## https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/revision-codes/README.md
Revision=$(cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}')
Serial=$(cat /proc/cpuinfo|grep 'Serial'|awk '{print $3}')
MACs=$(ifconfig | grep '[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:'|awk '{print $2}')
echo 'Serial = ' $Serial
echo 'MAC-address(es) = ' $MACs
echo 'Revision = ' $Revision
Encoded=$((0x$Revision >> 23 & 1))
if [ $Encoded = 1 ]; then
PCBRevision=('0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15')
ModelName=('A' 'B' 'A+' 'B+' 'Pi2B' 'Alpha' 'CM1' 'unknown' '3B' 'Zero' 'CM3' 'unknown' 'Zero W' '3B+' '3A+' 'internal use only' 'CM3+' '4B' '18 ?' '19 ?' '20 ?')
Processor=('BCM2835' 'BCM2836' 'BCM2837' 'BCM2711' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15')
Manufacturer=('Sony UK' 'Egoman' 'Embest' 'Sony Japan' 'Embest' 'Stadium' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15')
MemorySize=('256 MB' '512 MB' '1024 MB' '2048 MB' '4096 MB' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15')
EncodedFlag=('' 'revision is a bit field')
WarrantyVoidOld=('no' 'warranty void - Pre Pi2')
WarrantyVoidNew=('no' 'warranty void - Post Pi2')
echo 'PCBRevision = ' ${PCBRevision[$((0x$Revision&0xf))]}
echo 'ModelName = ' ${ModelName[$((0x$Revision>>4&0xff))]}
echo 'Processor = ' ${Processor[$((0x$Revision>>12&0xf))]}
echo 'Manufacturer = ' ${Manufacturer[$((0x$Revision>>16&0xf))]}
echo 'MemorySize = ' ${MemorySize[$((0x$Revision>>20&7))]}
echo 'EncodedFlag = ' ${EncodedFlag[$((0x$Revision>>23&1))]}
echo 'WarrantyVoidOld = ' ${WarrantyVoidOld[$((0x$Revision>>24&1))]}
echo 'WarrantyVoidNew = ' ${WarrantyVoidNew[$((0x$Revision>>25&1))]}
fi Current Revision bit field explanation # Bit NOs 3322 2222 2222 1111 1111 1100 0000 0000
# Decimal 1098 7654 3210 9876 5432 1098 7654 3210
# Fields uuuu uuHG FMMM CCCC PPPP TTTT TTTT RRRR
# WarrantyVoidNew/| |Mem Manu Proc ModelName PCB
# WarrantyVoidOld/ |Siz fact Rev
# EncodedFlag
#
# bits contains values
# R 00-03 PCBRevision ('0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15')
# T 04-11 ModelName ('A' 'B' 'A+' 'B+' 'Pi2B' 'Alpha' 'CM1' 'unknown' 'Pi3B' 'Zero' 'CM3' 'unknown' 'Zero W' 'Pi3B+' 'Pi3A+' 'internal use only' 'CM3+' '4B')
# P 12-15 Processor ('BCM2835' 'BCM2836' 'BCM2837' 'BCM2711)
# C 16-19 Manufacturer ('Sony UK' 'Egoman' 'Embest' 'Sony Japan' 'Embest' 'Stadium')
# M 20-22 MemorySize ('256 MB' '512 MB' '1024 MB' '2048 MB' '4096 MB')
# F 23-23 EncodedFlag ('' 'revision is a bit field')
# G 24-24 WarrantyVoidOld ('' 'warranty void - Pre Pi2')
# H 25-25 WarrantyVoidNew ('' 'warranty void - Post Pi2')
# u 26-31 unused | My 1GB PI4B returns revision a03111. $ cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 108.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 1
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 108.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 2
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 108.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 3
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 108.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
Hardware : BCM2835
Revision : a03111
Serial : 1000000060e0fce7
$ Your script returns the following on my Pi4B. Serial = 1000000060e0fce7
MAC-address(es) = dc:a6:32:03:fd:dc dc:a6:32:03:fd:dd
Revision = a03111
PCBRevision = 1
ModelName = 17 ?Pi4
Processor = 3 ?BCM2711
Manufacturer = Sony UK
MemorySize = 1024 MB
EncodedFlag = revision is a bit field
WarrantyVoidOld = no
WarrantyVoidNew = no |
Answer the following technical question about Raspberry Pi. | Title: CE1 not going low for pigpio.spi_open() with flags
Body: I'm attempting to modify joan's test script ( https://raspberrypi.stackexchange.com/a/44320/42126 ) for an RPi SPI master to communicate with an Atmega328P slave. I cannot change which GPIO pins I have configured due to hardware constraints in my project. I need to use CE1(BCM7) and auxiliary SPI (BCM[19:21]) My test script is below: pi = pigpio.pi()
channel = 1 # use CE1
flags = 0b100000000; # use auxiliary SPI
h = pi.spi_open(channel, baud)
#h = pi.spi_open(channel, baud, flags)
n = 0
while True:
n += 1
pi.spi_xfer(h, "Message {}\n".format(n))
time.sleep(1)
pi.spi_close(h)
pi.stop() I'm using an analog discovery unit as a logic analyzer, connected as follows: DIO0 CE1 (BCM7(
DIO1 SCK0 (BCM11)
DIO2 MOSI0 (BCM10)
DIO3 MISO0 (BCM9)
DIO4 SCK1 (BCM21)
DIO5 MOSI1 (BCM20)
DIO6 MISO1 (BCM19)
DIO7 CE2 (BCM16) If I use the flag to select auxiliary spi, I get clock and data, but SS doesn't go low. If I don't use a flag and monitor primary SPI with CE1, I get a good connection If I use channel 2 (the one normally associated with auxilary spi), I get data as well as CS2 low (MISO is not connected to the slave for this sample) It appears that channel 1 is not being brought low, but the documentation ( http://abyz.me.uk/rpi/pigpio/python.html#spi_open ) allows using channel 1 with auxiliary SPI. I don't see any flags that would conflict with this configuration ...
am I doing something wrong or is this a bug? | This seem to be a misunderstanding. The usage of GPIO by the main and auxiliary SPI devices is as follows. MISO MOSI SCLK CE0 CE1 CE2
Main SPI 9 10 11 8 7 -
Aux SPI 19 20 21 18 17 16 If you want to use the auxiliary SPI with a non-standard chip select you will have to toggle the GPIO yourself. This is straightforward. Set the selected GPIO low before each transfer and set it high afterwards. E.g. pi.write(7, 0)
(count, rx_data) = pi.spi_xfer(h, [1, 128, 0])
pi.write(7, 1) |
Answer the following technical question about Raspberry Pi. | Title: Raspberry Pi can't print to wireless printer
Body: I can print to my wireless printer from my laptop just fine, but I'm having trouble getting it to work from my Raspberry Pi. I found some instructions that said to install cups-client, then edit the cups client.conf file. However, after installing cups-client I didn't have the etc/cups directory. I tried also installing cups and found that the directory was created after that, but I still did not have the .conf file. I found an example file in /usr/share/doc/libcups2/examples and copied it to the cups directory. I then added ServerName [IP of my printer]:631 and tried printing again, but it still didn't work. I tried using lpr but nothing prints, and in LibreOffice the only printer listed is Generic Printer. lpstat doesn't output anything, and when I run lpstat -t I get scheduler is running
no system default destination
lpstat: -1 not supported!
lpstat: -1 not supported!
lpstat: -1 not supported!
lpstat: -1 not supported! Similarly, most other lpstat options give the not supported error. Does anyone know what I'm doing wrong here? | I don't have any experience with wireless printing via CUPS, but in the past I've had to setup a driver to get CUPS working over USB. This page might help: https://www.openprinting.org/drivers . I'd also test connecting it via USB first. Apologies if I couldn't be of more help. Hoping someone with a bit more experience comes along... |
Answer the following technical question about Raspberry Pi. | Title: Terminal-Only Capable Voip
Body: I am trying to run mumble on my headless pi. Unfortunately, mumble wants an x server to run. Is there any way to get a client to run through only terminal? I cannot seem to find anything quick and simple. Teamspeak apparently refuses to write a version for the pi. I have found asterisk and elastix, but both are enormous, and i think asterisk is a full OS. If not, are there other simple/small voip client/server programs that work on the pi in bash? My final goal is to have my pi as both the server and a client that can talk to other people. | linphone is quite small (~25MiB with gtk dependencies IIRC); Try apt-get install linphone-nogtk |
Answer the following technical question about Raspberry Pi. | Title: "Proper" way to (permanently) mount USB hard drive?
Body: What is the proper/best way to have a USB hard drive permanently mounted? I have done this using fstab using disk label as the identifier, but when I disconnected the drive and tried to boot the pi, it wouldn't boot (dropped to a root shell somewhere along the way) - I'd prefer it to boot even if the drive isn't connected. There are a couple of services (plex, squeezebox) that use the drive for their storage, which might complicate things more that just delaying the mounting till after booting has finished. And what would be the typical/standard location to mount such drives to? | using /etc/fstab is the proper way of doing this. if you do not want your system to depend on the drive on startup in case the usb drive is missing you have to set the relevant parameter / options from man fstab nofail do not report errors for this device if it does not
exist. so your fstab should have an entry like this: UUID=631 /mountpoint/ ext4 rw,auto,nofail 0 2 while only nofail should be the important option to you. |
Answer the following technical question about Raspberry Pi. | Title: What happens to the GPIO voltage after shutdown?
Body: I don't have a Raspberry Pi laying around at the moment and I would like to detect if my Raspberry Pi is shuted down. My Idea is that maybe after the Pi shutted down the Voltage at the 3V3 pin will drop and I can detect this. And if this still works when the Pi is getting powered via the 5V Pin.
Unfortunatly the Raspberry Pi Schematic is not completly available so I am not able to check this right now. | The Pi has 3 "components" the CPU, GPIO and Video Core which are relatively independent.
Even when the Pi is shutdown the Video Core continues to run, and the GPIO pins retain their state; only the CPU is not running. The 3.3V is supplied by separate circuitry and will be present while ever the Pi is connected to a 5V supply. The best way to reliably detect Pi shutdown is to use the gpio-poweroff service built into recent firmware which "Drives a GPIO high or low on poweroff" - this was included to control power circuitry. NOTE read the instructions carefully as there is some interaction with other services. You MUST remove power if this is used. Name: gpio-poweroff Info: Drives a GPIO high or low on poweroff (including halt). Using this
overlay interferes with the normal power-down sequence, preventing the
kernel from resetting the SoC (a necessary step in a normal power-off
or reboot). This also disables the ability to trigger a boot by driving
GPIO3 low. The GPIO starts in an inactive state. At poweroff time it is driven
active for 100ms, then inactive for 100ms, then active again. It is
safe to remove the power at any point after the initial activation of
the GPIO.
Users of this overlay are required to provide an external mechanism to
switch off the power supply when signalled - failure to do so results
in a kernel BUG, increased power consumption and undefined behaviour. Usage: dtoverlay=gpio-poweroff,<param>=<val> Params: gpiopin GPIO for signalling (default 26) active_low Set if the power control device requires a
high->low transition to trigger a power-down.
Note that this will require the support of a
custom dt-blob.bin to prevent a power-down
during the boot process, and that a reboot
will also cause the pin to go low.
input Set if the gpio pin should be configured as
an input.
export Set to export the configured pin to sysfs
active_delay_ms Initial GPIO active period (default 100)
inactive_delay_ms Subsequent GPIO inactive period (default 100)
timeout_ms Specify (in ms) how long the kernel waits for
power-down before issuing a WARN (default 3000). As GPIO retain their state, other methods of detecting state are unpredictable - the Pi sets the state of the poweroff pin before finally shutting down (and flashes the ACT LED 10 times). The Pi4 puts the power management chip into a low power state when off - turning off the 3.3V supply and effectively totally shutting down the SoC.
This low power on the Pi4 can be disabled e.g. to use the soft reboot option, but requires modified firmware. |
Answer the following technical question about Raspberry Pi. | Title: No activity LED after shorting a GPIO to ground : dead or fixable?
Body: This is a model 3B+, due to some under-power warnings on the screen I was testing the actual voltage between the 5V and ground pins on the header, but managed to touch pin 40 (SCLK) to pin 39 (GND) with the multimeter probe. This caused the Pi to reset and seemingly be dead - the polyfuse is fine (5v present at test point P7), the red power LED is lit but I don't get anything from the activity LED at all. I've tried the SD card in an identical 3B+ and it boots fine, also tried a fresh SD card with a new install of Raspbian, no help. Have I just killed to the board, plain and simple, or is there anything else worth trying to resurrect it? (And if anyone can explain why shorting pin 40 to ground would have such a dire effect, I'm also curious...) | Even with 50 years experience as an Electrical Engineer I wouldn't poke at a 0.1" header with a multimeter probe (although the 50 years experience probably taught me the hard way). Attach Du-pont leads to the pins, and measure the flying leads. Test the voltage on Pin 1 (3.3V) - if this is absent the Pi is dead. Connecting Pin 39 and 40 will not cause any damage - I do this regularly, and have a push button connected there to shut the Pi down. Even if Pin 40 (GPIO 21) is configured as an output this extremely unlikely to cause damage. I suspect you may have shorted Pin 1 & Pin 2 - which is invariably fatal. |
Answer the following technical question about Raspberry Pi. | Title: SSH into Raspberry Pi connected to OpenVPN
Body: I want to be able to remotely ssh into my rpi, while my rpi is connected to PIA (via OpenVPN). I can ssh into the pi from my local network while the pi is connected to OpenVPN, and I can also ssh into the pi remotely while the pi is not connected to OpenVPN. But when I try to ssh into the pi remotely while the pi is connected to OpenVPN I get a connection timeout. My idea was to connect to PIA, request port forwarding, set the ssh port to the port being forwarded, and then ssh pi@PIA_IP -p PIA_PORT. I thought this would work but I just get a connection timeout. I tried these commands to route ssh traffic through my router, but still get connection timeout: sudo ip route add default via <ROUTER_IP> table 65
sudo ip route flush cache
sudo iptables -t mangle -A OUTPUT -p tcp --sport 22 -j MARK --set-mark 65 EDIT: got it work work by doing this: sudo ip rule add fwmark 65 table novpn
sudo ip route add default via <LOCAL_ROUTER_IP> dev eth0 table novpn
sudo ip route flush cache
sudo iptables -t mangle -A OUTPUT -p tcp --sport 2022 -j MARK --set-mark 65
sudo iptables -A INPUT -i tun0 -p tcp -m tcp --dport 2022 -j DROP After running these commands, start OpenVPN.
Then I forwarded port 2022 on my router to my pi, and connected with: ssh pi@<PUBLIC_ROUTER_IP> -p 2022 | The problem is with the routing. You try to connect from remote to the PI, but the return packets are routed through the VPN. The port forwarding might work, you have to find out where it goes wrong. A solution to the routing problem is policy routing. Create a rule: ip rule add sport 22 table 222 This assumes that 22 is your SSH port, the table number 222 is arbitrary, you just have to use the same number in the route command that follows: ip route add default via 1.2.3.4 table 222 Replace 1.2.3.4 with the address of your router. These two commands together make sure that packets coming from port 22, that is return packets from the SSH connection, go through your router. If you want to use SSH over the VPN, you have to assign a different port for SSH over VPN from the direct SSH port, because the return packets will not go over the VPN with there rules. |
Answer the following technical question about Raspberry Pi. | Title: DS3231 doesn't update its internal time?
Body: UPD : with another chip of the same model RTC works just fine, presumably that the chip was broken/damaged. I installed DS3231 RTC clock ( which is detected as DS1307 for some reason). My config.txt looks like gpu_mem=64
dtoverlay=dwc2
dtoverlay=i2c-rtc,ds3231
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=1000000
dtparam=spi=on
enable_uart=1 The clock is detected by i2cdetect and I can see that /dev/rtc0 exists. dmesg | grep rtc shows dmesg | grep rtc
[ 4.021947] rtc-ds1307 1-0068: registered as rtc0 The problem is - hwclock -r always returns the same time. I can set it with hwclock -w and it will keep that very time for weeks. Am I missing something there? Isn't it supposed to tick ? | The ONLY thing you have to do is include in /boot/config.txt: dtoverlay=i2c-rtc,ds3231 All the RTC supported by the Pi kernel use the same rtc-ds1307 driver, but you NEED to tell the driver which chip you actually have. (The different chips have similar instruction sets and registers.) NOTE you NEED to use a separate dtoverlay line for each overlay. Putting dwc2,i2c-rtc will not work. There is no need to set time - it all happens AUTOMATICALLY, although you can set the RTC initially (if NTP not available) using hwclock --set see man hwclock for details. See https://raspberrypi.stackexchange.com/a/51782/8697 |
Answer the following technical question about Raspberry Pi. | Title: Read ip camera stream video on python using opencv3
Body: I installed opencv3 installation link on my raspberrypi 3 and i've tested this, everything is ok, but when i try to read the ipcamera video stream encountered this error self.stream = cv2.VideoCapture("rtsp://*:*@{}:525/stream2".format(ip_camera_address)) 'NoneType' object has no attribute '__array_interface__' Reading the webcam with the usb interface and everything is ok I think my problem is in ffmpeg library, I try to install this library but it won't fix. | I install opencv again [ best link for install this ] and i try to install FFmpeg from repository . affter installation of ffmepg i tried to read ipcamera video stream with this script Note : after finshing opencv cmake, FFmpeg subitems most all get YES. self.stream = cv2.VideoCapture("rtsp://user:password@{}:525/stream2".format(ip_camera_address)) And It worked successfully. This tutorial help me to install ffmpeg on raspberry pi link |
Answer the following technical question about Raspberry Pi. | Title: How to read Wiegand serial data? (Rx/Tx)
Body: Ok, I am losing my mind... Why is this so damn difficult? Current situation: - 12V Access control device that is connected like this i.e. Wiegand D0 to Tx and D1 to Rx, with voltage dividers. - Raspberry Pi 3 with Raspbian Lite OS. - Configured the GPIO serial port i.e. enabling uart and disabling the console. The following Python script runs: import serial
ser = serial.Serial(port='/dev/serial0', baudrate = 9600)
while 1:
print ser.readline() I swipe the 125KHZ cards, the device beeps, and nothing happens... I tried reading from /dev/serial1 , /dev/ttyAMA0 , /dev/ttyS0 ... Still nothing. What am I missing? | Question How to use Rpi UART to read Wiegand data? Answer No you can't. Wiegand and UART are different animals. They don't talk
to each other. But you can use two Rpi GPIO pins and write a simple python program instead. See details below. Wiegand format summary (1) has two output signal wires, one carrying Bit 1 signal, the other Bit 0
signal, (2) uses 26 bits format (16 bit for card number), (3) has no clock. Rpi GPIO reading Wiegand To use Rpi to read Wiegand, you can use a HC00 Quad NAND to preprocess
the two signals, then use two input mode GPIO pins to read the
processed data. It might take an average Rpi python hobbyist programmer one or two days to write a program (Of course you can borrow C++ code from the Arduino guys! :)). See Reference 2 below for more details. Converting 5V/12V Input Signals to 3.3V for Rpi Only hobbyists use resistor voltage dividers. The EE guys usually use
CMOS CD4050 (Note 1), which is low side single supply (3V3 in this
case) and specially designed for high to low level conversion. All
theses years I have been using CD4050 to convert 5V to 3V for Rpi, and
so far so good. Note 1 - Of course hex converter CD4050 is not the only choice. For stepping down just one or two 5V signals to 3V3 say, EE guys usually prefer to use one small signal diode to do the step down (5V - diode drop at cutoff is "usually" safe for high impedance 3V3 logic CMOS input - but no guarantee!) CD4050B CMOS Hex Buffer and Converter (5V (max 20V) Logic to 3V3, Vcc = 3V3) - TI References Understanding Wiegand Format Wiegand Serial Format AliExpress DC12V Access Control 26/34 Wiegand Reader Raspberry Pi and Wiegand: Step by Step (Useless!) CD4050B CMOS Hex Buffer and Converter (5V Logic to 3V3, Vcc = 3V3) - TI Appendices Appendix A - Quick and dirty buggy WieGand reader program draft V0.1 # *** Initialiation ***
Note - GPIO pinA reads Bit 0, GPIO pinB reads Bit 0 import GPIO module
set GPIO pinA and pinB to input mode
declare 16 elements dataBitList to store card number *** Read a pulse from either pinA or PinB *** Note - wait for pulse coming at PinA or pinB while (pinA OR pinB) NOT Low
sleep 100uS read pinA if pinA Low
return 0
else return 1 *** Main program *** Note - just read one card number, no parity checked. initialize pinA, pinB, dataBitList
loop 26 times
read start pulse
loop to read 8 factory data bits and discard
loop to read 16 card number bits and store in dataBitlist
read partity pulse
sleep 100mS print card number in the dataBitList |
Answer the following technical question about Raspberry Pi. | Title: Can I plug my SD card from Pi 3 into a Pi 4?
Body: If I upgrade the OS to Buster on an OS disk (SD card or USB stick) on my Pi 3, will it work if I boot a Pi 4 off that? Note : My question is not about the merits of upgrading, but if the same disk used for a Pi 3 will work on a Pi 4, assuming it's running Buster. | This can be done, but requires a bit of work to get the bootloader updated for Raspberry Pi 4. Here's how I did it: Back up your SD card!!! This can go wrong any number of ways. Not my fault if you bork something! Upgrade Raspbian on your Pi 3 to Raspbian Buster. Use Gparted on another computer to enlarge the boot partition of the card to 250MB. Make sure you don't move the start position of the boot partition. Put the card back in the Pi 3 and update the bootloader with the command sudo apt install --reinstall raspberrypi-bootloader raspberrypi-kernel Put the card in your Pi 4 and hope for the best. |
Answer the following technical question about Raspberry Pi. | Title: BitTorrent Sync on RPi with dynamic IP addresses, how to set it up?
Body: I've got a synology DS-212j with the BTSync client set up, and I've also set it up on a Raspberry Pi on the my LAN succesfully. The sync directories work perfect, and now that the test phase goes well, I'd like to use the RPi on my parent's house as a way to have a backup for some of my files here at home. The only thing that I am not sure about is how to configure the BTSync client there, because it's a remote location and the IP is dynamic . I guess I must use DynDNS or some free alternative (I've seen DNSexit ) and then configure somehow a fixed domain (I should then set up a lightweight webserver on the RPI as well?). What would be the appropiate steps to be able to sync files from my house to my parent's RPi through BitTorrent Sync? I'd like to do this with this client, although I know using rsync for example could be an option too... But BTSync runs in the background and once you configure you can leave it running comfortably. | Bittorrent Sync uses Bittorrent technology that is inherently peer-to-peer and IP-independent. You do not need need a fixed Internet IP. *This is my assumption as internal working is not revealed anywhere ... Each client makes a small amount of encrypted data (based on secret i presume) and stores it somewhere. Where I am not exactly sure- either on a bittorrent server or on other clients that share this data somehow (There are no details on the website how tracking is done) When you add a secret on a client it gets the tracking data and it knows what IP's are active, what ports to connect to it might even use this tracking system to get the remote client to initiate connection to overcome NAT and Firewall issues. In conclusion, the system is designed to know where clients are and what folders are shared without any knowledge of networking, ports or schmorts. It just works! It amazing and easy. My network has become so complex now, between work shared folders, home folders, server retentions and friends folders. I never needed to open any ports or configure any firewalls. How to install Bittorrent synch from repository sudo gpg --keyserver pgp.mit.edu --recv-keys 6BF18B15
sudo gpg --armor --export6BF18B15 | sudo apt-key add -
sudo echo deb http://debian.yeasoft.net/btsync wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
sudo echo deb-src http://debian.yeasoft.net/btsync wheezy main contrib non-free >> /etc/apt/sources.list.d/btsync.list
sudo apt-get update
sudo apt-get install btsync You can then add the secret from your computers client on the the remote computer client and it will start to synchronize. You can do this on as many Pi's as you like just make sure you have enough disk space :) When you are installing it on a headless system the only port is the web interface port that you might need but you should not forward that to the internet. It would be better to SSH into the box via 22 port and tunnel into the torrent interface. If you really must forward the web gui port make sure to secure the web interface with a proper password. You can install Bittorrent sync application that gives you a native GUI for your platform. It does not allow you to mange remote location though just folders synchronized with the current machine. For example: The Pi could be running headless connected to an external
1Terrabyte hard drive that stores all your files and your parents
files. Then on your computer at your remote location you install the
native client on Windows and you get the copy off all the data. You
then also install a client on your parents computer- This is nice
because BTSynch knows you are on LAN and synchronizing will very
fast. So the Pi is "like a dropbox server" and you and your parents
are the clients. You do not have to share the entire drive you can just select
specific folders like Photos shared amongst your self and parents but you might want
to backup your documents at home and your parents do not have to see that at all.
You can then share specific folders within Photos with a 1 time key or read only
attributes for friends or other family. Security And if you are worried about all the NSA hacking Bittorrent apparently uses a proper open source, non backdoored implementation of AES-256 with proper cryptographic engines. |
Answer the following technical question about Raspberry Pi. | Title: Xorg not working after upgrading to buster
Body: After switching to Raspbian Buster and rebooting RPi3 B+ boots into a shell. (I use the GUI so this is a bit odd) After typing in startx I get this error (I cutout a bunch of junk): (EE) no screens found(EE)
(EE) Server terminated with error (1). Closing log file
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error Is there any way to fix this? | This is the wrong answer. The top answer seems to be much better, but I won't accept it because I didn't try it. I eventually just sucked it up and reflashed my SD card with Buster. Wasn't too bad redoing everything |
Answer the following technical question about Raspberry Pi. | Title: Startup files on raspberry pi 3
Body: I have 4 python scripts running continuously. How I can open them in separate windows on startup? I need see the terminals when it's booting up. I tried rc.local : it's working but I can't see the terminals of each script.
I need that after reboot I can see 4 terminal windows like when I start scripts myself. There is way to do that? | I'm assuming your using Raspbian Stretch with Desktop or Raspbian Buster with Desktop. Edit the autostart file using: sudo leafpad /etc/xdg/lxsession/LXDE-pi/autostart Autostart file should look similar to: @lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
point-rpi Add your 4 Python programs to the end using @lxterminal: @lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
point-rpi
@lxterminal -e python3 /home/pi/test1.py
@lxterminal -e python3 /home/pi/test2.py
@lxterminal -e python3 /home/pi/test3.py
@lxterminal -e python3 /home/pi/test4.py |
Answer the following technical question about Raspberry Pi. | Title: How to Monitor GPIO Input Indefinitely Without Recursion
Body: I actually joined StackOverflow to ask this question because I wasn't sure it was RPi specific, but as I was thinking about how to form the question, I realized it might be GPIO specific (for some reason that I'm not even aware of), so hopefully this is the right place to ask. I'm running Raspbian Jessie 4.9.35-v7+ on a Pi 3 Model B. Over time, I've cobbled together a fairly basic python script to monitor a GPIO pin and send a network signal to a remote application. I run two slightly different copies of the script to monitor two different GPIO pins for two different network signals, and the scripts are launched from rc.local. A previous version of these scripts ran for months on end, but I just had the current version fail after maybe two weeks due to "RuntimeError: maximum recursion depth exceeded." The error output logged includes bouncing back and forth between two functions many times, so I ran this against the log: cat script2.log | grep -c File The log for script1 is 0 bytes, so I believe that command gives me a number that shows roughly how many levels of recursion the script encountered. The output was 984, and paired with the two functions I wrote repeating back and fourth all but 7 of those times, the 977 iterations seem high enough to indicate the problem lies in how my script is written as opposed to within an imported package. Here is an example of the script I am running: #!/usr/bin/env python
import RPi.GPIO as GPIO
import signal
import socket
import time
import requests
#Define GPIO pin here:
thiscontact = 2
GPIO.setmode(GPIO.BCM)
GPIO.setup(thiscontact, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def watchopen():
thisposition = GPIO.input(thiscontact)
if thisposition == True:
while thisposition == True:
time.sleep(0.1)
thisposition = GPIO.input(thiscontact)
watchclose()
watchclose()
def watchclose():
thisposition = GPIO.input(thiscontact)
if thisposition == False:
while thisposition == False:
#Send Trigger
requests.get('https://192.0.2.248:55756/Srv/Api/TriggerFacade/ActivateDeactivateTrigger?{"triggerName":"SignalOne","deactivateAfterSeconds":"3"}', auth=('Username', 'Password'), verify=False, timeout=1)
time.sleep(0.9)
thisposition = GPIO.input(thiscontact)
watchopen()
watchopen()
def exit_handler(signal, frame):
GPIO.cleanup()
raise SystemExit
signal.signal(signal.SIGTERM, exit_handler)
signal.signal(signal.SIGINT, exit_handler)
watchopen() This is what the end of the log file would look like from that example: File "/usr/local/bin/Door6B.py", line 34, in watchclose
watchopen()
File "/usr/local/bin/Door6B.py", line 20, in watchopen
watchclose()
File "/usr/local/bin/Door6B.py", line 28, in watchclose
requests.get('https://192.0.2.248:55756/Srv/Api/TriggerFacade/ActivateDeactivateTrigger?{"triggerName":"SignalOne","deactivateAfterSeconds":"3"}', auth=('Username', 'Password'), verify=False, timeout=1)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 60, in get
return request('get', url, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 48, in request
session = sessions.Session()
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 327, in __init__
self.mount('https://', HTTPAdapter())
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 90, in __init__
self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 126, in init_poolmanager
block=block, **pool_kwargs)
File "/usr/lib/python2.7/dist-packages/urllib3/poolmanager.py", line 65, in __init__
dispose_func=lambda p: p.close())
File "/usr/lib/python2.7/dist-packages/urllib3/_collections.py", line 46, in __init__
self._container = self.ContainerCls()
RuntimeError: maximum recursion depth exceeded Above that in the log file, the first two sections repeat 974 times following the first bit which is roughly the same: Traceback (most recent call last):
File "/usr/local/bin/Door6B.py", line 40, in <module>
watchopen() With a bit of searching, I've found advice such as " Rewriting the algorithm iteratively, if possible, is generally a better idea " and " For instance, it's quite possible that your outermost loop will hinge on a simple while ." However, I believe I previously found that I had to loop in order for the script to continue running indefinitely when I tested last year, so I am guessing that those answers don't apply to me and the assumption with those answers is that the script needs to complete a task and end. I'm not sure how to proceed for a number of reasons such as these: 1) The original version of this script that ran for months on end used socket instead of requests (and it looks like I never stopped importing that, so some script cleanup may be in order). Given this, while it seems unlikely to me, it may be possible that I'm not understanding recursion right and there is an issue in requests that caused this error vs the bouncing back and forth between my functions. 2) I have no idea how to make a script perform an action only when a switch is closed each time a switch is closed without this recursion, and I have no idea what to search for in order to find out how if that can even be done. 3) Even assuming the second piece of advice I found applies, if I remember correctly, I added the if loops around the while loops in order to prevent the script from terminating. However, logically speaking, even if the if loops are redundant and it would work with only while loops, I'm not sure that such a change would remove the recursion since each function still calls the other. 4) I suspect that I could have a bash script call the python script in a loop by only having the contents of watchclose() at the end of the python script followed by time.sleep(0.1) (or some sleep function in the bash loop), but I doubt that is the "right" way to deal with this from a programming standpoint or an efficiency standpoint. | When you have a recursive function like this (one with too much depth potential), you need to convert it into a loop. In this case you have two functions alternating calling each other: while True:
watchopen()
watchclose() This will loop forever (as does the original version, you are exiting on a signal), but you can also use some kind of state as a condition in the while loop. |
Answer the following technical question about Raspberry Pi. | Title: ssh in local LAN: works with IP, but not by name
Body: On a local LAN, I am trying to ssh into a freshly installed Raspberry Zero WH, by host name. I am connecting from an Ubuntu box. The Rasbperry Pi does boot, and connects to the Wifi. I can see it in my PfSense firewall/router page "Status: DHCP leases" as up and running with it's IP address and host name. It's online and the lease type is static. Now when I do $ ssh pi@raspberrypi-zero-wh I immediately get ssh: connect to host raspberrypi-zero-wh port 22: Connection refused However, I can ping it successfully ping it with this host name and immediately get a response. $ ping raspberrypi-zero-wh
PING raspberrypi-zero-wh.my.lan (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.029 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.063 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.064 ms I can also ssh into it by IP: $ ssh pi@192.168.77.3
pi@192.168.77.3's password: Why does ssh work by IP, but no by host name? Note: It's different from SSH works only with public IP but not with dynamic DNS hostname because this is all local, in the same subnet. Can ssh internally, but can't externally: port 22: connection refused may be related, but I fail to see a link between a firewall setting when IP-based routing works. I use a PiHole on the same LAN, but again, the ssh seems to be rejected by the destination device, not the DNS server. | You think that raspberrypi-zero-wh is that name of your Raspberry Zero WH, but as can be seen in the output of the ping command, that name resolves to 127.0.0.1 . So you don't try to connect to the Raspberry Zero WH, you try to connect to the computer running the ssh command. It seems to be a problem with the assignment of the DNS name. |
Answer the following technical question about Raspberry Pi. | Title: Automatically Create Hotspot if no Network is Available
Body: I want to automatically create an access point, if there is no network found, so that I can connect to my Raspberry Pi everywhere. If nobody is connected to the hotspot for a while it should search for the networks defined in wpa_supplicant.conf again. I don't want to install any additional software and to use only wpa_supplicant , wpa_cli and systemd-networkd . | The following can also easily be installed from a github repository that I created here . First we need to change over completely to systemd (which might be the future anyway), as Ingo has explained here : # deinstall classic networking
sudo -Es # if not already done
apt --autoremove purge ifupdown dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog
apt-mark hold ifupdown dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog raspberrypi-net-mods openresolv
rm -r /etc/network /etc/dhcp
# setup/enable systemd-resolved and systemd-networkd
apt --autoremove purge avahi-daemon
apt-mark hold avahi-daemon libnss-mdns
apt install libnss-resolve
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
systemctl enable systemd-networkd.service systemd-resolved.service 1. Configure wpa_supplicant Your wpa_supplicant-wlan0.conf should look something like this: country=FR
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
ap_scan=1 your access point/hotspot network={
ssid="RaspberrypiAP" # your hotspot's name mode=2
key_mgmt=WPA-PSK
psk="passphrase" # your hotspot's password
frequency=2462
} your network(s) network={
priority=10 # add a priority higher then 0 to any networks
ssid="yourWifi" # except the access point's one!
psk="passphrase" } We have to add a priority= higher then 0 to any network section except the hotspot's one, so wpa_supplicant will prefer them. Only if none of these networks is found, wpa_supplicant will create an access point/hotspot. If wpa_supplicant has created a hotspot the interface has to be given a static address and we need a DHCP server, so that we can connect our devices to it. This will be done by systemd-networkd . 2. Configure wireless interface with systemd-networkd We need to create the following files. The first one will configure your device as client, the second one as access point. The first one is the default due to the smaller number. sudoedit /etc/systemd/network/08-CLI.network [Match]
Name=wlan0
[Network]
DHCP=yes
LinkLocalAddressing=yes
MulticastDNS=yes sudoedit /etc/systemd/network/12-AP.network [Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
DHCPServer=yes
LinkLocalAddressing=yes
MulticastDNS=yes 3. Setup a systemd.service to automatically configure the interface based on wpa_supplicant events This service will run wpa_cli , which executes the script below on certain events. Run sudo systemctl edit --full --force wpa_cli@wlan0.service and paste the following lines to it: Description=Wpa_cli to Automatically Create an Accesspoint if no Client Connection is Available
After=wpa_supplicant@%i.service
BindsTo=wpa_supplicant@%i.service [Service]
ExecStart=/sbin/wpa_cli -i %I -a /usr/local/bin/autoAP.sh
Restart=on-failure
RestartSec=1 [Install]
WantedBy=multi-user.target 4. The script needed for the service This script has to be saved to the path defined in the ExecStart= section. It will configure the device as client if connected to some wifi, or as access point if wpa_supplicant has created one, which it will do automatically if no other network is found. If nobody is connected to the access point for a while it will restart wpa_supplicant to make it search for wifi networks again. sudoedit /usr/local/bin/autoAP.sh #!/bin/bash
device=wlan0 configure_ap () {
if [ -e /etc/systemd/network/08-CLI.network ]; then
mv /etc/systemd/network/08-CLI.network /etc/systemd/network/08-CLI.network~
systemctl restart systemd-networkd
fi
} configure_client () {
if [ -e /etc/systemd/network/08-CLI.network~ ] && wpa_cli -i$device status | grep -q "mode=station"; then
mv /etc/systemd/network/08-CLI.network~ /etc/systemd/network/08-CLI.network
systemctl restart systemd-networkd
fi
} reconfigure_wpa_supplicant () {
sleep "$1"
if [ "$(wpa_cli -i $device all_sta)" = ""]; then
wpa_cli -i $device reconfigure
fi
} case "$2" in # Configure access point if one is created
AP-ENABLED)
configure_ap
reconfigure_wpa_supplicant 2m &
;;
# Configure as client, if connected to some network
CONNECTED)
configure_client
;;
# Reconfigure wpa_supplicant to search for your wifi again,
# if nobody is connected to the ap
AP-STA-DISCONNECTED)
reconfigure_wpa_supplicant 20 &
;; esac Make the script executable chmod +x /path/to/script/autoAP.sh . Now we have to run sudo systemctl enable --now wpa_cli@wlan0.service , reboot the Pi and everything should work. I'll be glad for any suggestions on how to improve this setup. |
Answer the following technical question about Raspberry Pi. | Title: Why does Raspbmc hang randomly?
Body: My Raspberry Pi, running Raspbmc, hangs randomly while navigating in the menu/settings. Any hints what I could check to find out what's happening when it hangs? | Is it crashing or just hanging? You can try the top command it will show the usage of your resources CPU: 34.3% usr 10.8% sys 54.0% nic 0.0% idle 0.0% io 0.1% irq 0.5% sirq
Load average: 5.66 4.22 3.35 4/110 24166 I am using OpenELEC which is oriented on XBMC for small devices, it is not stable yet, but it worth the try (running OpenELEC-RPi.arm-devel-20120914034643-r11925 ). I do have small glitches in the navigation menu when the RPi is indexing media files or doing other operations. The RPi is built to do hardware decoding of specific formats. But since august 24th, if you buy some licenses you can decode MPEG-2 and VC-1 : http://www.raspberrypi.org/archives/1839 Hope this helps |
Answer the following technical question about Raspberry Pi. | Title: Running Hologram cellular network from startup issues [cannot run on rc.local or .bashrc]
Body: I’m playing around with the hologram Nova cellular USB kit and I’m trying to create an automatic connection using the /etc/rc.local file. Hologram uses it's own way of connecting to a ppp0 network connection and the way to enable or start a connection is through: sudo hologram network connect This command runs on the command line without any problem. However it doesn’t seem to ever run on boot up. For those of you who aren’t familiar with the Nova Hologram you can follow this link In order to get a ppp0 connection. So I have tried a rc.local edit just simply adding the command and it just doesn't seem to run... I have also tried running a crontab command (same command after reboot) in order to run. However it just doesn’t seem to run at all... After running crontab under admin priviledges: (sudo crontab e-) I type at the end of the file: @reboot sudo hologram network connect Nothing seems to happen when I reboot or power on Raspberry pi. Anyway, any help would be greatly appreciated! Thank you kindly Edit: After creating the unit service for systemd, as suggested by @Ingo Here is the following log result: Ok Here's the output from the termination error:
pi@BerryPi2:~ $ sudo systemctl status holConn.service
● holConn.service - Hologram Service
Loaded: loaded (/etc/systemd/system/holConn.service; enabled; vendor
preset: enabled)
Active: inactive (dead) since Fri 2019-07-05 00:41:26 EDT; 14s ago
Process: 1249 ExecStart=/usr/local/bin/hologram network connect
(code=exited, status=0/SUCCESS)
Main PID: 1249 (code=exited, status=0/SUCCESS)
Jul 05 00:41:20 BerryPi2 pppd[1256]: Connect: ppp0 <--> /dev/ttyACM0
Jul 05 00:41:24 BerryPi2 pppd[1256]: local IP address xx.xx.x.x # -> note I masked the real IP and DNS addresses
Jul 05 00:41:24 BerryPi2 pppd[1256]: remote IP address xx.xx.x.x
Jul 05 00:41:24 BerryPi2 pppd[1256]: primary DNS address xx.xx.xxx.xxx
Jul 05 00:41:24 BerryPi2 pppd[1256]: secondary DNS address xx.xx.xxx.xxx
Jul 05 00:41:26 BerryPi2 hologram[1249]: PPP session started
Jul 05 00:41:26 BerryPi2 pppd[1256]: Terminating on signal 15
Jul 05 00:41:26 BerryPi2 pppd[1256]: Connect time 0.1 minutes.
Jul 05 00:41:26 BerryPi2 pppd[1256]: Sent 0 bytes, received 0 bytes.
Jul 05 00:41:26 BerryPi2 pppd[1256]: Connection terminated. 2nd Edit: After the updates to the unit file, including the oneshot and other options suggested by @Ingo, the service stays active but shows status as exited. pi@BerryPi2:~ $ sudo systemctl status holConn.service
● holConn.service - Hologram Service
Loaded: loaded (/etc/systemd/system/holConn.service; enabled; vendor
preset: enabled)
Active: active (exited) since Fri 2019-07-05 11:55:42 EDT; 2min 19s ago
Process: 507 ExecStart=/usr/local/bin/hologram network connect
(code=exited, status=0/SUCCESS)
Main PID: 507 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/holConn.service
Jul 05 11:55:39 BerryPi2 systemd[1]: Starting Hologram Service...
Jul 05 11:55:42 BerryPi2 sudo[624]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/sbin/modprobe option
Jul 05 11:55:42 BerryPi2 sudo[624]: pam_unix(sudo:session): session opened for user root by (uid=0)
Jul 05 11:55:42 BerryPi2 sudo[624]: pam_unix(sudo:session): session closed for user root
Jul 05 11:55:42 BerryPi2 hologram[507]: ERROR: Modem not detected
Jul 05 11:55:42 BerryPi2 systemd[1]: Started Hologram Service. I'm guessing we have to modify the After option to wait for both network and usb modem to be recognized? is there such an option? I tried putting the idle.target because I read it was basically when the Pi is ready and everything has loaded... but I'm most likely wrong. | Please take note that using /etc/rc.local has limitations due to Compatibility with SysV . We have seen many problems here on this site using it. Following the recommendation of the developers from systemd you should avoid using it. Instead you should use a systemd Unit file to start your service. With systemd you have many options to make your service run. Your command only runs one time and does not stay in the background as a service. So we have to use oneshot . We have to find the condition that is available on the command line but not early on boot up. First we can try to wait until network-online.target . If it doesn't help we can try to start the command again after a time until it is started. This provides that the command fails without connection but it seems it finishes with (code=exited, status=0/SUCCESS) , why? The best is when we know what other service (condition available on command line) is needed so we can start our command After that without only fixing symptoms. Try this unit file. The possible alternatives I have commented out. You can create the unit with: rpi ~$ sudo systemctl --full --force edit holConn.service In the empty editor insert these statements, save them and quit the editor: [Unit]
Description=Connect Hologram service
After=network-online.target
# After=service needed to be available
[Service]
Type=oneshot
RemainAfterExit=yes
# Restart=on-failure
# RestartSec=5
# TimeoutStartSec=30
ExecStart=/usr/local/bin/hologram network connect
[Install]
WantedBy=multi-user.target You can edit it again with: rpi ~$ sudo systemctl --full edit holConn.service Enable the new service: rpi ~$ sudo systemctl enable holConn.service and reboot. Check status with: rpi ~$ systemctl status holConn.service It is likely that it doesn't run on the first attempt due to missing conditions. We will look at it then. Update: Using the chat we have found that there is an additional condition. A ppp connection on interface ppp0 must be established before starting the service. That was the missing # After=service needed to be available . We can check with sys-subsystem-net-devices-ppp0.device if the interface is up. So the final Unit file looks like this: [Unit]
Description=Connect Hologram Service
After=network-online.target
After=sys-subsystem-net-devices-ppp0.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/hologram network connect
[Install]
WantedBy=multi-user.target |
Answer the following technical question about Raspberry Pi. | Title: Is there a way to physically disable wireless networking capabilities?
Body: I'm looking to create a cheap air-gaped computing device to store and utilize sensitive data like cryptocurrency wallet addresses or PGP keys. Now, I'm a total newb when it comes to Raspberry Pi but they do seem suitable for these applications, save for the fact that most Pi boards have Wifi and Bluetooth built-in, which is actually undesirable in this case. The original Pi Zero doesn't have Wifi and Bluetooth built-in, but it's difficult to obtain from where I live, and it only has a single MicroUSB port for input, so a standard model might be preferable. So my question is if and how I would be able to physically modify the board in order to disable wireless networking functionalities on a Pi Zero W or Pi 3? Alternatively, might it be feasible to simply shield the board or (ideally) the wireless components using a faraday bag or similar? | You could of course just break out the WLAN chip and bluetooth chip, respectively. The WLan Chip should be the little thing with the raspberry icon on it. But why'd you do this? Fear of getting hacked, ripped off? You have multiple ways of protecting yourself if you feel paranoid.... LEARN USING LINUX: sudo ifconfig wlan0 down this will disable your wlan chip per kernel command. Simple as that. Oh, and if you don't use the general purpose raspbian kernel and instead use, let's say, arch linux, u can cut off wlan drivers from the beginning USE CORRECT DEVICE: Bitcoin can be stored on tags. Yes, simple as that. RFID tags. And you can place these inside a lead box if you're still paranoid. Also you can obtain a physical bitcoin, a coin that has the value printed on it ( and consists of metal that has a value by itself, lol) Also, what is the point on not having the wallet on your smartphone, where you can use it to actually buy stuff with? Are just 2 answeres that came to mind instantaniously. But if you still wanna go for it, then do it like that:
Carefully drill a hole in the chip, this would be the safest way of permanent disabling it without the risk of getting other stuff damaged that is around the wlan chip on the circuit board. |
Answer the following technical question about Raspberry Pi. | Title: Detecting the same RFID tag twice
Body: I have a problem with the MFRC522 library. It seems to me that after the tag was read / written one time correctly, in the next cycle the library always returns 2 on the check whether a card is present or not, meaning it skips one cycle every time. The "request" function seems to give controll to the "tocard" function which does strange magic like if ~((i != 0) and ~(n & 0x01) and ~(n & waitIRq)): where it just seems to check registers but it is too hard to understand from only the library. This is a HUGE problem for me, since I want the reader to poll, like a video game engine does when you hold a button pressed. To be specific, I want to recognise wheter a card that is present was already present in the last reading cycle, and so forth, meaning a user that just held the card onto the device would not create much dump data and senseless database entries, also what's the point in calculating a delta between timestamps when you are not even sure if your stamp was saved or just deleted lol. I tried something like this: # Scan for cards
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
# If a card is found
if status == MIFAREReader.MI_OK and same_card == False: # MI_OK == status code 0
print "Card detected"
elif status == MIFAREReader.MI_ERR: # MI_ERR == status code 2
print "debug: no card present"
same_card = False
else:
print "same card detected" [Setting same_card to true after writing data successfully, of course] For some reason I do not understand, the second reading cycle after I wrote data onto the card (or deleted it after getting my delta, this would be second time we enter work cycle) always returns status code 2 (MI.err) This can't be possible because I'm still here holding that card against the reader (even if I slept for about 5 seconds, no difference) The only other call at the end of the working cycle would be to def MFRC522_StopCrypto1(self):
self.ClearBitMask(self.Status2Reg, 0x08) but this will hardly cause this behaviour, right? Does anybody have a working example of a script that is blocking if the card is held against the reader constantly? No cheating allowed (sleeping f.e.).
Bonus points if you can provide something using interrupts.... Thank you | Well, after further searching I found an okish solution thanks to This post from Constantine Samoilenko What he said was to cleanup the GPIO at the end of the loop, and also to reinstantiate the MFRC522 object each time the loop restarts. (this creates much overhead and is therefor just a dirty hack, but hey, we are speaking about python here, processor time and ram are wasted per default anyway) And now it reads correctly on almost every loop. Almost. It still sometimes messes up, but works 9/10 times. (Which for me is enough, but the initial problem still remains, what if an user keeps holding the card against the reader.... ) Here is an estimate build of the program, if this helps anybody: continue_reading = True
same_card = False
while continue_reading:
# Create an object of the class MFRC522, reinstantiate on every loop
MIFAREReader = MFRC522.MFRC522()
time.sleep(0.5)
# Scan for cards
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
#If a card is found
if status == MIFAREReader.MI_OK and same_card == False: # MI_OK == status code 0
print "Card detected"
elif status == MIFAREReader.MI_ERR: # MI_ERR == status code 2
print "debug: no card present"
same_card = False
else:
print "same card detected"
# Get the UID of the card (basicly first 4 byte of sector 0) -> save into "uid"
(status,uid) = MIFAREReader.MFRC522_Anticoll()
#print "DEBUG: " + str(uid) + " UID VAL"
# If we have the UID, continue
if status == MIFAREReader.MI_OK and same_card == False: [ unlock card, do stuff, timestamp and calculate delta for time ] then, at the end: MIFAREReader.MFRC522_Write(4,payload)
MIFAREReader.MFRC522_StopCrypto1()
GPIO.cleanup()
same_card = True
else:
print "Authentication error" This way, it at least won't give me the status 2 (MI_ERR), so it won't delete my timestamp instantaniously again after writing it. [In my program, I check whether a timestamp is present, if not stamp it. But if one is there, calculate the time delta between now and timestamp and format card afterwards] |
Answer the following technical question about Raspberry Pi. | Title: POE without the Rpi Hat?
Body: I have a raspberry pi 3b+ with the 4 PoE connectors. How can I power the Pi with Ethernet without buying the PoE Hat? Is there a link to a schematic for the PoE hat? I need a different board on top of my Pi. Thanks. | Use a POE splitter: I’ve used the following with excellent results. Cheaper than a POE Hat to and leaves the GPIO pins free too!: https://www.amazon.co.uk/gp/product/B074Y6M67F/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1 |
Answer the following technical question about Raspberry Pi. | Title: How do I build Qt's mysql-plugin on Raspbian Buster
Body: I try to build the MySQL plugin on a Raspbian Buster with C++ and Qt 5.12.4. Building Qt itself worked fine by following this tutorial: https://www.tal.org/tutorials/building-qt-512-raspberry-pi However, if I add the option -sql-mysql to the command PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig ../qt-everywhere-src-5.12.4/configure -platform linux-rpi-g++ -v -opengl es2 -eglfs -no-gtk -opensource -confirm-license -release -reduce-exports -force-pkg-config -nomake examples -no-compile-examples -skip qtwayland -skip qtwebengine -no-feature-geoservices_mapboxgl -qt-pcre -no-pch -ssl -evdev -system-freetype -fontconfig -glib -prefix /opt/Qt5.12 -qpa eglfs -sql-mysql the output results in the following error: ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed. I assume that this is due to that the MySQL libraries were exchanged by MariaDB libraries in Raspbian Buster. Does anybody know, how to build Qt's MySql driver using the MariaDB libraries or in worst case how to install the MySQL libraries on Raspbian Buster? | You need to install the Mariadb packages and the mysql compatibility package in your sysroot. apt install mariadb-client mariadb-common mysql-common
libmariadb-dev-compat libmariadbclient-dev libmariadb-dev-compat package will create all the links necessary for compatibility between mariadb and mysql.
Then, when you call to qt configure script you must indicate the path of the mysql (mariadb) libraries: -sql-mysql MYSQL_INCDIR=/opt/rpi/buster_enigma/sysroot/usr/include/mysql
MYSQL_LIBDIR=/opt/rpi/buster_enigma/sysroot/usr/lib/arm-linux-gnueabihf Tested on host Ubuntu 18.04 - Target Raspbian Buster - QT 5.12.5 |
Answer the following technical question about Raspberry Pi. | Title: pi-4 cryptsetup benchmark output?
Body: On the pi-4 what is the output of "cryptsetup benchmark"? I want to asses its performance compared to the pi-3.
Apparently the new "quality standards" require this question to be needlessly verbose thus these 2 extra sentences. | https://forum.odroid.com/viewtopic.php?f=149&t=30103&p=215037 Algorithm | Key. | Encryption. | Decryption
aes-xts. | 512b | 66.1 MiB/s. | 56.8 MiB/s. |
Answer the following technical question about Raspberry Pi. | Title: Raspberry Pi4 extension to PCIe
Body: Is it possible to extend the Raspberry Pi 4 to provide a PCIe connection? I have a PC which has as only purpose to play music using this Soundcard (no Linux drivers that work well) "PCI Express X-Fi Titanium Fatal1ty Pro Series" by Creative and I am happy with the sound. But the PC takes away a lot of space. So I would like to know if there is a possibility to run Windows 7/10 on a Raspberry Pi and extend it by a PCIe lane? | Someone (see links below) has managed to connect a PCIE card to a Raspberry Pi 4 by desoldering the USB chip and connecting to the board, so it's kind of possible if you like soldering and damaging your Pi. The Pi 4 has one set of PCIE lanes, that is used for USB-3 support. I don't think Windows is available for newer Pis though. Windows IOT core was released for Pi 2&3, but hasn't had update since 2017? http://mloduchowski.com/en/blog/raspberry-pi-4-b-pci-express/ https://news.ycombinator.com/item?id=20399555 |
Answer the following technical question about Raspberry Pi. | Title: How can i install OpenCV on Raspberry Pi 4 (Raspbian Buster)?
Body: I have tried many days to install OpenCV on my Raspberry Pi 4 with Raspbian Buster but i couldn't get it done. The installation always works but when importing or using cv2 methods like cv2.imshow(), errors come up (see below). Did somebody get OpenCV working on a Raspberry Pi 4 or has an idea on how to get it working? Thank you in advance for your help :-)! Error after installing OpenCV with pip: pip install opencv-python
pip install opencv-contrib-python
python
>>> import cv2
ImportError: libImath-2_2.so.12: cannot open shared object file: nu such file or directory Error after installing OpenCV with conda: conda install -c conda-forge opencv
conda install -c conda-forge opencv=4.1.0
conda install -c menpo opencv
python
>>> import cv2
>>> img = cv2.imread("image.png", 0)
>>> cv2.imshow("Frame", img)
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /home/jhelmus/conda/conda-bld/opencv_1512174356192/work/modules/highgui/src/window.cpp, line 605
Traceback (most recent call last):
File "detect_video.py", line 113, in <module>
cv2.imshow("Frame", img_main)
cv2.error: /home/jhelmus/conda/conda-bld/opencv_1512174356192/work/modules/highgui/src/window.cpp:605: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage Error after installing OpenCV by compiling it I went through the compilation processes described in these two guides. These guides worked on my Raspberry Pi 3b, but not on my Raspberry Pi 4: https://www.pyimagesearch.com/2018/09/26/install-opencv-4-on-your-raspberry-pi/ https://www.learnopencv.com/install-opencv-4-on-raspberry-pi/ After the process from the make command reached almost the end, it could not link the openCV installation to the Python executable (neither the Python executable in my conda virtual environment /home/pi/miniconda3/envs/py35/lib/python3.5 , nor the global Python3 executable /usr/bin/python3 . The errors were somehow like "Permission denied: Could not access Python3.5". I used this cmake setting: cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D BUILD_opencv_python3=yes \
-D PYTHON_DEFAULT_EXECUTABLE=/home/pi/miniconda3/envs/py35/lib/python3.5 \
-D OPENCV_PYTHON3_INSTALL_PATH=/home/pi/miniconda3/envs/py35/lib/python3.5/site-packages \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D BUILD_TESTS=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF .. I once tried this cmake command with the PYTHON_DEFAULT_EXECUTABLE = /usr/bin/python3 . Thank you in advance for your help :-)! Paul | You should use OpenCV from the default Raspbian Repository. It is tested and fits best into the Raspbian distribution without errors (I hope :). On Buster you will find with: rpi ~$ apt list python*opencv*
Listing... Done
python-opencv-apps/testing 1.12.0-2 all
python-opencv/testing 3.2.0+dfsg-6 armhf
python3-opencv-apps/testing 1.12.0-2 all
python3-opencv/testing 3.2.0+dfsg-6 armhf
rpi ~$ Just sudo apt install python3-opencv and it should do. With apt show python3-opencv you will find that Version: 3.2.0+dfsg-6 is installed. If you like you can also install the additional apps. |
Answer the following technical question about Raspberry Pi. | Title: Screen resolution when VNCing into a Pi Zero W
Body: I am using TightVNC to get into a Raspberry Pi Zero W, running Raspbian. The pi normally runs headless and I will never attach a monitor to it, only remote in. When I remote in, I see a small desktop (I would guess 640 x 480), surrounded by black. How do I see it full screen when VNCing in? | The -geometry switch on the TightVNC command line will set the geometry as you like it. Where that command actually is depends on how you're starting VNC. Common situations are vncserver, xinetd, or using systemd. I did a write-up on setting up TigerVNC with systemd but can be easily applied to tightvnc. See https://github.com/gitbls/RPiVNCHowTo |
Answer the following technical question about Raspberry Pi. | Title: 3.5 mm jack speakers not being recognized
Body: Over the past several days, I have tried and failed to make my raspberry pi recognize the speakers that I connected to it through the 3.5mm jack. The USB microphone that I plugged in works perfectly well and I believe that my sound card is good as well. I have spent these days looking at everything on the internet and nothing has changed. If anyone has any idea what I should do, I would really appreciate it. Thank you! EDIT: @goldilocks I am using old analog speakers that use the auxilary port. I read several notices about amplifying the speakers, but I don't know anything about it and I am not using any amplifiers as far as I'm aware. EDIT 2: A very important note is that before I started plugging in speakers and microphones and changing the settings, I remember an "Analog" option for the speakers. However it disappeared and I haven't seen it since. | Question How to tell Rpi to use the speakers connected to the USB sound stick? Answer I am using Rpi3B+ stretch 9 GUI Desktop's automatically installed VLC
Media Player. My speaker is connected to the USB hub. Method 1 GUI Desktop Top Menu > Preferences > Audio Device Settings > Sound Card > Choose the following USB audio device, make it default, then OK. USB Audio Device (Alsa Mixer) , NOT bcm2835 ALSA (Alsa Mixer) Method 2: VLC Media Player > Top Menu > Audio > Audio Device You will see a long list 30+ audio devices. Select the following as
default: USB Audio Device USB Audio Default Audio Device Tips If you select USB audio in Raspberry Config, but then BCM something in
VLC Player, or vice versa, Rpi might become crazy. So the best thing
to do is select USB in both config menus . |
Answer the following technical question about Raspberry Pi. | Title: How to install Jasper on Raspberry Pi 3 (Model B)?
Body: Sorry ahead of time, I'm new to Raspberry Pi's. I am trying to install Jasper by using its guide ( https://jasperproject.github.io/documentation/installation/ ), but I cannot seem to figure it out. In the guide, it says to image the SD card with their .img file, so I did and I put the card on the Pi and it didn't start. So I thought it was something like maybe I'm suppose to wipe the SD card, install NOOBS, put it on the Pi, install Raspbian then image the Jasper file to one of the partitions that was created upon starting up the Pi with NOOBS, but that just made the Pi not boot up when I put the SD card in with a partition imaged. I don't know whether I am supposed to image a particular partition or what I should do. Any help is greatly appreciated, cheers! | You may try to install Jasper manually. Here is a short summary (for more details see Method 3: Manual Installation )
: Install and configure Raspbian as usual Clone Jasper Github repo and install/configure Jasper Install and configure dependencies for TTS engine But as Milliways said this link is obsolete and Jasper seems not under active development anymore (last commit was from January 2017) You may want to use an alternative like Kalliope . It aims to be a personal assistant with a similar concept like Alexa Skills. |
Answer the following technical question about Raspberry Pi. | Title: Can you use the Raspberry Pi 4 B to control 1 or more Raspberry Pi Zero's?
Body: My project is going to use Pi 4 to connect to 1 or 2 Pi Zeros. I would want the Pi 4 to control the Pi Zeros. Would that work? Also I am going to connect the Pi 4 to the Ethernet. Also would the Pi 4 link the Pi Zero to the internet? I will probaly use this for a Minecraft server with BungeeCord. I would prefer Raspbian Lite to use. Any suggestions or ideas would be great. | All of your raspberries will be connected to the same network, so in fact you could use a master to drive the other one distributing tasks. This could be achieved by SSH communications.
You should also take a look and force IP to your raspberries on your internet provider box.
I mean you can configure your internet router, to give your raspberries fixed IP, which will ne necessary if your want your raspberry network to be reboot resistant.
You may find theses configurations under DHCP Server (on your router). Anyway, what you are trying to achieve may be close to what is called Raspberry cluster , you will encounter the same issues so take a look at some tutorials Raspberry cluster tutorial |
Answer the following technical question about Raspberry Pi. | Title: whats the difference between includes from /usr/include/arm-linux-gnueabihf/sys and /usr/include/arm-linux-gnueabihf/bits
Body: I have a hard time to resolve a problem with time.h includes and I noticed that there are two include directories with some overlapping header files:
/usr/include/arm-linux-gnueabihf/sys and
/usr/include/arm-linux-gnueabihf/bits what is the difference, when I need to use ..../bits and when ..../sys? | when I need to use ..../bits and when ..../sys Neither. Just use: #include <time.h> This will source /usr/include/time.h , which sources the bits one directly, and probably indirectly sources the sys one too. In any case, the standard C time functions are declared in the toplevel header and for predictable results, stick with that. The purpose of this hierarchy is that /usr/include/time.h can be the same regardless of hardware architecture, and the implementation specific bits are further down so user code does not have to be concerned with them. This is part of what makes C a high level portable language. |
Answer the following technical question about Raspberry Pi. | Title: Raspberry 4 usbmount not working
Body: As the title suggests, I am having issues on the new raspberry pi 4 with buster and USBMOUNT. Well, it's not working. At 3b+ there was a similar issue, you had to edit a file and change MountFlags from slave to shared. Well there isn't a MountFlags setting in the systemd-udevd.service file, but no matter what, I added it but still not working. Any ideas or an alternative to usbmount for a headless setup, keeping in mind that not always the usb stick is mounted and ofcourse it's not always the same stick with the same label all the time. My dmesg: I plug the stick somewhere here
[ 41.511528] usb 1-1.2: new high-speed USB device number 8 using xhci_hcd
[ 41.647482] usb 1-1.2: New USB device found, idVendor=26bd, idProduct=9917, bcdDevice= 1.00
[ 41.647497] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 41.647509] usb 1-1.2: Product: SecureLock
[ 41.647521] usb 1-1.2: Manufacturer:
[ 41.647532] usb 1-1.2: SerialNumber: 0700413066DDE445
[ 41.649386] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[ 41.661890] scsi host0: usb-storage 1-1.2:1.0
[ 42.733384] scsi 0:0:0:0: Direct-Access SecureLock PMAP PQ: 0 ANSI: 4
[ 42.734206] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 43.843400] sd 0:0:0:0: [sda] 15124992 512-byte logical blocks: (7.74 GB/7.21 GiB)
[ 43.843621] sd 0:0:0:0: [sda] Write Protect is off
[ 43.843636] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[ 43.843866] sd 0:0:0:0: [sda] No Caching mode page found
[ 43.843879] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 43.866878] sda: sda1 and my df -h Filesystem Size Used Avail Use% Mounted on
/dev/root 3.0G 1.4G 1.5G 48% /
devtmpfs 334M 0 334M 0% /dev
tmpfs 463M 0 463M 0% /dev/shm
tmpfs 463M 6.3M 457M 2% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 463M 0 463M 0% /sys/fs/cgroup
tmpfs 100M 8.0K 100M 1% /var/log
tmpfs 30M 0 30M 0% /var/tmp
tmpfs 100M 4.0K 100M 1% /tmp
tmpfs 20M 956K 20M 5% /run/samba
tmpfs 20M 1.3M 19M 7% /var/cache/samba
tmpfs 30M 0 30M 0% /tmp/mqueue
/dev/mmcblk0p1 253M 40M 213M 16% /boot
/dev/mmcblk0p3 438M 4.6M 406M 2% /home
tmpfs 93M 0 93M 0% /run/user/0 Finally, my fdisk -l Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 532480 524289 256M c W95 FAT32 (LBA)
/dev/mmcblk0p2 540672 6832127 6291456 3G 83 Linux
/dev/mmcblk0p3 6832128 7774207 942080 460M 83 Linux
Disk /dev/sda: 7.2 GiB, 7743995904 bytes, 15124992 sectors
Disk model: SecureLock
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7fb5e9d8
Device Boot Start End Sectors Size Id Type
/dev/sda1 8064 15124991 15116928 7.2G c W95 FAT32 (LBA) This setup is working on a raspberry pi 2, pi 3b (jessie), pi 3b+ (stretch) | I faced the same issue with Raspberry Pi 4 and Raspbian Buster, the solution for me was to modify the following file: /lib/systemd/system/systemd-udevd.service You will see a line like this (I call this Before): PrivateMounts=yes Change this line to this (I call this After): PrivateMounts=no Then I rebooted and it was OK ;) |
Answer the following technical question about Raspberry Pi. | Title: How to send video on remote web server using Raspberry Pi and camera module?
Body: I want to create an IoT device that capture the video and send it to a remote web server via Internet. I don't want to create a webserver inside raspberry pi and access it in other devices like smart phones but rather the Pi based IoT device should send the video to remote server i.e. AWS or any other server and than allow users to access video from these server via App. So how to achieve it? Many tutorials like this describe a method of creating a web server inside raspberry pi to access video, but I don't want to use this method. | You can use python and HTTP POST for non-live stream , you can see an example of python code here . But many other solutions exists with another protocols or languages. |
Answer the following technical question about Raspberry Pi. | Title: What's the RPi camera board called (internally)?
Body: I connected a Rpi-camera board to the camera socket on my RPi (not a usb webcam). I have been searching the internet on how to call the camera in Python.
The camera works ( raspistill and raspivid both work). To be more specific, I'm using the qr-tools library and I'm trying to use the decode_webcam function. decode_webcam(self, callback=lambda s:None, device='/dev/video0') When using /dev/video0 , I get errors saying the device was not found. So what do I fill in after device= ? Thanks! | There are now a couple of V4L drivers for the Pi's camera module including an official one ; using such a driver should cause the camera module to show up as /dev/video0 (though you may find you need to fiddle with some settings using v4l2-ctl , as per the linked forum thread). |
Answer the following technical question about Raspberry Pi. | Title: Can't SSH into Raspberry Pi 3b+ from Windows 10
Body: I am unable to ssh into my raspberry pi 3b+ from Windows 10. I was able to up until yesterday evening. Not sure how to troubleshoot at this point. I am able to SSH into the pi from a virtual machine running ubuntu. I'm able to ping the pi from the windows machine and am able to ping the windows machine from the pi. PuTTY and PowerShell both report Connection timed out when attempting to ssh to the pi. My pi is at IP 192.168.1.69 and the windows machine is at 192.168.1.80. Running ssh -vvv pi@192.168.1.69 from windows results in the following: OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4
debug3: Failed to open file:C:\\Users\\aceda/.ssh/config error:2
debug3: Failed to open file:C:\\ProgramData\\ssh/ssh_config error:2
debug2: resolving "192.168.1.69" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 192.168.1.69 [192.168.1.69] port 22.
debug3: finish_connect - ERROR: async io completed with error: 10060, io:0000025506CC9EC0
debug1: connect to address 192.168.1.69 port 22: Connection timed out
ssh: connect to host 192.168.1.69 port 22: Connection timed out I searched around for help with the finish_connect - ERROR: async io completed with error: 10060 error above but couldn't find much that helped me. I'm looking for help on how to determine what is occurring on the pi that is blocking my windows machine from connecting to it. | I finally figure out what the issue was - fail2ban banned my IP. $ sudo iptables -L f2b-sshd -v -n --line-numbers [13:34:09]
Chain f2b-sshd (1 references)
num pkts bytes target prot opt in out source destination
1 44 2288 REJECT all -- * * 192.168.1.80 0.0.0.0/0 reject-with icmp-port-unreachable Removing that entries from iptables resolve my issue. sudo iptables -D f2b-sshd 1 |
Answer the following technical question about Raspberry Pi. | Title: Cannot connect to RasPi by SSH with WiFi interface only
Body: I'm observing really annoying issues with connectivity to RasPi on WiFi network. I have device connected on both LAN cable and WiFi. If both cable and WiFi dongle are plugged - both interfaces are working fine and I'm able to connect to RasPi through IP addresses of both interfaces. However, when I unplug the LAN cable - after restart - RasPi becomes unavailable by SSH.
If I unplug - till restart - device is still fully available via WiFi interface through SSH! After restart - it cannot be accessed any more. Here are my settings:
/etc/network/interfaces auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1
network={
ssid="linksys"
scan_ssid=1
mode=0
proto=WPA2
auth_alg=OPEN
pairwise=CCMP
group=TKIP
key_mgmt=WPA-PSK
psk="xxx-password-here"
id_str="raspberrypi-wif"
priority=1
} Please, help to identify the reason of the issue. | Check to make sure your SSH config is set to listen on all interfaces.
This will ensure that if the system boots and only WiFi is available, it will listen on the WiFi interface. I suspect this is ok based on your above description, but it is worth checking anyway. The other thing I would do is watch the boot process via a monitor (if possible, or via dmesg and logs after the fact), to check if the wireless interface is actually available before SSH tries to start. Depending on your wireless device, it may not be initialized or available at the time the SSH daemon is starting, which causes SSH to fail, and therefore no access to the Pi via SSH after a reboot with wireless only. |
Answer the following technical question about Raspberry Pi. | Title: Would it be possible to set up a security system like the one in jurassic park?
Body: Would it be possible to set up a security system like the one in jurassic park (the book) using raspberry pi's? If so, how much time would it take, and how much would it cost? Using python as the language. (I'm not 100% sure this is the right site to ask this question. If so, please direct/migrate me to the correct one so I can ask it there) | Question Is it possible to use Rpi and python to build a Jurassic Park security
system? Answer Yes, I guess we would need 1,000 Rpi4, and 2,000 sensors and actuators. But python is not enough, we need other languages like NodeRed which is more suitable for event driven, and web design etc. Perhaps the OP can propose a scaled down version with 2 cages and 4
baby dinosaurs. |
Answer the following technical question about Raspberry Pi. | Title: Powering a raspberry pi 4 using a micro usb power supply with adapters
Body: I previously owned a raspberry pi model 3b+ and have purchased a new raspberry pi 4b (4 gigabyte ram). I have an official micro USB power supply and some micro USB to USB type C converters designed to allow you to use old charging cables/accessories with modern smartphones. I would like to know whether I can use the old power supply with the new board using these adapters? I also won't be able to test this as it hasn't arrived in the post yet. | I have used a micro USB to USB C adapter to power my Pi4B. I used a 2 amp 5V wall-wart to provide the power. Please be aware that I only use my Pi's headless so my current requirements may be less than yours. I am currently powering the Pi4B via the 5V and ground pins on the expansion header (using a 5V UBEC powered from a 12V laptop PSU). |
Answer the following technical question about Raspberry Pi. | Title: C Raspberry Pi Zero w, read out button matrix
Body: I have trouble reading out an button matrix with my raspberry pi zero w . I am using pigpio for reading out the gpios, but I don't think this is a software issue. This is my source code: #include <stdio.h>
#include <pigpio.h>
#include <unistd.h>
int main() {
// 2, 3, 4, 14, 15, 18, 17
int gpio_colums[] = {15, 18, 17};
int gpio_rows[] = {2, 3, 4, 14};
if (gpioInitialise() < 0) {
fprintf(stderr, "pigpio initialisation failed\n");
return -1;
}
for (int i = 0; i < 3; i++) {
gpioSetMode(gpio_colums[i], PI_OUTPUT);
}
for (int i = 0; i < 4; i++) {
gpioSetMode(gpio_rows[i], PI_INPUT);
gpioSetPullUpDown(gpio_rows[i], PI_PUD_DOWN);
}
while (1) {
// power every colomn
for (int i = 0; i < 3; i++) {
gpioWrite(gpio_colums[i], 1);
// find pressed button
for (int j = 0; j < 4; j++) {
//printf("gpioRead retunrned %d\n", gpioRead(gpio_rows[i]));
if (gpioRead(gpio_rows[j]) == 1) {
printf("column gpio pin %d, row gpio pin %d\n", gpio_colums[i], gpio_rows[j]);
printf("column %d row %d\n", i, j);
usleep(200);
}
}
gpioWrite(gpio_colums[i], 0);
}
}
return 0;
} As ouput i get an endeless output. column 1 row 2 column gpio pin 18, row gpio pin 14 column 1 row 3 column gpio pin 15, row gpio pin 2 column 0 row 0 column gpio pin 15, row gpio pin 3 column 0 row 1 column gpio pin 15, row gpio pin 4 column 0 row 2 column gpio pin 15, row gpio pin 14 column 0 row 3 column gpio pin 18, row gpio pin 2 column 1 row 0 column gpio pin 18, row gpio pin 3 column 1 row 1 column gpio pin 18, row gpio pin 4 column 1 row 2 column gpio pin 18, row gpio pin 14 column 1 row 3 column gpio pin 15, row gpio pin 2 column 0 row 0 column gpio pin 15, row gpio pin 3 column 0 row 1 column gpio pin 15, row gpio pin 4 column 0 row 2 and so on ... This is the button matrix i am using: I conneted it from left to right with the gpio pins 2, 3, 4, 14, 15, 18, 17. I checked for electrical continuity and the button matrix and found with the folloring result. Button matrix pins (from 0 to 6) continuity if button pressed: Afer the '|' are the gpios that should be active 0 + 6 = '3' | 2 + 17 1 + 6 = '6' | 3 + 17 2 + 6 = '9' | 4 + 17 3 + 6 = '#' | 14 + 17 0 + 5 = '2' | 2 + 18 1 + 5 = '5' | 3 + 18 2 + 5 = '8' | 4 + 18 3 + 5 = '0' | 14 + 18 0 + 4 = '1' | 2 + 15 1 + 4 = '4' | 3 + 15 2 + 4 = '7' | 4 + 15 3 + 4 = '*' | 14 + 15 To compile the source gcc -o key main.c -lpigpio -lrt -lpthread What am i doing wrong? Thx for your help. | I fixed it by using configuring the gpios as pullups instead of pulldowns.
The api didn't return an error, but it seams like is not possible to configure the used pins as pulldown.
To avoid short circuit if two buttons are pressed at the same time I also had to set the not used OUTPUT gpio pins to inputs. This is my working code example: #include <stdio.h>
#include <pigpio.h>
#include <unistd.h>
int main() {
// 2, 3, 4, 14, 15, 18, 17
int gpio_colums[] = {15, 18, 17};
int gpio_rows[] = {2, 3, 4, 14};
if (gpioInitialise() < 0) {
fprintf(stderr, "pigpio initialisation failed\n");
return -1;
}
for (int i = 0; i < 3; i++) {
gpioSetMode(gpio_colums[i], PI_INPUT);
gpioSetPullUpDown(gpio_colums[i], PI_PUD_UP);
}
for (int i = 0; i < 4; i++) {
gpioSetMode(gpio_rows[i], PI_INPUT);
if (gpioSetPullUpDown(gpio_rows[i], PI_PUD_UP) < 0) {
fprintf(stderr, "pigpio initialisation failed\n");
return -1;
}
}
while (1) {
// power every colomn
for (int i = 0; i < 3; i++) {
gpioSetMode(gpio_colums[i], PI_OUTPUT);
gpioWrite(gpio_colums[i], 0);
usleep(10); // give the electronic components a bit time
// find pressed button
for (int j = 0; j < 4; j++) {
//printf("gpioRead retunrned %d\n", gpioRead(gpio_rows[i]));
if (gpioRead(gpio_rows[j]) == 0) {
printf("column gpio pin %d, row gpio pin %d\n", gpio_colums[i], gpio_rows[j]);
printf("column %d row %d\n", i, j);
usleep(200000);
}
}
gpioWrite(gpio_colums[i], 1);
gpioSetMode(gpio_colums[i], PI_INPUT);
}
usleep(10000);
}
return 0;
} Hope will help somebody. |
Answer the following technical question about Raspberry Pi. | Title: Force audio output to USB for Alarm Clock
Body: I tried to force audio to audio jack with amixer cset numid=3 1 or using the raspi-config which works for other applications like audacity, vlc and other multimedia software except for the alarm clock alarm-clock-applet https://github.com/joh/alarm-clock , Which I am using for a project. I tried removing pulseaudio to avoid conflict but yet no success. The alarm clock plays audio only via HDMI. I am using the new Raspian Buster. The Alarm Clock do not work properly on previous Raspbian. I need help to get audio out via USB Audio PnP Sound Device or default audio jack. If it will be possible to modify the settings of the App which I am still trying to find out how. | I decided to play the audio out for the mean time using VLC Media Player by adding this custom command vlc --vout none /path/to/alarm.mp3 on the Alert Start Application Box. Which works very well while I keep trying the default to see what went wrong. |
Answer the following technical question about Raspberry Pi. | Title: ssh raspberrypi.local not resolving in OSX
Body: Until recently ssh pi@raspberypi.local worked as would one expect it to normally. However within the last few days it no longer returns anything and will just sit forever until killed manually. The pi in question is ping-able and can be accessed via the IP returned by pinging it. Furthermore, changing the hostname of the pi to anything else causes ssh pi@newname.local to work just fine. The scope of the issue appears to be limited just to the raspberrypi.local hostname. I've examined my /etc/hosts file as well as removed anything related in known_hosts (via ssh-keygen -R raspberrypi.local ), but the issue persists. Can anyone advise? | It appears the issue was central to fish for some reason. Moving to bash caused ssh to work as expected. Returning to fish and typing out ssh pi@raspberrypi.local in full caused everything to work correctly; no idea why. Best guess is that something was wonky in the stored smart command stuff fish does. |
Answer the following technical question about Raspberry Pi. | Title: Using a Raspberry Pi to connect to a Public Hotspot
Body: Is there a way to use a Raspberry Pi to take a (public) WiFi Signal and create a hotspot such that devices can connect wirelessly to the internet via the Pi? Moreover, can this be done if a network has no password set but requires a user to login with credentials? The use of this would be to create an access point for multiple devices if a login to a network would have to be acquired separately. | Setting up an Access point as WiFi router/repeater is not a problem. The problem is the user to login with credentials. I suppose this is done with the internet browser on a login page. You can script this login but there is no standard login procedure. Every site has its own procedure so you have to script every login separately. And it is not a simple task to script it. You have to analyze the html GETs and PUTs and send the expected pages with login data. Or you use a "browser emulator" that can handle dialogs automatically in a human way. |
Answer the following technical question about Raspberry Pi. | Title: Convert 12V to 5V to power RaspberryPi
Body: I have an Eleksmaker laser cutter which has a board with a 12V output (see top of image). I would like to power my RaspberryPi using this 12V output. What is the advantage of powering the RaspberryPi over microUSB instead of hooking 5V onto the GPIO pins? Though I can easily cut a microUSB cable in two and attach the wires, how can I reduce the voltage from 12V to 5V? What other things should I be concerned with, or would I need to verify, before trying this out reasonably safely? | I use buck converters that convert 12VDC to 5VDC to power most of my raspberry pi computers. There are many available but be sure to check the amperage output. Most come with a USB A 5VDC output and that way you can use the microUSB for power thus having fuse protection My RPi Zero computers for my weather station as well as my RPi3B+ camera are all powered this way. |
Answer the following technical question about Raspberry Pi. | Title: how does the Raspberry Pi PoE shield work?
Body: I would like to do PoE for some Pies, but I dont like the real-estate the PoE hat takes up. what exactly is required for the PoE to work? what pins must I use on the raspberry PI, and what does the PoE hat do?
An electronic schematic would be nice. I saw the mechanical drawing of the PoE hat, its pretty vague. my guess is that PoE comes in at ~48VDC, and that gets converted to +5VDC, with maybe some noise filtering. But is that all? what are the 4 POE pins on the raspberry PI? | Here's a schematic you could use as a reference: X2 is wired in so-called passive mode which uses the pinout of 802.3af mode B - DC plus on pins 4 and 5 and DC minus on 7 and 8. These are available on RPi PoE header as TR2_TAP and TR3_TAP respectively: The supply is expected to provide power without any negotiation. The project page provides an example of such a power injector if you wonder how to build one: Make sure you read and understand all the warnings regarding passive PoE injectors. In short, don't plug your PoE cable into sockets which don't need to be powered, as that may result in damage. Also note that the MC34063A chip used in the schematic is rated at 1.5A output current, so you should use a beefier one (NCV891330?) if your target is to power an RPi 4. |
Answer the following technical question about Raspberry Pi. | Title: how to play audio from python on Raspbian Stretch Lite?
Body: I would like to play selected audio files through the built-in audio port on a Raspberry 3 that is running Raspbian Stretch Lite, from a python program. Unfortunately, none of the libraries or external applications that I have tried for this purpose work. sudo pip install pygame results in Unable to run "sdl-config". Please make sure a development version of
SDL is installed. and pip install sdl fails with Could not find a version that satisfies the requirement sdl (from
versions: ) No matching distribution found for sdl mplayer won’t install. mpg321 comes closest, installing but then failing when used, with ALSA lib errors, and you can’t install a new version of alas-utils because Could not find a version that satisfies the requirement alsa-utils
(from versions: ) No matching distribution found for alsa-utils What do people do to play music on this OS? | I have just tested it with two favorite programs: omxplayer and mpv . I used a fresh flashed up to date Raspbian Buster Lite but it shouldn't make a difference to Raspbian Stretch Lite. Playing music with this programs works out of the box without an modifications. For testing first I plugged in a simple earphone into the analog audio output plug of my Raspberry Pi 4B. Then downloaded a test mp3 file from Sample .mp3 download . I selected the smallest one: rpi ~$ curl https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3 > file_example_MP3_700KB.mp3 Then installed omxplayer : rpi ~$ sudo apt install omxplayer and played the test file: rpi ~$ omxplayer file_example_MP3_700KB.mp3 Same with mpv : rpi ~$ sudo apt install mpv
rpi ~$ mpv file_example_MP3_700KB.mp3 I would prefer omxplayer because it is lighter than mpv and explicitly supports the hardware acceleration of the Raspberry Pi. Now play it from python3: rpi ~$ python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.system('/usr/bin/omxplayer /home/pi/file_example_MP3_700KB.mp3') or playing it in the background: >>> import subprocess
>>> subprocess.Popen(['/usr/bin/omxplayer', '/home/pi/file_example_MP3_700KB.mp3'])
exit()
rpi ~$ # exit from python3 but still playing You may have a look at an omxplayer-wrapper. Look at google with python omxplayer-wrapper . |
Answer the following technical question about Raspberry Pi. | Title: GPIO generate 38KHz carrier frequency , understand duty cycle
Body: I try to understand how to generate IR carrier frequency with the raspberry and how PWM and NEC work visually. I learn PWM but I cannot find any explication of duty cycle. Ok it's a percentage of HIGH state on 1 cycle or 1 period or 1Hz ... But what is the require duty-cycle for IR LED and what is related to ? I have create this picture : I have also read this dicussion : Notes-on:-Pulse-Width-Modulation-(PWM) , control-hardware-pwm-frequency and driving-pwm-output-frequency I have written a script capable to find GPIO PWMC and PWMR configuration values, then the output of my script is: Enter the frequency in Hz : 38000
Enter the tolerance in % : .1
Tolerance: 0.1% (38 Hz)
PWMC:5, PWMR:101, PWM_RESOLUTION:0.3 us/unit, PWM_PERIOD:26.3 us, PWM_FREQ:38019.8 Hz DIFF:+19.8 Hz
PWMC:101, PWMR:5, PWM_RESOLUTION:5.3 us/unit, PWM_PERIOD:26.3 us, PWM_FREQ:38019.8 Hz DIFF:+19.8 Hz
PWMC:505, PWMR:1, PWM_RESOLUTION:26.3 us/unit, PWM_PERIOD:26.3 us, PWM_FREQ:38019.8 Hz DIFF:+19.8 Hz PWMC must be only an predefined even number ? (
In this case my script is wrong)
The nearest divider for a 38KHz carrier seems to be BCM2835_PWM_CLOCK_DIVIDER_512 = 512, /*!< 512 = 37.5kHz */ | A 38 KHz PWM carrier has 38000 cycles per second. Each cycle takes 1 million / 38 thousand microseconds, so approximately 26 microseconds per cycle. The dutycycle is the percentage time the PWM signal is high per cycle. Infrared devices use mark space PWM rather than balanced PWM. All you need to know is that mark space means the signal goes from high to low just once per cycle. For infrared signals I tend to use 50% dutycycle, so on for 13 µs then off for 13 µs. Commercial devices (i.e. remote controls) tend to use something like 30% dutycycle, so on for 8 µs, off for 18 µs. They only do that to save power so I'd stick to 50%. |
Answer the following technical question about Raspberry Pi. | Title: Raspberry shutsdown after boot
Body: I just got my first RPi, and installed NOOBS on an SD card etc etc. Followed the official guide and all went fine and Raspbian was installed then it shutdown. So I removed the power plug, waited a while and inserted it again. Now when it boots for a brief second I see the splash screen, then it goes to a white background with the RPi logo and "hold shift for recovery mode" then shuts down very fast. Sometimes I can hold shift and go to the install screen, sometimes it shuts down too fast. Edit: I'm using a brand new 5V = 1A charger, and tried 3 more before buying the new one. So the power shouldn't be the issue. | hustlerinc found his answer thanks to my mentioning of the issue with certain SD cards with NOOBS 1.3 Quote: RPi Awesomeness Another thing, what version of NOOBS are you using and what SD card? If you are using the newest (NOOBS 1.3) there is a known issue with a certain brand of SD cards. He asked me to post as answer, so here it is. Glad to help! |
Answer the following technical question about Raspberry Pi. | Title: 1-wire device not detected
Body: I'm having trouble getting a 1-wire sensor to be detected on my Raspberry Pi Model 3 B+. The sensor is this temperature and humidity sensor . I have wired the red wire to 3.3V, the black wire to ground and the yellow wire to GPIO4 (physical pin 7). I have also connected a 4.7k resistor from 3.3V to GPIO4 . I have enabled 1-wire in raspi-config, and my /boot/config.txt has the dtoverlay=w1-gpio line enabled (uncommented). The kernel modules seem to be loaded correctly: pi@raspberrypi:~ $ lsmod | grep w1
w1_gpio 16384 0
wire 45056 1 w1_gpio I'm running Raspbian 9 (Stretch) and my kernel version is: pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.42-v7+ #1219 SMP Tue May 14 21:20:58 BST 2019 armv7l GNU/Linux My pin configuration is: pi@raspberrypi:~ $ gpio readall
+-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | ALT0 | 1 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | ALT0 | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 0 | IN | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | IN | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 1 | IN | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | OUT | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 1 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+ However, no devices get detected: pi@raspberrypi:/sys/bus/w1/devices $ ls -la
total 0
drwxr-xr-x 2 root root 0 Jul 8 13:23 .
drwxr-xr-x 4 root root 0 Jul 8 13:03 ..
lrwxrwxrwx 1 root root 0 Jul 8 13:23 w1_bus_master1 -> ../../../devices/w1_bus_master1
pi@raspberrypi:/sys/bus/w1/devices/w1_bus_master1 $ cat w1_master_slaves
not found. I have scoped the line on GPIO4 and I do get the initial low going pulse followed by data, as expected : Does anyone have any idea what I can try next? Or what might be going wrong? | I doubt that is a 1-wire (Dallas) bus device. If it's manufactured by Aosong it's much more likely to use their one wire protocol (as used in their DHTxx series of temperature and humidity sensors). The Chinese datasheet confirms it uses the 40-bit Aosong one wire format (you can cut&paste the Chinese glyphs into Google translate). Either disable the 1-wire bus on GPIO 4 or connect the device data pin (and pull-up to 3V3) to a different GPIO. Then run some DHTxx software on that GPIO. I would suggest you try my software which auto detects the common types of DHTxx. http://abyz.me.uk/rpi/pigpio/examples.html#pdif2_DHTXXD TO BUILD gcc -Wall -pthread -o DHTXXD test_DHTXXD.c DHTXXD.c -lpigpiod_if2 TO RUN sudo pigpiod # start the pigpio daemon
./DHTXXD -g17 # one reading from DHT connected to GPIO 17
./DHTXXD -g14 -i3 # read DHT connected to GPIO 14 every 3 seconds |
Answer the following technical question about Raspberry Pi. | Title: Play multiple mp3 files
Body: I need to be able to play up to 8 mp3 files at the same time. Is this possible with the raspberry pi 3b+? They need to be started in python code. | Based on my answer here : The test is done on a Pi Zero with a recent Raspbian, Python 3.6, vlc (along with approx. 150 other packages), and it's Python-bindings. It's using a USB soundcard and alsa . Playing from Python worked straight forward: import vlc
instance = vlc.Instance('--aout=alsa')
p = instance.media_player_new()
m = instance.media_new('something.mp3')
p.set_media(m)
p.play()
p.pause()
vlc.libvlc_audio_set_volume(p, volume) # volume 0..100 I was able to run four independent mp3's from a single Python process with a CPU load of about 87%. Starting a fifth player resulted in this error: alsa audio output error: cannot estimate delay: Broken pipe Given the more powerful CPU of the Pi 3B+ and its four cores I dare say it'll work. Use multiprocessing though to allow for the distribution of the load to more than one core. Further reading: LibVLC API documentation of module vlc |
Answer the following technical question about Raspberry Pi. | Title: Piscope resolution
Body: I generate a carrier frequency at 38KHz and I see the output LIVE in the piscope, but the "pulse widths" are not perfect ... the pulses are more or less wide when they must all have the same width.
It is a problem of screen resolution due to a big zoom or something like that? The period is apparently rounded (because axys time is rounded). The period 38KHz is 26.3us, I see 27us for some pulses which is very very close ... but where do these imperfections come from please ? It can be a bad configuration of my carrier ? | You have to consider the pigpio sampling rate. By default pigpio samples every 5 µs, so a 26.3 µs square wave might be shown with a duration of 25 µs or 30 µs. The half way point might be 10 µs or 15 µs. If you want to get a better feel look at the time for 10 cycles. 10 cycles = 265 µs. Compare with the same square wave when pigpio is sampling at 1 MHz. The peaks and troughs look much more uniform. 10 cycles = 263 µs. |
Answer the following technical question about Raspberry Pi. | Title: MySQL not starting after powering the Raspberry Pi off
Body: I have a raspberry pi with MySQL installed. I turn off my raspberry Pi by unplugging the power (no system shutdown). At some points the MySQL get infected, and after that it will never turn on again. it gives me this error on startup checking for tables which need an upgrade are corrupt or were not closed cleanly how can I fix that without "system shutdown" is there any query I can run to prevent this or is there any better alternative to MySQL (maybe a light version!) ? thank you | how can I fix that without "system shutdown" You cannot. is there any... No, there isn't. No operating system in the world is designed to absorb having the cord pulled without a shutdown. If you keep doing this, you will find db corruption is only one of a wide range of possible problems. The purpose of software like MySQL is to provide high performance access to a database. To do that, the software must manage state, and part of that is cleanly shutting down. Software is not magical , it follows logical principles, and it cannot predict an arbitrary power outage. You could do that just for MySQL with: `service mysql stop` But in this case you might as well just use shutdown now because that will A) stop mysql for you, B) also take care of all those other potential problems. 1 It takes <2 seconds. So to be clear: You CANNOT manage the system by just yanking the power cord. You MUST shut it down properly. There is no advice, blog, or tutorial about any alternative to this because there CANNOT be any. It is not possible. Period. Do not waste your time trying to make 2 + 2 = 5. 1 Preventing db corruption will be an academic exercise if something more essential is corrupted and the system then fails to boot. |
Answer the following technical question about Raspberry Pi. | Title: Updating python code with usb
Body: I have a folder in the pi/home directory with python code. Is there a way to update (replace) these files by using one of the usb ports? I would like to be able to plug in the usb, reboot the pi, if there is a usb drive on boot, copy and replace the files in pi/home folder with the ones on the usb then automatically power back down. | Yes, you can. First configure your Raspberry Pi to auto-mount USB Storage Devices (guide here ). Then create a script that checks the folders under /media/ where the mounted USB stick would be. If it finds your scripts, replace the old ones with the new ones. Configure your script to run at boot by editing your /etc/rc.local (guide here ) |
Answer the following technical question about Raspberry Pi. | Title: are the Zero and Zero W software compatible?
Body: I'm having problems on a brand new Zero, I prepared the SD on a Zero W to install updates and other via internet, I disabled bluetooth and I left wifi enebled in case I'll need to change something on the SD using the Zero W headless. on the Zero W all works like a charm but when I move the SD on the Zero it freezes. so: 1 ) are the Zero and Zero W software compatible? 2 ) or do I need to disable both blueetooth and wifi to make it work on the Zero? 3 ) or maybe my Zero is faulty? 4 ) otherwhise how can I set up a Zero without internet connection, download updates from another computer and then move them to the Zero using an USB stick would be annoying UPDATE I formatted the SD card using SD Card Formatter then I wrote on it the 2019-04-08-raspbian-stretch-lite image, I changed config.txt and cmdline.txt as described here for gadget mode, when I booted the 1st time it got stuck on: after 5min it rebooted and then got stucked on: after 2min it rebooted and then got stucked on: touching it I almost burned myself for how hot it was, definitely faulty? | If the OS loads correctly but randomly freezes, there might be something wrong with the RPi, but if the boot process gets interrupted, or paused for a very long time without letting you login it most likely means the DHCP server is trying to find the interface in which your Pi was set and thus you may need to boot again on the other Pi and disable wifi, or create a new image using this Pi Zero. |
Answer the following technical question about Raspberry Pi. | Title: Created a Raspberry Pi 3B+ Wireless Hotspot, how can I extend the hotspot via Ethernet
Body: I have successfully created a WiFi hotspot for my RPi 3B+ using a Hologram Nova and the embedded WiFi card on the Pi. However I realized that the ethernet interface has disappeared and cannot extend the hotspot to the Ethernet interface. My setup is a mix of tutorials on how to create a hotspot but the main gist can be found here . I only changed the interface to be taken as the source the ppp0 instead of eth0. Now I find myself needing to use the ethernet interface to plug a device that has no WiFi capabilities but does have the ethernet interface. So my question is, how can I modify my hotspot to allow the dhcp server to serve the ethernet interface as well? I would like it to be dynamic as well so that I could potentially add an ethernet switch for more local devices. Your help would be greatly appreciated! As per your request, I ran: ip --brief link show And when I run ifconfig I get lo, ppp0 and wlan0 but no eth0. Here is a screenshot of my current /etc/network/interfaces file | On your installation you have predictable network interface names enabled so you will not always find classical interface names like eth0 . Your wired interface has the name enxb827eb3f0e89 . Instead of eth0 you have to use this name. If you don't like predictable network interface names you can use sudo raspi-config to disable it with " 2 Network Options -> N3 Network interface names ". If it doesn't help you can edit /boot/cmdline.txt and add net.ifnames=0 to the line. You can use the wired interface name (whatever name do you use) to configure either a routed or bridged interface. I suggest to use a bridge together with the wlan0 interface so all devices on wifi and wired are on the same subnet. I do not use deprecated ifupdown , managed with /etc/network/interfaces , since years so I cannot help much with this setup to create a bridge. I use systemd-networkd and do it this way: How can I set my pi 3 up to be WiFi AND ethernet router simultaneously? . In that setup I think you could just replace usb0 with ppp0 . |
Answer the following technical question about Raspberry Pi. | Title: using serial interface /dev/ttyAMA0 crashes Raspberry Pi
Body: I've disabled console on the GPIO serial interface, lowered the speed to 9600 and had some communications observed with minicom and a simple cat /dev/ttyAMA0 talking to an arduino all ok. Now for some reason the Pi crashed and upon hard reboot if I try to use /dev/ttyAMA0 in any way, eg configure the speed with stty -F /dev/ttyAMA0 9600 or cat /dev/ttyAMA0 the Pi crashes immediately and requires the power reconnected to get it running again. Voltage level conversion between rPi 3.3v & Arduino 5v was carried out with a MOSFET 2N7000 based design explained here: http://www.fritz-hut.com/connecting-an-arduino-and-raspberry-pi/ Any suggestions as I'm stumped with this one. | Ok, well no answers here but thought I'd update it anyway. problem has resolved itself since I upgraded the raspberry pi. I'm really not sure what the cause was but it's no longer a problem since doing. apt-get update
apt-get upgrade |
Answer the following technical question about Raspberry Pi. | Title: Can I connect RaspberryPi GPIO to Nintendo DS Buttons?
Body: I was wondering if I can connect a Raspberry Pi to the buttons of a Nintendo DS. I have seen something similar on Youtube for the Switch controller. My goal is to control the buttons using a Raspberry Pi. | Indeed you can, if you want something easy to play with the GPIO I suggest you WiringPi, if you already worked on Arduino it's the same thing but on raspberry . If i have well understood you you want to make the raspberry play for you ? Some sort of Rogue player? For doing so you will have to understand the schematic of the button, is it a pull-up or pull-down etc ? Knowing that you will be able to know where you should connect the DS to the RSP. And don't forget to connect both ground. Thus you should keep in mind that the raspberry's GPIO are 3.3V only , so if the DS use 5V you will have to use a logical level converter . |
Answer the following technical question about Raspberry Pi. | Title: RPI3B+: What are the four components below the HDMI connector called?
Body: I am trying to get the following RPI3B+ to work. Apparently the machine is booting ok, since I can see it using nmap on my local network: # nmap 192.168.0.23
Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-09 17:37 CEST
Nmap scan report for 192.168.0.23
Host is up (0.0056s latency).
Not shown: 996 closed ports
PORT STATE SERVICE
111/tcp open rpcbind
139/tcp open netbios-ssn
445/tcp open microsoft-ds
8080/tcp open http-proxy
MAC Address: B8:27:EB:1F:09:2E (Raspberry Pi Foundation) But I get no display, if I zoom right next to HDMI connector here is what I see: One of those four components seems to be sideways. Would that explain why I get nothing on the screen ? Is that even fixable ? | While the official Raspberry schematics don't tell a thing about these components we can learn from the picture of the PCB that they are connected to the paired pins 1 and 3, 4 and 6, 7 and 9, 10 and 12 - that's all the differential signal and clock lines. Since the devices have just four pads (not six) they are not dual-rail clamp ESD protectors, e.g. see here , as these would need to be connected to GND and VCC too. As they are connected to the paired lines of the differential signals these devices are very likely Common Mode Filters to suppress EMI, e.g. see here . This is how they are connected in the differential circuit ( source ). Note that if they are missing or not properly connected the circuit is broken - thus no display is working: And this is how they look - pretty much like the stuff mounted to the Pi - ( source ): Suggested repair: try to resolder the component if you have the equipment and skills to do so. Make sure to not thermally damage the component. Note that high speed TMDS differential signal routing at high frequencies is rather critical. Parasitic loads and asymmetries to the transmission lines may disturb the signals to the point of a failing transmission. |
Answer the following technical question about Raspberry Pi. | Title: Can I drive a custom LED matrix from my Pi
Body: I have an idea for a project, but I am unsure of the best route to take. I am going to create a custom 11x10 LED matrix (addressable LEDs like WS2812) with the intention of lighting up certain LEDs given different input arguments in my code. However, I haven't yet seen a good example of people doing such a thing on Youtube or Instructables etc. This is not a scrolling text banner, but this matrix could be used for such a thing later in life. So far from my research it seems that most people use an Arduino Nano to achieve something like this, and can even power the Nano from the same 12v 4A power supply that the LEDs require. I have also seen of course the small 8x8 matrix that is already on offer, but this is far too small for my purposes. Can anybody advise or point me to any information on if this is possible? I currently have a RPi 3B, but I am wondering if I could get away with using the small ZeroW board to do this. | What you are trying to achieve doesn't take a lot of ressources , so if it is possible on a Arduino nano, it is possible on a Raspberry Zero ( in terms of ressources ) Then, you will have to drive the LEDs from the Raspberry, for that you will have to use GPIO. GPIO can simply, and in an Arduino way be used with WiringPi . It's a library that allow you to use the GPIO on a Raspberry pretty much like on Arduino . So in fact using wiringPi and with a basic understanding of the Raspberry and Linux, you should reach your goal by following any Arduino tutorial and adapting to Raspberry. Thus libraries for Arduino (for adressable LEDs for example are written in C so implementing them on Raspberry shouldn't be that difficult) EDIT : I believe WS2812 are working on 5v, so in fact you could even use the same power supply for your LEDs and for the Raspberry, maybe just adding some capacitors for filtering and decoupling : in order for the Raspberry to have a clean 5V supply . An example of similar project Neo Pixel Library for Raspberry |
Answer the following technical question about Raspberry Pi. | Title: Will this TFT LCD work with the Pi?
Body: I got this screen from Amazon, and I mistook it for having RCA input. Anywhoo, it came today and I was wondering if it will work with the Pi. A whole caboodle of reviews said it did, but I don't know what to do about the adapter. Should I cut the cable and run wires directly, or should I get an adapter? I'm going to ask this over on http://electronics.stackexchange.com as well to see if they know anything. | It looks like you are missing a cable: |
Answer the following technical question about Raspberry Pi. | Title: is there any advantage in using Raspbian Buster instead of Stretch on a Raspberry Pi Zero
Body: I was wondering if are there some real advantages in using Buster on a Raspberry Pi Zero, or I should continue using Stretch | What are you doing with this Pi Zero ? If you're doing some project without connection to internet or just locally ( home automation , etc) I would say no. If no big bug endangering your project has been corrected it may no be worth the time and effort required to put again in place your project. Now, if your Zero is hosting some web server , everything opened to the world it could benefit from kernel updates and other software updates . (Some of them could be patching vulnerability , etc). In short it's down to safety en reliability against the time you will have to invest to update your project to this new OS. |
Answer the following technical question about Raspberry Pi. | Title: Peculiar features of I2C communication between RPi and Arduino
Body: I am currently trying to establish two-way communications between an Arduino Leonardo and a Pi model B using the I2C bus, as slave and master respectively. Spookily, the Pi can successfully send commands to the Arduino, but fails when requesting data from the Arduino. Spcifically, smbus2 throws OSError: [Errno 121] Remote I/O error whenever I call the moisture_read() function. The included water() function has the intended outcome -- the Arduino reacts and alters its pins (more or less) correctly. Arduino Code: #include <Wire.h>
#define SOILPWR 11
#define SOILSIG A0
#define MOTORPWR 5
#define MOTORDTEC A1
#define BUFSIZE 16
#define CHANNEL 0x03
int readMoisture(byte power, word dlay){
analogWrite(SOILPWR,power);
delay(dlay);
int moisture = analogRead(A0);
analogWrite(SOILPWR,0);
return moisture;
}
void motorPulse(byte power, word dlay){
// Motor is active low
analogWrite(MOTORPWR,255-power);
delay(dlay);
analogWrite(MOTORPWR,255);
delay(1000);
}
void setup() {
// put your setup code here, to run once:
pinMode(SOILSIG, INPUT);
pinMode(SOILPWR, OUTPUT);
pinMode(MOTORPWR, OUTPUT);
pinMode(MOTORDTEC, INPUT);
digitalWrite(MOTORPWR, HIGH);
Wire.onReceive(receiveEvent);
Wire.onRequest(requestEvent);
Wire.begin(CHANNEL);
#ifdef DEBUG
Serial.begin(9600);
#endif
}
// BYTE STRUCTURE:
// ['S'][speed][time_LSB][time_HSB]
void receiveEvent(int nbytes){
byte msg[nbytes];
for (int i=0;i<nbytes;i++){
msg[i]=Wire.read();
}
#ifdef DEBUG
Serial.print("Message:");
for (int i=0;i<nbytes;i++){
Serial.print(msg[i]);
Serial.print('\n');
}
Serial.println();
#endif
byte b=msg[0];
if (nbytes >= 4 && b == 'S'){
// S for [S]oak
// look I don't know why it's like this
byte fast = msg[1];
word t = msg[2] + (word) msg[3] << 8;
#ifdef DEBUG
Serial.print("Time: ");
Serial.println(t);
#endif
// Limit watering to 1 minute
t = t < 60000 ? t : 60000;
motorPulse(fast,t);
} else {
#ifdef DEBUG
Serial.println("FAILED");
#endif
}
}
byte sendbuf[BUFSIZE];
// BYTE STRUCTURE
// [soil_LSB][soil_MSB][0][0]
void requestEvent(){
int moisture = readMoisture(255, 200);
sendbuf[0] = moisture&0x0f;
sendbuf[1] = moisture&0xf0;
for (int i=2; i<BUFSIZE;i++){
sendbuf[i]=0x00;
}
Wire.write(sendbuf, 4);
}
void loop() {
delay(100);
} Pi Code: import smbus2
import struct
import time
CHANNEL = 0x03
# Bus number is 1
bus = smbus2.SMBus(1)
def water(speed, time):
req_str = struct.pack('>B',speed)
req_str += struct.pack('<H',1024*time)
bus.write_i2c_block_data(CHANNEL, ord('S'), req_str)
def moisture_read():
# read a block of 4 bytes (offset 0)
res = bus.read_i2c_block_data(CHANNEL, 0, 4)
return struct.unpack('<HBB',res) | For what it's worth, my solution was to work around the problem entirely. I read rumors on other questions that the smbus read_i2c_block_data doesn't actually work, and so I rewrote the code such that the Arduino only ever sends one byte at a time (imitating the behaviour of a register on a basic I2C chip). The final code can be found at https://github.com/Spuriosity1/basilbot . The basic idea was: Store an array of bytes byte buf[16] that contains all relevant data and an index byte idx RPI writes a command to set idx (with range protection for safety) RPI requests from slave, which sends buf[idx] . |
Answer the following technical question about Raspberry Pi. | Title: Building a 'Packet squirrel" using Raspberry Pi
Body: I recently read about hack5s' Packet squirrel , and now I am interested in building a similar device that sits between 2 endpoints (say router and PC) and monitor all the traffic but be invisible to the 2 endpoints. (Figure) I was thinking of using the RPi's ethernet interface as one interface and a USB to ethernet module as the other. Then the RPi could capture the packets in either direction, replace the MAC addresses and IP addresses and forward them. At the same time all transactions will be logged. Could anybody point me in the right direction? Edit: I also found this device ( How to create a Pi Zero packet capturing computer ), but it seems too easy and too good to be true! | To make a man in the middle attacker with a Raspberry Pi 3B(+) or 4B is very simple. You will use an additional USB/ethernet dongle so you have a second wired interface eth1 available. Now just bridge eth0 and eth1 and you have a complete transparent and stealth device. Start with a fresh flashed image Raspberry Pi OS Lite and use systemd-networkd to set it up. Just follow to Use systemd-networkd for general networking . You can use section "♦ Quick Step" . Then come back here. Create these three files to configure the interfaces and the bridge: rpi ~$ sudo -Es # if not already done
rpi ~# cat > /etc/systemd/network/02-br0.netdev << EOF
[NetDev]
Name=br0
Kind=bridge
EOF rpi ~# cat > /etc/systemd/network/04-br0_add-eth.network << EOF
[Match]
Name=eth*
[Network]
Bridge=br0
EOF rpi ~# cat > /etc/systemd/network/12-br0_up.network << EOF
[Match]
Name=br0
#[Network]
#DHCP=yes to use static IP uncomment following and comment DHCP=yes #Address=192.168.50.60/24
#Gateway=192.168.50.1
#DNS=84.200.69.80 1.1.1.1
EOF Reboot. The [Network] section in the last file is all commented. This ensures that the device does not get an ip address and is completely invisible on the network. The bridge will do its work without ip addresses. Just to get updates or to install software you can temporary uncomment [Network] DHCP=yes or the static ip address and do rpi ~$ sudo systemctl daemon-reload
rpi ~$ sudo systemctl restart systemd-networkd.service First you should install rpi ~$ sudo apt install tcpdump Comment the Network, daemon-reload and restart as shown above. Now you can sniff the traffic on the line. Here just a short snippet from visiting google.com assuming your sniffed device has ip address 192.168.10.113: rpi ~$ sudo tcpdump -N -A -i eth1 host 192.168.10.113 21:11:25.080976 IP wq-in-f102.http > titan.46152: Flags [.], ack 75, win 244, options [nop,nop,TS val 1247970405 ecr 10499619], length 0
E..42...l.y.J}.f..
q.P.H6h...+He...........
Jb.e..6#
21:11:25.083929 IP wq-in-f102.http > titan.46152: Flags [P.], seq 1:529, ack 75, win 244, options [nop,nop,TS val 1247970409 ecr 10499619], length 528: HTTP: HTTP/1.1 301 Moved Permanently
E..D2...{.h.J}.f..
q.P.H6h...+He...........
Jb.i..6#HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Wed, 10 Jul 2019 20:11:25 GMT
Expires: Fri, 09 Aug 2019 20:11:25 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML> 21:11:25.084225 IP titan.46152 > wq-in-f102.http: Flags [.], ack 529, win 237, options [nop,nop,TS val 10499624 ecr 1247970409], length 0
E..4~.@.@.....
qJ}.f.H.P.+He6h.............
..6(Jb.i.. You can use nftables to mangle the passing traffic or any other tool. I haven't tried it. That's your exercise :-) The alphabetical order of the file names is important for execution. In man systemd.network in the second paragraph you will find: All configuration files are collectively sorted and processed in lexical order, regardless of the directories in which they live. However, files with identical filenames replace each other. You can use what names you want but you must ensure that a .netdev file is executed before using the bridge name in .network files (ok, systemd will execute it always before .network files). And .network files must have an order. The interfaces must be added to the bridge before bringing up the bridge. I like to use the old style SysV naming for init files with preceded numbers. For me I have reserved 00 to 03 for .netdev, 04 to 07 for wired interfaces, 08 to 11 for wifi interfaces and the rest for others where I use a gap of four numbers to be able to insert additional configuration files. |
Answer the following technical question about Raspberry Pi. | Title: How to implement the push button example using rpio?
Body: Background I am trying to learn how to use the rpio library ( https://github.com/jperkin/node-rpio ) in my nodejs application. What do I want to do So far I have been able to test the blink led example form the documentation, and I was trying to do the push button test ("Poll a button switch for events" as is it called at the documentation). I had copied the content of the example and tried to execute it both when a page loads, to execute it on the server-side through a post request, and tried also in simply executing it when the server starts. Here is the code: rpio.open(15, rpio.INPUT, rpio.PULL_UP);
function pollcb(pin)
{
/*
* Wait for a small period of time to avoid rapid changes which
* can't all be caught with the 1ms polling frequency. If the
* pin is no longer down after the wait then ignore it.
*/
rpio.msleep(20);
if (rpio.read(pin))
return;
console.log('Button pressed on pin P%d', pin);
}
rpio.poll(15, pollcb, rpio.POLL_DOWN); I am using the circuit schematic as shown at the image below: The difference is that I dont have the switch, but I guess that just using wires to simulate the pessing of a button will do it The problem It is not working at all... Everytime when I call the function, my ssh command line gets stuck for 5-10 seconds and then my connection to the raspberry pi is reset, not allowing me to connect to the raspberry again; and then I have to unplug the raspberry to restart it! It is like the whole board collapses when I try to do this approach, which is also concerning me about the fact that I have to shut down my raspberry not in a safe way, what can consequently corrupt my sd card. edit: It looks like that whenever I try to execute the rpio.poll function, it breaks the application and the board. I appreciate any possible help about this issue.. Thank you! | Unfortunately I was not able to put it to work using the rpio.poll function However, I managed to listen to the input pin by using a setInterval() method: function status(){
rpio.open(15, rpio.INPUT, rpio.PULL_UP);
setInterval(function(){
var status = rpio.read(15)
console.log(status)
},1000)
} I did try to listen every second, which was enough for the purpose in which I wanted to work, but if anyone try with a smaller interval, it might work as well. |
Answer the following technical question about Raspberry Pi. | Title: Reading more than 8 bits from an SI7021 sensor
Body: I am using the Si7021-A20 sensor on a Raspberry Pi Zero WH (headless, controlled via ssh and VNC). I want to get readings using Python (version 3). However, I have a very hard time to actually get more than a single byte of data. Here's what I have now (SI7021-test2-doublebyteread-nohold.py): from smbus import SMBus
import time
# Get I2C bus
bus = SMBus(1)
#Measure Relative Humidity, No Hold Master Mode 0xF5
bus.write_byte(0x40, 0xF5)
# SI7021 address, 0x40 Read 2 bytes, Humidity
time.sleep(0.1)
data0 = bus.read_byte(0x40)
time.sleep(0.1)
data1 = bus.read_byte(0x40)
print(data0)
print(data1)
# Convert the data
humidity = ((data0 * 256 + data1) * 125 / 65536.0) - 6
print(humidity) this gives in Thonny (and similar from the command line) ========================= RESTART =========================
>>> %Run SI7021-test2-doublebyteread-nohold.py
104
104
44.9796142578125 44.9 is actually a realistic value, matching another device's reading. Note, that the two bytes are having the same value. This is always the case. If the humidity increases, both value increase to the same value.Now I fail to get that second byte out of the sensor. I tried the "Hold" and "No hold" modes, played with the timings, used smbus2, and also with the I2C blocks like: rh = bus.read_i2c_block_data(0x40, 0xE5, 2) But this gives >>> %Run SI7021-test1-i2c-block.py
Traceback (most recent call last):
File "/home/pi/SI7021-test1-i2c-block.py", line 10, in <module>
rh = bus.read_i2c_block_data(0x40, 0xE5, 2)
OSError: [Errno 5] Input/output error How to get that second byte as valid reading? Note: There are various blog posts, forum threads and other resources, but no I found helped me beyond what I describe here. | Credit for the solution goes to @joan. Key here seems to omit the I2C and SMBus python implementations and query the sensor via the pipgio library. Using @joan's pigpio library and his Si7021.py script I finally got a solution that uses the full resolution. I've written in detail in my blog post about how I used the library and script , but basically you can do it like this in the terminal: # installing pigpio first
sudo apt-get install pigpio python-pigpio python3-pigpio
# get the Si7021.py script
wget http://abyz.me.uk/rpi/pigpio/code/Si7021_py.zip
unzip Si7021_py.zip
# start the pigpiod daemon; -l disables the remote socket interface, it's not needed to read a local sensor
sudo pigpiod -l
# start the main function in the module
python3 Si7021.py |
Answer the following technical question about Raspberry Pi. | Title: Can't connect to the samba server?
Body: I am trying to set up a file sharing server on this here raspberry pi. The pi is running on Raspbian. I have it plugged in to my Google Wi-Fi router via Ethernet. SSH and ping are working fine, but when I try to install samba it is unable to connect to the server. I can connect to the Raspbian samba download server fine on my laptop. Here is the apt-get output (note that I have already run sudo apt-get update ): pi@raspberrypi:~ $ sudo apt-get install samba samba-common-bin
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
attr ibverbs-providers libavahi-client3 libboost-atomic1.67.0
libboost-iostreams1.67.0 libboost-regex1.67.0 libboost-system1.67.0
libboost-thread1.67.0 libcephfs2 libcups2 libgfapi0 libgfrpc0 libgfxdr0
libglusterfs0 libgpgme11 libibverbs1 libjansson4 libldb1 libnspr4 libnss3
libpython2.7 librados2 libtdb1 libtevent0 python-crypto python-dnspython
python-gpg python-ldb python-samba python-talloc python-tdb samba-common
samba-dsdb-modules samba-libs samba-vfs-modules tdb-tools
Suggested packages:
cups-common python-crypto-doc bind9 bind9utils ctdb ldb-tools ntp | chrony
smbldap-tools ufw winbind heimdal-clients
The following NEW packages will be installed:
attr ibverbs-providers libavahi-client3 libboost-atomic1.67.0
libboost-iostreams1.67.0 libboost-regex1.67.0 libboost-system1.67.0
libboost-thread1.67.0 libcephfs2 libcups2 libgfapi0 libgfrpc0 libgfxdr0
libglusterfs0 libgpgme11 libibverbs1 libjansson4 libldb1 libnspr4 libnss3
libpython2.7 librados2 libtdb1 libtevent0 python-crypto python-dnspython
python-gpg python-ldb python-samba python-talloc python-tdb samba
samba-common samba-common-bin samba-dsdb-modules samba-libs
samba-vfs-modules tdb-tools
0 upgraded, 38 newly installed, 0 to remove and 7 not upgraded.
Need to get 8,978 kB/26.8 MB of archives.
After this operation, 101 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Err:1 http://raspbian.raspberrypi.org/raspbian buster/main armhf samba-libs armhf 2:4.9.5+dfsg-4
404 Not Found [IP: 93.93.128.193 80]
Err:2 http://raspbian.raspberrypi.org/raspbian buster/main armhf python-samba armhf 2:4.9.5+dfsg-4
404 Not Found [IP: 93.93.128.193 80]
Err:3 http://raspbian.raspberrypi.org/raspbian buster/main armhf samba-common all 2:4.9.5+dfsg-4
404 Not Found [IP: 93.93.128.193 80]
Err:4 http://raspbian.raspberrypi.org/raspbian buster/main armhf samba-common-bin armhf 2:4.9.5+dfsg-4
404 Not Found [IP: 93.93.128.193 80]
Err:5 http://raspbian.raspberrypi.org/raspbian buster/main armhf samba armhf 2:4.9.5+dfsg-4
404 Not Found [IP: 93.93.128.193 80]
Err:6 http://raspbian.raspberrypi.org/raspbian buster/main armhf samba-dsdb-modules armhf 2:4.9.5+dfsg-4
404 Not Found [IP: 93.93.128.193 80]
Err:7 http://raspbian.raspberrypi.org/raspbian buster/main armhf samba-vfs-modules armhf 2:4.9.5+dfsg-4
404 Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/s/samba/samba-libs_4.9.5+dfsg-4_armhf.deb 404 Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/s/samba/python-samba_4.9.5+dfsg-4_armhf.deb 404 Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/s/samba/samba-common_4.9.5+dfsg-4_all.deb 404 Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/s/samba/samba-common-bin_4.9.5+dfsg-4_armhf.deb 404 Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/s/samba/samba_4.9.5+dfsg-4_armhf.deb 404 Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/s/samba/samba-dsdb-modules_4.9.5+dfsg-4_armhf.deb 404 Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/s/samba/samba-vfs-modules_4.9.5+dfsg-4_armhf.deb 404 Not Found [IP: 93.93.128.193 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? My sources.list looks like this: deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free I uncommented that line and updated still no luck. Update with information from comments: I can successful ping raspbian.raspberrypi.org and also get html data with curl -L http://raspbian.raspberrypi.org/raspbian with one of the first lines <title>Index of /raspbian</title> . | I was getting the same thing and this worked for me. Try running: sudo apt update && sudo apt full-upgrade -y Then install Samba as normal. I got this from here |
Answer the following technical question about Raspberry Pi. | Title: Help in setup for RPi3 for internet connection sharing to eth0 and wlan0 (from eth1)
Body: I have already setup the RPi3 for share my internet connection (from eth1 usb ethernet dongle) to my eth0 (Rpi3 internal ethernet port). The "ASCII diagram" is this: Internet -> Fiber Router (192.168.1.1) -> Rpi3 # eth1 (usb dongle @ 192.168.1.10) -> Rpi3 # eth0 (192.168.0.1) -> switch -> my note (192.168.0.20) It's working and I have all iptables filter working as well. I'm using isc-dhcp-server to make the DHCP server for eth0. It's possible to use the built-in RPi3 Wifi to share, by wlan0 the connection as well?
I thought in Rpi3 wlan0 has the static ip 192.168.0.10 and share the connection the same way, together with the eth0 in the switch. How can I accomplish this? Thanks in advance. | As far as I understand you want to extend your local network with a wifi access point in addition to the wired network and all devices, no matter if they are associated to the access point or connected by wire, should have access to the internet. This can be achieved with a bridge. The wifi interface wlan0 and the wired interface eth0 will become members of the bridge so all devices are on the same subnet. The bridge itself will route all traffic to the internet. You can setup it in two steps: first create the bridge and test it and in a second step you can setup routing between eth1 and the bridge to get the connection to the internet. I have a suggestion using systemd-networkd. How I would setup it you can look at Configuring Raspberry pi as Router, Wifi and Ethernet Bridge . |
Answer the following technical question about Raspberry Pi. | Title: Changing to XFCE from LXDE
Body: Apologies if this seems straight forward but I've recently downloaded XFCE to replace LXDE environment. I did this by using sudo apt-get install xfce4 and following all the instructions. Then to remove LXDE I carried out: sudo apt-get --purge remove lxde
sudo apt-get clean My problem lies that whenever I run startx it still opens and runs LXDE? I know that I should be running startxfce4 but I want to know how to completely remove LXDE? and understand how startx works? Edit: Also how do I modify the startx file so that I can choose (if both are installed) which desktop environment I want startx to run? | I posted this question in the Linux Stack Exchange as well, and a user named Vasa1 suggested to check apt-cache show lxde which listed all the associated packages with lxde, and therefore since lxde is a meta package, I therefore had to delete and remove the other associated packages in order to run startx to boot xfce4. |
Answer the following technical question about Raspberry Pi. | Title: Cannot get installed system to output component video, but NOOBS can
Body: Background: Pi 3 B+ connected to an old tube TV with front composite video connection. I've installed NOOBS on a 32GB microSD card, and am able to successfully boot it, using the keyboard 4 key (NTSC) to display the graphical installer. After the install finishes and the Pi boots, I can no longer get any video to display . I have set sdtv_mode=0 and hdmi_ignore_hotplug=0 in the config.txt on the /boot partition of the SD card. | According to the forum topic posted here , the newest version of Raspbian (Buster) had an option added to support the Pi 4 that broke component video out. Downgrading my Raspbian version and using a bare install solved this issue for me. |
Answer the following technical question about Raspberry Pi. | Title: Using SD card from 3 B+ in 3
Body: I have a SD Card wich works perfectly on my Pi 3 B+ but I want to use it in my other Pi 3 but the Pi doesnt seem to start. Is there something that needs to be changed to use the same Card for both versions? | No rep to comment yet, so this goes as answer. This is generally a bad idea to use the same SD card swapping between devices, as each of them has its own configuration - despite the same system. Devices differ by on-board components id, or even might be different due to newer revision of board. I own 2 rPi 1 B+ and swapping cards is impossible due to errors with boot. |
Answer the following technical question about Raspberry Pi. | Title: Raspberry PI to PC communication
Body: I am thinking of using Raspberry Pi to share Internet from a PC. The Raspberry Pi would have a Wi-Fi module which would be running in AD-HOC mode. The Raspberry Pi would be connected to a PC through a USB cable. The PC is the only device connected to the Internet. I plan to use my laptop to connect to the Pi on AD-HOC. The Pi would route all my traffic through the USB cable to the PC. The PC would route the traffic to its original destination and return the results back to me through the Pi. The main problem I have with this scenario is the Pi talking to the computer through USB. What I want to know is if my plan is possible/practical or impossible/impractical. If it is possible, would the PC host need elevated privileges to talk to the Pi through USB? | I think you can use Serial to USB connection for your plan. I'm using Serial->USB converter for debug messages and login via serial line. There are many information about serial to USB connection in raspberrypi.stackexchange.com answers. At this page there is an information about network connection with pppd through Serial->USB cable. Buy an PL2303 Serial-USB converter Connect your PC-RPi via serial. Run pppd from PC to connect Rpi. |
Answer the following technical question about Raspberry Pi. | Title: One coil is always active on my stepper motor(ULN2003)
Body: When I startup my pi or stop my script, the led on the ULN2003 lights up and stays. That means that one coil is active and the motor is heating up. At the end of my script I introduced a few lines of code which set all input pins to zero. stepper_pins = [3, 4, 18, 27]
for pin in range(4):
GPIO.output(self.stepper_pins[pin], 0) This code works, but when I exit the program the led lights up again. | I haven't looked through all the code so this is still a guess. If there is a call to cleanup() in the code during exit that will switch the GPIO you use back to INPUT mode. You are using GPIO 3 and 4. When set as INPUTS they will both be high. GPIO 3 will be high because it has an external 1k8 pull-up to 3V3. GPIO 4 will be high as it defaults to having a weak internal pull-up to 3V3. I suggest you substitute other GPIOs for 3 and 4. Any spare GPIO higher than number 7 should be fine. |
Answer the following technical question about Raspberry Pi. | Title: How to disable wifi in Raspberry Pi 4
Body: How to disable WiFi in Raspberry Pi4, possibly keeping the chip powered off. | Raspbian is managing hardware with overlays. In /boot/overlays/README you will find: Name: pi3-disable-wifi
Info: Disable Pi3 onboard WiFi
Load: dtoverlay=pi3-disable-wifi
Params: <None> I suggest you just add dtoverlay=pi3-disable-wifi to /boot/config.txt to disable wifi. I have tested it with a Raspberry Pi 4B. It is also valid for Pi4. When disabled you will not get a WiFi interface wlan0 as you can check with ip -br addr . UPDATE: @JeffAtwood noted in his comment They renamed it to disable-wifi so you can use that, pi3-disable-wifi was kept as a synonym for compatibility. Same thing with disabling bluetooth. 2019-10-25: seems everything is documented now in /boot/overlays/README . |
Answer the following technical question about Raspberry Pi. | Title: Dhcpcd config file - two wifi configs at once
Body: I have a Raspberry Pi Zero W v 1.1, to which I don't have any way to connect display adapter, therefore I communicate with it through ssh. It is connected to one isolated wifi network(with no internet access) for this connection. I need to connect it to another wifi at the same time from a different wifi adapter - connection is allowed only from certain Mac address, so I must use it - in order to have internet access. From the information I understood from here: https://raspberrypi.stackexchange.com/a/37921 That on older raspbian versions connection was as easy as modifying the interfaces file with wpa-conf parameter. However, on new versions all things are resolved by dhcpcd.conf, where I can't find direct equivalent of this functionality. Is there any way to do this in this version, or should I just go back to old way of defining it? | You can create different wpa_supplicant files for each interface. If you search my Answer on setting up network “Use different wpa_supplicant files “ explains. Create a file named wpa_supplicant-"$interface".conf in /etc/wpa_supplicant/ e.g. wpa_supplicant-wlan0.conf will only be used by wlan0. It is a good idea to enable Predictable Network Interface Names which will create an interface based on MAC, to ensure that only the desired interface is used. |
Answer the following technical question about Raspberry Pi. | Title: RPi 3 - Reduce power consumption
Body: I am looking to reduce the power consumption to a minimum on my RPi 3. For my project, the Raspberry Pi Zero is not an option. for now, I disabled Bluetooth and WiFi and made sure to kill some process when the PI is running on battery until the power comes back. however, I am having issue disabling USB port individually as I need to keep one running do you guys have an idea how I can do that? I am also looking to throttle the CPU as the PI, will be just checking sensors and sending payloads to DB. what is a reasonable arm_freq? I would appreciate any tips on how I can reduce my consumption. and how I disable HDMI, Audio and USB from config.txt instead of using a command like /usr/bin/tvservice -o | As far as I know, you can not disable only one USB. When you turn USBs power off, also the Ethernet port turned off. I don't know if there is a way to disable USB/Ethernet in config.txt, but in cmd line you can do it with: echo '1-1' |sudo tee /sys/bus/usb/drivers/usb/unbind To enable the ports use: echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/bind What device do you use connected to the usb port? Maybe it could be possible to use GPIO to communicate with it (Serial, SPI, I2C). -- About the config.txt, you can disable HDMI adding: hdmi_blanking=2 I think that you can save a little bit of power disabling the LEDs on board (PWR and ACT). Add the following lines to config.txt: dtparam=act_led_trigger=none
dtparam=act_led_activelow=off
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off About disabling audio, I'm not sure if it will help with power consumption, but you can try. I think that the line in config.txt is: dtparam=audio=off |
Answer the following technical question about Raspberry Pi. | Title: Controlling a headless torrent server via transmission
Body: I'm running transmission-daemon on a Raspberry Pi running headless Raspbian. I can SSH into it fine, and the FTP server on it runs without a hitch, but I can't use the terminal interface for Transmission to control it. Running: $ transmission-remote -m
$ transmission-remote localhost -m
$ sudo transmission-remote -m All give the following error: Unexpected response: 401: Unauthorized User: deflate, gzip Any ideas? Or am I using the wrong command? I want to be able to see active torrents, add more, etc. | Transmission-daemon has a web interface. If you want a pure command line interface, use transmission-cli Otherwise if you want to use transmission-remote, you'll need to modify /etc/transmission-daemon/settings.json and modify this line - "rpc-authentication-required": true, and make the true a false |
Answer the following technical question about Raspberry Pi. | Title: lxterminal show tool bar
Body: In Lxterminal I chose the option under "Display" to hide the toolbar, thinking that pressing F10 would make it pop up again. It doesn't. Without the toolbar, I can't see/access the toolbar. Is there a command to bring it back? The man page was not helpful to me. | Run nano ~/.config/lxterminal/lxterminal.conf , and change this line: hidemenubar=true to: hidemenubar=false Press Ctrl + O to save, and Ctrl + X to exit. Then exit LXTerminal if that is what you are currently using. This works even in LXTerminal Another way would be to right click and click 'Preferences', and untick 'Hide menu bar' under the 'Display' tab. |
Answer the following technical question about Raspberry Pi. | Title: How durable are the Raspberry Pi and the Raspberry Pi Camera?
Body: I plan to use my Pi and the Pi camera v2 no IR version as a wildlife camera. Now my question is can I run the camera in the winter (maybe -10 degrees Celsius) and will it still work like the Raspberry Pi? My other question is can the Raspberry + camera survive some dust? | Raspberry Pi devices themselves do not have any proper International Protection Rating , therefore device itself is not recommended for such usage. From my own experiences, Raspberry Pi devices can survive temperatures as low as -20°C(at least one in my backpack worked well) but need to be treated as a bare motherboards - with great care, far from any dust/electricity conducting materials. I'd suggest finding proper case for the Pi AND the camera before risking the damage. |
Answer the following technical question about Raspberry Pi. | Title: Where is the USB2 OTG port on the RPi 4 Model B located?
Body: According to this answer the Raspberry Pi 4 Model B has a total of five USB ports (two USB3 host, two USB2 host, one USB2 OTG). Where is the fifth USB2 OTG port located and how can I use it? Can I use it with OTG Gadget mode? | USB2 OTG port is inside the USB-C connector. Yes, you will be able to use the Gadget mode drivers, as it's an upstream-facing (slave) USB port. OTG is a rather bad name here, because it means a port which can work as both upstream-facing and downstream-facing (i.e. as a host, similar to other USB ports on the RPi). Yet it's not the case: OTG ports should be able to toggle the CC lines of USB-C between 5V and GND, but in case of RPi4 these lines are grounded, making it a strictly upstream-facing (slave). |
Answer the following technical question about Raspberry Pi. | Title: How to login throught ssh to my raspberry with a lcd screen
Body: So I just got a 3.5 inch lcd screen for my raspberry 3 b+. I connected it and installed the drivers and is working fine, but when it boots it prompts me with the ssh login (obviously, I just didnt think about that). I want to have the same ssh session on my laptop, for example, and on the display so I can see what I'm doing. Is there anyway I can achieve this? I hope I'm explaining myself. Also as an extra, how can I rotate the orientation of the screen?
Thanks. | You can use tmux for this ( apt install tmux ). First find a tutorial you like to get the hang of how it works generally (it is pretty popular amongst linux users and has been around for more than a decade, so there's plenty of stuff online). 1 One of the first things you will learn is how to create, detach, and join sessions. tmux new-session -s foo Starts a session called foo (this can be anything). If you do this directly on the Pi, obviously enough this will be foreground on the console (starting it in the foreground, ie., on the local display, remotely, is possible, but that's another question...). You can then SSH in and: tmux attach-session -t foo Notice the switch is here is -t not -s (the primary documentation can be found in man tmux ). Anyway, whatever you do in one, will happen simultaneously in the other. You can try this out just using two local terminals. If you're familiar with tmux this may at a glance look like I split one session into two panes (this is part of its functionality) but such is not the case: that's the same single pane session in two terminal windows. You don't see the invocation ( tmux new-session and tmux attach-session ) because when it starts it takes the whole terminal view. The green bar along the bottom is part of tmux, set that way in ~/.tmux.conf (you'll find examples of such online). Including this, by one of our members , from our now abandoned blog. The previous part of that is about how to install tmux from source, which I strongly recommend against . The package in current Raspbian is just fine. |
Answer the following technical question about Raspberry Pi. | Title: Network or shutdown issues on my Arch Pi
Body: I'm using a B board as a headless print/scan server with Cups installed on Arch. The pi is plugged into a linksys router with DHCP, but i'm using the "Reserve IP address" feature on the router to ensure it has a consistent IP address. I'm powering it with a Samsung 1A micro USB phone charger. It works fine, but the problem is that after a long time has passed (overnight, or at the end of the day) the Pi doesn't seem to be connected. Normally, all the LEDs that should be on are on, but there isn't any blinking. I have no access to a screen, so I'm not sure how I can check if the Pi is even on at this stage, since it doesn't respond to pings or SSH and it doesn't seem to be on the Client table. At this point, I usually just unplug it and plug it back in and it works for another while, but obviously this isn't ideal. Any suggestions? | It could be a weak power supply or something running on the Arch that causes it to hang. Difficult to say. You need to inspect logs and try and work it out. Maybe the Pi itself is damaged? You can use the built in watchdog to reset the Pi if it hangs though. sudo apt-get install watchdog Uncomment the following line in /etc/watchdog.conf watchdog-device = /dev/watchdog Edit /etc/modules And add the following: # hardware watchdog
bcm2708_wdog Run the following command to activate the module and service: sudo modprobe bcm2708_wdog
sudo service watchdog restart The default settings are that if the Pi uses allot of resources during 1 minute period it will do a hard reset. You can test with a fork bomb. Type this into the console. It should restart within a minute. If it doesn't check the configuration. : (){ :|:& };: |
Answer the following technical question about Raspberry Pi. | Title: Raspbian keyboard layout
Body: I want to set my keyboard settings to Swedish, but on the Raspbian configuration tool my keyboard is not on the list. Update : Changing XKBLAYOUT to "se" doesn't work. And internationalization in raspi-config doesn't either. My keyboard is a Logitech Wireless Touch Keyboard K400r, if that might help. | Take a look at the Raspberry Pi wiki on re-mapping the keyboard with Debian Squeeze : Re-mapping the keyboard with Debian Squeeze If different letters appear on-screen from that which you typed, you
need to reconfigure you keyboard settings. In Debian, from a command
line type: sudo dpkg-reconfigure keyboard-configuration Follow the prompts. To apply the changes type: sudo setupcon Or: From the command line type: sudo nano /etc/default/keyboard Then find where it says XKBLAYOUT=”gb” and change the gb to the two letter code for your country. Here is the list of current country codes from Wikipedia if you don't know your country code (use the codes in the column labeled alpha-2). Another way you can try switching the keyboard layout: $ setxkbmap de
$ setxkbmap fr
$ setxkbmap us |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 22