Skip to content

Instantly share code, notes, and snippets.

@rngadam
Last active March 17, 2017 10:32
Show Gist options
  • Select an option

  • Save rngadam/2415e10ca7e8067c98f174ee745d3647 to your computer and use it in GitHub Desktop.

Select an option

Save rngadam/2415e10ca7e8067c98f174ee745d3647 to your computer and use it in GitHub Desktop.
Raspberry pi installation

Raspberry pi installation

installation image

Using your Mac and the USB MicroSD card adapter, we want to flash the SD card with the Raspberry Pi Full Raspbian image.

Copy image from

  • pre-setup existing RPi on the network (accept identity, username/password is pi/raspberry)
  • use USB disk with image on it to transfer
scp pi@cbpi002.local:2017-02-16-raspbian-jessie.zip .
unzip 2017-02-16-raspbian-jessie.zip

DANGER: Adapt these instructions below carefully (make sure you use the external disk! otherwise you'll wipe your Mac)

> diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            250.1 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            Macintosh HD           +249.8 GB   disk1
                                 Logical Volume on disk0s2
                                 958C5088-1FD0-44AE-8420-BA424B6DDEF2
                                 Unlocked Encrypted

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *31.1 GB    disk2
   1:             Windows_FAT_32 NO NAME                 31.1 GB    disk2s1

> diskutil umountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
> sudo dd bs=1m if=2017-02-16-raspbian-jessie.img of=/dev/rdisk2

Now you can take out the MicroSD card from the Mac reader and put it in the Raspberry Pi.

(OPTIONAL) Booting from USB disk instead

Can use a USB external disk instead but you need to setup the internal hardware to boot from USB.

Start with SD card:

root@westside:/home/pi# echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt
program_usb_boot_mode=1
root@westside:/home/pi# sudo reboot

check output

$ vcgencmd otp_dump | grep 17:
17:3020000a

now should boot from USB disk instead of microsd card.

Booting Raspberry Pi

  • Connect screen and keyboard monitor
  • Connect power
  • Turn on

Basic configuration locale, keyboard, hostname

Run sudo dpkg-reconfigure locales and changing from en_GB.UTF-8 to en_US.UTF-8 (or whatever country setting you need).

Run sudo dpkg-reconfigure keyboard-configuration and change the keyboard to Generic 101 PC key (again, change as needed).

Reboot.

In the menus, use space key to select/de-select options

Use the team name / sticker name attached to your Raspberry Pi

change it using raspi-config

sudo raspi-config

Reboot

Connect to wireless

https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

Add to /etc/wpa_supplicant/wpa_supplicant.conf

network={
        ssid="Agora Space"
        psk="getstuffdone"
}

reload settings:

reboot

testing network connectivity

From a Mac, this will make it available on the network as that hostname as follows:

> ping lafayette.local -c 10
PING lafayette.local (10.1.10.86): 56 data bytes
64 bytes from 10.1.10.86: icmp_seq=0 ttl=64 time=6.570 ms
64 bytes from 10.1.10.86: icmp_seq=1 ttl=64 time=6.655 ms
64 bytes from 10.1.10.86: icmp_seq=2 ttl=64 time=8.819 ms
64 bytes from 10.1.10.86: icmp_seq=3 ttl=64 time=6.410 ms
64 bytes from 10.1.10.86: icmp_seq=4 ttl=64 time=6.638 ms
64 bytes from 10.1.10.86: icmp_seq=5 ttl=64 time=7.171 ms

starting ssh server by default

sudo update-rc.d ssh defaults
sudo update-rc.d ssh enable
sudo service ssh start

connecting through ssh

From now on, on your Mac, you can connect through ssh

ssh pi@lafayette.local

On Windows, use putty: http://www.putty.org/

First time it will look like this:

> ssh pi@lafayette.local
The authenticity of host 'lafayette.local (10.1.10.86)' can't be established.
ECDSA key fingerprint is SHA256:BC2V9xfuaymOgMY4R16MIrTC54iMkqgGN/iGBuBBkH0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'lafayette.local,10.1.10.86' (ECDSA) to the list of known hosts.
pi@lafayette.local's password: 

username/password is the default:

username: pi
password: raspberry

(very insecure, change password when going to untrusted network)

Node-RED setup

http://nodered.org/docs/hardware/raspberrypi.html

enable at boot and start:

sudo systemctl enable nodered.service
sudo service nodered start

Should now be able to connect on port 1880

http://$HOSTNAME.local:1880

The IP above (10.1.10.239) should also work with the $HOSTNAME.local name

installing additional node-red packages in China

install npm first:

http://nodered.org/docs/getting-started/adding-nodes

sudo apt-get install npm

npm is slow in China, so we want to use the Taobao mirror:

https://npm.taobao.org/

You can create a command to set the right parameters

alias cnpm="npm --registry=https://registry.npm.taobao.org \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npm.taobao.org/dist \
--userconfig=$HOME/.cnpmrc"

install influxdb node-red plugin

you want to be in the $HOME/.node-red directory:

cd ~/.node-red
cnpm install node-red-contrib-influxdb
sudo service nodered restart

influxdb should be immediately available in the left-side palette of Node-RED web interface.

@jpbeltrami

jpbeltrami commented Mar 4, 2017

Copy link
Copy Markdown
  • suggest giving "changing hostname" it's own section
  • unclear how to get into http://$HOSTNAME.local:1880 in node-red setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment