composants:rpi_card

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
composants:rpi_card [2020/11/06 15:59] – [Running scripts at startup] mhcomposants:rpi_card [2020/11/06 16:54] – [Running scripts at startup] mh
Line 1: Line 1:
 ====== Raspberry Pi ====== ====== Raspberry Pi ======
  
-===== General Infos ===== 
  
-==== Default login ====+=== Default login ===
  
   ***User :** pi   ***User :** pi
Line 9: Line 8:
  
  
-==== Activating SSH ====+====SSH =====
  
 +<code bash>
 +$ sudo raspi-config
 +</code>
  
-==== Running scripts at startup ====+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'' 
 + 
 +===== Camera ===== 
 + 
 +==== Activating the camera ==== 
 + 
 +<code bash> 
 +$ sudo raspi-config 
 +</code> 
 + 
 +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. 
 + 
 +<code bash> 
 +$ touch camera.py 
 +</code> 
 + 
 +Edit this file and copy the following : 
 + 
 +<code python> 
 +#!/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() 
 +</code> 
 + 
 +//Warning, this will save to user pi's desktop, remember to change username if you aren't using user pi// 
 + 
 +Run the script : 
 + 
 +<code bash> 
 +$ python camera.py 
 +</code> 
 + 
 +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. 
 + 
 +==== Creating a Timelapse with Camera ==== 
 + 
 +You can use the built-in ''raspistill'' tool or make up your own in your choice of code language. 
 + 
 +Example with ''raspistill''
 + 
 +<code bash> 
 +$ raspistill -w 1920 -h 1080 - t 10000 -tl 1000 -o image%04d.jpg 
 +</code> 
 + 
 +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'' 
 +===== Scripts @ startup =====
  
 Modify the /etc/rc.local file (requires sudo) Modify the /etc/rc.local file (requires sudo)
  • composants/rpi_card.txt
  • Last modified: 2021/05/23 19:48
  • by mh