Open Energy Monitor

We want to know how much energy we produce when cycling. The open source tool of Open Energy Monitoring will help us visualizing the energy production and in extension the consumption.

https://guide.openenergymonitor.org/setup/

Our system now is build in the following way :
– input : 18-34Vdc 8A, five times
– buffer : supercapacitor 18-48Vdc
– output : 18-34Vdc 45A or 230Vac 3.5A
– output 2 : 24Vdc 3A
We want to display the following on a live screen :
– total energy production, time log, every 5 sec for 15 min
– total energy consumption, time log
– buffer voltage, instantaneous, every second
– energy production by bicycle, instantaneous (in option)
This will be the architecture of the system :
– visualisation : computer/phone with website emoncms
– data transmission : emon base web based
– data collection : arduino, connected to a raspberry pi
– sensor in : dc current sensors
– sensor out : ac sensor
– sensor out 2 : dc sensor
Step 1 – Connection the sensors
The voltage bridge is dividing the max voltage of 48V of the super capacitor to the 5V of the Arduino. R1 = 18.0 MOhm, R2 = 2.2 MOhm.
The Current sensor is a Pololu current sensor.
current_sensor_offset = 500.0-4.45; // (mV) because the sensor can also sense negative amps !
// the above offset is not precise, it should be calibrated on the right VCC
current_sensor_sensitivity = 7.5188; // 133mV/A = 0.133mV/mA = 7.5188 mA/mV
The Arduino is a regular Arduino UNO microcontroller.
Step 2 – Setting up the raspberry Pi
If you setup a raspberrypi with our emonSD software image that should give you everything to get going on the emoncms logging and visualisation side.
https://github.com/openenergymonitor/emonpi/wiki/emonSD-pre-built-SD-card-Download-&-Change-Log#emonsd-07nov16

You then need to setup a piece of software on there called emonhub to read serial data on the raspberrypi serial connectors,,
https://github.com/openenergymonitor/emonhub/blob/emon-pi/configuration.md
We connected via Ethernet to the local network. We found the ip address with an IP scanning software.

N.B. The address of http://emonpi or http://emonpi.local did not work on Windows. It works best to find the Raspberry Pi if there are no other devices on the network.

Step 3 – Managing emon cms

The local emoncms account
velom2
sur http://192.168.10.92 au Openfab

Now we can connect the Arduino to the raspberry. http://openenergymonitor.blogspot.com/2014/01/oem-gateway-serial-port-emoncms-link.html
And a little modification https://community.openenergymonitor.org/t/sending-data-from-arduino-to-rasberrypi-using-serial/3822/5
image

Configuring the emonhub :

[[SerialDirect]]
Type = EmonHubSerialInterfacer
[[[init_settings]]]
com_port = /dev/ttyACM0
com_baud = 9600
[[[runtimesettings]]]
pubchannels = ToEmonCMS,

This is the Arduino code finally

/*
23/05/2018
We are measuring the current and voltage on the input of our energy system.
The current is measured with a current sensor from pololu.com
The voltage is measured with a voltage divider.

! we are working in mV and float values for accuracy (so put .0 when declaring) and avoiding to devide.
*/
const int nodeID = 6; // for loggin on the emoncms

float VCC = 5020.0; // (mV) 5.35V on Raspberry, 5.56V on USB Laptop, 5.02 on USB laptop (23/05/2018)
float sensor_scale = VCC / 1023.0; // Convert the analog reading (which goes from 0 – 1023) to a voltage (0 – 5000mV):

// Voltage probe measurement parameters and hardware configuration
float R1 = 18.0; //* 1000.0; // (MOhm) Voltage divider resistor 1
float R2 = 2.2; //* 1000.0; // (MOhm) Voltage divider resistor 2 (the one you’re using between Vout and ground)
float voltage_sensor_sensitivity = 9.181; // (mV/mV) = (R1 + R2) / R2;

// Current sensor measurement parameters and hardware configuration
float current_sensor_offset = 500.0-4.45; // (mV) because the sensor can also sense negative amps !
// the above offset is not precise, it should be calibrated on the right VCC
float current_sensor_sensitivity = 7.5188; // 133mV/A = 0.133mV/mA = 7.5188 mA/mV

int current_sensor_value = 0 ;
int voltage_sensor_value = 0 ;
float current_sensor_voltage = 0.0 ;
float voltage_sensor_voltage = 0.0 ;
float current_measured = 0.0 ;
float voltage_measured = 0.0 ;
float power_measured = 0.0 ;

float current_mean = 0.0 ;
float voltage_mean = 0.0 ;
float power_mean = 0.0 ;

float current = 0.0 ;
float voltage = 0.0 ;
float power = 0.0 ;

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);

}

