Simple DIY emonpi

Hello, has anyone had any luck putting together a simple DIY emonpi with a RaspberryPi 3 and an Arduino nano or uno with just one CT of Appliance monitoring at 120 volts ?

Do you want to measure just one appliance, running at 120 V?
If you want to do that with an Arduino Uno and feed the output by a wired connection into a Raspberry Pi, then you need to follow the basic instructions in ‘Learn’ - Interfacing with an Arduino to get the current measuring part working, then to connect that to the GPIO of your RPi, follow Direct connection emonTx V3 > Raspberry Pi GPIO in the Wiki via Resources → EmonTx V3 → Hardware Docs.

Why do you ask? Are you still struggling with your Shield?

Hello, Yes just one 120 volt device. I ordered the sheild I few days back I’m in the US, probably will be a few days before I receive it. Basically was asking because I have a few RaspberryPi 3s here not being used here. I was also reading through the forum is there also away to use and ADC like a ADS1115 to interface the CT coil and the RaspberryPi together?

You should be able to use an external ADC, but that one isn’t really suitable. The max data rate, according to the spec. sheet, is 860 samples per second, and that will give you 14 samples per cycle, It’s hardly enough. The AtMega 328P manages just over 2500 pairs of voltage and current samples per second, or about 40 per 60 Hz cycle.

Ok, would it be a good idea to run the Arduino Uno or nano at 3.3 volts since the RaspberryPi’s gpio pins are 3.3 volts, use a level shifter or would it be acceptable to use an Arduino pro mini 3.3 volts 8 MHz or is that to slow?

If your Arduino will happily run at 3.3 V, then that is the simplest solution. Or if not, then check the data sheets, you’ll need to reduce the 5 V from the Arduino to 3.3 V for the Pi, but you might find that the Arduino will reliably see the lowest ‘high’ voltage from the Pi.

From what you’ve written, the Arduino won’t be doing any heavy processing with only one ADC channel in use, so the slower version should be OK.

ok,Ill try it out. would I need to change the Irms *230.0 to 120 for the USA voltage?

#include “EmonLib.h”
// Include Emon Library
EnergyMonitor emon1;
// Create an instance
void setup()
{
Serial.begin(9600);

emon1.current(1, 111.1); // Current: input pin, calibration.
}

void loop()
{
double Irms = emon1.calcIrms(1480); // Calculate Irms only
Serial.print(Irms*230.0); // Apparent power
Serial.print(" ");
Serial.println(Irms); // Irms
}

Thanks.

Indeed you would.

You might also want to add a delay in the loop, so that it prints the result less frequently, and hence fills the database and available memory less quickly.

Ok, for some reason I can’t get this to update on the web ui I’m not sure if something is wrong with the configuration on the RaspberryPi Emon pi image or if something is wrong with the wiring connections. I have the Arduino promini 3.3 volt getting power and ground and Arduino TX going to Pi’s RX and PIs TX going to Arduinos RX. Also the CT is connect as show in the Arduino CT connection guide.

If this is an Arduino the Rx should go to the Pi’s Tx and Tx to the Pi’s Rx, the emonTx is non-compliant with the norm, but almost all non OEM devices do not go Tx to Tx and Rx to Rx.

Correct,that is what I have. On the web ui the update line says n/a and is red.

Hello, Would I need to have a realtime clock connected to the Raspberry Pi for this to work?

What lies between your device and emoncms?

Assuming you are using the emonSD image for now, there are several steps to check between connecting the serial port and not seeing an input in emoncms.

Is the device outputting any serial data? Is that data in the right format?

Is the device being successfully connected to by emonhub? Is that serial data being received?

Is emonhub publishing or sending the data succesfully?

Check your emonhub logs for answers to most of the questions above, but first and formost you must confirm you are able to get serial output from your device when powered at 3.3v.

Arduino pro mini’s come in 2 flavors, 5v or 3.3v, if you are using a 3.3v pro mini it requires an input voltage of >3.5 volts on the RAW pin, if powering from the Pi, use 5v.

And just for future reference, it is possible to get 3.3v 16MHz clone pro mini’s if you search for them.

