Quantcast
Channel: Recent Questions - Raspberry Pi Stack Exchange
Viewing all 50160 articles
Browse latest View live

Turn off USB of a port and leave power on while no device attached

$
0
0

I want to turn off (and back on) the USB functionality of a port while leaving the power for charging purpose. I can do this easily with unbind and bind once a device is connected. However, is there a way to do it before a device is connected, to never have a device going active in the first place? I only want to have this one USB port active (manually activated from the console) for service purpose.

I'm using RPi3 ComputeModule with Raspbian Stretch.

Thanks McL


Sharing SPI Adafruit PiTFT and RFID RC522

$
0
0

I have a Pi Zero 1.2 connected to an Adafruit 2.8" PiFTF screen and a RFID-RC522 board. I also have a thermal printer connected to TX/RX, but I don't think this plays a part in my question.

The TFT screen has a 26 pin header, designed for the older Pi boards. It also has a breakout connector underneath giving access to these same pins.

The RFID board is connected as per the instructions here: https://github.com/ondryaso/pi-rc522

The problem

My problem is that I can either have the TFT screen working, or the RFID, but not both at the same time. At the moment I have commented out this line in /boot/config.txt to work on the RFID:

#dtoverlay=pitft28-capacitive,rotate=270,speed=64000000,fps=30

I'm a bit stuck trying to figure out if it's possible to have both the TFT and the RFID connected and working. I understand there may be an alternative way to connect the RFID to a second SPI SPI1?

What have I tried?

I have enabled dtoverlay=spi1-1cs in /boot/config.txt and can see the following:

crw-rw---- 1 root spi 153, 0 Aug  2 19:01 spidev0.1
crw-rw---- 1 root spi 153, 1 Aug  2 19:01 spidev1.0

But when I run my RFIDUtil.py (from ondryaso GitHub), it errors out with:

$ sudo python rfid-util.py 
Traceback (most recent call last):
  File "rfid-util.py", line 5, in <module>
    rdr = RFID()
  File "/home/pi/Development/printer/rfid/pirc522/rfid.py", line 68, in __init__
    self.spi.open(bus, device)
IOError: [Errno 2] No such file or directory

The code is as follows:

from pirc522 import RFID
import signal
import time

rdr = RFID()
util = rdr.util()
# Set util debug to true - it will print what's going on
util.debug = True

