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

Using Raspberry Pi to flash its own SD card

$
0
0

I'm developing a Buildroot OS for the Raspberry Pi, and my workflow requires very frequent re-flashing of the SD card to test new iterations. The process of removing the SD card from the Pi, flashing it on a Windows PC and then re-inserting it takes a lot of time. I would like to write a script that uses the currently running OS on the Rpi (accessed over SSH) to

  1. Download the new SD image
  2. Flash it to the SD, overwriting all existing OS files
  3. Reboot into the new OS

Step 2 is where I'm stuck. Is it possible for an operating system to overwrite itself?


Tuning watchdog cpu usage

$
0
0

I've enabled the watchdog module

# /etc/modules

i2c-dev
bcm2835_wdt

And installed and activated the watchdog daemon with the following configuration:

# /etc/watchdog.conf

realtime = yes
priority = 1

watchdog-timeout = 15
watchdog-device = /dev/watchdog

max-load-1 = 24
max-load-5 = 18
max-load-15 = 12

In order to fine-tune max-load-* parameter I would like to monitor the same cpu usage the watchdog daemon is looking at. I've been warned that is not the same that the cpu usage programs like htop reports.

Which command is watchdog using?

Pi motor HAT code question

$
0
0

I'm using a raspberry pi 4b and it's running Raspbian 10 (Buster). I have a Geekworm Pi Motor HAT Full function Robot Expansion Board. I'm using the GitHub code: Raspi-MotorHat-master. I'm using Python version 3.7. This is the link to the GitHub library I'm using: https://github.com/Alictronix/Raspi-MotorHat

I'm trying to build a simple robot and drive 2 DC motors. I'm trying to get 4WDTEST.py to work. I keep getting this error in Raspi_MotorHAT.py:

File "/home/xxxxx/PythonCode/Raspi-MotorHat-master/Raspi_MotorHAT.py", line 213, in setSpeed
    self.MC._pwm.setPWM(self.PWMpin, 0, speed*16)
AttributeError: 'Raspi_DCMotor' object has no attribute 'PWMpin'

This is the function where the code is failing:

    def setSpeed(self, speed):
        if (speed < 0):
            speed = 0
        if (speed > 255):
            speed = 255
        self.MC._pwm.setPWM(self.PWMpin, 0, speed*16)

I assume this code was done for Python 2.7 or earlier. I can't figure out how to get past this error. I've looked at the Adafruit-Motor-HAT-Python-Library-master code and it is the same. I assume this code works. Any help would be greatly appreciated.

Connect camera via gpio pins

$
0
0

is there anyway to connect wires from a camera to gpio pins on a Pi to use/control the camera? In my case this is the camera. enter image description here

to look something like this enter image description here

libc 2.29 on buster

$
0
0

I am trying to use my new Pi 4 to run a Rust executable that I compiled on Linux but it will not run because it needs libc 2.29 and it appears that buster comes with libc 2.28. Is it possible to update the version of libc6 and if it is then what is the procedure to do so?

HDMI Display still not working after config.txt edit

$
0
0

I have this HDMI 800x480 display (XPT2046) and what's happening is it just displays "HDMI" at the upper left corner of the screen then "No Signal" at the center even though I tried all modifications to config.txt

Correct me if I'm wrong but my RPi 3 boots correctly since it is able to connect to my wifi. Or it doesn't imply that my RPi 3 connects to the wifi means it's booting correctly.

If everything is fine other than the display issue, what can I do?

Additional info: Even if I plug this HDMI display to my laptop it still produces the same problem (No Signal).

Additional info-2: When I turn on the display while attached to the RPi3, the red light goes out.

Which GPIOs can receive DHT11 data?

$
0
0

The 'kookye'DHT11 tutorial suggests connecting to GPIO14 (TXD) at pin 8. An rpi3B+ and a relay board uses the GPIO14 for programming firmwware per the table:

PIN    GPIO   CLASS      RELAY BOARD FUNCTION 
3,5    2,3    SDA,SCL    I2C commands
7      4      GPCLK0     Interrupt Handler
8,10   14,15  TXD,RXD    Firmware Programming 

The Circuit basics tutorial indicates configuring GPIO-4 (GPCLK0) Pin-7:

enter image description here

QUESTIONS

  • Can a common GPIO (i.e. GPIO-17) be configured to receive DHT11 data?

  • Which GPIOs can be configured to receive DHT11 data?

enter image description here

TEST PROCEDURE

  1. Enter this at the command prompt to download the library:

    git clone https://github.com/adafruit/Adafruit_Python_DHT.git

  2. Change directories with:

    cd Adafruit_Python_DHT

  3. Now enter this:

    sudo apt-get install build-essential python-dev

  4. Then install the library with:

    sudo python setup.py install

  5. Invoke python and issue commands:

    import sys; import Adafruit_DHT

    humidity, temperature = Adafruit_DHT.read_retry(11, 37) #GPIO-26 on pin-37

    humidity, temperature = Adafruit_DHT.read_retry(11, 26)

Error Messages

