Updating NodeJS from v0.12.6 to 5.0.0

Word on the street there is a new security patch about to drop for NodeJS that will fixes DoS and SSH issues.

I am running an older version of NodeJS (v0.12.6) from August 2015. NodeJS has jumped to version v5.1.0 in 5 months.

I am feeling brave and I decided to upgrade my NodeJS by running these commands.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Then I updated my node modules.

sudo npm install npm@latest -g

Now to re ran my NodeJS service. Dang I received this error.

Error: Module version mismatch. Expected 47, got 14.
at Error (native)
at Object.Module._extensions..node (module.js:450:18)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at bindings (/redactedpath/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44)
at Object. (/redactedpath/node_modules/bcrypt/bcrypt.js:3:35)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)

Thanks to Google I found this guide in seconds.

First remove bcrypt.

sudo node remove bcrypt

The update CCC (from gcc v4.8.2 to v4.8.5).

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-4.8 g++-4.8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8

Then reinstall bcrypt.

sudo node install bcrypt

Now you should be able to run your node server.

node server.js

Yay

Raspberry Pi 2 Setup

Here is a quick guide to setting up a Raspberry pi 2 (OS, Wifi etc) using a pre loaded NOOBS Raspian OS on a Micro SD card.

I ordered the Raspberry Pi 2 Model B WiFi Pack from Wiltronics.

      This Raspberry Pi 2 Model B WiFi Pack includes a Raspberry Pi 2 Model B computer, durable clear case, a power adaptor, a USB WiFi antenna, an HDMI cable and an 8GB micro SD Card with NOOBS OS loaded.

WEB_RPiB340C2

Plug in a keyboard, mouse, wifi, HDMI and power and you are good to go.
sipi02_install_001

I had to check my old guides to refresh myself:

1. Select Raspian and press enter
sipi02_install_002

2. Press Y
sipi03_install_003

3. Wait for the install to complete.
sipi02_install_004

sipi02_install_005

sipi02_install_006

4. The Pi will ask to reboot (this is what it looks like)
sipi02_install_007

5. The first program that will run is the Raspberry Pi Configuration.
sipi02_install_008

6. I tried to expand the file systems but my card was already expanded.
sipi02_install_009

7. I followed the prompts to change the device password

sipi02_install_010

sipi02_install_011

sipi02_install_012

8. I reviewed the Internationalisation Options
sipi02_install_013

9. Change Locale.
sipi02_install_014

10. tip use space to deselect UK and select em_AD.UTF-8 UTF-8.
sipi02_install_015

11. em_AD.UTF-8 UTF-8
sipi02_install_016

12. Select Australia.
sipi02_install_017

13. Select Sydney
sipi02_install_018

14, Under Advanced change the Hostname (computer name)
sipi02_install_019

15. I entered “sipi02”.
sipi02_install_020

16. I selected Enable SSH (remote login)
sipi02_install_021

17. Select Finish and Yes to reboot.
sipi02_install_022

sipi02_install_023

18. After the raspberry Pi rebooted I could login with the user name “pi” and my new password
sipi02_install_024

19. If you are new to Linux and are not sure of any Terminal commands (like DOS commands) check out this Linux Commands Cheat sheet from http://linoxide.com/linux-command/linux-commands-cheat-sheet/

Linux Commands Cheat Sheet
Linux Commands Cheat Sheet

Booting up the GUI desktop.

20. GUI Desktop

You can type “Startx” to start the Raspian Desktop.

21. Desktop

The Pi Desktop is easy to use and navigate.

sipi02_install_025

sipi02_install_026

sipi02_install_027

sipi02_install_028

sipi02_install_029

sipi02_install_030

22. Internet Check

I plugged in in a spare USB TP-Link TL-WN821N wireless adapter, followed the wireless setup and verified I had a network connection by typing the following commands.

ping www.google.com

ifconfig

I did indeed have an internet connection.

23. Update/Upgrade

I dropped back out of X and ran the following commands to update the Pi’s firmware and software.

sudo apt-get update
sudo apt-get upgrade
sudo reboot

Then after reboot.

sudo rpi-update
sudo reboot

This took a while to download and install 130MB of data.

24. FTP Server

I setup an FTP server.

25. I2C Tools

Installed i2c-tools and configuring it. Troubleshooting here.

Added the following to “/boot/config.txt”

dtparam=i2c1=on
dtparam=spi=on

sudo apt-get install python-smbus
sudo apt-get install i2c-tools

26. Installed Python2 GPIO

sudo apt-get install python3-rpi.gpio

27. MoPI (Dual Power supply board)

Setup my MoPi

sudo apt-get install simbamond

FAQ’s here, here and here.

I did things a bit out of order and I think I needed to power up the MoPi/Pi from batteries (and no mains power) for 2iC to detect. But all is god, I can power up and shutdown my Pi from 6xAA batteries.

mo_pi_01

mo_pi_02

28. Install Python Camera module

sudo apt-get install python3-picamera

29. Python

Installed Python PIP

sudo apt-get install python3-pip

30. Monit System Monitoring

