Installing Emoncms on Raspberrry Pi 2

Emoncms can do some great input processing and visual dashboards, along with many other things. Below is the process I used to install it on a Raspberry Pi 2 using Raspian.

Install Dependencies

Install all the dependencies.

During this install, it will prompt you for further information. Install pecl dependencies (redis and swift mailer)

Add pecl modules to php5 config

Configure dependencies


Configure redis to run without logging or data persistence.

Comment out redis log file and all the redis saving.

Then restart the Redis service


Emoncms uses Apache to route requests, so modrewrite needs to be enabled.

Modify the Apache2 config to allow rewrite.

Change (line 7 and line 11), AllowOverride None to AllowOverride All. Comment out line # CustomLog ${APACHE_LOG_DIR}/access.log combined Comment the access log to other-vhosts (add #)

Now Reboot the Pi

Install Emoncms

For the install Emoncms, it will be installed from the git repository for Emoncms. First, lets setup the web directory and permissions.

Download Emoncms from the git repository. For this we’re using a cloning a specialised version of Emoncms which has been designed to write less to the SD Card.

Configure Emoncms


Lets setup the mysql database for Emoncms. If you would like to move the mysql database to another location (for easier backup,etc), now is the time to do it. For this, I’ve chosen to move the Mysql database to /home/pi/data/mysql. I first create the directory and then copy the mysql data accross.

Now update the mysql configuration file to use the new location.

change line datadir to /home/pi/data/mysql Create the Emoncms database.

This will prompt you for a password and the following SQL will create the database.

Now create a user and assign permissions that Emoncms will use to access the mysql databse. In the commands below, update username and password to suit your choice.

Data directory

Now we create some directories were the Emoncms’ feed engines ( phpfina and phptimeseries) will store data. I chose /home/pi/data/.

Emoncms Configuration settings

Lets setup the configuration file for Emoncms. We copy the default.settings.php to settings.php.

Now we update the settings to suit this installation of Emoncms.

Update the following things: Database Settings. Update these to the username and password you created previously when setting up Mysql.

If you chose a different location to store your data directory earlier, update these lines to suit your data directories.

Setup the feedwriter script as a service.  Copy the service script to /etc/init.d/, update permissions and enable for service.

Now go to a web browser and go to the emoncms website. Update the IP-Address below to your host.

Click Register and create yourself a new Admin user. After you have successfully logged in and do not want to create any other users for this Emoncms, it is best to disable the register functionality. To do this, we edit the settings again.

And change $allowusersregister to FALSE.

As you have now gone through the initial setup for Emoncms, you can also disable the dbtest.


The following log entries should be created and help with this.


Installation of Pywws on Raspberry Pi 2 for Weather Station

This is the process I followed to install pywws on a Raspberry Pi 2 on Raspian.  I have a 3080 compatible weather station connected to the Raspberry Pi 2 via USB.

Install Dependencies

As pywws is written in Python, it has a few dependencies which need to be installed on the Raspberry Pi 2.  I like to make sure that before this I update to the latest updates.

Now install the python, libusb and gnuplot.  Libusb as we need to access the weather station via USB and gnuplot in order for draw graphs with pywws.

There are other dependencies if you want to use other features or pywws (eg. twitter), but these will give you the basics to get pywws up and running.  Other dependencies can be found here.

Install Pywws and permissions

After all the required software is installed, you can install pywws.

After it has installed, plug in the internal weather station unit to the Raspberry Pi 2 via USB. Now you can test to ensure it can talk to the weather station.

This command should produce some output that looks like this.

If this does not work, further information is available at which may help. You have to run pywws in python using sudo. It is much better to run it as the user Pi and the give the Pi user access to the USB port. First create a group to grant the access and add the Pi user to the group

You need to identify the idVendor and idProduct for your WeatherStation that is plugged into the USB port. Look into the kernal log file.

Look for idVendor and idProduct, mine were idVendor=1941 and idProduct=8021. My kern.log look like this.

To modify the USB, create a rule that sets the usb port to the group weather

Copy and paste the following into this file. Make sure you update the idVendor and idProduct to suit your USB.

After you’ve saved and exit, reboot the Pi. Once the Pi has started again, test connecting to the weatherstation as user Pi, without sudo.

You should get the same results as you did above when you tested using the command with sudo. As we’ll be running this as user Pi, ensure that all the weather data is owned by user Pi.

Configuration of Pywws

I wanted readings every 5 minutes from the weather station and as pywws can easily read and log the weather station data every 5 minutes (recommended setting is 5min too), this was ideal. So, I set the weather station to log every 5 minutes.