humidity, temperature = Adafruit_DHT.read_retry(11, 37) #GPIO-26 on pin-37

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Adafruit_DHT/common.py", line 94, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "Adafruit_DHT/common.py", line 80, in read
    platform = get_platform()
  File "Adafruit_DHT/common.py", line 55, in get_platform
    from . import Raspberry_Pi_2
  File "Adafruit_DHT/Raspberry_Pi_2.py", line 22, in <module>
    from . import Raspberry_Pi_2_Driver as driver
ImportError: cannot import name Raspberry_Pi_2_Driver

Retry with GPIO (26) and not PIN (37)

humidity, temperature = Adafruit_DHT.read_retry(11, 26)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Adafruit_DHT/common.py", line 94, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "Adafruit_DHT/common.py", line 80, in read
    platform = get_platform()
  File "Adafruit_DHT/common.py", line 55, in get_platform
    from . import Raspberry_Pi_2
  File "Adafruit_DHT/Raspberry_Pi_2.py", line 22, in <module>
    from . import Raspberry_Pi_2_Driver as driver
ImportError: cannot import name Raspberry_Pi_2_Driver

Raspberry Pi 3 / using standard USB webcam with Python(3) for display

$
0
0

Watching a milling process I want to use a USB webcam. Using Raspbian 'stretch' on a RPi3 I tried lots of suggestions form the web without success.

  • OpenCV was hard to install and did not recognize my cameras (a=Logitech, b=Creative, c=SPEEDLink).
  • pygame did not recognize the format of all cameras
  • mplayer works fine with all cameras from command-line, e.g.: mplayer tv://dev/video0

The camera should be used for:

  • watching a NC mill or laser during work
  • building a measuring device using an x-y cnc frame with e.g. GRBL. A picture shall be displayed inside a GUI window and a cross-hair is inserted to point to the actual coordinate.

Due to my bad experiences with including the usb web-cam into Python(3) I would ask for help in selecting a suitable interface or environment for this project. Many posts seem to work with earlier Raspbian versions but not with 'Stretch'.

Thanks for help.


e-ink display ghost image

$
0
0

There is a ghost image (not sure if that is the right term) on my e-ink display from waveshare:

Is there any way I can fix this, or do I have to replace the display?

The ghosting appeared after several days of use and I think it appeared because I didn't put the display to sleep after updating it. Can anyone confirm that adding the .sleep() call would prevent this to happend again?

    import epd2in13

    def showImageOnScreen(image):
        epd = epd2in13.EPD()
        epd.init(epd.lut_full_update)
        epd.clear_frame_memory(0xFF)
        epd.set_frame_memory(image, 0, 0)
        epd.display_frame()
        epd.sleep()

Hosting Multiple Websites on RPi 4

$
0
0

So I've already set everything as for port forwarding in my router settings, I've set a static IP address for the RRi 4, and have already managed to get 1 page visible through my Pi web server.

The problem began when I went to set up the "Virtual Host" files in Apache2 to point to each domain that I plan on hosting on the RPi 4. Now no page shows, and the message I keep seeing says the following:

"404 Not Found The requested URL was not found on this server. Apache/2.4.38 (Raspbian) Server at MY-PUBLIC-IP-ADDRESS-HERE Port 80" As shown in the image below (404 message):

enter image description here

I have website1.com inside of "/var/www/website1.com/public_html/index.php" and I have website2.com inside of "/var/www/website2.com/public_html/index.php"

My Apache2 folder inside of directory "/etc/apache2/" looks like this:

enter image description here

And here is how I've set up my Virtual Host file (for website1.com) inside the directory "/etc/apache2/sites-available/Website1.com.conf":

<VirtualHost *:80>
ServerAdmin admin@Website1.com
ServerName Website1.com
ServerAlias www.Website1.com
DocumentRoot /var/www/Website1/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

AND the other file is a duplicate for website2.com inside of directory "/etc/apache2/sites-available/Website1.com.conf":

<VirtualHost *:80>
ServerAdmin admin@Website2.com
ServerName Website2.com
ServerAlias www.Website2.com
DocumentRoot /var/www/Website2/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I haven't set my DNS records for my real website domains yet, but as far as I remember, I should have been able to test on my localhost or check through my public IP address that is forwarding to my RPi 4 IP address to preview these 2 separate domains/websites.

Does it look like I've structured the Apache Virtual Hosts properly? Thanks.

Pi in "meshed" wireless network

$
0
0

Is there a way to create a wireless network with Rpi as access points so that computers can connect to the Rpi and let the Rpi's route the traffic between the wireless access points. Should every Pi be a DHCP server? how should I do DNS? I'm trying to do this decentralized so when one Pi fails not all connectivity is lost. Should I use an address block, let's say 10.1.1.1\24 only for the Pi's and give every Pi a different block to distribute to clients? Also I would like to do this with 1 WLAN interface per Pi

Pi wireless:

How can I connect an EasyADC board mikroe340?

$
0
0