No that shouldn’t be necessary to get this working. If you have no internet connection to the Pi, it will not get the time via NTP and that could cause other issues, but posting to a local emoncms should always be possible, even if the time is wrong, all parties are using the same wrong time, so aside from the time of the data being wrong, it should still update “now” even if now appears to be 2 years ago :slight_smile:

Ok, thanks. I’m using the EmonPi SD image off the site. The Arduino displays data when connected to the computer serial monitor. I just have ground and power I changed from 3.3v to vcc to 5 volts to raw pin to the pro mini and tx rx are connected. In the Emonhub is says something about not being able to find the Dev port.

2018-11-05 03:14:22,506 INFO MainThread Exit completed
2018-11-05 03:14:23,479 INFO MainThread EmonHub emonHub emon-pi variant v2.1.1
2018-11-05 03:14:23,480 INFO MainThread Opening hub…
2018-11-05 03:14:23,480 INFO MainThread Logging level set to DEBUG
2018-11-05 03:14:23,481 INFO MainThread Creating EmonHubSerialInterfacer ‘SerialDirect’
2018-11-05 03:14:23,483 ERROR MainThread [Errno 2] could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: ‘/dev/ttyUSB0’
2018-11-05 03:14:23,483 DEBUG MainThread Setting SerialDirect pubchannels: [‘ToEmonCMS’]
2018-11-05 03:14:23,484 INFO MainThread Creating EmonHubMqttInterfacer ‘MQTT’
2018-11-05 03:14:23,487 DEBUG MainThread Setting MQTT subchannels: [‘ToEmonCMS’]
2018-11-05 03:14:23,487 DEBUG MainThread Setting MQTT pub channels: [‘ToRFM12’]

thanks.

That’s a USB to serial converter its looking for, have you actually got tx & rx connected directly with the Pi GPIO pins? If so, precisely which pins are they connected to? The Pi3 has 2 serial ports, one of which is connected to the bluetooth radio by default (unless you have turned that off).

I think the first thing you need to do is get EmonHub talking to the correct serial port and make sure that is defined correctly in your emonhub.conf file

Please paste the contents of your emonhub.conf file and we can go from there.

Ok heres what I have.

#######################################################################
####################### emonhub.conf #########################
#######################################################################

emonHub configuration file, for info see documentation:

http://github.com/openenergymonitor/emonhub/blob/emon-pi/configuration.md

#######################################################################
####################### emonHub settings #######################
#######################################################################

[hub]

loglevel must be one of DEBUG, INFO, WARNING, ERROR, and CRITICAL

loglevel = DEBUG

Uncomment this to also send to syslog

use_syslog = yes

#######################################################################
####################### Interfacers #######################
#######################################################################

[interfacers]

This interfacer manages the RFM12Pi/RFM69Pi/emonPi module

[[RFM2Pi]]

Type = EmonHubJeeInterfacer

[[[init_settings]]]

com_port = /dev/ttyAMA0

com_baud = 38400 # 9600 for old RFM12Pi

[[[runtimesettings]]]

pub channels = ToEmonCMS,

sub channels = ToRFM12,

group = 210

frequency = 433

based = 5 # emonPi / emonBase nodeID

calibration = 230V # (UK/EU: 230V, US: 110V)

quiet = true # Disable quite mode (default enabled) to enable RF packet debugging, show packets which fail cry

# interval = 0 # Interval to transmit time to emonGLCD (seconds)

[[SerialDirect]]
Type = EmonHubSerialInterfacer
[[[init_settings]]]
com_port = /dev/ttyUSB0 # or /dev/ttyAMA0 or/dev/ttyACM0 etc
com_baud = 9600 # to match the baud of the connected device
[[[runtimesettings]]]
pubchannels = ToEmonCMS,

[[MQTT]]

Type = EmonHubMqttInterfacer
[[[init_settings]]]
    mqtt_host = 127.0.0.1
    mqtt_port = 1883
    mqtt_user = emonpi
    mqtt_passwd = emonpimqtt2016

[[[runtimesettings]]]
    pubchannels = ToRFM12,
    subchannels = ToEmonCMS,

    # emonhub/rx/10/values format
    # Use with emoncms Nodes module
    node_format_enable = 1
    node_format_basetopic = emonhub/

    # emon/emontx/power1 format - use with Emoncms MQTT input
    # http://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md
    nodevar_format_enable = 1
    nodevar_format_basetopic = emon/

