Caméra jevois + raspberry pi 0 W

wget http://jevois.org/data/jevois-image-latest-8G.zip
unzip jevois-image-latest-8G.zip
sudo dd if=jevois-image-1.0-8G.img of=/dev/sdX bs=1M # exact .img file name may vary
sync

ne fonctionne pas : pas de partitions

installer etcher :

https://github.com/resin-io/etcher#redhat-rhel-and-fedora-based-package-repository-gnulinux-x86x64

wget https://bintray.com/resin-io/redhat/rpm -O /etc/yum.repos.d/bintray-resin-io-redhat.repo
760 dnf install -y etcher-electron
761 etcher-electron

[155313.184801] usb 1-1: New USB device found, idVendor=1d6b, idProduct=0102
[155313.184808] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[155313.184813] usb 1-1: Product: JeVois-A33 Smart Camera
[155313.184817] usb 1-1: Manufacturer: JeVois Inc
[155313.186345] uvcvideo: Found UVC 1.00 device JeVois-A33 Smart Camera (1d6b:0102)
[155313.187136] uvcvideo 1-1:1.0: Entity type for entity Processing 2 was not initialized!
[155313.187145] uvcvideo 1-1:1.0: Entity type for entity Camera 1 was not initialized!
[155313.187497] input: JeVois-A33 Smart Camera: JeVois as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/input/input32
[155313.191735] usb-storage 1-1:1.4: USB Mass Storage device detected
[155313.192743] scsi host3: usb-storage 1-1:1.4
[155313.275458] cdc_acm 1-1:1.2: ttyACM0: USB ACM device
[155313.276457] usbcore: registered new interface driver cdc_acm
[155313.276459] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[155314.216786] scsi 3:0:0:0: Direct-Access JeVois Smart Camera 0333 PQ: 0 ANSI: 2
[155314.217857] sd 3:0:0:0: Attached scsi generic sg1 type 0
[155314.218154] sd 3:0:0:0: Power-on or device reset occurred
[155314.221489] sd 3:0:0:0: [sdb] Attached SCSI removable disk

https://fablab.coagul.org/Installer_MJPG-Streamer_sur_Raspberry_Pi

sudo apt-get install subversion libjpeg8-dev imagemagick libv4l-dev
svn checkout http://svn.code.sf.net/p/mjpg-streamer/code/mjpg-streamer/
sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h

cd mjpg-streamer
make
make install

Créer le fichier /etc/init.d/mjpg_streamer avec le contenu suivant, et le rendre exécutable.

#!/bin/sh
# /etc/init.d/mjpg_streamer
# v0.21 phillips321.co.uk and pila
### BEGIN INIT INFO
# Provides:          mjpg_streamer.sh
# Required-Start:    $network $local_fs
# Required-Stop:     $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: mjpg_streamer for webcam
# Description:       Streams /dev/video0 to http://IP/?action=stream
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin 

INPUT="/usr/local/lib/input_uvc.so -d /dev/video0 -r 640x480 -f 20"
OUTPUT="/usr/local/lib/output_http.so -p 8080 -w /usr/local/www"
f_message(){
        echo "[+] $1"
}

# Carry out specific functions when asked to by the system
case "$1" in
        start)
                f_message "Starting mjpg_streamer"
                mjpg_streamer -b -i "$INPUT" -o "$OUTPUT"
                sleep 2
                f_message "mjpg_streamer started"
                ;;
        stop)
                f_message "Stopping mjpg_streamer..."
                killall mjpg_streamer
                f_message "mjpg_streamer stopped"
                ;;
        restart)
                f_message "Restarting daemon: mjpg_streamer"
                killall mjpg_streamer
                mjpg_streamer -b -i "$INPUT" -o "$OUTPUT"
                sleep 2
                f_message "Restarted daemon: mjpg_streamer"
                ;;
        *)
                f_message "Usage: $0 {start|stop|restart}"
                exit 1
                ;;
esac
exit 0

Il reste alors à l’ajouter aux scripts de démarrage :

 sudo chmod +x /etc/init.d/mjpg_streamer
 sudo update-rc.d mjpg_streamer defaults

Raspberry pi 0 W + caméra jevois + chargeur portable tel

Raspberry pi zero w + lidar lite v3

[table id=2 /]

[codesyntax lang=”python”]

import smbus
import time
bus=smbus.SMBus(1)
addr=0x62

while True:
    bus.write_byte_data(0x62,0x00, 0x04)   
    val_high=bus.read_byte_data(0x62,0x0f)   
    val_low=bus.read_byte_data(0x62,0x10)   
    dist_cm=val_high*256+val_low
    print `dist_cm` + " cm   "
    time.sleep(1)

[/codesyntax]

Maj 22/12/2018

J’ai du réinstaller le Pi 0 W et le lidar ne fonctionnait plus. Faire :

