Raspberry Pi 2 B

Raspbian Wheezy

sudo raspi-config

Select option 1 Expand File System.

Once you have rebooted the system update to the latest firmware drivers by running the following commands:

sudo apt-get update

(This updates the list of available packages and their versions, but it does not install or upgrade any packages.)

sudo apt-get upgrade

(This actually installs newer versions of the packages you have. After updating the lists, the package manager knows about available updates for the software you have installed.)

sudo apt-get autoremove

(This will then remove all of the reduntant packages after the latest upgrade)

Remote access

For terminal access on a remote Terminal in Mac OS on same network

ssh pi@192.168.1.90

For a remote desktop a VNC server can be installed on the Pi. Instructions for setting this up can be found here.

I use VNC Viewer on the Mac and connect to

192.168.1.90:1

Remember to change the IP address to the address that your router assigned to the Pi.

CSR V4.0 Bluetooth USB dongle

You can run a quick check on the command line to see if the bluetooth device has been successfully registered:

lsusb

This will list the currently connected USB devices and should yield the following connected device:

Bus 001 Device 005: 1D 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HC1 mode)

Install Bluez

http://www.elinux.org/RPi_Bluetooth_LE

sudo apt-get install bluetooth bluez blueman libbluetooth-dev libudev-dev

Next we need to check if your dongle supports Bluetooth LE (4.0)

sudo hciconfig -a

to check if the bluetooth service is running

sudo hciconfig

If DOWN then

sudo hciconfig hci0 up

will start the bluetooth service

You can then scan for Bluetooth LE devices using

sudo hcitool lescan

ctrl-C to stop scanning.

VNC

Beginner’s Guide to Installing Node.js on a Raspberry Pi

Install node.js

wget https://nodejs.org/dist/v0.12.9/node-v0.12.9.tar.gz

tar -xvf node-v0.12.9.tar.gz
 cd node-v0.12.9
 ./configure
 make -j 4
 sudo make install

check node version: sudo node -v

v0.12.9

check npm version: npm -v

v2.11.1

Install node.js latest version

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash –

sudo apt install nodejs

Install mqtt and mongodb for node.js

sudo apt-get install mongodb-server

sudo npm install mqtt mongodb

Install Node-Red

sudo npm install -g --unsafe-perm  node-red

To test the node-Red install start the node-red server

node-red

v0.12.5

to stop the server ctrl-C

A work in progress

To install Raspbian Jessie download the image. While this is downloading follow the instructions here to format the card. Then follow the instructions here to copy the image to your micro SD card. Note copying the image to the SD card will take some time so be patient.

Once this is done put the crd in the pi and apply power to boot up. To optimise storage we then need to run from the Terminal

sudo raspi-config

Select option 1 Expand File System.

Once you have rebooted the system update to the latest firmware drivers by running the following commands:

sudo apt-get update

(This updates the list of available packages and their versions, but it does not install or upgrade any packages.)

sudo apt-get upgrade

(This actually installs newer versions of the packages you have. After updating the lists, the package manager knows about available updates for the software you have installed.)

sudo apt-get autoremove

(This will then remove all of the reduntant packages after the latest upgrade)

To use the BlueGiga BLED112 Bluetooth LE USB Dongle follow the instructions here to ensure that this is working on you system.

Node-Red

Node-Red is preinstalled on Raspbian-Jessie however we want to upgrade to the latest version of node.js. So we need to remove it first

The pre-install uses the default node.js within Debian Jessie, which is version 0.10.29. To use more recent versions of Node.js such as v0.12.x or v4.2.x

To do this you must uninstall the built-in version and re-install using the instructions below. To uninstall:
sudo apt-get remove nodered
sudo apt-get remove nodejs nodejs-legacy
sudo apt-get remove npm # if you installed npm

This will remove all the built in packages but leave your workspace – by default at ~/.node-red . You may then proceed to re-install as per instructions below.

Then install the latest version of node.js

wget https://nodejs.org/dist/v4.0.0/node-v4.0.0-linux-armv7l.tar.gz
tar -xvf node-v4.0.0-linux-armv7l.tar.gz
cd node-v4.0.0-linux-armv7l

sudo cp -R * /usr/local/

To check Node.js is properly install and you have the right version, run the command node -v and to check that npm is installed run the command npm -v

Install Node-Red

sudo npm install -g --unsafe-perm  node-red

To test the node-Red install start the node-red server

node-red

to stop the server ctrl-C

 

Node-Red TI SensorTag node

Navigate to the node-red installation

cd ~/.node-red

npm install node-red-contrib-sensortag

To enable the operation of noble which is required for the sensor tag node when node-red  is not run from root the following steps must be completed. Using sudo to run node-red does not work.

