Sonde DS18B20 avec Raspberry Pi 3

  1. Sonde DS18B20 : Mettre une résistance de 4.7 kO entre le signal (fil jaune) et le + (fil rouge)
  2. Brancher le fil rouge au +5V du RPI3, le fil noir à la masse et le dernier sur le GPIO4
  3. Activer le One Wire sur le RPI3 : en root, lancer raspi-config  (le GPIO4 est le GPIO par défaut pour le One Wire)
  4. root@raspberrypi:~# cat /sys/bus/w1/devices/28-0218313772ff/w1_slave
    9e 01 4b 46 7f ff 0c 10 8a : crc=8a YES
    9e 01 4b 46 7f ff 0c 10 8a t=25875
    Lire T=25.875

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