Raspberry Pi weather station

A few months ago I started putting together a R-Pi weather station using:

After a corrupted Pi SD Card and loosing the backups I’ve decided to restart this and will document everything this time. Its taken about half a day to just work out what libraries I was using. 🙁

Luckily I stored my code in Github

To start off download the latest version of Wheezy.

Update to the latest version.
apt-get update
apt-get upgrade

I came across this site to remove all the extra packages you dont need on the Pi (If you are not running GUI)

First setup the wireless dongle. I used a cheap RT5370 dongle from eBay which works great.

You will also need to install some libraries – took me ages to get it working at first. After this was installed it worked first time.
sudo apt-get install firmware-ralink

To get the BMP085 working via i2c, there are some setup steps that need to be performed.
I2C Installation for Raspberry Pi – Step by Step Guide

Also to read the MCP3008 chip there are some additional steps that need to be done. A script needs to run at startup.

The R-Pi collects all the data from the sensors and writes it to a MySQL database running on a internal server. I’m busy working on the php code for the weather front end so its a work in progress.

Netware 3.12 on the Raspberry Pi

After successfully booting Windws 1.01 – 95 on the Pi, for the next feat I decided to try and get Netware 3.12 booting.

This proved a challenge and took quite a few hours to get working. Initially I used the same method I did for the booting of Windows but when trying to get Netware running there were loads of abend issues when mounting the SYS volume.

The install was successful on Virtualbox but I ran into problems with the ATA driver – when using this and mounting the SYS volume there were disk errors would I tried to repair with vrepair but they just kept returning.

After reading through How To: install Novell Netware 3.x on VMware I decided to try loading the latest patches.

Update Netware 3.12

A good few hours later with the system patched I then used the IDEATA driver instead of the ATA driver and now the SYS volume was successfully mounted in VirtualBox!!!

I then copied over the vdi file to the Pi and ran under qemu.

Abends when the SYS volume was mounted! Agghh!!!

After retrying with the latest qemu (1.1.2) which still gave issues I then decided to give bochs a bash
Bochs is another open source emulator which luckily is already package so no need to compile. The latest version I used was 2.4.6-5

apt-get install bochs

A few more hours later after figuring out how bochs works – you need a .bochsrc file.

This site was helpful for the config of bochs.

Here’s what mine looks like:

megs:32
romimage: file=/usr/share/bochs/BIOS-bochs-latest
display_library: sdl
log: bochsout.txt
ata0-master: type=disk, path=”netware.vdi”, mode=flat, cylinders=243, heads=16, spt=63
ata0-slave: type=cdrom, path=”Installation.img”, status=inserted
floppya: 1_44=”Disk1.img”, status=inserted
boot: disk

I then tried to run the vdi file with bochs….only to find out bochs doesn’t support vdi files. Luckily there is a VirtualBox tool that lets you convert the file to .img

vboxmanage clonehd source.vdi destination.img --format RAW

Changed the .bochrs file to
ata0-master: type=disk, path="netware.img", mode=flat, cylinders=243, heads=16, spt=63

Started bochs and waited a few mins….and what do you know. SYS vol mounted and Netware 3.12 booting!!!

Bochs seems a lot slower than qemu but as least its working (Takes about 8 mins to startup Netware)

I did some editing on the video and speeded some parts up.

Jump forward to see the Netware snake – should bring back some good memories for some.

Windows emulation on the Pi

After reading a few posts on the RaspBerry Pi forums from users who have gotten Win95 working on the R-Pi I decided to give it go and see if I could run Windows from v1.0 to 95.

Windows runs on the R-Pi via qemu but its really slow. This is really just to show that it can be done – its hardly usable though, especially Windows 95.

There are lots of helpful threads on getting this to work. I started off reading this one:

Win95 on the Pi

I also wanted to remote to my R-Pi via Xming which is really easy to do:
Xming to the Pi

My first attempt to get Win95 booting proved tricky but I eventually got it working with Qemu and a older version of Wheezy. For some reason Win95 kept crashing with the latest version of Wheezy

Here are the steps I used to get Windows 95 booting:

Downloaded 2013-09-10-wheezy-raspbian.zip

Expands FS

Do a apt-get update and apt-get upgrade

Windows 95 only successfully boots with Qemu 0.15.50. To install this you need to download from source and compile

