Creating a local EmonCMS installation on a Raspberry Pi

(Transplanted from http://openenergymonitor.org/emon/node/4908 for easier access)

The easiest way is to put the image on BOTH the sd and the hdd, boot up on the sd and then edit the hdd to prepare it to boot to, so first you need to give the hdd a unique uuid and then mount the hdd

sudo tune2fs -U random -L hdd  /dev/sda2

sudo mkdir /media/hdd

sudo mount /dev/sda2 /media/hdd

then edit the hdd's fstab

sudo nano /media/hdd/etc/fstab

change " /dev/mmcblk0p2 " to " /dev/sda2 " and Ctrl+x, y, enter,

while we are here just edit the inittab (this step is only required if you're intending to use rfm2pi or serial port)

sudo nano /media/hdd/etc/inittab

edit the very last line by adding a hash so it reads " # T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 "

edit the cmdline.txt and reboot (the next 2 lines are 1 line wrapped, be sure it is entered as 1 line "sudo" to "txt'")

sudo sh -c 'echo "dwc_otg.lpm_enable=0 console=tty1 root=/dev/sda2 rootfstype=ext4 elevator=deadline rootwait" > /boot/cmdline.txt'

sudo shutdown -r now

should now boot up to the hdd so add the repo to sources list, update and install (next 2 lines as one line again)

sudo sh -c "echo 'deb http://emon-repo.s3.amazonaws.com wheezy unstable' >> /etc/apt/sources.list"

sudo apt-get update

sudo apt-get -y --force-yes install emoncms emoncms-module-event emoncms-module-rfm12pi

(if you do not need or want the event module or rfm2pi module delete them from that last line to suit)

you will get asked a series of questions about mysql and emoncms passwords

The first 2 questions are to set the root password for the mySQL database root user, it's most important you set this password correctly, The rest are questions about setting up the emoncms database and email. You can accept all the default values except the second emoncms question (4th overall) this password gives emoncms access to mySQL so It should be set to the MySQL root password you just entered for questions 1 & 2. If you make a mistake with the emoncms settings it's not a problem as you can go through the questions again by using sudo dpkg-reconfigure emoncms --force.

Once these settings are entered the databases and server will be created, this will take a while, once there done run 

sudo a2ensite emoncms

sudo a2enmod rewrite

sudo /etc/init.d/apache2 restart

and if you have an rfm2pi installed also run

sudo service rfm12piphp start

go to http;//IP.ADD.OF.PI/emoncms and register a user and with any luck you're in.

 

In future when you use sudo apt-get update && sudo apt-get upgrade emoncms will get updated along with everything else.and as more modules become available in apt packaging you can install them with apt-get install as well but there maybe other steps also and that will be documented with each module.

The second partition of your sdcard still holds a redundant copy of raspbian, you could copy just the boot partition to a smaller sdcard if you wanted to free up this sdcard or if not just leave it there and if ever you have an issue with your "hdd" version you can whip out the sdcard edit the /boot/cmdline.txt file on windows by changing "/dev/sda2" to "/sda/mmcblk0p2" and pop it back it the pi to boot into the sdcard image and explore / fix your hdd image.

There are tidier methods to do this but this is by far the easiest way without another linux machine.
 

Paul

 

Bramco's picture

Re: Creating a local EmonCMS installation on a Raspberry Pi

Thanks Paul,

This worked for me using just the boot image on the SD Card from the emoncms instructions at http://emoncms.org/site/docs/raspberrypihdd. So that's the file boot_23Feb14.img copied onto the SD

And the standard Raspbian image from the raspberry pi download page 2014-01-07-wheezy-raspbian.img copied onto the HDD.

Of course It took a few tries due to typos.  Resorted to setting right click in MobaXterm to paste so I could copy from your instructions and paste into the SSH session. Worked a treat.

Also doing it this way meant that I didn't run into the problem I had in the other thread where RFM12Pi wasn't functioning. I did have to do a reboot after completing your instructions to see the inputs.

 

Thanks again for writing this up in a seperate set of instructions - they should probably go onto the wiki somewhere.

Simon

PS Doing it with the standard Raspbian image also allowed me to run startx and set up wifi before starting to do everything which also helped a lot.

pb66's picture

Re: Creating a local EmonCMS installation on a Raspberry Pi

Glad it helped Simon.

Although you should be ok with the "alternative" boot image on this occasion because I believe they are of the same "era" so the kernel files should be the same. It's worth mentioning incase of future issues the "other" files on the boot partition kernel.img & start.elf etc etc MUST exactly match the kernel files in use the main partition or at some point in the future when there is an update to the kernel things will go horribly wrong, 

I'm not familiar with MobaXterm so can't comment, I use putty or WinSCP both will copy and paste,

Also as you mentioned xstart I thought I would mention that I also like to use windows remote desktop to raspberrypi's xrdp so I can have a remote "xstart" screen open on my windows PC. but I could never get it to work with any emonCMS image until I used this method. It is now fully functional.

If you want/need to expand the partition on the hdd see Br1an's notes here http://openenergymonitor.org/emon/node/3889

Paul

Eric_AMANN's picture

Re: Creating a local EmonCMS installation on a Raspberry Pi

Hi,

It worked very well for me.

I also installed Emonhub on the same RPI with this guide.

In that case do NOT install the rfm2pi module .

Eric

pb66's picture

Re: Creating a local EmonCMS installation on a Raspberry Pi

Thanks Eric,

You're right, he emoncms rfm2pi module is required only when emoncms needs to access the rfm2pi board directly. When using emonHub (or OEM gateway) the module should not be installed and will cause problems if it is.

So where the guide above says

sudo apt-get -y --force-yes install emoncms emoncms-module-event emoncms-module-rfm12pi

leave off the " emoncms-module-rfm12pi ", so to just install emoncms use

sudo apt-get -y --force-yes install emoncms

and since the module is not installed you won't need to start the service so you don't need to run

sudo service rfm12piphp start

When emonHub is fully released it should be available as a debian package and so emonHub will be able to be installed on the same command as emoncms

sudo apt-get -y --force-yes install emoncms emonhub

so much neater.....

Paul

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.