From Futuragora Wiki
Revision as of 20:42, 30 January 2019 by Reset (talk | contribs) (→‎Fish Cam)
Jump to navigationJump to search

Project: Open Senses Pi


Tecnologias e componentes: - Raspberry Pi - Relay Board for arduino DFRobot - Pen wifi - InfraRed

GPI in use:

GPIO 17 - Infra red GPIO 23 - Infra red

Mapa do GPIO: https://developer-blog.net/wp-content/uploads/2013/09/raspberry-pi-rev2-gpio-pinout.jpg

Mount USB

mkdir /mnt/usb
mount -t ntfs-3g /dev/sda1 /mnt/usb


Control gpio pin with bash:

# Set up GPIO 23 and set to input
echo "23" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio23/direction
echo "24" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio24/direction
# Write output
echo "1" > /sys/class/gpio/gpio23/value
echo "1" > /sys/class/gpio/gpio24/value

Control with python:

sudo python
import RPi.GPIO as GPIO
GPIO.setup(22, GPIO.OUT)
GPIO.setup(25, GPIO.OUT)
GPIO.output(22, True)
GPIO.output(25, False)



View state:

cat /sys/class/gpio/gpio17/value

Relay Specs:

The module provides three connections labeled COM, NC and NO. NC stands for "NORMALLY CLOSED". This means that when the relay has no signal (LOW or 0V from an Arduino), the connected circuit wil be active; conversely, if you apply 5V or pull the pin HIGH, it will turn the connected circuit off. NO stands for "NORMALLY OPEN", and functions in the opposite way; when you apply 5V the circuit turns on, and at 0V the circuit turns off. Relays can replace a manual switch. Remove the switch and connect its wires toCOM and NO. When the relay is activated the circuit is closed and current can flow to the device you are controlling. Module Description: this module features an 250v 10A mounted on a 2 module TinkerKit board, one standard TinkerKit 3pin connector, one transistor, a green LED that signals that the module is correctly powered and an yellow LED that indicates when the relay is active.

Relay 1: d2 verde echo 23 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio23/direction echo 1 > /sys/class/gpio/gpio23/value echo 0 > /sys/class/gpio/gpio23/value

Relay 2 d7 laranja echo 23 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio23/direction echo 1 > /sys/class/gpio/gpio23/value echo 0 > /sys/class/gpio/gpio23/value

Relay 3 d8 azul echo 24 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio24/direction echo 1 > /sys/class/gpio/gpio24/value echo 0 > /sys/class/gpio/gpio24/value

Relay 4: d10 castanho 2 xLuzes do aquário echo 25 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio25/direction echo 1 > /sys/class/gpio/gpio25/value

Projectos: Led: http://razzpisampler.oreilly.com/ch03.html

gpio readall

apt-get install rpi.gpio

import RPi.GPIO as GPIO

nano /boot/config.txt nano /etc/modules


Infra Red: sudo apt-get install lirc

/etc/init.d/lirc stop

First test a remote control that you know to be working (example TV remote) to ensure that IR interface of the Raspberry Pi is working as expected.

On the terminal emulator

$mode2 -d /dev/lirc0

Point the working remote control at the Raspberry Pi

sudo service lirc stop $cd ~ Run the program irrecord $irrecord -d /dev/lirc0 my_remote_control.conf When the irrecord program wizard ask you to map key names, open another terminal emulator and list all the possible key names available in LIRC so that you can choose the best one that fits your requirement. The output of the command below is shown in the screenshot $irrecord --list-namespace Finally, the irrecord program will process your input and create a configuration file ~/my_remote_control.conf as shown in the third screenshot.

http://ozzmaker.com/how-to-control-the-gpio-on-a-raspberry-pi-with-an-ir-remote/ gcc -o irelay irelay.c -lwiringPi -llirc_client


sudo apt-get install v4l-utils

v4l2-ctl --list-devices

Fish Cam

  • Não consigo correr o script dentro de um sh, melhor meti-o o comando num cron.

Capture to OGV in High def:

avconv -y -f mjpeg -re -t 5 -i http://fa:fresco@ -r 25 -b 18550k -vcodec libtheora /root/fishcam.ogv

Low res:

avconv -y -f mjpeg -re -t 60 -i http://fa:fresco@ -an -r 15 -acodec vorbis -vcodec libtheora fishcam.ogv

Take a shot from video:

avconv -i ./fishcam.ogv -f mjpeg -vf "select=eq(n\,0)" -q:v 3 fishot.jpg

Rpi script:

picamshot.sh (takes a 1 minute video at 12PM)

echo "1" > /sys/class/gpio/gpio23/value
sleep 60
avconv -y -f mjpeg -re -t 60 -i http://fa:fresco@ -an -r 15 -acodec vorbis -vcodec libtheora /root/fishcam.ogv

Server FA scripts:


ssh get file at 12:15PM

fishot.sh (takes a shot and archive one copy at 12:30)

avconv -y -i /home/futuragora/public_html/futurai/opensenses/pi/fishcam.ogv -f mjpeg -vf "select=eq(n\,0)" -q:v 3 /home/futuragora/public_html/futurai/opensenses/pi/fishot.jpg | cp /home/futuragora/public_html/futurai/opensenses/pi/fishot.jpg "/home/futuragora/public_html/futurai/opensenses/pi/fishots/fishot-`date +"%Y%m%d_%H%M%S"`.jpg"




http://www.instructables.com/id/Record-Infrared-Codes-of-Any-Remote-Control-Unit-f/ http://ozzmaker.com/wp-content/uploads/2013/10/IRwiring2.png?csspreview=true http://ozzmaker.com/how-to-control-the-gpio-on-a-raspberry-pi-with-an-ir-remote/ https://www.modmypi.com/blog/raspberry-pis-remotes-ir-receivers http://www.instructables.com/id/Add-Infrared-Interface-to-Your-Raspberry-Pi/ http://www.instructables.com/id/Install-and-Configure-Linux-Infrared-Remote-Contro/ http://www.instructables.com/id/Record-Infrared-Codes-of-Any-Remote-Control-Unit-f/