Download older version of Qemuwget http://thoronir.net/raspi-dev/qemu-git.tar.bz2

Install libsdl sudo apt-get install libsdl1.2-dev

tar -xvf qemu-git.tar.bz2

cd qemu

./configure --target-list=i386-softmmu --enable-sdl --extra-cflags="-O3 -mfloat-abi=hard -mfpu=vfp -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -march=armv6zk"

make

After a few mins you will some errors – you will need to edit 2 files to get rid of these errors:

Edit qemu/tcg/arm/tcg-target.c and qemu\tcg\i386\tcg-target.c

Search for: static void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)

And replace with:

static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)

Run make and make installl which should now complete. It took around 15 mins to compile on my Pi.

Now that you qemu built, copy the Windows 95 img file to the Pi and run qemu win95.img -m 64

After successfully running Windows 95 I decided to try out Windows 1.01, 2.1, 2.11, Windows for Workgroups 3.1

All successfully booted and running on the Pi

I found the best way to create the images is to install VirtualBox and then setup Windows. Once you have it working copy over the vdi file to the R-Pi which you can then run with qemu.

Windows 1.01

Windows 2.1

Windows 2.11

Windows for Workgroups 3.1

Windows 95

MyFitnessPal weight importer

Update: July 2018

This script is no longer working due to some changes by MyFitnesspal

Source code is available if you want to try and get it working:

http://blog.gjmccarthy.co.uk/myfitnesspal.php

I wrote this php script as MyFitnesspal does not have the functionality available to import a historical list of weight/body fat values.

After looking at the http post values I came up with a script to read a file and post the values to the MFP site.

In order to upload the data you need to provide your MFP credentials, the script then logs onto MFP and creates a drop down options box based on your settings in MFP.

You will then need to provide a text file containing the data and weight (or Body fat, or what ever you want to import)

Format:

dd/mm/yyyy 123.1

The data will also need to be tab delimited with no blank line of the last line of the scipt. The data will then be uploaded to MFP – it took a good few mins to upload about 2 years of my data so just be patient. Not sure if this is a limitation on the MFP side.

One problem I have noticed is that the first and last values uploaded always contain the wrong vlaue. I will need to fix this up but please we aware of this.

The script also does not check if the data already exists – I’m not sure what would happen. Haven’t tested it.

There are bound to be a few bugs in this. Let me know if you find any. I’ve uploaded 4 years of weight values and it seems to have been uploaded successfully.

After the script has finished the uploaded file and cookies are delete. No personal data is stored on the server.

Update: Busy relooking at my code. Seems MFP has changed something and it no longer works 🙁

Setting up web based/client less SSH for the Raspberry-Pi

I had a spare Raspberry Pi lying around so though I would see if I would get a web based SSH session going for the raspberry pi, as well as setting up SSL using a free 1 year SSL cert from StartSSL

It was surprisingly simple.

After searching around I came across GateOne which gets some good reviews and seemed easy to setup.

First to setup SSL you will need to have a FQDN that points to your Pi. There are loads of free sites out there that allow you to do this, for this example we will assume we have setup ssh.example.com which points to the IP address of the Pi (You will need to setup port forwarding if you are doing this on your home broadband router)

You could also skip the below step and use the self-signed cert that is automatically generated, but I’m not a fan of self signed certs on the internet. For your own home use on a LAN fine, but its its internet facing then generate a proper cert. I googled a bit and found that StartSSL offer free 1-year certs.

You will need to generate a keyfile using:
openssl genrsa -out ssh.example.com.key 2048

This generates a 2048 bit keyfile for ssh.example.com

The below will generate a CSR file (after completing a few questions):
openssl req -new -key ssh.example.com.key -out ssh.example.com.csr

The csr file then needs to be uploaded to the CA, and they will validate it and then give you a PEM encoded certificate.

Both of these files (ssh.example.com.key and ssh.example.com.pem) need to be saved to
GateOne-master/ssl

Now onto configuring GateOne. Connect to your Pi and download the master file from Github:
https://github.com/liftoff/GateOne/

Extract on the R-Pi using
unzip master.zip

Once unzipped run ./run_gateone.py
This will generate a conf file for you under conf.d/10server.conf

I changed the following lines:

"certificate": "/home/pi/GateOne-master/ssl/ssh.example.com.pem",
"keyfile": "/home/pi/GateOne-master/ssl/ssh.example.com.key",
"origins": ["ssh.example.com"],
"port": 443,