https://github.com/raspberrypi/firmware/issues/828

  1. Download the old module here.
  2. Copy this file into /boot/overlays.
  3. In /boot/config.txt add the line dtoverlay=i2c1-bcm2708 at the end.

Veilleuse

Le supercondensateur est rechargé par le panneau solaire. La led s’allume quand il fait sombre et le seuil est réglable via le potentiomètre.

Raspberry pi Zero W + servo

Source : http://espace-raspberry-francais.fr/Composants/Controler-Servo-Moteur-Raspberry-Francais/

[codesyntax lang=”python”]

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.setwarnings(False)

ajoutAngle = 5

print("\n+----------/ ServoMoteur  Controlleur /----------+")
print("|                                                |")
print("| Le Servo doit etre branche au pin 11 / GPIO 17 |")
print("|                                                |")
print("+------------------------------------------------+\n")

print("Comment controler le Servo ?")
choix = input("1. Choisir un angle\n2. Faire tourner de 0 a 180\n")

if choix == 2 :

    nbrTour = input ("Entrez le nombre d'aller-retour que fera le Servo :\n")

    pwm=GPIO.PWM(17,100)
    pwm.start(5)

    angle1 = 0
    duty1 = float(angle1)/10 + ajoutAngle

    angle2=180
    duty2= float(angle2)/10 + ajoutAngle

    i = 0

    while i <= nbrTour:
         pwm.ChangeDutyCycle(duty1)
         time.sleep(0.8)
         pwm.ChangeDutyCycle(duty2)
         time.sleep(0.8)
         i = i+1
    GPIO.cleanup()

if choix == 1 :
    angle = input("Entrez l'angle souhaite :\n")
    duree = input("Entrez la duree durant laquelle le Servo devra tenir sa position : ( en secondes )\n")

    pwm=GPIO.PWM(17,100)
    pwm.start(5)

    angleChoisi = float(angle)/10 + ajoutAngle
    pwm.ChangeDutyCycle(angleChoisi)
    time.sleep(duree)
    GPIO.cleanup()

[/codesyntax]

Raspberry pi zero W + MCP3002 (ADC)

Source : http://makesensors.botbook.com/

[codesyntax lang=”python”]

# pot.py - potentiometer with mcp3002
# (c) BotBook.com - Karvinen, Karvinen, Valtokari
import spidev # installation help in book and botbook_mcp3002.py	# <1>
import time

def readPotentiometer():
	spi = spidev.SpiDev()	# <2>
	spi.open(0, 0)	# <3>
	command = [1, 128, 0]	# <4>
	reply = spi.xfer2(command)	# <5>
	#Parse reply 10 bits from 24 bit package
	data = reply[1] & 31	# <6>
	data = data << 6	# <7>
	data = data + (reply[2] >> 2)	# <8>
	spi.close()	# <9>
	return data

def main():
	while True:
		potentiometer = readPotentiometer()	# <10>
		print("Current potentiometer value is %i " % potentiometer)
		time.sleep(0.5)	

if __name__ == "__main__":
	main()

[/codesyntax]

 

Raspberry pi zero W + water pump

[codesyntax lang=”python”]

#!/usr/bin/python
# coding=utf-8

import RPi.GPIO as GPIO         ## Import GPIO Library
import time                     ## Import 'time' library (for 'sleep')
import os 
import commands,sys

outPin = 21                     
GPIO.setmode(GPIO.BCM)        ## Use BOARD pin numbering
GPIO.setup(outPin, GPIO.OUT)    ## Set pin 21 to OUTPUT

GPIO.output(outPin, 1)  ## Turn off LED
time.sleep(10)
GPIO.output(outPin, 0) 
GPIO.cleanup()      

[/codesyntax]

Save

Raspberry pi zero W + Soil Humidity Sensor

20170801_195806

20170801_195940

[table id=1 /]

[codesyntax lang=”python”]

#!/usr/bin/python
# coding=utf-8

import RPi.GPIO as GPIO ## Import GPIO Library
import time ## Import 'time' library (for 'sleep')
import os
import commands,sys

inPin = 2 
GPIO.setmode(GPIO.BCM) ## Use BOARD pin numbering
GPIO.setup(inPin, GPIO.IN) ## Set pin 2 to OUTPUT

value=GPIO.input(inPin)
print value
GPIO.cleanup()

[/codesyntax]

 

Save

Save

Save

Save

Save

Save

Save

Save

Tracker GPS

20170217_232938

Composants

  • Une carte Arduino Nano
  • Un module GPS Ublox neo-6m
  • Un adaptateur microSD
  • Une plaque à insertion rapide
  • Des fils
  • Un ordinateur avec l’environnement de développement Arduino

Schéma de câblage

trackergps_bb

 

Code

#include “SoftwareSerial.h”
#include <SD.h>
#include <SPI.h>
#include <TinyGPS++.h>

