Machine learning with Raspberry PI

How to access Raspberry Pi 3 remotely from PC

  • Install VNC viewer on Raspberry pi, installation details at VNC on Raspberry Pi
  • Plug the Ethernet cable between PC and Pi.
  • Start VNC server called raspberrypi. Username is pi and password is dapa.
  • Ping from PC: ping raspberrypi, 192.168.137.12—> OK
  • From VNC viewer connect the Raspberry Pi to wireless network.
  • Remove the Ethernet cable, restart the VNC application on PC and start again.
  • VNC viewer shall connect to Raspberry Pi via wireless network.
  • To use the Raspberry Pi without router,  create hotspot on mobile phone.
  • Connect via VNC viewer to the hotspot dapa by inseting the password.
  • Connect the PC to the hotspot dapa by inseting the password.
  • Restart VNC viewer and connection is established with internet access via 4G.

Basic configuration on Raspberry Pi 3

  •        Start SSH server:      sudo systemctl start ssh (allow connection using ssh):
  • RaspPi config:           sudo raspi-config
  • RaspPi reboot:          sudo reboot
  • Update RaspPi:         sudo apt-get update
  • Upgrade RaspPi:       sudo apt-get upgrade (many updates done)
  • Clean after update:  sudo apt-get clean

Playing with GPIO’s:

rp2_pinout

Hardware interfaces for the Raspberry Pi 3 are exposed through the 40-pin header J8 on the board https://pinout.xyz/. Functionality includes:

  • 24x – GPIO pins (2 PWM’s)
  • 1x – Serial UARTs (RPi3 only includes mini UART)
  • 2x – SPI bus
  • 1x – I2C bus
  • 2x – 5V power pins (measured 4.85 V no load when supplied from USB pack)
  • 2x – 3.3V power pins (measured 3.43 V no load when supplied from USB pack)
  • 8x – Ground pins

Power supply

Raspberry Pi 3 can be supplied only from a 5V external supply by 3 methods:

  1. via micro USB.
  2. using GPIO pin 2 or 4 and GND 6 or 14.
  3. via pads on the bottom PCB, under the micro USB connection.
  • The current consumption can go up to 1.5A. (during stand by 0.3A, during a compile 0.55A).
  • In sleep the current consumption is 0.07A.

To wake up the RPi connect pin 5 to GND.

i2c communication

 

OpenCV and TesorFlow

OS Hypriot Docker for Raspberry Pi 

  • Download docker image from blog hypriot.com
  • Flash SD card with the OS image: Etcher
  • Usefull link to check is the micro SD card is ok: RPi_SD_cards
  • Wireless network is down with default image instalation, check Issue 60.
  • OpenCV instalation is not supported on Docker for ARM, only x64

OS Raspbian 9 Stretch Lite

  • Download Raspbian stretch lite release 4.9 2017-11-29 image and flash it on micro SD card using Etcher.
  • Configure wireless network
    • sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
    • network={
      ssid=”testing”
      psk=”testingPassword”
      }
    • sudo reboot
    • ifconfig wlan0 (inet is the IP)
  • Enable SSH
    • sudo systemctl enable ssh
    • sudo systemctl start ssh
    • test with: ssh pi@raspberrypi ot ssh pi@192.168.100.21
  • Use Telnet on Windows to connect with Raspberry Pi. SSH connection with IP will work but not with raspberrypi as host name.
    • systemctl list-unit-files | grep enabled (use alt+124 for | alt codes ).  Check if avahi is installed, if not install it:
    • sudo apt-get install libnss-mdns
    • sudo apt-get install avahi-daemons
    • avahi-browse -arp (if raspberrypi.local not in the list, avahi doesn’t make the job). Try then with samba server.
  • Install Samba to use “raspberrypi” as hostname.
    • sudo apt-get -y install samba (try more times if Aachen server is down)
    • connect with putty by using hostname raspberrypi.
  • Install OpenCV by using  install-opencv sh script
    • If you got a fresh rasbian image you might have to do first:
      • make sudo apt-get install cmake
      • doesn’t work with the script -> to check with Adrian Rosebrock page.

STEP 9: OS Raspbian 9 Stretch with Desktop

  • Download Raspbian stretch with desktop release 4.9 2017-11-29 image
  • Flash it on micro SD card using Etcher.
  • Enable SSH and connect via Telnet with fix IP.
    • sudo systemctl enable ssh
    • sudo systemctl start ssh
      If download error occurs during update or upgrade then
    • uncomment line 3 in sudo nano /etc/apt/sources.list
      • In sudo nano /etc/hosts paste the following lines at the end of /etc/hosts file:
        • 93.93.128.193 mirrordirector.raspbian.org
        • 93.93.128.191 archive.raspbian.org
  • Install OpenCV 3.3.0 . Working like a charm,  credit to Adrian Rosebrock .
  • Virtual environment python 2.7.13 created on Toshiba 16Gb, C4: cv
  • RPi.GPIO is not seen in the virtual environment,  pip install RPi.GPIO
  • Pi Camera is not seen in the virtual environment,  pip install picamera
  • Library for image manipulation pip install imutils
  • Run the example in tutorial object detection with opencv.
  • Install Tensor Flow and Keras Keras version: 2.1.3 and Tensor Flow 1.10
  • Rup optimized Open CV 3.3.0 for RPi

Sites to remember

http://www.instructables.com/id/IBM-Watson-Cloud-Robot/

https://www.pyimagesearch.com/2017/12/18/keras-deep-learning-raspberry-pi/

https://files.coinmarketcap.com/static/widget/currency.js