Run ./run_gateone.py
and with a bit of luck you should be able to open up a browser and browse to https://ssh.example.com

GateOne

GateOne - SSH Session

Once connected to the Pi, i can then SSH to all my other Linux servers….mwaaa haaaa haaaa! 🙂

I still need to setup run_gateone.py to start automatically but that should be easy enough.
A quick search shows a few sites on how to do it:

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=37&t=49153

Laser trigger for Canon camera

I build this project so I could setup my camera to take pictures of water drops.

This was built on a Arduino and then transferred to a veroboard.

The circuit uses a laser diode with a LM317 setup as a current limiter. A LDR is connected to the Arduino’s analogue pin and triggers the camera shutter when the laser shining on the LDR is triggered. The trigger allows you to set the delay time for the trigger by means of 2 switches and the delay is displayed on 2 x 7 Segment Displays (driven by 2 x 74HC595 shift registers)

I used the below current limiting schematic which I got from the http://laserpointerforums.com web site.

Current limiter for Laser Diode using LM317

The Canon DSLR camera uses a 2.5mm stereo plug for remote triggering of the shutter.

Canon 2.5mm plug connector

Breadboard layout

Fritzing Laser Trigger

The source code for the arduino sketch can be found here LaserTrigger.ino

The end result (Note to self – next time be more careful when glueing in the LED’s and switches!)

IMAG0045

Here are a few pictures I took – I will need to get the setup 100% with the lightning but you can see what type of pics you can get:

Water drop 1

Water drop 2

Water drop 3

Raspberry Pi – 16×2 LCD

Setup my Raspberry Pi with a spare 16×2 LCD connected to the pi’s GPIO pins. For some reason I could not get it working with the example from Adafruit

http://learn.adafruit.com/drive-a-16×2-lcd-directly-with-a-raspberry-pi/overview

After a bit of searching around I came across Raspberry Pi Spy. Tried the example from there and it worked first time.

Temperatures and pH probe

A few of the parts I ordered have finally arrived.

– DS1307 RTC

– pH Probe

– 3.2 TFT Screen

– DS18B20 Temperature Sensors

 

I’ve been using the Dallas Temperature control library for the temperature sensors. They really work well.

http://milesburton.com/Dallas_Temperature_Control_Library

 

Also using the following library for the 3.2 TFT screen with touch.

http://henningkarlsen.com/electronics/library.php?id=34

 

So far all the example arduino sketches I have tried out are working – rtc, sd card, tft

I’ve now added in a ENC28J60 ethernet module. For that I’ve used the following library:

https://github.com/jcw/ethercard

 

This was a real bugger to get going but it seems to be working and sending sample values to Xively. (Was Cosm, before that Pachube)

 
I’m still busy testing so fake values are being used.
 

 

Can’t these guys just decide on a name.

 

I also looked at Thingspeak to store data – still deciding between the two.

 

Arduino aquarium controller

So I’ve been reading up all about open source aquarium controllers and some of the projects people are putting together is amazing. I though I’d startup my own project which will do the basics and then I’ll add on modules as I get the time.

Its going to take while to do this project but its going to be very interesting.

I’d like to also complete a Arduino LED controller for the aquarium but I think that will be the next project.

For starters I’ve found these links which will be very helpful:

http://www.nano-reef.com/topic/196161-reefbuddy-diy-aquarium-controller-89/

https://code.google.com/p/aquatroller/

http://www.aquariumcontroller.net/diy.html

For starters I plan to use a Arduino Mega 2560 with a 3.2″ TFT Screen and DS1307 RTC.

pH measurements will be takes with a pH probe which you can get cheaply from eBay.

I’ll be using the pH amplifier from here:

http://www.electro-tech-online.com/electronic-projects/41430-ph-amplifier-micro.html

Temperatures from  DS18B20 sensors and salinity from a EC conductivity probe. I’m still looking for ways to impletement this as this looks like the trickiest part of the project.

First thing is first – need to order an Arduino Mega 2560

 

[ad]

Ordering parts

I’ve ordered the following parts  – mostly off ebay.

 

DHT22 Sensor

DHT22 Sensor

Pressure Sensor

Pressure Sensor

Ethernet module for Arduino

Ethernet module for Arduino

AtMega328

AtMega328