while True:
    # Wait for tag
    rdr.wait_for_tag()

    # Request tag
    (error, data) = rdr.request()
    if not error:
        print("\nDetected")

        (error, uid) = rdr.anticoll()
        if not error:
            # Print UID
            print("Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3]))

            # Set tag as used in util. This will call RFID.select_tag(uid)
            util.set_tag(uid)
            # Save authorization info (key B) to util. It doesn't call RFID.card_auth(), that's called when needed
            util.auth(rdr.auth_b, [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF])
            # Print contents of block 4 in format "S1B0: [contents in decimal]". RFID.card_auth() will be called now
            util.read_out(4)
            # Print it again - now auth won't be called, because it doesn't have to be
            util.read_out(4)
            # Print contents of different block - S1B2 - RFID.card_auth() will be called again
            util.read_out(6)
            # We can change authorization info if you have different key in other sector
            util.auth(rdr.auth_a, [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF])
            #If you want to use methods from RFID itself, you can use this for authorization
            # This will authorize for block 1 of sector 2 -> block 9
            # This is once more called only if it's not already authorized for this block
            util.do_auth(util.block_addr(2, 1))
            # Now we can do some "lower-level" stuff with block 9
            rdr.write(9, [0x01, 0x23, 0x45, 0x67, 0x89, 0x98, 0x76, 0x54, 0x32, 0x10, 0x69, 0x27, 0x46, 0x66, 0x66, 0x64])
            # We can rewrite specific bytes in block using this method. None means "don't change this byte"
            # Note that this won't do authorization, because we've already called do_auth for block 9
            util.rewrite(9, [None, None, 0xAB, 0xCD, 0xEF])
            # This will write S2B1: [0x01, 0x23, 0xAB, 0xCD, 0xEF, 0x98, 0x76......] because we've rewritten third, fourth and fifth byte
            util.read_out(9)
            # Let's see what do we have in whole tag
            util.dump()
            # We must stop crypto
            util.deauth()

These questions are similar, but haven't got me a working solution as yet.

I have access to PiZero 1.3 and PiZero W if that makes any difference? Any help greatly appreciated.

Raspberry Pi Zero hardware based video encoding

$
0
0

I'm trying to build a dashcam with a Raspberry Pi Zero with an official Raspberry Pi Camera (version 2) in an official Raspberry Pi Zero case mounted with a old GPS device cradle. I installed motion with a motion eye Web UI to control it and set it up to record constantly to a SanDisk Industrial SD Card.

The frame rate is abysmally slow to the point that it'll never be effective as a dashcam. It's sometimes only 2.0 FPS at higher resolutions and setting it to 640x320 can get me up to about 15.0 FPS but that's still not good enough for what I want to use it for.

I understand FFMpeg is used by motion and that it's not optimised for ARMv6. Now I'm wondering about what other options I have to do hardware based video encoding on the Zero because software based encoding seems unworkably slow.

Is the Zero powerful enough to at the very least save 1080p at 30 FPS to it's SD Card? Are there other options for encoding video I haven't explored?

Connecting a 1TB USB 2.0 WD Elements drive

$
0
0

I've just purchased a Raspberry Pi 3 and I've installed OpenELEC onto the Pi so I can run the Kodi.

After this step - after this first step - I've succesfully set it all up and I've managed to get the USB ports working with a Wi-Fi dongle and also a wireless keyboard. I've also set Kodi to see my movies folder on another NAS.

The problem I have is that Kodi cannot see my external HDD which is plugged into a spare USB port. The HDD is a WD Elements with 1TB of storage and USB 2.0 connection.

The good thing: it has its own power supply. Its got an NTFS file system and this works on my linux machine, my Windows machine and my Linux-Machine.

Well - I guess that I have to use PuTTy into the OpenELEC and try to mount so that I have something like; /dev/sdb1

Is there anything else I should do?

Raspberry Pi stuck at black screen with blinking cursor

$
0
0

After starting pi, the screen gets stuck at blinking cursor at uppermost left side corner. When Ctrl+alt+F2 is presssed the login prompts for very small interval & disappears and this (as shown below) goes on until ctrl+alt+F2 is pressed.

Raspbian GNU/Linux 9 raspberrypi tty2

raspberrypi login:

I am not able to type login and password for. Any solution to make this prompt still so that I can type login and password.

pigpio.error: 'no permission to update GPIO' (again)

$
0
0

I am a beginner in Python and in the Raspberry field. I want to write a code to drive 3 leds with a PWM signal. The three leds must not emit at the same time and I want them to emit pulses trains. In order to do that, I triggered the driving signals for the three leds on the rising edge of a fourth PWM signal name "clock".

Firstly I write a code with the RPi library and it worked quite well. But for a frequency above 1 kHz, the Raspberry doesn't generate a clean signal. This is why I want to use the pigpio library.

Thus, I modified my previous code to adapt it to the pigpio library. The code is the following :

import pigpio
import time


pi = pigpio.pi()

clock=11

led_1=35

led_2=32

led_3=33



pi.set_mode(12, pigpio.OUTPUT)

pi.set_mode(clock, pigpio.INPUT)

pi.set_mode(led_1, pigpio.OUTPUT)

pi.set_mode(led_2, pigpio.OUTPUT)

pi.set_mode(led_3, pigpio.OUTPUT)


pi.set_PWM_frequency(clock, 10)

pi.set_PWM_dutycycle(clock, 128)

pi.set_PWM_frequency(led_1, 2000)

pi.set_PWM_frequency(led_2, 10)

pi.set_PWM_frequency(led_3, 10)



pi.wait_for_edge(clock)

pi.set_PWM_dutycycle(led_1, 0)

pi.set_PWM_dutycycle(led_2, 0)

pi.set_PWM_dutycycle(led_3, 0)


while(1) :

        pi.wait_for_edge(clock)
        pi.set_PWM_dutycycle(led_1, 25)
        pi.wait_for_edge(clock,FALLING_EDGE)
        pi.set_PWM_dutycycle(led_1, 0)

        pi.wait_for_edge(clock)
        pi.set_PWM_dutycycle(led_2, 25)
        pi.wait_for_edge(clock,FALLING_EDGE)
        pi.set_PWM_dutycycle(led_2, 0)


        pi.wait_for_edge(clock)
        pi.set_PWM_dutycycle(led_2, 25)
        pi.wait_for_edge(clock,FALLING_EDGE)
        pi.set_PWM_dutycycle(led_2, 0)


        pi.wait_for_edge(clock)
        pi.set_PWM_dutycycle(led_3, 25)
        pi.wait_for_edge(clock,FALLING_EDGE)
        pi.set_PWM_dutycycle(led_3, 0)

When I run the program with sudo, it returns to me this error message :

Traceback (most recent call last):

  File "led_train_2.3.py", line 16, in <module>
    pi.set_mode(led_1, pigpio.OUTPUT)

  File "/usr/local/lib/python2.7/dist-packages/pigpio.py", line 1340, in set_mode

    return _u2i(_pigpio_command(self.sl, _PI_CMD_MODES, gpio, mode))
  File "/usr/local/lib/python2.7/dist-packages/pigpio.py", line 975, in _u2i
    raise error(error_text(v))

pigpio.error: 'no permission to update GPIO

I have read many topics about this type of error but I didn't find a solution which worked for me. Please, if you could explain it to me in the simplest way I would very grateful.

Lionel.

Raspberry 4 B not booting from raspberry stretch OS

$
0
0

My new pi boots perfectly from Raspian buster but once the sd card is flashed with stretch os then only red light turns on. I need to install stretch os to work with opencv in C++ using geany editor. Kindly help.

Reliable 5v relay

$
0
0

I have been using raspberry pi for my home automation project. To control 12v power, I use 5v relay low triggering to turn on or off the power. My coding and connection work fine. Problem is reliability of 5v relay. It is so frustrating to find 5v relay being broken and not working anymore. If there are someone who have recommendation of reliable 5v relay, please let me know. Price does not much matter.

Thank you all in advance.


WLAN module gone - RPI 4 B+

$
0
0

The WLAN module of my RPI 4 B+ disappeared. At first I thought that the hardware component had blown. How can I properly diagnose whether there is a hardware or software problem?

What I have done for diagnosting so far:

# uname -a
Linux xxx 4.19.88-1-ARCH #1 SMP PREEMPT Wed Dec 11 20:19:41 UTC 2019 armv7l GNU/Linux

# ip l
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether dc:a6:32:xx:xx:xx brd ff:ff:ff:ff:ff:ff

# rfkill list                                                 
0: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no

# cat /boot/config.txt
[..]
gpu_mem=64
initramfs initramfs-linux.img followkernel

# dmesg | rg brcm
[    5.053910] brcm-pcie fd500000.pcie: dmabounce: initialised - 32768 kB, threshold 0x00000000c0000000
[    5.053953] brcm-pcie fd500000.pcie: could not get clock
[    5.054007] brcm-pcie fd500000.pcie: host bridge /scb/pcie@7d500000 ranges:
[    5.054049] brcm-pcie fd500000.pcie:   MEM 0x600000000..0x603ffffff -> 0xf8000000
[    5.094140] brcm-pcie fd500000.pcie: link up, 5.0 Gbps x1 (!SSC)
[    5.094360] brcm-pcie fd500000.pcie: PCI host bridge to bus 0000:00
[    5.334403] brcmstb_thermal fd5d2200.thermal: registered AVS TMON of-sensor driver
[   10.018800] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43455-sdio for chip BCM4345/6
[   10.020754] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43455-sdio.txt failed with error -2
[   10.021792] usbcore: registered new interface driver brcmfmac
[   11.027387] brcmfmac: brcmf_sdio_htclk: HT Avail timeout (1000000): clkctl 0x50

Direct firmware load for brcm/brcmfmac43455-sdio.txt failed with error -2

From my point of view that clearly indicates a driver problem.

How should I proceed reasonably to fix this?

PS: The error probably occurred shortly after the encryption of the root partition.

PPS: Text has been edited multiple times to comply to forum rules (make it a question) and to clean up.

Proper way to bigbang I2C

$
0
0

As already mentioned in this question Reading and writing with smbus package, there are chips that, apart for standard SDA and SCL lines, use a third communication line. This means that this "modified" I2C communication cannot be made using standard kernel and smbus library, which advantage is that communication is very orderly (perfect SCL pulses).

I already managed to bitbang communication using RPi.GPIO library. The communication works, but it is uneven and each clock pulse has different length, since RPi.GPIO library (and probably Python itself) is just too slow.

Now I want to write my own library for the communication with the chip. In order for library to work properly, I have to solve two problems:

  1. Would it be appropriate to use standard I2C Raspberry Pi pins (GPIO2, GPIO3) plus one arbitrary GPIO for that? Maybe this is not good idea because it might create a conflict with kernel and smbus library? What do you think?

  2. How should I write this communication to be as orderly as possible - should I write special C routines within my Python program and what commands should I use to access the GPIOs?

I would prefer stand-alone solutions that don't use existing communication libraries (e.g. RPi.GPIO, pigpio), since they contain a lot of capabilities completely unnecessary for the problem.

How do I SSH into my Pi at home from a remote location?

$
0
0

I can't seem to find a straight answer anywhere. So I'm just going to ask SO instead.

For arguments sake, lets assume these are my details

public IP       ~ 11.111.11.11
Pi's private IP ~ 192.168.0.6
Port forwarded  ~ 21 both TCP and UDP
Pi's name       ~ pi@mikespi 

I have my pi turned on, sitting at home. Now I'm at work, and I want to SSH onto my pi. I am running linux mint so I want to use the terminal (bash) to SSH. What command do I write?

even ssh -h hasn't helped me work out how to do this remotely.

Note: I have managed to SSH onto the pi within my own network easily.

Large Download Pi Server

$
0
0

I have a raspberry pi 4 (2gb) set up as a file server. I was wondering if it was possible to create a tool, where when I paste a link into some sort of prompt, my raspberry Pi would download the file to it's hard drive.

Basically, it would have a input, where I paste a file link (https://example.com/example.zip) and it would download the file to a specific folder, then I could move it to my main computer when it was done, at a much higher speed.

Does this exist? / Would it be possible to create my own?

Edit: I used https://github.com/fredthedoggy/Web-PHP-Download-Manger for downloading

AP Bridge VPN IPTABLES rules needed

$
0
0

I have set up an access point with a bridge (bridge: I want to be able to access all other devices within my network).

Now I'm facing a serious problem: How to get the wifi connected devices to the VPN tunnel.

  • My router has 192.168.2.1 behind another router with 192.168.1.1 (provided by my Chinese ISP).
  • My RPi4 with the WLAN bridge has 192.168.2.15 (DHCP from the router 192.168.2.1; I would prefer static but I haven't tried so far).
  • expressvpn is running on the RPi4 (I live in China, without vpn no google & Co).
  • Everything is ok with Putty-SSH, google.de can be reached. However, WiFi@RPi connected devices have internet, they can not reach google.de due to ISP block in China which means, the traffic from device is not going through the vpn tunnel or DNS is leaking and ISP is blocking access. So I have to configure iptables.
  • How do I configure the IPTables?

Below are all changed files listed and here the output of:

pi@Pi4:~ $ sudo iptables -L -v

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
42675   13M xvpn       all  --  any    any     anywhere             anywhere

Chain xvpn (1 references)
 pkts bytes target     prot opt in     out     source               destination
42675   13M xvpn_dns   all  --  any    any     anywhere             anywhere
37923   13M xvpn_ks    all  --  any    any     anywhere             anywhere

Chain xvpn_dns (1 references)
 pkts bytes target     prot opt in     out     source               destination
42675   13M xvpn_dns_iface_exceptions  all  --  any    any     anywhere             anywhere
42675   13M xvpn_dns_ip_exceptions  all  --  any    any     anywhere             anywhere
  228 20176 DROP       udp  --  any    !lo     anywhere             anywhere             udp dpt:domain

Chain xvpn_dns_iface_exceptions (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain xvpn_dns_ip_exceptions (1 references)
 pkts bytes target     prot opt in     out     source               destination
 4157  260K ACCEPT     udp  --  any    any     anywhere             10.199.0.1           udp dpt:domain

Chain xvpn_ks (1 references)
 pkts bytes target     prot opt in     out     source               destination
37923   13M xvpn_ks_iface_exceptions  all  --  any    any     anywhere             anywhere
24548   11M xvpn_ks_ip_exceptions  all  --  any    any     anywhere             anywhere
    0     0 ACCEPT     udp  --  any    any     anywhere             anywhere             udp dpts:bootps:bootpc
   11  1692 DROP       all  --  any    !lo     anywhere             anywhere

Chain xvpn_ks_iface_exceptions (1 references)
 pkts bytes target     prot opt in     out     source               destination
10900 1686K ACCEPT     all  --  any    tun0    anywhere             anywhere

Chain xvpn_ks_ip_exceptions (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  any    any     anywhere             10.0.0.0/8
    0     0 ACCEPT     all  --  any    any     anywhere             172.16.0.0/12
  722 81202 ACCEPT     all  --  any    any     anywhere             192.168.0.0/16
    0     0 ACCEPT     all  --  any    any     anywhere             169.254.0.0/16
   14  1411 ACCEPT     all  --  any    any     anywhere             base-address.mcast.net/24
20556 9294K ACCEPT     all  --  any    any     anywhere             45.84.213.70


root@Pi4:~ # cat /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="RPi4"
    mode=2
    frequency=2437
    #key_mgmt=NONE   # uncomment this for an open hotspot
    # delete next 3 lines if key_mgmt=NONE
    key_mgmt=WPA-PSK
    proto=RSN WPA
    psk="Entensalt"
}

root@Pi4:~ # cat /etc/systemd/network/02-br0.netdev
[NetDev]
Name=br0
Kind=bridge

root@Pi4:~ # cat /etc/systemd/network/04-br0_add-eth0.network
[Match]
Name=eth0
[Network]
Bridge=br0

    root@Pi4:~ # cat /etc/systemd/network/12-br0_up.network
    [Match]
    Name=br0
    [Network]
    MulticastDNS=yes
    DHCP=yes
    # to use static IP uncomment these and comment DHCP=yes
    #Address=192.168.50.60/24
    #Gateway=192.168.50.1
    #DNS=84.200.69.80 1.1.1.1

    root@Pi4:~ # cat wpa_supplicant@wlan0.service
    cat: wpa_supplicant@wlan0.service: No such file or directory
    #I don't know how to show you this file, but changes were made according your setup.

pi@Pi4:~ $ expressvpn status
Connected to Hong Kong - 4

   - If your VPN connection unexpectedly drops, internet traffic will be blocked to protect your privacy.
   - To disable Network Lock, disconnect ExpressVPN then type 'expressvpn preferences set network_lock off'.

pi@Pi4:~ $ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
    link/ether dc:a6:32:10:b5:18 brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:9c:50:65:3a:36 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.15/24 brd 192.168.2.255 scope global dynamic br0
       valid_lft 82883sec preferred_lft 82883sec
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether dc:a6:32:10:b5:19 brd ff:ff:ff:ff:ff:ff
6: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
    link/none
    inet 10.199.0.18 peer 10.199.0.17/32 scope global tun0
       valid_lft forever preferred_lft forever

pi@Pi4:~ $ curl ipinfo.io/ip
45.135.186.71

pi@Pi4:~ $ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.199.0.17     128.0.0.0       UG    0      0        0 tun0
0.0.0.0         192.168.2.1     0.0.0.0         UG    1024   0        0 br0
10.0.0.0        192.168.2.1     255.0.0.0       UG    0      0        0 br0
10.199.0.1      10.199.0.17     255.255.255.255 UGH   0      0        0 tun0
10.199.0.17     0.0.0.0         255.255.255.255 UH    0      0        0 tun0
45.84.213.70    192.168.2.1     255.255.255.255 UGH   0      0        0 br0
128.0.0.0       10.199.0.17     128.0.0.0       UG    0      0        0 tun0
172.16.0.0      192.168.2.1     255.240.0.0     UG    0      0        0 br0
192.168.0.0     192.168.2.1     255.255.0.0     UG    0      0        0 br0
192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 br0
192.168.2.1     0.0.0.0         255.255.255.255 UH    1024   0        0 br0

pi@Pi4:~ $ ip route
0.0.0.0/1 via 10.199.0.17 dev tun0
default via 192.168.2.1 dev br0 proto dhcp src 192.168.2.15 metric 1024
10.0.0.0/8 via 192.168.2.1 dev br0
10.199.0.1 via 10.199.0.17 dev tun0
10.199.0.17 dev tun0 proto kernel scope link src 10.199.0.18
45.84.213.70 via 192.168.2.1 dev br0
128.0.0.0/1 via 10.199.0.17 dev tun0
172.16.0.0/12 via 192.168.2.1 dev br0
192.168.0.0/16 via 192.168.2.1 dev br0
192.168.2.0/24 dev br0 proto kernel scope link src 192.168.2.15
192.168.2.1 dev br0 proto dhcp scope link src 192.168.2.15 metric 1024

Connecting a USB Device by GND, VCC, RX, and TX

$
0
0

I have a few basic devices that utilize a mini USB port. Rather than plugging them into a USB hub, is it possible to connect them and have them recognized by a Raspberry Pi through the four GND, VCC, RX, and TX wires?
I've enabled UART successfully and tried plugged in Red => 3.3v, Black => GND, Green => RX, White => TX, but I cannot get my device to show up on the Pi (I've also tried switching the White and Green wires just in case I got them mixed up).

The program I'd like to utilize the devices with does search for a /dev/ttyS* device and the UART is at /dev/ttyAMA0, so I tried linking /dev/ttyAMA0 to /dev/ttyS1 in hopes that the program will pick the device up, but it doesn't work. Is there is a way to get something like this working?

wire

MiniDLNA stops scanning after a few files

$
0
0

I used to have this running happily under Raspbian jessestretch but under Raspbian stretchbuster it gives up with no error after a few files.

  • I've checked that the minidlna user has access to all the files.
  • I've enabled debug level logging
  • I've tried running with the -R option
  • I've tried deleting /var/cache/minidlna/*
  • I've checked file ownership of /var/cache/minidlna/* (as suggested here)
  • I've tried with and without ionotify
  • I've tried removing the dir that it stops at; then it just stops at the next one.

It serves the files it indexed OK. I just can't figure out why it stops where it does! It's like it has a limit of 100 files or something.


USB external antenna not working

$
0
0

I have been experimenting with GPIO control from a local hosted web sever on the raspi 3B+, Unfortunately the range from the built-in antennae is less than adequate for my needs. So I hopped on to amazon and purchased this https://www.amazon.com/Wifi-Antenna-Raspberry-Pi-Instructions/dp/B00H95C0A2 But when I tried to use it doesn't seem to work. It shows in lsusb, but I can't seem to get it to to switch over from using the built-in antennae to the one I bought on amazon. Any help?

System crashes when a USB device is plugged in or a web browser is opened

$
0
0

I recently turned my pi into a standalone network following this guide: https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md But now when I open a web browser, or plug in a usb device it crashes and reboots and sometimes even gets stuck in a boot loop causing to to pull the plug and restart it. (USB crashes happen about 50% of the time something is plugged in). I really don't know where to start troubleshooting this problem. Where should I be looking? Any tips or things to look out for?

How to update GTK3 image using a button to capture a picture from the camera using C++?

$
0
0

I managed to create a program that will display some buttons and and Image. Now I would like to update the image when a button is clicked. How do I do that?

Here is what I have so far, it all works but missing code to update the displayed image.

#include <iostream>
#include <raspicam/raspicam.h>
#include <wiringPi.h>
#include <gtk/gtk.h>

#include <fstream>
#include <vector>
#include <unistd.h>

using namespace std;

void Capture_Image(void){
    //camera setup
    raspicam::RaspiCam camera; //Camera object

    if (!camera.open()) 
    {
        cerr << "Could not open the camera"<< endl; 
        //return 1;
    }

    camera.grab();

    std::vector<unsigned char> buf;
    buf.resize(camera.getImageTypeSize(raspicam::RASPICAM_FORMAT_RGB));

    camera.retrieve(buf.data(), raspicam::RASPICAM_FORMAT_RGB);

    std::ofstream outFile("/home/pi/s.jpg", std::ios::binary);
    outFile << "P6\n"<< camera.getWidth() << ""<< camera.getHeight() << " 255\n";
    outFile.write((char*)buf.data(), buf.size());

    cout << "Image saved to output.ppm"<< endl;
}

int main(int argc, char **argv)
{
    wiringPiSetup();
    gtk_init (&argc, &argv);

    //Main Box
    GtkWidget *mainBox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
    gtk_container_add (GTK_CONTAINER (win), mainBox);

    //camera image container
    GtkWidget *cameraBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
    gtk_container_add (GTK_CONTAINER (mainBox), cameraBox);

    GtkWidget *cameraView = gtk_image_new_from_file("/home/pi/s.jpg");
    gtk_box_pack_start (GTK_BOX (cameraBox), cameraView, TRUE, TRUE, 0);

    //resize image
    GdkPixbuf *pixBuf = gtk_image_get_pixbuf(GTK_IMAGE(cameraView)); 
    pixBuf = gdk_pixbuf_scale_simple(pixBuf, 300,200,GDK_INTERP_BILINEAR);
    gtk_image_set_from_pixbuf(GTK_IMAGE(cameraView),pixBuf);

    //image capture button
    GtkWidget *imageCapture = gtk_button_new_with_label ("Image Capture");
    g_signal_connect (imageCapture, "clicked", G_CALLBACK (Capture_Image), NULL);
    gtk_box_pack_start (GTK_BOX (cameraBox), imageCapture, TRUE, TRUE, 0);

    //show the new window
    gtk_widget_show_all (win);
    //Start the GTK main loop
    gtk_main ();

    return 0;
}

How to record system audio on Raspberry pi?

$
0
0

I’m trying to figure out how to record the system audio from raspbian. I want to record audio from either the OS or a specific program... like recording an audio stream... if it possible? I tried searching but everything is talking about using a USB sound card. Any help is appreciated.

Muting speakers with a switch, and using the GPIO to detect if muted

$
0
0

I need to be able to have physical mute for a speaker via a switch, and I need to be able to detect the switch's position via GPIO inputs, so I can't just hook the switch up directly to the speaker. I got the idea to use a button with 3 outputs: 1) GPIO in on raspi 2) 2 transistors to open power to the 2 speakers when the switch is high. I got this transistor idea from a peristaltic pump project, driving the pump with 12v, activated by GPIO, following the bottom schematic here; this had turned out great!

So I adapted my old circuit as such with one speaker, omitting the GPIO input for nowenter image description here

The line out is coming from this pi hat, driving a 5W 8-ohm speaker. The diode is a 1N4007, to prevent back emf, and the transistor is N2222A (note this has a max current of 800 mA which I think I would barely stay under with a 5W 8-ohm speaker). The resistor is 2.2 kOhms, and I'm using a pi zero W.

Anyway, it works great! Holding the button activates the speaker, letting go deactivates. However, the issue is my pi is getting blazingly hot ... scalding actually, within minutes of turning on when hooked up like this; I think it's the CPU. I have a feeling something isn't quite right, I've probably committed some kind of circuit treason, drawing way too much current somewhere and lucky my pi isn't fried. What would be the issue?

Once this circuit is working, I'd want to hook up a second wire on row 10 to a GPIO pin, with a pull-down, so when the switch is hit it reads high, ie it is unmuted. I also want to hook up the third wire on row 10 to a second transistor setup for the second speaker. I'm learning all this slowly, I've taken a year of physics in college but that's about it. Thanks for all the help.

Viewing all 50160 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>