<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Timelapse Archives - Esperimenti con logiche programmabili</title>
	<atom:link href="https://logicaprogrammabile.it/tag/timelapse/feed/" rel="self" type="application/rss+xml" />
	<link>https://logicaprogrammabile.it/tag/timelapse/</link>
	<description>Tutorial in italiano per imparare a programmare usando Arduino, Raspberry PI, Netduino</description>
	<lastBuildDate>Sat, 27 Feb 2021 22:08:58 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://logicaprogrammabile.it/wp-content/uploads/2017/11/cropped-logicaprogrammabile-logo-02-32x32.png</url>
	<title>Timelapse Archives - Esperimenti con logiche programmabili</title>
	<link>https://logicaprogrammabile.it/tag/timelapse/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Il miglior progetto timelapse camera con Raspberry Pi Zero</title>
		<link>https://logicaprogrammabile.it/miglior-progetto-timelapse-camera-raspberry-pi-zero-picam/</link>
					<comments>https://logicaprogrammabile.it/miglior-progetto-timelapse-camera-raspberry-pi-zero-picam/#respond</comments>
		
		<dc:creator><![CDATA[Marco Lai]]></dc:creator>
		<pubDate>Mon, 01 Mar 2021 07:00:04 +0000</pubDate>
				<category><![CDATA[Tutorial Raspberry PI]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[raspberry]]></category>
		<category><![CDATA[Timelapse]]></category>
		<guid isPermaLink="false">https://logicaprogrammabile.it/?p=6334</guid>

					<description><![CDATA[<p>Timplapse con registrazione circolare I progetti timelapse basati su schede Raspberry Pi sono numerosi, ben documentati e replicabili. Perchè quindi creare l&#8217;ennesimo progetto camera timelapse? La mia esigenza è quella di creare un sistema che scatta delle fotografia ad intervalli regolari, ma con la possibilità...</p>
<p>The post <a href="https://logicaprogrammabile.it/miglior-progetto-timelapse-camera-raspberry-pi-zero-picam/">Il miglior progetto timelapse camera con Raspberry Pi Zero</a> appeared first on <a href="https://logicaprogrammabile.it">Esperimenti con logiche programmabili</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>Timplapse con registrazione circolare</h1>
<p>I progetti timelapse basati su schede Raspberry Pi sono numerosi, ben documentati e replicabili. Perchè quindi creare l&#8217;ennesimo progetto camera timelapse?</p>
<p>La mia esigenza è quella di creare un sistema che scatta delle fotografia ad intervalli regolari, ma con la possibilità di registrarle in modo circolare. Cosa significa registrazione circolare?<br />
Il classico timelapse esegue un numero continuo di scatti. Il timelapse circolare invece, dopo aver raggiunto un numero massimo di scatti continua la sequenza di registrazione sovrascrivendo le foto meno recenti.</p>
<p>Questo sistema ha il vantaggio di non andare mai a saturare la memoria e quindi si adatta in tutte quelle situazioni in cui non possiamo andare spesso a scaricare le fotografie.</p>
<p>Infatti questo sistema è utile quando viene installato in zone remote e quando non abbiamo la certezza di andare a scaricare le foro in maniera regolare avendo la certezza che la registrazione saturerà la memoria del Raspberry.</p>
<p><span id="more-6334"></span></p>
<p>Nel dispositivo che ho realizzato ho inserito anche una serie di pulsanti in modo da avere un sistema gestire il software senza usare l&#8217;interfaccia grafica.</p>
<p>Lo scarico dei dati avviene utilizzando dei pulsanti che permettono di stoppare il timelapse, trasferire i files sulla pen drive e riprendere il ciclo di funzionamento.</p>
<p>Nella figura seguente è possibile osservare lo schema elettrico.</p>
<figure id="attachment_6589" aria-describedby="caption-attachment-6589" style="width: 838px" class="wp-caption aligncenter"><img fetchpriority="high" decoding="async" class="wp-image-6589 size-full" src="https://logicaprogrammabile.it/wp-content/uploads/2021/02/Timelapse_schema.png" alt="schema timelapse" width="838" height="471" srcset="https://logicaprogrammabile.it/wp-content/uploads/2021/02/Timelapse_schema.png 838w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/Timelapse_schema-300x169.png 300w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/Timelapse_schema-150x84.png 150w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/Timelapse_schema-768x432.png 768w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/Timelapse_schema-585x329.png 585w" sizes="(max-width: 838px) 100vw, 838px" /><figcaption id="caption-attachment-6589" class="wp-caption-text"><strong>Schema elettrico di collegamento</strong></figcaption></figure>
<p>I quattro ingressi del Raspberry sono normalmente bassi (resistenze da 10k collegate a massa), premendo un pulsante porteremmo la 3.3Vdc sul pin di ingresso. I due led invece servono per avere delle indicazioni luminose sull&#8217;operazione che il software sta eseguendo.</p>
<figure id="attachment_6592" aria-describedby="caption-attachment-6592" style="width: 700px" class="wp-caption aligncenter"><img decoding="async" class="wp-image-6592 size-full" src="https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam1.jpg" alt="pi zero cam" width="700" height="402" srcset="https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam1.jpg 700w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam1-300x172.jpg 300w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam1-150x86.jpg 150w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam1-585x336.jpg 585w" sizes="(max-width: 700px) 100vw, 700px" /><figcaption id="caption-attachment-6592" class="wp-caption-text"><strong>Pi Zero cam timelapse &#8211; lato componenti</strong></figcaption></figure>
<figure id="attachment_6591" aria-describedby="caption-attachment-6591" style="width: 394px" class="wp-caption aligncenter"><img decoding="async" class="wp-image-6591 size-full" src="https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam.jpg" alt="Pi Zero cam timelapse" width="394" height="700" srcset="https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam.jpg 394w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam-169x300.jpg 169w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam-84x150.jpg 84w" sizes="(max-width: 394px) 100vw, 394px" /><figcaption id="caption-attachment-6591" class="wp-caption-text"><strong>Pi Zero cam timelapse &#8211; vista frontale</strong></figcaption></figure>
<figure id="attachment_6594" aria-describedby="caption-attachment-6594" style="width: 700px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-6594 size-full" src="https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam2.jpg" alt="zero cam" width="700" height="394" srcset="https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam2.jpg 700w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam2-300x169.jpg 300w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam2-150x84.jpg 150w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam2-585x329.jpg 585w" sizes="auto, (max-width: 700px) 100vw, 700px" /><figcaption id="caption-attachment-6594" class="wp-caption-text"><strong>Pi Zero cam timelapse &#8211; lato connettori</strong></figcaption></figure>
<figure id="attachment_6595" aria-describedby="caption-attachment-6595" style="width: 700px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-6595 size-full" src="https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam3.jpg" alt="Pi Zero cam timelapse" width="700" height="402" srcset="https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam3.jpg 700w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam3-300x172.jpg 300w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam3-150x86.jpg 150w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam3-585x336.jpg 585w" sizes="auto, (max-width: 700px) 100vw, 700px" /><figcaption id="caption-attachment-6595" class="wp-caption-text"><strong>Pi Zero cam timelapse &#8211; interfaccia di controllo</strong></figcaption></figure>
<figure id="attachment_6597" aria-describedby="caption-attachment-6597" style="width: 700px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-6597 size-full" src="https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam4.jpg" alt="zero cam timelapse" width="700" height="412" srcset="https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam4.jpg 700w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam4-300x177.jpg 300w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam4-150x88.jpg 150w, https://logicaprogrammabile.it/wp-content/uploads/2021/02/zero_cam4-585x344.jpg 585w" sizes="auto, (max-width: 700px) 100vw, 700px" /><figcaption id="caption-attachment-6597" class="wp-caption-text"><strong>Pi Zero cam timelapse &#8211; montaggio su supporto</strong></figcaption></figure>
<p>Il codice scritto in Python permette di acquisisce e memorizzare le foto, gestisce i pulsanti i led e scaricare le foto sulla pen drive.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">from picamera import PiCamera
from os import system
import shutil
import time
import RPi.GPIO as GPIO
import os.path
import os

src_folder = "/home/pi/PythonProject/tl_pics/"
dest_folder = "/media/pi/logicapro/foto"

StartTL = True
AutoStart = True

i = 0
loop = False
newloop = False

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

GPIO.setup(19, GPIO.IN)
GPIO.setup(26, GPIO.IN)
GPIO.setup(4, GPIO.IN)
GPIO.setup(17, GPIO.IN)

GPIO.setup(27, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)

#led rosso on giallo off
GPIO.output(27, GPIO.HIGH)
GPIO.output(22, GPIO.LOW)

camera = PiCamera()
camera.resolution= (1024,768)

pics_id = open('/home/pi/PythonProject/PicsIndex.dat')
i = int(pics_id.read())
pics_id.close()

if (i&gt;0):
    loop=True

def StopTL(channel):
    global StartTL
    global AutoStart
        
    print("STOP TL")
    
    if StartTL == True:
        StartTL = False
        AutoStart = False
        print ("StartTL =", StartTL)
        print ("AutoStart =", AutoStart)
        GPIO.output(27, GPIO.HIGH)        
        time.sleep(1)    
        
            
def RunTL(channel):
    global StartTL
    global AutoStart
    
    print("START TL")
    
    if StartTL == False:
        StartTL = True
        AutoStart = True
        print ("StartTL =", StartTL)
        print ("AutoStart =", AutoStart)
        pics_id = open('/home/pi/PythonProject/PicsIndex.dat')
        i = int(pics_id.read())
        print ("RunTL i =", i)
        pics_id.close()
        GPIO.output(27, GPIO.LOW)
        GPIO.output(22, GPIO.LOW)        
        time.sleep(1)

GPIO.add_event_detect(17, GPIO.RISING, callback=StopTL, bouncetime=500)
GPIO.add_event_detect(4, GPIO.RISING, callback=RunTL, bouncetime=500)

while True:
    
    #primo pulsante
    if AutoStart == True:
        #start timelapse       
        while (StartTL):
            i += 1
            #print (i)
            if loop==True:
                #print ("i=", i)
                
                try:
                    t = time.localtime()
                    anno = str(t[0])
                    mese = str(t[1])
                    giorno = str(t[3])
                    #print(giorno + "-" + mese + "-" + anno)
                    #se esiste il file lo cancello
                    if (os.path.isfile('/home/pi/PythonProject/tl_pics/image{0:05d}.jpg'.format(i)) == True):
                        print("elimino file esistente ".format(i))
                        os.remove('/home/pi/PythonProject/tl_pics/image{0:05d}.jpg'.format(i))
                    
                    print("Eseguo shot " + str(i))
                    camera.capture('/home/pi/PythonProject/tl_pics/image{0:05d}.jpg'.format(i))
                    time.sleep(0.7)
                    GPIO.output(27, GPIO.HIGH)
                    time.sleep(0.3)
                    GPIO.output(27, GPIO.LOW)
                    #time.sleep(60)
                    pics_id = open('/home/pi/PythonProject/PicsIndex.dat', 'w')
                    pics_id.write(str(i))
                    pics_id.close()
                    print("pic_shot = " + str(i))
                except (e):
                    print("Errore shot " + str(i))
                    f = open('/home/pi/PythonProject/Error.txt', 'a')
                    f.write("Errore shot file " + str(e) + " ")
                    f.write(str(i) + "\n")
                    f.close()
                except:
                    print("Errore generico shot " + str(i))
                    f = open('/home/pi/PythonProject/Error.txt', 'a')
                    f.write("Errore shot file " + str(i) + " \n")
                    f.close()
            
                fc = open('/home/pi/PythonProject/CopyLog.txt', 'a')
                fc.write("Current shot ")
                fc.write(str(i) + "\n")
                fc.close()
            
                #attendi 2 minuti 60x2sec
                for tempo in range (60): #range(60):
                    GPIO.output(22, GPIO.HIGH)
                    time.sleep(0.1)
                    GPIO.output(22, GPIO.LOW)
                    time.sleep(1.9)
                    
                    if StartTL == False:
                        break
            
            #10080 5040
            if i &gt;= 4320:
                i=0                
                loop=True                
                print("NEW LOOP")
                time.sleep(1)
            
            if GPIO.input(17):
                break
            
        print ("Exit loop")    
    
    #terzo pulsante
    if GPIO.input(19):
        #crea un video dai file del timelapse
        print("Terzo Pulsante")
        GPIO.output(22, GPIO.HIGH)
        time.sleep(0.5)
        GPIO.output(22, GPIO.LOW)
        time.sleep(0.5)
        GPIO.output(22, GPIO.HIGH)
        time.sleep(0.5)
        GPIO.output(22, GPIO.LOW)
        time.sleep(0.5)
        GPIO.output(22, GPIO.HIGH)
        time.sleep(0.5)
        GPIO.output(22, GPIO.LOW)
        time.sleep(0.5)
        os.system("sudo reboot")
        
    #quarto pulsante
    #copia le foto nella cartella della pen drive
    if GPIO.input(26):
        GPIO.output(27, GPIO.HIGH)
        GPIO.output(22, GPIO.HIGH)
        time.sleep(1)
        try:
            print("Copia file in corso")
            time.sleep(1)

            src = os.listdir(src_folder)

            for files in src:
                GPIO.output(22, GPIO.HIGH)
                time.sleep(0.1)

                if (files.endswith(".jpg")):
                    shutil.copy("/home/pi/PythonProject/tl_pics/" + files, dest_folder + "/" + files)
                    print(files)
                    
                GPIO.output(22, GPIO.LOW)
                time.sleep(0.1)
            
            #fine copia files
            GPIO.output(27, GPIO.LOW)
            GPIO.output(22, GPIO.LOW)
            
            os.system("sudo umount /media/pi/logicapro")
            time.sleep(3)
            
            print("Copia file terminata")
            AutoStart=True
            StartTL = True
            
        except (IndexError):
            print("Errore copia file")
            AutoStart=False
            GPIO.output(22, GPIO.HIGH)
            GPIO.output(27, GPIO.HIGH)
            time.sleep(3)
            GPIO.output(22, GPIO.LOW)
            GPIO.output(27, GPIO.LOW)
            f = open('/home/pi/PythonProject/Error.txt', 'a')
            f.write("Errore copia file ")
            f.write(str(files) + "\n")
            f.close()
        except  (Exception, e):
            print("Errore generico")
            f = open('/home/pi/PythonProject/Error.txt', 'a')
            f.write("Errore generico " + str(e))
            f.write(str(files) + "\n")
            f.close()
            AutoStart=True
            StartTL = True
        

GPIO.cleanup()
</pre>
<p>I commenti nel codice illustrano come lavorano le istruzione Python.</p>
<p>Per la realizzazione ho scelto di utilizzare una Raspberry Pi ZERO, principalmente per il basso costo e le dimensioni contenute. La Pi camera può essere sostituita con la versione ir.</p>
<p>Per quanto riguarda l&#8217;alimentazione della scheda in zone remote è necessario un pannello solare, un regolatore di carica e una batteria dimensionati opportunamente per fornire la corrente per alimentare la Pi Zero e la Pi Camera.</p>
<p>The post <a href="https://logicaprogrammabile.it/miglior-progetto-timelapse-camera-raspberry-pi-zero-picam/">Il miglior progetto timelapse camera con Raspberry Pi Zero</a> appeared first on <a href="https://logicaprogrammabile.it">Esperimenti con logiche programmabili</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://logicaprogrammabile.it/miglior-progetto-timelapse-camera-raspberry-pi-zero-picam/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