It’s worth noting that the memory in the internal unit is not very large and although it will buffer some data, it cannot hold very much weather data. Now to setup where to log the data.  I chose /home/pi/data/weather, but it could be anywhere.  If a different directory is used, update the url through the rest of this page to the select directory.

All the weather station’s logged data should go into this directory. As per the getting started doco above for pywws, we now need to setup the timezone and weather station type. We will need to run the following command and it will create the configuration files the first time it is run.

The configuration files are found in the data directory /home/pi/data/weather/data. I adjusted the following in the weather.ini configuration file.

There is a full page in the doco about the weather.ini configuration settings here. I also update the configuration paths in the weather.ini file.

My full weather.ini looks like this.

Now create these directories and copy the pywws examples into them.

Then we run the command again.

This will probably need to run for a while to download the data. It should have some output similar to this.

So now that the weather station data can be downloaded, I want to setup a service that will run to download the weather data. There are two options, an hourly update or a live logger. I opted for the live logger as I wanted data updated as close to every 5min as possible. Pywws comes with a livelogger than can run as a daemon.  It can be run like this.

While this works well, it will not start automatically. A service init script is much easier to manage for me. Create a new init.d file by running the following.

Now copy and paste the following into this file. Update the DAEMON, DATADIR and LOGFILE to suit your installation.

Once the init script has been saved, it needs to be made executable and added to rc.d so it will start and stop at startup and shutdown.

You can also start/stop pywws as a service.


Weather Station

I recently purchased a weather station from ebay, model WS-3081.  The weather station has an internal and external unit and transmits via wireless between them – 433Mhz.  The internal unit runs on batteries and although unverified, it appears like it will also run off power supplied via USB.  The external unit has rechargeable batteries and a solar panel to recharge the batteries.

WH3080 Weather StationThe weather station can measure wind speed, wind direction, rainfall, temperature, humidity, solar UV and lux from the external unit.  The internal unit can measure temperature, humidity and pressure.

This is great, but I want to a way to get that information into the computer so that I can more interesting things with it.  The weather station comes with Windows software, which will let you download the data over USB to the internal unit.  I had a look at this and although it works, it doesn’t give me the flexibility I want to download the data quickly, easily and export in an automated way.

Further posts coming on the weather station as I work on getting it automated.

Raspberry Pi 2 Node-Red setup

In order to setup node-red, node.js is required.  Node.js runs on javascript and is one of the building blocks of node-red.  The install processes for Raspberry Pi and Raspberry Pi 2 are different and have different instructions.  Below are instructions for Raspberry Pi 2 and I have tested this process on Raspian wheezy 2015-20-16.  These are my own notes for my own purposes, but hopefully somebody else will find them useful too.

Before running these, update Raspian first.


To install node-red for the Raspberry Pi 2, the node-red guys have made it much easier.

Run the following command. This will update the raspian package cache and the source list.

Now to install all the packages.

Verify that node and npm have installed correctly. Run the following.

You should get results similar to the following.

Once these are installed, run the following command to install node-red.

This takes quite some time.

I got a few warnings and the build of the node-icu-charset-detector node failed completely, however node-red still built successfully.

Now to test node-red. Run the following to start node-red from the command line.

Node-Red should start and should look something like this.

You should get the node-red web interface by going to the following page in your web browser.

Now to install an initialisation script so that node-red can run as a service and start/stop automatically on startup/shutdown.  Create a new init.d file by running the following.

Then copy and paste the script below into this file and save.  This script will run node-red as the user pi.  It’s very simliiar to the Adafruit (link below) except updated for the new installs for Raspberry Pi 2.

Once the init script has been saved, it needs to be made executable and added to rc.d so it will start and stop at startup and shutdown.

You can also start/stop/restart the node-red service using this script.

node-red addons

There are many addons for node-red.  Some of my favorites are ping, wol, emoncms, prowl, mysql and pushbullet – but there is many others. To install them, use npm from the node-red directory.  The following will install my favorite addons.

There are many other addons and you can find other packages at


I found that the install didn’t always successfully compile all addons. If there is an addon you expect to see in the node-red GUI that is not there, you can enable more verbose logging.  It should tell you if it is getting any errors or if it cannot load a specific module.  The below will run node-red manually from the command line.  Ctrl-C to break out.

Useful node-red sites & references
Adafruit has a very nice guide for setting up node-red on a Raspberry Pi (version1). Very useful.
Has many npm packages which can be installed.
The Node-Red site.
Interesting demo. Twitter, Mongo REST API and sentiment Analytics in 3 minute demo.
The Git Hub repository for Node-Red.