I've got a 4-channel 12-bit ADC "Mikroe340" from Mikroelektronika (datasheet). I'm wondering how to wire it with GPIO.

!(http://static4.tme.eu/products_pics/3/d/7/3d785623be45a644c66a1632ed688914/73330.jpg)

How to install Ubuntu MATE without HDMI output?

$
0
0

I'm new to Raspberry Pi 2, I just bought a Raspberry Pi 2 1.1, I don't have a TV or monitor with HDMI input, so I have to install Ubuntu MATE without it, is there any way to use composite video? i have cable and a TV, but it does not work, shows white line and buzzing sound.

I looked all over the Internet and configured config.txt. It didn't work for me. My cable is fine by the way.

How to make the taskbar appears on top of a full screen application automatically?

$
0
0

Do I need to show the taskbar on top of a full-screen page opened by google chrome browser?
Is it possible?

I tried to search but no results were found.

Thanks.

RPI not responding to SD card

$
0
0

I have a Raspberry PI 3 and I want to install Kali Linux onto my RPI so I downloaded the RPI image file from https://www.offensive-security.com/kali-linux-arm-images/. Then with Win32 Disk Imager I wrote the image onto my micro SD card. I put my SD card into my RPI, plugged my RPI into a monitor threw VGA with a HDMI adapter, then plugged in the power cord for my RPI. All I got was a blank screen from my monitor and a red light from my RPI. The monitor sensed that there was something plugged into it but that was all. My micro SD card has 32GB space and I got it with NOOBS preinstalled on it, but deleted it on my card.


Not able to connect Raspberry to laptop

$
0
0

I'm trying to connect my laptop to my Raspberry PI with just a LAN cable and without a router because I don't have one. So I just configured a static IP in both the devices and tried to setup a network between them. It appears that the network has been established but when I try to ping (to check whether they are able to communicate or not) my Windows laptop from the Raspberry PI then it is not able to ping but when I ping my Raspberry PI from laptop it pings successfully. My real problem is actually that I am not able to ssh from the laptop to the Raspberry PI through ethernet. The description about pinging I gave just because I thought it will be related to same problem because of which I cannot ssh from laptop to the Raspberry PI, and that the ping description may help you to find the solution to my problem.

Please help me to fix my problem, and be able to access my Raspberry from my laptop.

What kind of additional network detail and configuration should I provide you for the help?

Raspberry pi 3 boot issues

$
0
0

Got a new Raspberry Pi 3 and I'm trying to use it with my Mac. I formatted the SD card and downloaded NOOBS. The green light comes on sometimes but when I add this to terminal:

ssh pi@raspberrypi.local

I get this error message:

ssh: Could not resolve hostname raspberrypi.local: nodename nor servname provided, or not known

Please advise.

Raspberry pi 12v relay

$
0
0

I have bought this relay:

https://rover.ebay.com/rover/0/0/0?mpre=https%3A%2F%2Fwww.ebay.co.uk%2Fulk%2Fitm%2F262722739443

In the '1 channel 12v relay' variety

I am going to be using it to power and unpower a 12v mag lock. Am I correct in saying that the mag lock needs 12v power from the wall as well as the relay, as the relay doesn't actually power the mag lock itself does It?

As the pi won't be able to give the relay 12v Surely?

If I need a 12v adapter for the relay how many amps will it need to be?

Syncing to SD Card is too slow

$
0
0

I'm writing some bytes to the filesystem. Afterward I'm calling sync to ensure the buffered data is flushed to the SD card. This command takes several seconds!

I'm working with raspbian. My SD Card is a 16GB Kingston Class 10 (industrial). Logging the disk io with sudo iotop -o -d 1 -a say, that only some 100 KBytes are written to disk.

To find out the source of the problem I'm doing following:

  • Watching the output of sudo iotop -o -d 1 -a in one Terminal
  • Run some application that writes about every minute some 100Kbytes
  • Calling time sync in an other terminal after the write is done. This one takes sometimes several seconds (up to 5sec). (if nothing is written to disk it takes only some milliseconds)

Whats wrong that sync takes as long?

How to speed up SPI chip select transition using "spidev"?

$
0
0

I successfully drive a DAC via SPI using the spidev native SPI driver using a RaspberryPi3. The core portion of my code is as follows:

fd = open("/dev/spidev0.0", O_RDWR);
txarr[0]=0xAA;
txarr[1]=0x01;
trstruct.tx_buf = (unsigned long)txarr;
ioctl(fd, SPI_IOC_MESSAGE(1), &trstruct);

It works ok, but timing is far from what I was expecting. Inspecting the SPI signals shows the following (top trace is chip select, mid trace is data and bottom trace is SCLK): enter image description here As we can see, the chip select is asserted low far before data transfer(about 6.5us earlier, and data transfer lasts just 1.9us). This behavior voids the benefits of using SPI at high speeds when multiple subsequent data transfers are needed.

Any idea how to speed up the chip select assertion low and to minimize its lasting low after data transfer is finished ?

Many thanks in advance, Marco

Viewing all 50244 articles
Browse latest View live


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