2019-12-02 05:56:45 +01:00
|
|
|
.. _install:
|
|
|
|
|
2019-12-02 05:56:22 +01:00
|
|
|
============
|
2019-12-02 06:00:41 +01:00
|
|
|
Acquisition
|
2019-12-02 05:56:22 +01:00
|
|
|
============
|
2019-12-02 05:54:40 +01:00
|
|
|
|
2019-12-02 05:57:16 +01:00
|
|
|
If you are using the `Raspbian`_ distro, it is best to install picamera using
|
|
|
|
the system's package manager: apt. This will ensure that picamera is easy to
|
|
|
|
keep up to date, and easy to remove should you wish to do so. It will also make
|
|
|
|
picamera available for all users on the system. To install picamera using apt
|
|
|
|
simply::
|
2019-12-02 05:59:41 +01:00
|
|
|
|
2019-12-02 06:02:50 +01:00
|
|
|
Import the librairies needed to execute the script
|
2019-12-02 05:59:41 +01:00
|
|
|
=======================================================
|
|
|
|
|
|
|
|
If you are using the `Raspbian`_ distro, it is best to install picamera using
|
|
|
|
the system's package manager: apt. This will ensure that picamera is easy to
|
|
|
|
keep up to date, and easy to remove should you wish to do so. It will also make
|
|
|
|
picamera available for all users on the system. To install picamera using apt
|
|
|
|
simply::
|
|
|
|
|
|
|
|
from gpiozero import LED
|
|
|
|
import smbus2 as smbus
|
|
|
|
from time import sleep
|
|
|
|
from picamera import PiCamera
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
2019-12-02 06:02:50 +01:00
|
|
|
Define the used pinout
|
2019-12-02 05:59:41 +01:00
|
|
|
=========================
|
|
|
|
|
2019-12-02 06:02:04 +01:00
|
|
|
If you are using the `Raspbian`_ distro, it is best to install picamera using
|
|
|
|
the system's package manager: apt. This will ensure that picamera is easy to
|
|
|
|
keep up to date, and easy to remove should you wish to do so. It will also make
|
|
|
|
picamera available for all users on the system. To install picamera using apt
|
|
|
|
simply::
|
|
|
|
|
2019-12-02 05:59:41 +01:00
|
|
|
GREEN = LED(16)
|
|
|
|
RED = LED(12)
|
|
|
|
BLUE = LED(26)
|
|
|
|
|
|
|
|
RELAY = LED(14)
|
|
|
|
|
|
|
|
|
2019-12-02 06:02:50 +01:00
|
|
|
Configuration file
|
2019-12-02 05:59:41 +01:00
|
|
|
=====================
|
|
|
|
|
2019-12-02 06:02:04 +01:00
|
|
|
If you are using the `Raspbian`_ distro, it is best to install picamera using
|
|
|
|
the system's package manager: apt. This will ensure that picamera is easy to
|
|
|
|
keep up to date, and easy to remove should you wish to do so. It will also make
|
|
|
|
picamera available for all users on the system. To install picamera using apt
|
|
|
|
simply::
|
|
|
|
|
2019-12-02 05:59:41 +01:00
|
|
|
camera = PiCamera()
|
|
|
|
|
|
|
|
camera.resolution = (2592, 1944)
|
|
|
|
camera.iso = 60
|
|
|
|
camera.exposure_mode = 'off'
|
|
|
|
camera.shutter_speed = 100
|
|
|
|
camera.awb_mode = 'off'
|
|
|
|
camera.awb_gains = (2,1)
|
|
|
|
|
|
|
|
nb_frame=300
|
|
|
|
|
|
|
|
duration_loading=120 #(sec)
|
|
|
|
duration_flushing=20 #(sec)
|
|
|
|
duration_aeration=30 #(sec)
|
|
|
|
|
2019-12-02 06:02:50 +01:00
|
|
|
Define simple sequence for I2C modules (Valves and pump)
|
2019-12-02 05:59:41 +01:00
|
|
|
===========================================================
|
|
|
|
|
2019-12-02 06:02:04 +01:00
|
|
|
If you are using the `Raspbian`_ distro, it is best to install picamera using
|
|
|
|
the system's package manager: apt. This will ensure that picamera is easy to
|
|
|
|
keep up to date, and easy to remove should you wish to do so. It will also make
|
|
|
|
picamera available for all users on the system. To install picamera using apt
|
|
|
|
simply::
|
|
|
|
|
2019-12-02 05:59:41 +01:00
|
|
|
def pump(state, verbose=True):
|
|
|
|
|
|
|
|
sleep(0.2)
|
|
|
|
|
|
|
|
if state is 'forward':
|
|
|
|
# Stop pumping
|
|
|
|
bus.write_byte(0x30, 1)
|
|
|
|
sleep(1)
|
|
|
|
feedback=bus.read_byte(0x30)
|
|
|
|
if feedback == 1:
|
|
|
|
if verbose is True:
|
|
|
|
print("Pumping : Forward")
|
|
|
|
|
|
|
|
if state is 'backward':
|
|
|
|
# Stop pumping
|
|
|
|
bus.write_byte(0x30, 2)
|
|
|
|
sleep(1)
|
|
|
|
feedback=bus.read_byte(0x30)
|
|
|
|
if feedback == 2:
|
|
|
|
if verbose is True:
|
|
|
|
print("Pumping : Backward")
|
|
|
|
|
|
|
|
if state is 'stop':
|
|
|
|
# Stop pumping
|
|
|
|
bus.write_byte(0x30, 0)
|
|
|
|
sleep(1)
|
|
|
|
feedback=bus.read_byte(0x30)
|
|
|
|
if feedback == 0:
|
|
|
|
if verbose is True:
|
|
|
|
print("Pumping : Stop")
|
|
|
|
|
|
|
|
if state is 'slow':
|
|
|
|
# Start pumping
|
|
|
|
bus.write_byte(0x30, 3)
|
|
|
|
sleep(1)
|
|
|
|
feedback=bus.read_byte(0x30)
|
|
|
|
if feedback == 3:
|
|
|
|
if verbose is True:
|
|
|
|
print("Pumping : Slow")
|
|
|
|
|
|
|
|
if state is 'medium':
|
|
|
|
# Start pumping
|
|
|
|
bus.write_byte(0x30, 5)
|
|
|
|
sleep(1)
|
|
|
|
feedback=bus.read_byte(0x30)
|
|
|
|
if feedback == 5:
|
|
|
|
if verbose is True:
|
|
|
|
print("Pumping : Medium")
|
|
|
|
|
|
|
|
if state is 'fast':
|
|
|
|
# Start pumping
|
|
|
|
bus.write_byte(0x30, 9)
|
|
|
|
sleep(1)
|
|
|
|
feedback=bus.read_byte(0x30)
|
|
|
|
if feedback == 9:
|
|
|
|
if verbose is True:
|
|
|
|
print("Pumping : Fast")
|