Thursday, November 20, 2014

new Raspberry PI Monitor

I bought one of these - what sold me was the price, the 800x600 resolution  and the 7"size.
I had a Dangerous Prototypes ATX breakout board hooked up to an old power supply, thinking that the 12 v could be supplied to the monitor.  However I found that if you draw current from only the 12v supply and nothing from the 5v rail the power supply thinks something bad is happening and shuts down.

I had an radio shack wall wart power supply with multiple jack sizes that plugged in - the holes looked suspiciously the same size as the pin spacing on a screw terminal that i had -  so i tried that. Voila the monitor powered up. {note to self - add picture or find link}

The second issue was even though it powered up - plugging it into the rca video gave no picture. Turns out that you had to edit the /boot/config.txt on the PI. NOOBS sets it to only work with HDMI and I had to comment out a few lines.

# NOOBS Auto-generated Settings:

Now I had video from the pie - it was a bit pixely - but entirely readable.
The arduino IDE in the GUI is larger than the screen resolution. But right clicking on the taskbar at the bottom of the screen and selecting maximize fixed that. or should i say i could now select the menu items - but editing in this mode would be impossible - So its plug in the big monitor when editing, and just use the little monitor to view output.

Opening LOCALHOST on the browser gave a perfectly readable weewx screen.

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.


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  for guidance.
and used a lot from How to install weewx for Debian (pi) Linux 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   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

and on my MotoX 


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 ...

Thursday, November 6, 2014

Weather Station part deaux


I am still working on the receiver part - but i think i have the outside part pretty much figured out.

My goals are

  • Interface with the Sparkfun Weather instruments
  • Use a battery and charger to keep it running as long as possible before replacing.  The well head i am using as a mounting base - is 80 or so feet from the back door. Plus i have alread tun over a previous setup's rain gauge cable - never want to do that again.
Interfacing with Sparkfun weather instrument.

I grabbed some code from here and hooked it up and tested it.  The code uses interrupts to get the values from the Anemometer and Rain Gage -  and relies on Millis() to calculate the values display.  It is a single source Solution - and uses the most power since the the Arduino runs at full power all the time.

Power Down sleep mode turns off all the clocks and counters on the chip.  I thought through many scenarios to try and figure a way to use other timing sources. One promising one is using a 32,767 watch crystal - but since i am using a pro-mini - getting to the pins was more than I wanted to deal with. Then I saw something on the forums and had a DUH moment - use the outside to gather the raw data - and do data processing on the receiver.

I used the RF24Network library and added these parts 

//nrf2l01 stuff
#include "printf.h"
  nc---n/c---8  7--miso--12  
  11-- mosi--6  5--sck---13 
  08-- csn---4  3--ce----09 
  ++-- Vcc---2  1--gnd---gnd

RF24 (cepin, cspin)
#define CE_PIN 9
#define CS_PIN 8
RF24 radio(CE_PIN, CS_PIN);
RF24Network network(radio);

// Address of our node
const uint16_t this_node = 1;

// Address of the other node
const uint16_t other_node = 0;

then  in setup added
//nrf24l01 setups
  network.begin(/*channel*/ 90, /*node address*/ this_node);

to setup the structure of the packet to send

// Structure of our payload
struct payload_t
  float Temperature;//4 bytes
  double unitWind;//4 bytes
  double Gust; //4 bytes
  int WindVane;//2 bytes
  unsigned int UnitRain;//2 bytes
  unsigned long ms;//4 bytes
  long vcc;//4 bytes

The network header adds 8 bytes so I had to fiddle with the types to make it all fit in 32 bytes.

This time I am going to do it!!!!

So far I have spent way more than a good Davis weather station would cost - and I am still not getting weather data to the web.  So i am going to start all over, again.  I can definately say it all has been a ton of fun so far, but it's just not what I wanted to accomplish

Publish Weather information to the web.

So far I have  a weather instrument from Sparkfun, a temperature sensor , all hooked up to an arduino mini clone. A sketch on the arduino gets the sensor data and sends it via an NRF24l01+ . Power is supplied by a solar cell charging an old laptop lithium battery.

Its the inside part that has always been the rub.  I have tried with various arduino sketches to get the data and send it out to a PC then on to the weather site.  This time I am going to plug the arduino into a Raspberry PI and use weewx. Low power and always on - plugged into the big screen to look every once in a while.

Now all I have to do is conquer Python to interface the weather data to Weewx.   Wish Me Luck

wwall sent me an email outlining the task at hand

if the sparkfun weather station is one-wire, then you can use the OWFS driver.  you will have to make a few modifications, depending on the rain bucket and anemometer you use.
otherwise, you will probably have to write a driver.  it is pretty easy to write a driver, and there are now many examples.  first read the "porting to new weather station hardware" section of the weewx customization guide:
for your problem, there are (at least) two approaches:

1) the driver reads data directly from the serial port

2) the driver reads data from the log file

