Category Archives: Computers

Raspberry Pi 3 and Wirelessthings sensors

After all the issues migrating Wheezy over I decided to start from scratch with the Pi 3 and my wirelessthings sensors. This guide is pretty poorly written but is step by step everything I did. it assumes you have no mouse, keyboard or monitor attached.


IMG_20160410_095010_1460278477793_2
This post is correct as of the 9th of april 2016

Prepare the Pi:

1. Download the latest Raspbean Jessie Image and Using your favourite method, prepare your SD card using the downloaded image for the Pi (I used Apple Pi Baker other GUIs are available).

2. Plug an ethernet cable into the Pi and connect to a router serving DHCP and Boot your Pi using the newly prepared SD card.

3. Using a network scanner (or login to your router) to determine the IP address of your Pi, I use fing on my smartphone.

4. Log into the pi using SSH in OSX type

SSH pi@IP Address

and use the password “raspberry”

5. type

sudo raspi-config

select Internationalisation Options and set your timezone then go into Advanced options and turn ON serial! Exit raspi-config and reboot your Pi when prompted

It is good practice to expand your filesystem at this point however I haven’t found raspi-config GUI very good at this so run:

raspi-config --expand-rootfs and reboot when finished

6. SSH back into your pi run:

sudo apt-get update
sudo apt-get upgrade -y

7. Change the default password! type

passwd

and enter your old password followed by your new one as prompted!

Configure VNC:

1. to Install VNC Viewer type

sudo apt-get install tightvncserver

2. If you want to change the VNC port type

sudo nano /usr/bin/vncserver

find the line

$vncPort = 5900 + $displayNumber;

and change 5900 to the port you want to use, I use 59000 which equated to 59001 in real life. Press Ctrl>X, Y, Enter to save and exit nano

3. To make VNC run from boot you need to create a script, type

sudo nano vnc.sh

paste the following into it;

#!/bin/sh
vncserver :1 -geometry 1920x1080 -depth 24 -dpi 96

save and exit nano, type

sudo chmod 755 vnc.sh

then type

./vnc.sh

and you will be prompted to enter a VNC password.

Type

sudo nano /etc/rc.local

add these lines after the commented section


# Auto run VNC
sudo /home/pi/./vnc.sh &

save and exit nano, reboot and VNC should now run from startup!

4. You can now connect to your Pi using VNC! so VNC into your Pi and set a static IP using the network settings GUI in the top right of the screen and reboot, the next few steps can be done through SSH or terminal in VNC its up to you.

Configure Webserver and PhpMyadmin:

1. install apache server

sudo apt-get install apache2 apache2-doc apache2-utils -y

then install support packages

sudo apt-get install libapache2-mod-php5 php5 php-pear php5-xcache -y

finally install php mysql connectivity

sudo apt-get install php5-mysql -y

2. install mysql server

sudo apt-get install mysql-server mysql-client -y

you will me prompted for a mysql password during installation.

3. install phpmyadmin

sudo apt-get install phpmyadmin -y

when prompted select yes and enter the password you chose above, then specify a phpmyadmin password.

4. we now need to configure phpmyadmin

nano /etc/apache2/apache2.conf

scroll to the bottom and add the following line

Include /etc/phpmyadmin/apache.conf

save and exit nano

5. Restart apache

sudo /etc/init.d/apache2 restart

and you should be good to go!

Setup Shares:

1. we are going to setup samba shares to make moving scripts etc easier, so install samba

sudo apt-get install samba samba-common-bin -y

2. once installed type

sudo nano /etc/samba/smb.conf

scroll down and make sure you have the correct workgroup (I just use WORKGROUP) and that Wins Support is enabled.

3. to be safe you should only add your pi user so type

smbpasswd -a

and enter your desired password, if you do want to add the root user type

sudo smbpasswd -a

4. to add shared folders type

sudo nano /etc/samba/smb.conf

and at the bottom add the code:

[www]
comment=www Share
path=var/www/
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no

[RootFolder]
comment=Root Folder Share
path=/
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no

5. You should now be able to connect to these shares using standard UNC paths from your windows or macintosh computers

Setup the “Slice of Radio” (Wireless message bridge)

Beacuse of a change to the way the Pi 3 uses Uart, we need a workaround to get the Slice of radio working.

1. type

sudo nano /boot/config.txt

and add

# Change device tree to enable slice of radio
dtoverlay=pi3-miniuart-bt

to the end of the file then reboot

sudo reboot

2. we now need to disable the serial prompt in a non standard way so type

sudo nano /boot/cmdline.txt

comment out the line in this file and add:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Save and exit nano

If you haven’t installed your slice of radio yet, shut down your Pi and fit it

sudo shutdown 0 otherwise reboot the Pi sudo reboot

IMG_20160410_095022_1460278476747_1
3. next we need to setup your radios, If you’ve already done this skip to step 5 otherwise dowload launchpad from wirelessthings and copy it to your pi, this is a collection of gui python scripts used to configure your wireless sensors. I have put mine in home/pi/launchpad using vnc in terminal run

