Monday, November 10, 2014

Installing weewx and Arduino on the Raspberry PI

Screen shot on the pc

This took awhile - so give yourself time.

I did not want to get mired with any customization the first time around, so I decided I would always take the defaults whenever possible. After I fully understand all that got installed, I could mess things up with customization later on. Come on - you have never bollixed up a working system trying to customize it, have you.  My primary goal was a simple, no fills, working system.

WhatIDidWas:

Downloaded NOOBS

Formatted a class10 16gb sd card with sdformatter.exe

After booting set the timezone to New York
set up the wireless since I don't have a hard wire to the PI.

Updated the locations and got all changed modules for raspian
  
  sudo apt-get update
  sudo apt-get upgrade

Installed arduino on the pi

  sudo apt-get install arduino

Set up the board to match my hardware and selected the serial port (there was only one)
Loaded, compiled, and uploaded the blink sketch to test - OK

Opened http://davies-barnard.co.uk/2013/12/weewx-rasp/  for guidance.
and used a lot from How to install weewx for Debian (pi) Linux
http://www.weewx.com/docs/debian.htm This last link has lots of information - especially where the various parts of weewx gets installed from the deb package.

Added weewx user
  sudo suadded 
  adduser weewx 
  usermod -a -G sudo weewx

Downloaded weewx package to a thumb drive on the pc
http://sourceforge.net/projects/weewx/files/   Found weewx_2.7.0-1_all.deb (YRMV)

Then plugged thumb drive into powered hub on the pi and copied to my home directory on the pi using the GUI file manager.

Installed weewx

  dpkg -i weewx_2.7.0-1_all.deb


Make sure you have the latitude, longitude and altitude available. It will be asked for in the installation.  This saves editing config files after install. I chose the Simulator driver just to get something on the screen.

Got a lot of missing warnings  one of the informational messages was to do this command - it resolved all missing pieces and installed all but the python serial

  sudo apt-get -f install


Installed Python serial. I will use this to get serial data from Arduino.

  sudo apt-get install python-serial 

Picked NGINX as my web server and installed

 sudo apt-get install nginx

I kind of got stumped then - I found that the nginx had set up its root to point to /usr/share/nginx/www.  Weewx was putting its files at /var/www/weewx.

I tried to set a link from one to another - but the Linux LN link documentation read like graduate physics to me - so I just edited the ngnix conf file - but not the one that is documented.
The basic conf file is located @ /etc/nginx/nginx.conf - this file loads other config files. The one that contained the root location was /etc/nginx/sites-available/default
So I edited that with:

  sudo nano default

Commented out the line:

   #root /usr/share/nginx/www;

added the line:

   root /var/www/weewx; (the semicolon is important)

Voila the pi was serving demo pages on the pi at localhost, and from the pc
  
   http://pi-ip#/weather/index.html

and on my MotoX 

  http://pi-ip#/smartphone/index.html

So now I have all three pieces. The weather station transmitting, The Arduino inside receiving, and weewx running.  Not all I have to do is get the serial data from the arduino into weewx.

Stay tuned - film at 11 ...