Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Three scripts to one
#1
Hello,
Would need help combining three python scripts into one.

The function I am looking for is the following, in step one a sensor GPIO20 is affected, this triggers a photoshoot with a usb camera save to a file to /home/pi/test.jpg on my raspberry pi
In the second step i want to read out the tag from a serial rfid reader, the information i get out there through the readout i want to rename my test.jpg to!
I have the following script but I am really a beginner at this and have got stuck, hope someone can help me further Angel ?!


---------------------------------------------------------------------------------------------
# My camera script
#!/usr/bin/env python
from time import sleep
import RPi.GPIO as GPIO
import time 
import os

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

while True:
    
    if GPIO.input(20):
        sleep(0.5)
        os.system('fswebcam -r 1280x720 -S 3 --jpeg 100 --save /home/pi/test.jpg')
        time.sleep(1)
---------------------------------------------------------------------------------------------
# My serial script to read rfid tag.
#!/usr/bin/env python
import time
import serial
import tempfile

ser = serial.Serial(
 port='/dev/ttyUSB0',
 baudrate = 9600,
 parity=serial.PARITY_NONE,
 stopbits=serial.STOPBITS_ONE,
 bytesize=serial.EIGHTBITS,
 timeout=1
)
counter=0
while 1:
 x=ser.readline()
 print (x)
---------------------------------------------------------------------------------------------
# My script to rename file.
#!/usr/bin/env python
import os  
os.rename('/home/pi/temp.jpg','/home/pi/rfidtagnumber.jpg')
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020