gksudo python LaunchPad.py

to fire it up. (using gksudo rather than sudo fixes display 0.0 errors caused by running X programs on VNC, you may not need this if using a monitor.)

4. In LaunchPad, Click on message bridge and hit start wait a second, then click on Configuration wizard (ignore the message stating “Message bridge not found”) then select “serial” in the next window you can configure your sensors, press the configure button on a sensor for one second, wait for it to communicate with wireless bridge and follow the on screen setup, repeat for each sensor. Once you are finished exit LaunchPad

5. next we install minicom to test communication with your sensors is working correctly so type

sudo apt-get install minicom -y

once installed we need to run

minicom -b 9600 -o -D /dev/ttyAMA0

This will open minicom and if all is well you will see your sensors responding, remember they will only report as often as you have told them to so you may need to be patient! Exit minicom when you are happy that the sensors are responding.

Ctrl A, X

Screen Shot 2016-04-09 at 19.53.13

BACKUP your SD Card:

At this point I’d recommend backing up your SD card image and archiving it:

Apache2 optimisation:

you can disable unused modules to speed up apache2, I disabled these but it’s made no difference.

sudo a2dismod autoindex -f
sudo a2dismod auth_basic -f
sudo a2dismod status -f
sudo a2dismod deflate -f
sudo a2dismod ssl -f
sudo a2dismod authz_default -f

Summary

Thats kind of it for configuration, you now have a Pi 3 running the latest Raspbian, you have sensors attached and reporting, you have a webserver installed, mysql, php and python so you can do with it what you like!

Originally I followed this project to get me going http://www.lourenco.eu/temperature/instructions.html but I have since ditched it in place of my own version.

References:
http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two

Tutorial – Install PhpMyAdmin on your Raspberry Pi

Home

Wireless Hot Water Temperature sensor

I wanted to add hot water temperature to my raspberry pi powered “Pimometer” but wirelessthings dont make a suitable XRF sensor.

I decided to buy a standard wirelessthings temperature sensor, unsoldered the thermistor and added a flying lead resoldering the thermistor to this, making sure to insulate the legs of the thermistor.

PSX_20160404_092428_1459758292979_1

Luckily (or not) our hot water cylinder has no insulation around the immersion heater at the top of the tank, using some thermal paste i attached it to the bare metal and taped it in place with some foil tape. I then added it to my pi and left it to get some readings.

PSX_20160404_091450_1459757847093_2

The final step was making sure the readings are relatively accurate, using a thermometer under the hot water i compared the real life temperature to the readings on the pi and to my suprise they are are only a couple of degrees out so definitely accurate enough for what I need.

PSX_20160404_091653_1459757847042_1

After seven days of data logging i lagged the hot water cylinder to see if there was any significant improvement in heat retention.

PSX_20160411_095301

NOTE: When first testing this setup I didn’t use thernal paste, the readings were around 30% out which was nowhere near accurate enough, by adding the thermal paste and angling the bead of the thermistor it has improved this considerably.

Hog 1000 backlight replacement (retrofit Cold Cathode with LED)

image

The backlight on my Hog 1000 died, this is not surprising considering its age and the fact that backlights do eventually die! Sadly the inverter and cold cathode tube for this console are no longer available so I decided to replace it with some LED strip!

I first removed the main PCB then the LCD, I de-soldered the inverter and took the cold cathode tube out of the casing.

image
LCD with tube mounted

I removed the foil that covered the tube and slid a strip of daylight LED tape into the aluminum holder (covering the terminals on the tape and the cable where it exits) with some PVC tape.

image
Test fitting the LED tape

Finally I found a12vdc supply from the rear PCB and I put the console back together!

image

It works a treat and is very bright, you can’t control how bright it is from the console anymore and it doesn’t automatically switch off when the console is inactive but beggars cannot be choosers and it works brilliantly!

To get around the dimming issue I have ordered a 12v LED dimmer switch online and plan to fit it just under one of the wooden side panels. I did consider taking a feed from the other LCD backlights so that they dimmed and turned off together in the end I decided it was safer to leave them as they were and not fiddle too much!

image
Better than new!

Stop helping the “Like Harvesters”

Facebook_like_thumb

Its called “Like Harvesting” and its a way for people or organisations to boost their facebook pages allowing them to target larger audiences with subsequent adverts or to sell likes and potentially your profile information to third parties.

Usually these will be a picture, maybe a small girl with a sign saying things such as “my mum says if I get 200,000 likes then I can get a pony”, a picture of a sports car/iPad/high value item with a bow on it pretending to be a competition or more often than not a high value voucher offer for a supermarket or similar.

Its not going to hurt you but think before you share anything on Facebook, try and make sure posts are not created purely for likes and check out the person posting it to see if their page looks legit.

Finally, if the offer seems too good to be true then it probably is!