int CS_PIN = 10;

File file;

char data;

double latitude;
double longitude;
double latitudedec;
double longitudedec;

TinyGPSPlus gps;

SoftwareSerial mySerial(4, 5); // RX, TX

void setup()
{
Serial.begin(9600);
Serial.println(“uBlox Neo 6M”);
mySerial.begin(9600);
initializeSD();
}
void loop() // run over and over
{
if (mySerial.available())
{

data = mySerial.read();
// Serial.print(data);
gps.encode(data);
if (gps.location.isUpdated())
{
latitudedec = gps.location.rawLat().billionths;
longitudedec = gps.location.rawLng().billionths;
latitude = gps.location.rawLat().deg;
longitude = gps.location.rawLng().deg;

Serial.println(“——– FIX GPS ————“);
Serial.print(“LATITUDE=”); Serial.println(latitude);
Serial.print(“LONGITUDE=”); Serial.println(longitude);
File dataFile = SD.open(“datalog.txt”, FILE_WRITE);
dataFile.println(String(gps.date.value())+”;”+String(gps.time.value())+”;”+String(latitude)+”;”+String(latitudedec)+”;”+String(longitude)+”;”+String(longitudedec));

dataFile.close();
}
}
}

void initializeSD()
{
Serial.println(“Initializing SD card…”);
pinMode(CS_PIN, OUTPUT);

if (SD.begin())
{
Serial.println(“SD card is ready to use.”);
} else
{
Serial.println(“SD card initialization failed”);
return;
}
}

Ci dessous un code en Python pour générer un fichier pour Google-earth

 

#!/usr/bin/python

import math
import os,sys,glob
import os,commands,sys
import datetime,time

class KML_File:
“For creating KML files used for Google Earth”
def __init__(self, filepath):
self.filepath = filepath
“adds the kml header to a file (includes a default style)”
file = open(filepath,”w”)
file.write(
“<?xml version=\”1.0\” encoding=\”UTF-8\”?>\n”\
“<kml xmlns=\”http://www.opengis.net/kml/2.2\”>\n” \
“<Folder>\n”\
“<name></name>\n”)
file.close()

def close(self):
file = open(self.filepath,”a”)
file.write(“</Folder>\n”)
file.write(“</kml>”)
file.close()

def open_folder(self, name):
file = open(self.filepath,”a”)
file.write(
“<Folder>\n”\
” <name>” + name + “</name>\n”)
file.close()

def close_folder(self):
file = open(self.filepath,”a”)
file.write(
“</Folder>\n”)
file.close()

def add_placemarker(self, allLonAndLat, altitude = 0.0, description = ” “, name = ” “, range = 6000, tilt = 45, heading = 0):
“adds the point to a kml file”
file = open(self.filepath,”a”)
file.write(
“<Placemark>\n”\
” <description>” + description + “</description>\n”\
” <name>” + name + “</name>\n”\
” <Point>\n”\
” <coordinates>”+allLonAndLat+”</coordinates>\n”\
” </Point>\n”\
” </Placemark>\n”)
file.close()

def add_coord(self, allLonAndLat, altitude = 0.0, description = ” “, name = ” “, range = 6000, tilt = 45, heading = 0):
“adds the point to a kml file”
file = open(self.filepath,”a”)
file.write(
“<Placemark>\n”\
” <visibility>1</visibility>\n”\
” <LineString>\n”\
” <extrude>1</extrude>\n”\
” <tessellate>1</tessellate>\n”\
” <altitudeMode>absolute</altitudeMode>\n”\
” <coordinates>” + allLonAndLat + “</coordinates>\n”\
” </LineString>\n”\
” </Placemark>\n”)
file.close()
def convert(val):
eval = int(val/100.)
return eval + (float(val) – eval*100.0)/60.0
if __name__ == “__main__”:
a=KML_File(“test.kml”)

f=open(‘DATALOG.TXT’,’r’)
lines=f.readlines()
f.close()

prevlat=0
prevlon=0
n=0
for l in lines:
print l

tmp=l.split(‘;’)
londeg=tmp[4].strip()
latdeg=tmp[2].strip()
londec=tmp[5].strip()
latdec=tmp[3].strip()

lat=float(latdeg)+float(latdec)/1000000000.0
lon=float(londeg)+float(londec)/1000000000.0

if float(lon) < 5 or float(lat)< 30:
continue

if lon == prevlon and lat == prevlat:
continue

prevlat=lat
prevlon=lon
desc=tmp[0]+’ ‘+tmp[1]
tname=tmp[0]+’ ‘+tmp[1]
t=str(lon)+”,”+str(lat)
a.add_placemarker(t, altitude = 0.0, description = desc, name=str(n), range = 6000, tilt = 45, heading = 0)
n=n+1
a.close()

 

Save

Save

Save