Installed Monit System Monitoring Web server to keep and eye on the MoPi from a web server (config here)

sudo apt-get install monit

More info here https://www.the-hawkes.de/monitor-your-raspberrypi-with-monit.html

31. Temperature Sensors

Add temperature sensing service to Monit (guide here)

sudo apt-get install lm-sensors

32. NGINX Web Server, PHP and Perl

Ok, now I am going to install a web server (NGINX, PHP and Perl) using this guide http://youtu.be/I_2yGGPus90

sudo -i
apt-get update
apt-get install nginx php5-fpm php5-cgi php5-cli php5-common libfcgi-perl

33. Python and raspberry Pi GPIO Pin Library

sudo apt-get install python-dev
sudo apt-get install python-pip
sudo pip install RPi.GPIO

33. Witty Pi – Realtime Clock and Power on/off scheduling board. Good review here.

wittypi

wittypi_02

wget http://www.uugear.com/repo/WittyPi/installWittyPi.sh
sudo sh installWittyPi.sh

Everything installed for me.

sudo shutdown -r now

On reboot I noticed warning on boot up about GPIO pin conflicts with my MoPi. Maybe the MoPi and Witty Pi are clashing? I changed GP17 on the Witty Pi and rebooted. I still had a conflict so I set GP4 on the Witty Pi to also be custom. After a reboot I still had MoPi warning.

wittypi_03

I am now researching how to redirect the GOI pins that the Witty Pi uses.

Do’h, I just realised that the Pi is powered by Mains USB on the pi and the MoPi warning may just be a warning about the MoPi not controlling the external power. I removed the mains power ad instead connected up the MoPi to a 9v DC supply.

wittypi_04

I reset the Witty Pi pins to their defaults and powered up the Pi via the Pi MoPI power button. All MoPi warnings have gone. Now to resume the WittyPi setup.

I will possibly use the MoPi to power down the Pi when battery gets low and use the Witty Pi to boot up the Pi every day and to use the Realtime clock.

tip: Make sure the folder you install witty pi to is spelled exactly like “%HOME%/wittyPi” and not “%HOME%/WittyPi”. My daemons would not start because it way looking for “/home/pi/wittyPi” and not “/home/pi/WittyPi”.

Now I configured the Witty Pi’s time.

sudo ./wittyPi.sh
1
7

34. SD Card Check

Ok run the following command to get the location of your boot filesystem

df

Now run this command to check your boot disk (replace the boot disk with the one identified above).


fsck -fy /dev/mmcblk0p5
reboot

You may notice potential corrupted files and fixes from the output above.


sudo dosfsck -w -r -l -a -v -t /dev/mmcblk0p5

Also run a check after reboot.


sudo shutdown -F -r now

You can run these commands to review any errors.


cat /var/log/fsck/checkfs
cat /var/log/fsck/checkroot

35. Filesystem Update
sudo apt-get update
sudo apt-get upgrade
sudo reboot

Then after reboot.

sudo rpi-update
sudo reboot

35. SD Card Backup

Type “distil list” to show your connected disks. My Pi is “disk5”

diskutil list
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_CoreStorage Macintosh 10.9 HD 499.4 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1 (internal, virtual):
#: TYPE NAME SIZE IDENTIFIER
0: Apple_HFS Macintosh 10.10 HD +499.0 GB disk1
Logical Volume on disk0s2
532F6F24-17C1-4187-8637-45392549B220
Unencrypted
/dev/disk5 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *7.9 GB disk5
1: Windows_FAT_16 RECOVERY 858.8 MB disk5s1
2: Linux 33.6 MB disk5s3
3: Windows_FAT_32 boot 62.9 MB disk5s5
4: Linux 7.0 GB disk5s6

Clone the SD Card (this command has no feedback so please wait).

sudo dd if=/dev/disk5 of=/Users/simon/Backup/SiPi02/Jan3rd2016.dmg

Eject the SD Card


sudo diskutil eject /dev/rdisk5

How to restore a Disk Image to the SD Card.


diskutil unmountDisk /dev/disk5
sudo dd if=/Users/simon/Backup/SiPi02/Jan3rd2016.dmg of=/dev/disk5
sudo diskutil eject /dev/rdisk5

36. No back to reading the MCP3008 Analog to Digital Converting chip.

The following commands were taken from this video.

wget https://github.com/Gadgetoid/py-spidev/archive/master.zip
unzip master.zip
cd py-spidev-master
sudo python3 setup.py install

Enable SPI at boot (video guide here)

sudo rasps-config
advanced options
SPI
Enable: Yes, Yes Finish
sudo reboot

Note:I completed the code above but my python script could not see spider (it was if the module was not installed. This resolved it.


cd ~
sudo git clone git://github.com/doceme/py-spidev
cd py-spidev/
sudo python setup.py install

 

todo

Part 3 (convert data):

Part 4 (advanced):

Part 5 (humidity sensor)

Comfast CF-WU755P WIFI

This guide may help me: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=109919&p=755521

I might try this guide: https://blog.samat.org/2014/12/15/realtek-8188eu-based-wi-fi-adapters-on-the-raspberry-pi/