// the loop routine runs over and over again forever:
void loop() {

current_mean = 0.0 ;
voltage_mean = 0.0 ;
power_mean = 0.0 ;

// start loop over 5 seconds //the emoncms interface is limited to 5sec
for (int i=0; i < 5; i++){

// read the input on analog pin 0 and pin 1
current_sensor_value = analogRead(A0); // 0 – 1023
voltage_sensor_value = analogRead(A1); // 0 – 1023
//Serial.println(sensor_value);

// Convert the analog reading (which goes from 0 – 1023) to a voltage (0 – 5000mV):
current_sensor_voltage = current_sensor_value * sensor_scale; //mV
current_measured = (current_sensor_voltage – current_sensor_offset) * current_sensor_sensitivity; //mA

voltage_sensor_voltage = voltage_sensor_value * sensor_scale;
voltage_measured = voltage_sensor_voltage * voltage_sensor_sensitivity; //mV

// sum before average
current_mean = current_mean + current_measured ;
voltage_mean = voltage_mean + voltage_measured ;
power_measured = current_measured * voltage_measured ;
power_mean = power_mean + power_measured ;

delay(1000);
}
// end loop over 5 seconds
current = current_mean / 5.0 ; //mA
voltage = voltage_mean / 5.0 ; //mV
power = power_mean / 5.0 ; //mW

// print out the value you read:
// These for compatibility, but whatever you need if emonHub is configured to suit.
Serial.print(nodeID); Serial.print(‘ ‘);
Serial.print((int)(current)); Serial.print(‘ ‘); //mA
Serial.print((int)(voltage)); Serial.print(‘ ‘); //mV
Serial.print((int)(current_sensor_value)); Serial.print(‘ ‘); //0-1023
Serial.print((int)(voltage_sensor_value)); Serial.print(‘ ‘); //0-1023
Serial.print((int)(power_mean)); Serial.println(); //mW //println is important for data transfer !
//for (int i=0; i < 5; i++) {Serial.print((int)(i)); Serial.print(‘ ‘); }
//int MyArray[] = {1,2,3;4,5,6};
}

Putting the API key in the emonhub.
image(1)
Checking the logging.
image(4)
Now we can begin configuring the inputs.
https://guide.openenergymonitor.org/setup/local/

We adjusted the current offset on basis of the current feed. We searched the average when there is no power.
float additionnal_offset = 46.0; //mA
Because the Vcc is different when conneceted to the raspberry or to an ordinary computer, this needs to be done via the logging data.

 

Making a dashboard.
We are logging every 1 second and making an average every 5 seconds. This is presented in the dashboard on the local emon cms.

! When the float value is exceeding the max value, the power becomes negative !
We tried this :
– change power to mW (change emonhub to mW as well)
– make a new input currentxvoltage
– make a new feed currrentxvoltage
– make a new feed in emoncms.org currentxvoltage

Step 4 – Logging to an other device.

First we need to connect to the wifi. We are using a wifi dongle for the raspberry to connect to the wifi.
smartphone local hotspot slimme telefoon van Milena
https://guide.openenergymonitor.org/setup/connect/#1a-connect-to-wifi

! Sometimes you need to do hotspot off/on to enable new devices to connect !

172.20.10.7/emoncms
http://emonpi.local/emoncms

Login on the emoncms platform. https://guide.openenergymonitor.org/setup/remote/
login : velom2

We put the read&write API key of the emoncms.org in the local emonhub :
[[emoncmsorg]]
Type = EmonHubEmoncmsHTTPInterfacer
[[[init_settings]]]
[[[runtimesettings]]]
pubchannels = ToRFM12,
subchannels = ToEmonCMS,
url = https://emoncms.org
apikey = ae2957a3090532a3b84ef48667fb0137
senddata = 1                    # Enable sending data to Emoncms.org
sendstatus = 1                  # Enable sending WAN IP to Emoncms.org MyIP > https://emoncms.org/myip/list
sendinterval= 5                # Bulk send interval to Emoncms.org in seconds
We put the setinterval to 5 but it still sends every 10seconds.

 

N.B. Download the cvs data in the feed-menu.
Connecting the emoncms to the smartphone app. https://itunes.apple.com/us/app/emoncms/id1169483587

! The app only works if the emonpi receives data !

 

Next steps

  • Making a new feed on the emoncms.org that calculates the power from the current x voltage feed.
  • Making an applet for the wordpress website.
  • Verifying the accuracy of the current sensor.
  • Find a socket for the raspberry alimentation.
  • Place the arduino and the reaspberry pi in a convenient place in the energy module.
  • Making a box for the Arduino and raspberry.

Long term : being independent of the phone hotspot. Putting a 4G dongle for internet connection.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s