sudo apt-get install libcap2-bin

(This is already likely to be including in Jessie)
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

See for more details https://github.com/ibm-iot/node-red-contrib-sensortag

Node-Red Publish data to IBM IoT foundation node

To publish data to IoT foundation so that you can access it from Bluemix

npm install node-red-contrib-scx-ibmiotapp

You can then either use a Quickstart or a registered session using an API Key. In order to use the API Key you first need to create an API Key and Authentication Token in your IBM IoT Foundation Service Dashboard.

  1. Select the ACCESS tab and then API Keys tab
  2. Then click the Generate API Key button
  3. COPY AND SAVE the display API Key and Token as this cannot be recovered.
  4. Give it a meaningful description
  5. Click Finish

Backup Raspberry Pi SD card

Format SD card (MacOS).

First find mount name

diskutil list

Format disk (mounted as disk2) as FAT32 with name RASPBIAN

sudo diskutil eraseDisk FAT32 RASPBIAN MBRFormat /dev/disk2

Create disk img from SD card

To create a disk image copy of the SD card from the terminal.

sudo dd if=/dev/disk1 of=~/Desktop/Jessie.img

To compress the disk image

tar -zcvf ~/Desktop/Jessie.tar.gz ~/Desktop/Jessie.img

Writing an image to the SD card

To decompress (Double clicking the file in finder will also decompress it)

tar -zxvf ~/Desktop/Jessie.tar.gz

Before writing to the SD card you need to unmount it

diskutil unmountDisk /dev/disk1

To write an image to an SD card (assuming that the BSD name of the SD card on your system is disk1)

sudo dd bs=1m if=~/Desktop/Jessie.dmg of=/dev/disk1

(You can also use the raw write which should be faster)

sudo dd bs=1m if=~/Desktop/Jessie.dmg of=/dev/rdisk1

When writing to or reading from the SD card ctrl+T lets you see the progress

When finished you can eject the card

sudo diskutil eject /dev/rdisk1

Shutdown the Pi

sudo shutdown -h now

Restart

sudo shutdown -r now

 

Node-Red Gateway App

Screen Shot 2016-01-13 at 23.16.55

[{"id":"c5bc06d4.3a43f8","type":"ibmiot","z":"f1bd11ac.0e42f","name":"Benn"},{"id":"a14916ec.5eb6e8","type":"sensorTag","z":"f1bd11ac.0e42f","name":"sensorTag","devices":["3057aaf8243e411bbd20eefcb8e24d76"],"temperature":true,"humidity":true,"pressure":true,"magnetometer":false,"magnetometerPeriod":"","accelerometer":false,"accelerometerPeriod":"","gyroscope":false,"gyroscopePeriod":"","luxometer":true,"luxometerPeriod":"30000","keys":true,"x":246,"y":195,"wires":[["bc530994.43acf8","a6929826.596d68"]]},{"id":"79c42aa6.863bd4","type":"ibmiot out","z":"f1bd11ac.0e42f","authentication":"apiKey","apiKey":"c5bc06d4.3a43f8","outputType":"evt","deviceId":"b827eb08a9f0","deviceType":"RaspberryPi","eventCommandType":"status","format":"json","data":" {\"d\":{\"myName\":\"Arduino Uno\", \"temperature\":0}}","name":"IBM IoT","service":"registered","x":667.2649269104004,"y":321.6239414215088,"wires":[]},{"id":"1697eb04.e96815","type":"function","z":"f1bd11ac.0e42f","name":"Format JSON Data for IBMIoT","func":"var newmsg = {topic: \"Data\", payload: \"{\\\"d\\\":{\\\"sensor\\\":\\\"\" + msg.sensor + \"\\\",\\\"sensorData\\\":\" + msg.payload + \"}}\" };\nreturn newmsg;","outputs":1,"noerr":0,"x":462.04481506347656,"y":295.3675022125244,"wires":[["2062bcb2.df9d44","79c42aa6.863bd4"]]},{"id":"2062bcb2.df9d44","type":"debug","z":"f1bd11ac.0e42f","name":"","active":false,"console":"false","complete":"payload","x":670.7371864318848,"y":278.2563796043396,"wires":[]},{"id":"bc530994.43acf8","type":"json","z":"f1bd11ac.0e42f","name":"","x":348.121826171875,"y":240.55984783172607,"wires":[["1697eb04.e96815"]]},{"id":"a6929826.596d68","type":"debug","z":"f1bd11ac.0e42f","name":"","active":false,"console":"false","complete":"true","x":395.66882705688477,"y":194.11539936065674,"wires":[]}]
Advertisements