[[emoncmsorg]]
Type = EmonHubEmoncmsHTTPInterfacer
[[[init_settings]]]
[[[runtimesettings]]]
pubchannels = ToRFM12,
subchannels = ToEmonCMS,
url = https://emoncms.org
apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
senddata = 1 # Enable sending data to Emoncms.org
sendstatus = 1 # Enable sending WAN IP to Emoncms.org MyIP > Emoncms - myip list
sendinterval= 30 # Bulk send interval to Emoncms.org in seconds

#######################################################################
####################### Nodes #######################
#######################################################################

[nodes]

See config user guide: http://github.com/openenergymonitor/emonhub/blob/master/configuration.md

[[5]]
nodename = emonpi
[[[rx]]]
names = power1,power2,power1pluspower2,vrms,t1,t2,t3,t4,t5,t6,pulsecount
datacodes = h, h, h, h, h, h, h, h, h, h, L
scales = 1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
units = W,W,W,V,C,C,C,C,C,C,p

[[6]]
nodename = emontxshield
[[[rx]]]
names = power1, power2, power3, power4, vrms
datacode = h
scales = 1,1,1,1,0.01
units =W,W,W,W,V

[[7]]
nodename = emontx4
[[[rx]]]
names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
datacodes = h,h,h,h,h,h,h,h,h,h,h,L
scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
units =W,W,W,W,V,C,C,C,C,C,C,p

[[8]]
nodename = emontx3
[[[rx]]]
names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
datacodes = h,h,h,h,h,h,h,h,h,h,h,L
scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
units =W,W,W,W,V,C,C,C,C,C,C,p

[[9]]
nodename = emontx2
[[[rx]]]
names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
datacode = h
scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
units =W,W,W,W,V,C,C,C,C,C,C,p

[[10]]
nodename = emontx1
[[[rx]]]
names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
datacode = h
scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
units =W,W,W,W,V,C,C,C,C,C,C,p

[[11]]
nodename = 3phase
[[[rx]]]
names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
datacodes = h,h,h,h,h,h,h,h,h,h,h,L
scales = 1,1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
units =W,W,W,W,V,C,C,C,C,C,C,p

[[12]]
nodename = 3phase2
[[[rx]]]
names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
datacodes = h,h,h,h,h,h,h,h,h,h,h,L
scales = 1,1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
units =W,W,W,W,V,C,C,C,C,C,C,p

[[13]]
nodename = 3phase3
[[[rx]]]
names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
datacodes = h,h,h,h,h,h,h,h,h,h,h,L
scales = 1,1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
units =W,W,W,W,V,C,C,C,C,C,C,p

[[14]]
nodename = 3phase4
[[[rx]]]
names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
datacodes = h,h,h,h,h,h,h,h,h,h,h,L
scales = 1,1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
units =W,W,W,W,V,C,C,C,C,C,C,p

[[19]]
nodename = emonth1
[[[rx]]]
names = temperature, external temperature, humidity, battery
datacode = h
scales = 0.1,0.1,0.1,0.1
units = C,C,%,V

[[20]]
nodename = emonth2
[[[rx]]]
names = temperature, external temperature, humidity, battery
datacode = h
scales = 0.1,0.1,0.1,0.1
units = C,C,%,V

[[21]]
nodename = emonth3
[[[rx]]]
names = temperature, external temperature, humidity, battery
datacode = h
scales = 0.1,0.1,0.1,0.1
units = C,C,%,V

[[22]]
nodename = emonth4
[[[rx]]]
names = temperature, external temperature, humidity, battery
datacode = h
scales = 0.1,0.1,0.1,0.1
units = C,C,%,V

[[23]]
nodename = emonth5
[[[rx]]]
names = temperature, external temperature, humidity, battery, pulsecount
datacodes = h,h,h,h,L
scales = 0.1,0.1,0.1,0.1,1
units = C,C,%,V,p

