Use Emonhub with RPICT

From lechacal
Jump to: navigation, search


DO NOT USE THIS GUIDE WITH EMONPI / EMONCMS IMAGE. This is for use on a native Raspbian image. If using the emoncms image this is not necessary as emonhub is already installed.

This document will demonstrate how to prepare the rasberrypi to use Emonhub with the RPICT.

Emonhub will be used to forward the data from the RPICT series board and forward them to Emoncms.

We assume here a fresh install of raspbian has been installed and all steps to get the serial port operating have been carried out. See Howto_setup_Raspbian_for_serial_read.

Also make sure the RPICT board supports Emonhub format as output.

Install Emonhub

This is not necessary if you are using the image from Emoncms as emonhub is already installed.

To install emonhub we would recommend following the steps indicated on the emonhub github page.

We have summarized the commands to executre below:

sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget
sudo apt-get update
sudo apt-get install -y mosquitto python-serial python-configobj
sudo easy_install -U pip
sudo pip install paho-mqtt
sudo pip install pydispatcher

Open and modify this file below:

sudo nano /etc/mosquitto/mosquitto.conf

Set persistence parameter as false

persistence false
mkdir data
git clone && emonhub/install
sudo service emonhub start

RPICT configuration

The format parameter should be set to emonhub, code number 3.

format = 3

Emonhub configuration

The configuration file for emonhub is located in /home/pi/data

Open this file. Delete all its content and replace with this one below:

### loglevel must be one of DEBUG, INFO, WARNING, ERROR, and CRITICAL
### see here :
loglevel = DEBUG #(default:WARNING)


  Type = EmonHubSerialInterfacer
      com_port = /dev/ttyAMA0
      com_baud = 38400
     pubchannels = ToEmonCMS,

   Type = EmonHubEmoncmsHTTPInterfacer
       subchannels = ToEmonCMS,
       #url = http://localhost/emoncms #uncomment to save on local pi
       apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
       senddata = 1                    # Enable sending data to
       sendstatus = 1                  # Enable sending WAN IP to MyIP >
       sendinterval= 30                # Bulk send interval to in seconds


  nodename = my_RPICT7V1
     names = RP1, RP2, RP3, RP4, RP5, RP6, RP7, Irms1, Irms2, Irms3, Irms4,Irms5,Irms6,Irms7,Vrms
     scales = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
     units =W,W,W,W,W,W,W,mA,mA,mA,mA,mA,mA,mA,V
     datacode = 0

Change the node information as relevant. Also change the apikey to the one that emoncms gave you.