Interactive Media Arts Capstone Technical Documentation

This documentation covers some technical issues I encountered as I work on the IMA capstone interactive project.

Enabling SSH for headless Raspberry Pi

Source: https://www.raspberrypi.org/blog/a-security-update-for-raspbian-pixel/

SSH is disabled by default in the latest Raspbian Jessie, however, we can enable it by putting a file called ssh in the /boot/ directory in the sd card.

Connecting Raspberry Pi to nyu WiFi

Source: http://blog.iamlevi.net/2017/01/connect-raspberry-pi-peap-mschap-v2-wifi/

  1. Get the MD4 hash of the password by running the command below:
    $ echo -n 'YOUR_REAL_PASSWORD' | iconv -t utf16le | openssl md4
  2. Open wpa_supplicant.conf with your favorite text editor:
    $ sudo vi /etc/wpa_supplicant/wpa_supplicant.conf
  3. Append the following text to the file:
    network={
    ssid="nyu"
    priority=1
    proto=RSN
    key_mgmt=WPA-EAP
    pairwise=CCMP
    auth_alg=OPEN
    eap=PEAP
    identity="the_netid"
    password=hash:the_hashed_password
    phase1="peaplabel=0"
    phase2="auth=MSCHAPV2"
    }
  4. Remember to run the following command to clean up history for security reason:
    $ history -w
    $ history -d

Passwordless SSH Access

Source: https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md

  1. Check if there are ssh keys on your computer
    $ ls ~/.ssh
  2. If there’s none, generate new keys on your computer
    $ ssh-keygen -t rsa -C "Raspberry Pi #123"
  3. If there’s no ~/.ssh folder on the Pi, create one with following command
    $ cd ~
    $ install -d -m 700 ~/.ssh
  4. Copy your public key from your computer to your Pi by running following command on your computer
    $ cat ~/.ssh/id_rsa.pub | ssh @ 'cat >> .ssh/authorized_keys'

Disable Password Login for SSH

Source: http://raspi.tv/2012/how-to-set-up-keys-and-disable-password-login-for-ssh-on-your-raspberry-pi

  1. Open the file below on Raspberry Pi
    $ sudo vi /etc/ssh/sshd_config
  2. Set #PasswordAuthentication to no
    #PasswordAuthentication yes # old
    PasswordAuthentication no   # new

Configuring for GrovePi+

Source: https://www.dexterindustries.com/Grove – Pi/get-started-with-the-Grove – pi/setting-software/

  1. Clone the repo
    $ git clone https://github.com/DexterInd/Grove - Pi.git
  2. Run the script
    $ cd /home/pi/Desktop/Grove - Pi/Script
    $ sudo chmod +x install.sh
    $ sudo ./install.sh

Serial Communication between Raspberry Pi and Arduino

Sources: http://www.instructables.com/id/Connect-Your-Raspberry-Pi-and-Arduino-Uno/?ALLSTEPS

http://www.seeed.cc/project_detail.html?id=168

http://forum.arduino.cc/index.php?topic=396450

http://spellfoundry.com/sleepy-pi/setting-arduino-ide-raspbian/#Setting_up_the_Serial_Pins (This didn’t seem to work with GrovePi+ RPISER)

Setting up PHP Serial

Sources:

http://www.raspberry-projects.com/pi/programming-in-php-and-javascript/uart/uart-control-from-php

https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=100481

https://peopleorientedprogrammer.wordpress.com/2013/05/12/raspberry-pi-arduino-and-php-a-home-automation-baby-step/

  1. Get PhpSerial.php from GitHub
    $ wget https://github.com/Xowap/PHP-Serial/archive/1.0.1.tar.gz
  2. Untar the file
    $ tar -zxvf 1.0.1.tar.gz
  3. Copy PhpSerial.php to the folder where index.php lives
    $ sudo cp PHP-Serial-1.0.1/src/PhpSerial.php /var/www/html/
  4. Install minicom to prevent Arduino from resetting itself every time we open a connection to it through serial
    $ sudo apt-get install minicom
  5. Run below command and then
    1. go to serial port setup, and then set the serial device to /dev/ttyUSB0 (or whatever yours is)
    2. set the Bps/Par/Bits to C, 9600 (this may differ for different Arduinos.)
    3. Then ‘save setup as dfl’ and exit.
    $ sudo minicom -s -c on
  6. Run minicom before running any PhpSerial command

Setting up Automatic Email Notification on Boot on nyu Network

Sources:

http://unix.stackexchange.com/questions/8518/how-to-get-my-own-ip-address-and-save-it-to-a-variable-in-a-shell-script

http://stackoverflow.com/questions/7013137/automating-telnet-session-using-bash-scripts

  1. Create a file auto_mail and paste the text below and save it
    #!/bin/sh
    
    IP="$(ifconfig | grep -A 1 'wlan0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)"
    telnet nyu.edu 25 <<EOF
    HELO nyu.edu
    MAIL FROM: <pi@nyu.edu>
    RCPT TO: <net_id@nyu.edu>
    DATA
    From: "Raspberry Pi" <pi@nyu.edu>
    To: "Your Name" <net_id@nyu.edu>
    Subject: Notification
    $IP
    .
    QUIT
    EOF
  2. Open the rc.local with command below
    $ sudo vi /etc/rc.local
  3. Add the path to the previous file you created to rc.local before exit 0
    sh /home/pi/auto_mail
  4. Reboot to test
    $ sudo reboot

Installing VIM GUI

Source: http://askubuntu.com/questions/284957/vi-getting-multiple-sorry-the-command-is-not-available-in-this-version-af

$ sudo apt-get install vim-gui-common

Recording and Saving Video with OpenCV and python

Below is the version of cv2 I’m using:

cv2.__version__ = ‘2.4.11’

After Googling for so long, I figured something like this would work on macOS:

import cv2
fourcc = cv2.cv.CV_FOURCC('m','p','4','v')
out = cv2.VideoWriter()
out.open('output.mp4', fourcc, 20, (width,height))
while (camera.isOpened()):
_, frame = camera.read()
out.write(frame)
out.release()

Troubleshooting

RST LED on GrovePi+ is on

GrovePi+ will not work properly when the RST led is on, to resolve the problem, navigate to the Troubleshooting folder in GrovePi, and run avrdude_test.sh

$ ~/GrovePi/Troubleshooting/avrdude_test.sh

grovepi.digitalRead() not working on GrovePi+

Somehow this function doesn’t work with firmware 1.2.7, downgrade to firmware 1.2.6 will solve the problem

$ cd ~/GrovePi/Firmware/Source/v1.2/grove_pi_v1_2_6/

$ bash install_test_firmware_software.sh

grovepi.ultrasonicRead() not working when GrovePi+ firmware is 1.2.6

Open grovepi.py and comment out the 3rd line in ultrasonicRead()

# Read value from Grove Ultrasonic

def ultrasonicRead(pin):

  write_i2c_block(address, uRead_cmd + [pin, unused, unused])

  time.sleep(.06) #firmware has a time of 50ms so wait for more than that

  #read_i2c_byte(address)

  number = read_i2c_block(address)

  return (number[1] * 256 + number[2])

 

Useful Links

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s