composants:rpi_card

Raspberry Pi

Default login

  • User : pi
  • Pass : raspberry

At first boot on a fresh flash it is good practice to immediately run updates and configure a few options using raspi-config before proceeding to any more tuning.

$ sudo raspi-config

Go to Interface Options then SSH and activate it. No reboot is required.

It is good practice to have your router assign a static IP address to a RPi if you want to regularly connect to it via ssh

$ sudo raspi-config

Go to Interface Options then Camera and activate it. Raspi-config will propose a reboot which should be accepted.

Navigate to a folder where you want the script to be located.

$ touch camera.py

Edit this file and copy the following :

#!/usr/bin/env python
 
from picamera import PiCamera
from time import sleep
 
camera = PiCamera()
camera.start_preview()
sleep(5)
camera.capture('/home/pi/Desktop/picture.jpg')
camera.stop_preview()

Warning, this will save to user pi's desktop, remember to change username if you aren't using user pi

Run the script :

$ python camera.py

You can view the picture by either copying it to another machine with scp or by using a screen and mouse/keyboard on the pi itself.

You can use the built-in raspistill tool or make up your own in your choice of code language.

Example with raspistill :

$ raspistill -w 1920 -h 1080 - t 10000 -tl 1000 -o image%04d.jpg

This will take FullHD shots at 1 second interval for 10 seconds, naming them with 4-digit incremental numbers.

If no -w and -h options are provided, the Raspberry Pi will default to taking full sized pictures : 4056 x 3040 which will weigh approx. ~6 MB each. Also note that a Pi 4 will not be able to take these effeciently at an interval ~< 2s.

raspistill has a lot of options and effects that can be activated/parametered, have a look at raspistill –help or man raspistill

Official Documentation

Modify the /etc/rc.local file (requires sudo)

$ sudo nano /etc/rc.local

Before the 'exit 0' line at the end insert lines like this one :

bash /path/to/script.sh
$ cat /sys/class/thermal/thermal_zone0/temp

Divide by 1000 to get °C format

$ vcgencmd measure_temp
$ /opt/vc/bin/vcgencmd measure_temp (Full Path)

These measures were done on a Rapsberry Pi 4 running Raspbian with no heavy-duty program running, no screen or USB devices attached and at a room temperature around 20°C

  • With a 5V fan connected to 5V the temperature is stable around 35-38°C. Fan is loud and disturbing
  • With a 5V fan connected to 3.3V the temperature is stable around 41-42°C
  • With no fan connected the temperature is stable around 55-58°C
# Exports pin to userspace
$ echo "18" > /sys/class/gpio/export                  
 
# Sets pin 18 as an output
$ echo "out" > /sys/class/gpio/gpio18/direction
 
# Sets pin 18 to high
$ echo "1" > /sys/class/gpio/gpio18/value
 
# Sets pin 18 to low
$ echo "0" > /sys/class/gpio/gpio18/value 
 
# Exports pin to userspace
$ echo "4" > /sys/class/gpio/export
 
# Sets pin 4 as an input
echo "in" > /sys/class/gpio/gpio4/direction
 
# Read value of pin 4
cat /sys/class/gpio/gpio4/value
  • composants/rpi_card.txt
  • Last modified: 2021/05/23 19:48
  • by mh