Archive for category Web Data
Notes about Raspberry Pi, an ARM based pc about the size of a deck of cards which costs $35. I might use it as a replacement for the Asus WL520 GU wifi modems I’ve been using as an Xbee WSN Gateway.
- Home Page: http://www.raspberrypi.org/
- Wiki: http://elinux.org/RaspberryPiBoard
- Quick Start: http://www.raspberrypi.org/quick-start-guide
- Verified Peripherals: http://elinux.org/RPi_VerifiedPeripherals#USB_WiFi_Adapters
- OpenWRT for the Raspberry Pi- probably won’t use this as OpenWRT is focused on WiFi functionality.
- Raspberry Pi OS Downloads
I started out with the 4G SD Card from Newark that was pre-loaded with wheezy-debian. Now I’m using the distro from Adafruit called Occidentalis v0.2. It includes ssh and other features that makes it easier to confugure.
Copy the image to a 4G SD Card using Win32DiskImager. Basically you download an OS image to a windows machine and copy it to an SD Card. When using WinDiskImager, pay close attention to your read/write actions because it’s possible to overwite the wrong drive.
Before selecting an SD Card, look at the list in Verified Peripherals. Not all SD Cards work the same, and I spent a lot of time trying to launch the OS even though the image copy was successful. If you get to the point where you’ve successfully copied the image but it won’t boot up, cut your losses and try another SD Card.
- login as: pi, password: raspberry
- I set up a root account and did most of the installation as root
Expanding the partition on the sccard
Once installed, expand the SD Card partition to fill the 4G memory space. The image on the 4G sdcard is 1.8G. This describes how to expand the partition to fill the entire 4G.
Set up SSH so you can access the Raspberry Pi from a terminal program of via Putty and/or WinSCP.
ssh-keygen -t rsa -C "email@example.com"
I used the CISECO daughter board kit which costs about $6 which has a GPIO connector and a place to hook up an xbee to the serial port on the GPIO. It derives the 3.3V from the GPIO and it includes an array of through holes for misc prototyping.
- XBee Radio PCB daughter board- by CISECO – basically a breakout board for the GPIO connections with access to the serial port and 3.3V.
- Getting started with GPIO and PythonThis is the first of two articles showing basic GPIO on the Raspberry-Pi using the prototype area of the Slice of Pi. This covers basic details on the GPIO pins, setting up a Python library to allow access to the GPIO. There is an example circuit to build on the Slice and some code to get the outputs working. This was originally a blog post on Matts blog at http://lwk.mjhosting.co.uk
- Serial port on the GPIO connector accessed as: /dev/ttyAMA0
- More notes on serial Interfacing: http://lavalink.com/2012/03/raspberry-pi-serial-interfacing/
On the Adafruit distro, Occidentalis v0.2, I was having some issues with reading the serial port in my python code. I kept getting erros related to the serial port being in use. Some research got me to this article on the RaspberryPi.org site and this article from Clayton’s Domain. I edited a file, /boot/cmdline.txt, and this is what it came down to (all on one line):
/boot/cmdline.txt dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
Install Apache on Raspberry Pi
Eventually I will want to set up a web interface to allow users to edit the gateway config items, like the network protocol and to manage the various sensors, python scripts, etc. For now, I’m just going to manage it it by ssh command line.
- Webmin- “Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.”
- Raspcontrol- PHP based Dashboard application. More about status then configuring.
Installing Python components
Rasberry Pi, default linux install, has python already installed.
I needed these modules to allow me to access various web services like Cosm (pachube), Thing Speak, Open.Sen.se, and my own SOAP based service that I wrote in C#.
We need some extra libs to run the sensor programs.
Check if python is installed and what version is installed
WGet the file then unpack it:
wget http://sourceforge.net/projects/pyserial/files/pyserial/2.5/pyserial-2.5.tar.gz/download tar -zxvf pyserial-2.5.tar.gz cd pyserial-2.5 python setup.py install
simplejson 2.6.1 is compatible with python 2.5.
WGet the file then unpack it:
wget http://pypi.python.org/packages/source/s/simplejson/simplejson-2.6.1.tar.gz tar -zxvf simplejson-2.6.1.tar.gz cd simplejson-2.6.1 python setup.py install
The suds libs provide services for SOAP calls.
Need to install python’s setup tools:
apt-get install python-setuptools
cd /home/tinaja/downloads/ wget https://fedorahosted.org/releases/s/u/suds/python-suds-0.4.tar.gz tar -zxvf python-suds-0.4.tar.gz cd python-suds-0.4/ python setup.py install
Used by Cosm (pachube)
http://pypi.python.org/pypi/python-eeml/1.1.0 ? git clone git://github.com/petervizi/python-eeml.git # cd /home/tinaja/downloads/ # wget http://pypi.python.org/packages/source/p/python-eeml/python-eeml-1.2.0.tar.gz # older version - wget http://pypi.python.org/packages/any/p/python-eeml/python-eeml-1.1.0.linux-i686.tar.gz # tar python-eeml-1.2.0.tar.gz # python setup.py install
- Source code: https://github.com/petervizi/python-eeml/
I’ve loaded the python code I’m using on GitHub:
The Raspberry Pi can be wifi enabled with a USB based wifi device. The main concern would be with power consumption; the raspberry pi runs off of a 5V (currently 700mA) supply (like a cell phone charger) and a wifi device might strain the load.
For now (8.26.2012) the wired ethernet configuration works great. It can just plug into a IP provider modem.
To change the boot-up text
Did this to brand the OS as one I set up. Only for show…
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Type 'startx' to launch a graphical session This version, from Adafruit's Occidentalis v0.2, set up by: _____ _ _ _ _ |_ _(_)_ __ __ _ (_) __ _ | | __ _| |__ ___ | | | | '_ \ / _` || |/ _` | | | / _` | '_ \/ __| | | | | | | | (_| || | (_| | | |__| (_| | |_) \__ \ |_| |_|_| |_|\__,_|/ |\__,_| |_____\__,_|_.__/|___/ |__/ TinajaLabs.com, Summer 2012 -----------------------------------------------------
To set a program to start at boot-up
To automatically run the main python script, allsensors.py, when the computer starts…
Edit /etc/rc.local and add the python line shown below:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi # add this for Tinaja Labs sensor tracking python /home/tinaja/allsensors.py & exit 0
To set up Tomcat Server
At some point I might want to set up a Tomcat server and use it with some Java apps. Later.
- JDK for Linux ARM, JRE for Mac OS X: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=34&t=14635
To watch the message log file
This allows you to see the system messages generated by the script as it sends various sensor readings to the web services.
cd /var/log/ tail -f messages
To kill the Tinaja python script
Look for the process id of the python script with this command:
ps aux # for a full list ps aux | grep python # to see only python processes
Take note of the process id number and issue this command:
kill 9999 # where 9999 is the process id number
That’s all I have for now, hope you found something useful here.
Tendril has a post on their blog that talks about an emerging style of energy monitoring connectivity that they are calling a Hybrid-HAN (home area network). It envisions a dual network, one that utilizes a the Utility’s smart meter and a second provided b y the consumer; a wifi router, for example. They figure this is a good thing because it will unburden the smart meter from the growing list of sensors and controls that will become more popular as consumers learn to understand the benefits of monitoring their home environment.
The consumer side of the system uses something called the ZigBee Smart Energy Profile. Not sure about the Smart Energy Profile but Zigbee is a well known low power wireless protocol that I’ve been experimenting with for a low power, inexpensive monitoring system. Each Zigbee (aka xBee) module can transmit or receive signals that cover most residential buildings and costs about $20.
Interestingly the image shows the data from the consumers gateway (basically a specialized router) being fed back to the utility company but I’m not sure that’s the way it will play out.
In the future, data locality will not be so crucial. There are always concerns about this or that silo of data that stands alone and unaccessible from external sites. But as we grow to understand the benefits of shared data, any system will be able to aggregate date from any other system (with proper authentication of course).
I was working on some Google Charts and came across this one. Here’s my new business card:
As they say, "read 'em and weep".
From the overview of Google's QR codes charts:
"QR codes are a popular type of two-dimensional barcode. They are also known as hardlinks or physical world hyperlinks. QR Codes store up to 4,296 alphanumeric characters of arbitrary text. This text can be anything, for example URL, contact information, a telephone number, even a poem! QR codes can be read by an optical device with the appropriate software. Such devices range from dedicated QR code readers to mobile phones."
Anyone have a laser reader? Here's one:
Here's a sample app to read a QR code from your smartphone:
Knitting QR codes:
This is going to be a base post (I’ll make it sticky) to hold the outline of tutorials related to various aspect of wireless sensor networks. From the sensors and radios, to a gateway, to web services, data logging and eventually, charting and analysis. Look at this overview of Wireless Sensor Networks on Wikipedia.
Our interest is in developing a wireless sensor network platform that is inexpensive and simple to use. There is a sweet spot between super high tech and older outdated technology where we believe there exists a meaningful set of technologies that will fit our goals.
What we’ve discovered is that we can use radios, like the xBee radios from Digi, with up to 4 sensors hooked up to each one, as our remote sensor boards. We have also discovered that we can transform a wifi router into a tiny, low powered computer running an embedded, open source, operating system called OpenWRT. Many wifi routers have a serial port available on the main pcb inside the device to which we can hook up a coordinating xBee radio; the counterpart to the ones on each sensor board. Then we install a scripting language, Python, into the Linux operating system. Finally, we install python scripts which can be used to collect the data being transmitted from the sensor boards and send that data to web services like Cosm (formerly Pachube), ThingSpeak, Open.sen.se, Paraimpu, etc.
So we have wireless sensor boards sending sensor data to a radio wired into the serial port of a wifi router. The wifi router has been re-flashed with an open source embedded Linux operating system, OpenWRT, and to that we’ve added Python as an easy to use scripting language. We have then added various scripts to bundle the incoming data and send it to the internet for further processing, charting, and so forth.
It is an inexpensive, flexible, easy to use, wireless sensor network platform.
In this ongoing quest to learn more about sensor networks I’ll add links to the Resources Page.
Here’s a list of notes we’ll be updating with information about how to build you’re own wireless sensor network.
- WSN: Sensors: this is where is all begins. The sensor responds to some environmental events and generates a voltage or a digital signal. I’ll be going over a few sensor types that I’ve built; Tweet-a-watt, Temperature, Gas (example of indoor air quality), and a Force Sensitive Resistor (FSR) as an example of Elder Care.
- Radio: XBee – Radios allow us to create the wireless part of sensor networks. The XBee radio is very accessible to beginners even if configuration is a bit challenging. I’ll describe the various aspects of XBee radios that I’ve used.
- Gateway: Wifi Router – in the original design for the Tweet-a-watt the output from the sensor’s transmitter sent data to an XBee receiver hooked into a PC (via FTDI-USB). The approach I describe uses a low powered (about 4 watts) Asus wi-fi router in place of a PC. I’ll describe using OpenWRT as a replacement OS and adding a USB memory stick to extend the storage memory of the device. I’ll also show how I added python with web service calls in order to send data to the internet.
- Client facing site: a site for users to register their gateway devices and manage the sensors associated with each. Also the place to look at the charts and subsequent analysis for the sensor data. This is an MVC web application written in C# and ASP.NET using Visual Studio 2010 Express and SQL Server 2008 Express.
Next: WSN: Sensors
Developed for DOE by the Environmental Energy Technologies Division at Lawrence Berkeley National Laboratory this site is a preliminary test version of a new web-based energy efficiency calculator, designed for residential home energy auditors and inspectors.
Interestingly, Microsoft has licensed the technology for their energy calculator application known as HOHM.
Apparently they have a service based API. I’m going to research that and see what it looks like.