[[24]]
nodename = emonth6
[[[rx]]]
names = temperature, external temperature, humidity, battery, pulsecount
datacodes = h,h,h,h,L
scales = 0.1,0.1,0.1,0.1,1
units = C,C,%,V,p

[[25]]
nodename = emonth7
[[[rx]]]
names = temperature, external temperature, humidity, battery, pulsecount
datacodes = h,h,h,h,L
scales = 0.1,0.1,0.1,0.1,1
units = C,C,%,V,p

[[26]]
nodename = emonth8
[[[rx]]]
names = temperature, external temperature, humidity, battery, pulsecount
datacodes = h,h,h,h,L
scales = 0.1,0.1,0.1,0.1,1
units = C,C,%,V,p

[[99]]
nodename = my-serial-device
[[[rx]]]
names = power1, power2, power3, power4, vrms
datacode = 0 # not essential as “0” is default datacode for serial interfacer
scale = 1 # not essential as “1” is default scale for serial interfacer
units =W,W,W,W,V

Can you edit your post so that the file isn’t interpreted and formatted?

Use three “backtick” characters on a line by themselves before and after it, like this:
```
file contents here
```
which then looks like this:

file contents here

On to the problem you’re having, the relevant section is this bit:

[[SerialDirect]]
    Type = EmonHubSerialInterfacer
    [[[init_settings]]]
        com_port = /dev/ttyUSB0 # or /dev/ttyAMA0 or/dev/ttyACM0 etc
        com_baud = 9600 # to match the baud of the connected device
    [[[runtimesettings]]]
        pubchannels = ToEmonCMS,

That com_port needs to be the serial port you’ve connected your device to.

What devices do you have? What is the output of:

ls -l /dev/tty*

Something like this?

