This is an old revision of the document!
Raspberry Pi
Default login
- User : pi
- Pass : raspberry
Activating SSH
$ 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
Activating Camera
$ sudo raspi-config
Go to Interface Options
then Camera
and activate it. Raspi-config will propose a reboot which should be accepted.
Python script to take pictures
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 once.
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.
Running scripts at startup
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
Temperature checks
CPU temp
$ cat /sys/class/thermal/thermal_zone0/temp
Divide by 1000 to get °C format
GPU temp
$ 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
GPIO
Using GPIO through bash
# 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