Skip to content

ebd622/raspberry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry PI

Short Introduction

Interfacing hardware with the Raspberry

Pinout Orientation RaspberyPi Zero W

Connect devices with wires and boards

What is Grove

Grove is a modular, standardized connector prototyping system.

Grove connectors look like these:

Many different Grove-modules are available:

Raspberry Pi HAT

HAT stands for “Hardware attached on top”. It is a new hardware specification for add-one modules for the Raspberry Pi.

Auto-configuration is a most interesting feature of HATs. With a controller on the board, the add-on board identifies itself. It tells the Raspberry Pi, which IO pins it is using, how they need to be configured and what drivers have to be loaded.

Grove Base Hat for Raspberry Pi Zero

In our examples we will use a Hat for Raspberry Pi Zero:

Grove.py library

Grove.py is python library for Seeedstudio Grove devices.

Hight level architecture

Grove.py depends on different hardware interface/libraries:

HW-libraries

  • MRAA is a low-level library, developed by Intel, for accessing the I/O functions (GPIO, I2C, SPI, PWM, UART) on a variety of boards such as Intel's Galileo and Edison boards, MinnowBoard Max, Raspberry Pi, and more. It is written in C/C++ and provides Python and Javascript bindings. libmraa supports the UP board since (v0.9.5) and is included with ubilinux.

  • UPM (Useful Packages & Modules) is a high-level library that makes use of mraa, and provides packages/modules to manage a variety of sensors and actuators. v0.5.1 is also included with ubilinux.

  • SMBUS (System Management Bus) is a subset from the I2C protocol. smbus2 is a Python implementation of the python-smbus package.

HW-interfaces

  • GPIO General purpose input/output
  • I2C is a bus, serial protocol and interface;
  • PWM is Pulse Width Modulation Interface

Install Raspbian OS

  1. Download the Raspbian-Image "With Desktop and recommended software based on Debian Buster".
    (Other images can be found here)

  2. Get the image on the SD Card using a formating tool like Etcher

  3. Copy two config files to SD Card, to the root folder:

  1. Edit wpa_supplicant.conf to specify wifi-network and password

  2. Put the SD Card into Raspberry Pi

  3. Power on Raspberry Pi

Here is the video instruction How to Setup Raspberry Pi Zero

SSH to Raspberry Pi

First try to ping Raspberry to make sure that it is up and running:

ping raspberrypi.local

Than try ssh:

ssh pi@raspberrypi.local

The default password is raspberry

Set up remote Desktop (optional)

sudo apt-get install tightvncserver
sudo apt-get install xrdp

Install packages

Updated installed packages:

sudo apt-get update

Install gpiozero library (if not installed yet)

sudo apt install python3-gpiozero

Install/update all dependencies and latest grove.py:

curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -

It make take some time (~15-20 min) to install/update all packages. At the end, when everything is successfully installed the follwing message should be printed:

Successfully installed grove.py-0.6
#######################################################
  Lastest Grove.py from github install complete   !!!!!
#######################################################

You may have error(s) during the installation process when you use not a full rasbian image. It happens because some packages are not preinstalled on the light version. Than you need to install missed packages manually. For example, to install pip run the following command:

sudo apt-get install python3-pip

Than install grove.py

sudo pip3 install grove.py

Copy manually MRAA & UPM

cd /usr/local/lib/python3.7/dist-packages
pi@raspberrypi:/usr/local/lib/python3.7/dist-packages

sudo cp -r /usr/lib/python3.5/dist-packages/upm .
sudo cp /usr/lib/python3.5/dist-packages/mraa.py .
sudo cp /usr/lib/python3.5/dist-packages/_mraa.so .

Simple (hello world!) Led-project

As an example let's create a simple project with Led.

  • Create a python script led.py:
import time
from grove.grove_led import GroveLed

# connect to pin 5(slot D5)
PIN = 5
led = GroveLed(PIN)
while True:
    led.on()
    time.sleep(1)
    led.off()
    time.sleep(1)
  • Connect Led to the slot D5;
  • Run the following command:
python3.7 led.py

Pushbullet

Pushbullet is a group of applications and an API for sharing files and notifications between devices.

Pushbullet automatically shows you all of your phone's notifications right on your computer, this means you can see who's calling or read and reply to text messages even if your phone is on silent or in another room.

Pushbullet also makes it easy to send pictures, files, links, and more to your devices and even to friends.

Setup account and install libraries

  1. Setup Pushbullet account

  2. Installing Pushbullet Libraries on Raspberry Pi (upgrade may take some time: ~15..20 min)

sudo apt-get update
sudo apt-get upgrade
sudo pip install pushbullet.py

You can also use pip3 to install pushbullet.py, in this case you can skip the step 3:

sudo pip3 install pushbullet.py
  1. Copy manually websocket ans pushbullet packages (skip if you used pip3):
cd /usr/local/lib/python3.7/dist-packages

sudo cp -r /usr/local/lib/python2.7/dist-packages/websocket .
sudo cp -r /usr/local/lib/python2.7/dist-packages/websocket_client-0.56.0.dist-info .
sudo cp -r /usr/local/lib/python2.7/dist-packages/pushbullet .
sudo cp -r /usr/local/lib/python2.7/dist-packages/pushbullet.py-0.11.0.dist-info .
  1. Check out the example. Add your own access token and a phone number where you want to send SMS-message. Than run the command:
python3.7 push_examples.py

You should receive notifications on your mobile

Assignements

Workshop 1

  • Install Raspbian OS;
  • Hello World app - one led on / off / disco
  • Motion or light sensor -> led on / off;
  • Motion sensor and display -> show motion detected / lights off

Workshop 2

  • Motion sensor and LED are connected to Raspberry, when any motion is detected than:
    • LED is on;
    • A notification is pushed to mobile;
    • SMS-message is sent to another mobile (or the same);
    • A photo is pushed to mobile (let's assume that a photo has been taken by a camera connected to Raspbery when a motion has been detected)

Useful resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published