pi@emonpi(ro):~$ ls -l /dev/tty*
crw-rw-rw- 1 root tty       5,  0 Nov  5 03:18 /dev/tty
crw--w---- 1 root tty       4,  0 Nov  5 03:18 /dev/tty0
crw------- 1 pi   tty       4,  1 Nov  6 02:26 /dev/tty1
crw--w---- 1 root tty       4, 10 Nov  5 03:18 /dev/tty10
crw--w---- 1 root tty       4, 11 Nov  5 03:18 /dev/tty11
crw--w---- 1 root tty       4, 12 Nov  5 03:18 /dev/tty12
crw--w---- 1 root tty       4, 13 Nov  5 03:18 /dev/tty13
crw--w---- 1 root tty       4, 14 Nov  5 03:18 /dev/tty14
crw--w---- 1 root tty       4, 15 Nov  5 03:18 /dev/tty15
crw--w---- 1 root tty       4, 16 Nov  5 03:18 /dev/tty16
crw--w---- 1 root tty       4, 17 Nov  5 03:18 /dev/tty17
crw--w---- 1 root tty       4, 18 Nov  5 03:18 /dev/tty18
crw--w---- 1 root tty       4, 19 Nov  5 03:18 /dev/tty19
crw--w---- 1 root tty       4,  2 Nov  5 03:18 /dev/tty2
crw--w---- 1 root tty       4, 20 Nov  5 03:18 /dev/tty20
crw--w---- 1 root tty       4, 21 Nov  5 03:18 /dev/tty21
crw--w---- 1 root tty       4, 22 Nov  5 03:18 /dev/tty22
crw--w---- 1 root tty       4, 23 Nov  5 03:18 /dev/tty23
crw--w---- 1 root tty       4, 24 Nov  5 03:18 /dev/tty24
crw--w---- 1 root tty       4, 25 Nov  5 03:18 /dev/tty25
crw--w---- 1 root tty       4, 26 Nov  5 03:18 /dev/tty26
crw--w---- 1 root tty       4, 27 Nov  5 03:18 /dev/tty27
crw--w---- 1 root tty       4, 28 Nov  5 03:18 /dev/tty28
crw--w---- 1 root tty       4, 29 Nov  5 03:18 /dev/tty29
crw--w---- 1 root tty       4,  3 Nov  5 03:18 /dev/tty3
crw--w---- 1 root tty       4, 30 Nov  5 03:18 /dev/tty30
crw--w---- 1 root tty       4, 31 Nov  5 03:18 /dev/tty31
crw--w---- 1 root tty       4, 32 Nov  5 03:18 /dev/tty32
crw--w---- 1 root tty       4, 33 Nov  5 03:18 /dev/tty33
crw--w---- 1 root tty       4, 34 Nov  5 03:18 /dev/tty34
crw--w---- 1 root tty       4, 35 Nov  5 03:18 /dev/tty35
crw--w---- 1 root tty       4, 36 Nov  5 03:18 /dev/tty36
crw--w---- 1 root tty       4, 37 Nov  5 03:18 /dev/tty37
crw--w---- 1 root tty       4, 38 Nov  5 03:18 /dev/tty38
crw--w---- 1 root tty       4, 39 Nov  5 03:18 /dev/tty39
crw--w---- 1 root tty       4,  4 Nov  5 03:18 /dev/tty4
crw--w---- 1 root tty       4, 40 Nov  5 03:18 /dev/tty40
crw--w---- 1 root tty       4, 41 Nov  5 03:18 /dev/tty41
crw--w---- 1 root tty       4, 42 Nov  5 03:18 /dev/tty42
crw--w---- 1 root tty       4, 43 Nov  5 03:18 /dev/tty43
crw--w---- 1 root tty       4, 44 Nov  5 03:18 /dev/tty44
crw--w---- 1 root tty       4, 45 Nov  5 03:18 /dev/tty45
crw--w---- 1 root tty       4, 46 Nov  5 03:18 /dev/tty46
crw--w---- 1 root tty       4, 47 Nov  5 03:18 /dev/tty47
crw--w---- 1 root tty       4, 48 Nov  5 03:18 /dev/tty48
crw--w---- 1 root tty       4, 49 Nov  5 03:18 /dev/tty49
crw--w---- 1 root tty       4,  5 Nov  5 03:18 /dev/tty5
crw--w---- 1 root tty       4, 50 Nov  5 03:18 /dev/tty50
crw--w---- 1 root tty       4, 51 Nov  5 03:18 /dev/tty51
crw--w---- 1 root tty       4, 52 Nov  5 03:18 /dev/tty52
crw--w---- 1 root tty       4, 53 Nov  5 03:18 /dev/tty53
crw--w---- 1 root tty       4, 54 Nov  5 03:18 /dev/tty54
crw--w---- 1 root tty       4, 55 Nov  5 03:18 /dev/tty55
crw--w---- 1 root tty       4, 56 Nov  5 03:18 /dev/tty56
crw--w---- 1 root tty       4, 57 Nov  5 03:18 /dev/tty57
crw--w---- 1 root tty       4, 58 Nov  5 03:18 /dev/tty58
crw--w---- 1 root tty       4, 59 Nov  5 03:18 /dev/tty59
crw--w---- 1 root tty       4,  6 Nov  5 03:18 /dev/tty6
crw--w---- 1 root tty       4, 60 Nov  5 03:18 /dev/tty60
crw--w---- 1 root tty       4, 61 Nov  5 03:18 /dev/tty61
crw--w---- 1 root tty       4, 62 Nov  5 03:18 /dev/tty62
crw--w---- 1 root tty       4, 63 Nov  5 03:18 /dev/tty63
crw--w---- 1 root tty       4,  7 Nov  5 03:18 /dev/tty7
crw--w---- 1 root tty       4,  8 Nov  5 03:18 /dev/tty8
crw--w---- 1 root tty       4,  9 Nov  5 03:18 /dev/tty9
crw-rw---- 1 root dialout 204, 64 Nov  5 03:18 /dev/ttyAMA0
crw------- 1 root root      5,  3 Nov  5 03:18 /dev/ttyprintk
crw-rw---- 1 root dialout   4, 64 Nov  5 03:18 /dev/ttyS0
pi@emonpi(ro):~$ 

[[SerialDirect]]
     Type = EmonHubSerialInterfacer
      [[[init_settings]]]
           com_port = /dev/ttyUSB0      # or /dev/ttyAMA0 or/dev/ttyACM0 etc
           com_baud = 9600              # to match the baud of the connected device
      [[[runtimesettings]]]
           pub channels = ToEmonCMS,

I just have a wireless keyboard receiver connected to the PI’s usb port.