the first approach would have fewer moving parts, but you will need to know how to read/write serial.  this is really easy to do inpython using pyserial, but if the device has odd protocol or semantics then you might have to use fctl/select, which is considerably more challenging.

the second approach would let you get something running in about 10 minutes.  install weewx, then install this AcuLink driver in the user folder, then modify that driver to parse your "log file" (look for the 12 july posting with v0.4):!topic/weewx-user/bT0mCwMScuI
the v0.4 driver is misnamed.  actually it is a "FileInput" driver - it simply reads name=value pairs from a file then inserts them into weewx loop packets for processing.

Monday, June 2, 2014

Nrf24l01+ antenna

I set up shop in the living room so I could fiddle with he nrf24 radios and Arduinos between commercials on the TV.  I bought a few arduino 3,3v  pro minis and some radios with the zigzag antennas.  I loaded the example to test the radios out and all I got was failed and time out packets.  The receiver was getting the packets periodically but timed out in the ack part of the transmission.

The next thing I did was lower the transmission speed to 250k, but still no joy.  Thinking that there was a loose connection I pressed down on the radio and noted that it started completing transmissions.  It seemed if I touched the antenna on the board the transmissions completed - as soon as I removed them - they failed.

So power or antenna was the problem - rechecked the power and saw an alligator lead wire laying on the table and just clipped one on the radios antenna on the PCB and voila (it's yellow in the picture) - perfect transmission.  The was probably all kinds of mismatch between the antenna and lots of vswr - but it worked. 

I am just wondering what would be a better way of putting a wire on the board to make a matched antenna.

update - it seems that a full wave antenna for 2.4ghz  is amazingly close to the length of the alligator clip length (~4.92 inches) - who have thunk it? 

Wednesday, April 23, 2014

WHEEEEE - Raspberry Pi Is totally fun

I started out in personal computing with a soldering iron in my hand - then along came the radio shack model 1 - it was enthralled... All that computing power on my desk.

Now i run into a Raspberry pi and it is a little dynamo - I have it right now installing mysql .  I have installed apache, and have had it updating Xively with the %busy variables for a day or two now.  Even have a Arduino mini sending some data over.  Whew - lots of Goggling and lots of cut and paste.

It is exciting to see the Pi really busy - it is more fun trying to keep the little green bar in the bottom right corner pegged at 100%.

Been playing with the Arduino for a year or two now - fun, but a lot of wires and a lot of scratching my head figuring out how to stuff all that code into it...

Goal is to
1) Document all this
2) Get something connected to the Arduino (temp and/or humidity and/or Barometer)  Sending it all up to Xively and saving it locally.
3) Build some kind of page to display it on a local browser  & smartphone

In the very near future hook up some nrf24l01s to some Arduinos and put out in the Yard , basement all over the house...  You get the idea.

Currently doing the things mentioned here. and here

Since it is much more fun doing all this, than documenting it - stay tuned - film at 11:00

Sunday, April 20, 2014

Raspberry Pi and Arduino

In spite of a severe cold - or probably because of it I decided that I would play with my pi.

The goal is to get the weather information from my Weather Station inside and send it out to the internet of things someplace.  I have had it running in the past - but it invloved me leaving the desktop running and eating way too much power.

I have seen a lot of elaborate lashups using spi and whatnot hooked into the pi and the nrf24l01 - but I figured that I would do it different.  Let the Pi do what id does best and the Arduino do what it does best.
The pie is a Unix computer and will do the heavy lifting since it has internet connectivity built in and lots of ways to display the data or send it out to one of the IOT cloud servers.

The Arduino because of its robust pin protection and scads of code to talk to the nrf24l01.
1) Run the Pi from a hard drive.  I have seen lots of posts of sd card failures after a while.  They have a limited R/W Life.  Plus I have a bunch of old hard drives.

2) Plug the Arduino into the Pi and run the Arduino IDE there.  This keeps me from having to run all over the house and finding various things to get a sd card reader set up and into one of my computers.  It is so much better to keep it all in once place.

The key to all this is a Powered USB hub - it has everything plugged into it and powers the whole show.  I found one at newegg that has 7 ports and an on off switch. Keyboard and mouse go in the end - everything else goes in the top - to reboot a locked pi without dealing without unplugging a USB - there is that switch - very convenient.  The PC has a hundred watt power supply and uses a lot of power spinning up 3.5 terabytes of hard drive storage.  The power plug for the hub is 10 watts, very efficient.

I won't bore you with the details - others have already done an excellent job of documenting what to do.

  • Setting up the PI - I used Berryboot since it has an option to install directly on a hard drive. My settings include booting to a desktop and enabling SSH,
  • How to install tightvnc on the PI -
  • Installing the Arduino IDE was as easy as sudo apt-get install arduino
  • Putty  and vncviewer installed on the PC and lets me get the monitor the PI is plugged into back onto the PC.

Sounds easy - and it was - but it took a while - The Pi is not know known for its speed.

Part two will involve actually plugging the hardware together and running some simple scripts (and for me to start up the Python learning curve)