After successfully running for 18 months my SD card failed probably due to the amount of mysql data read/writes. Luckily it failed read only so I didn’t loose too much data however I decided to start fresh using rasbian stretch and an external mysql table on a traditional drive (Not an SD Card) so here is a little guide of what I did again it assumes you have no mouse, keyboard or monitor attached and is correct as of December 2017
Prepare the Pi:
1. Download the latest Raspbean Stretch Image and Using your favourite method, prepare your SD card using the downloaded image for the Pi (I used Etcher on my laptop).
2. Add an empty file to the boot folder called “SSH”
3. Plug an ethernet cable into the Pi and connect to a router serving DHCP and Boot your Pi using the newly prepared SD card.
4. Using a network scanner (or login to your router) to determine the IP address of your Pi, I use fing on my smartphone.
5. Log into the pi using SSH in OSX type
SSH pi@IP Address
and use the password “raspberry”
Change User Password – Follow Prompts to set a new password
Localisation Options – set your timezone and wifi country
Interfacing options > Serial – Turn OFF serial prompt but turn ON Serial Hardware
Interfacing options > VNC – Disable VNC Server as using tightVNC
Exit raspi-config and reboot when prompted.
sudo apt-get update
sudo apt-get upgrade -y
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;
vncserver :1 -geometry 1920x1080 -depth 24 -dpi 96
save and exit nano, type
sudo chmod 755 vnc.sh
and you will be prompted to enter a VNC password.
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:
As I am initially only using the RPi to collect sensor data and write it to an external mysql table and web server I have skipped this step but left its heading in.
I used my Synology NAS and installed MariaDB and web station (Apache)
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
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:
comment=Root Folder Share
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)
Because of a change to the way the Pi 3 uses Uart, we need a workaround to get the Slice of radio working.
sudo nano /boot/config.txt
# Change device tree to enable slice of radio
to the end of the file then reboot
If you haven’t installed your slice of radio yet, shut down your Pi and fit it
sudo shutdown 0 otherwise reboot the Pi
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 minute, then click on Configuration wizard (If this is a rebuild rather than fresh install you can skip configuration and just install minicom to check the sensors are responding) 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
BACKUP your SD Card:
At this point I’d recommend backing up your SD card image and archiving it, also I would suggest a Cron job to backup any scripts you write to an external destination.
That is kind of it for configuration, you now have a Pi 3 running the latest Raspbian, you have sensors attached and reporting,.
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.