Cdj Energy Monitor

8 years 6 months ago - 8 years 6 months ago #2420 by cdj
Cdj Energy Monitor was created by cdj
Hiya people....

In this project we use a sct-013-030 sensor to read energy and EmonLib

This is sketch :
/*
  Arduino & OpenEnergyMonitor 
  Test & Calibration sketch
  author Mirco Piccin aka pitusso
*/
/*  mod by Cdj for EasyIOT
 *  Using PRESSURE Widget to print watt in forecast space
 */

// Include Emon Library

#include <Esp8266EasyIoT.h>
#include <SoftwareSerial.h> 
#include "EmonLib.h"                   

#define CORRENTE 0
float lastvalue;
float valuekw;

Esp8266EasyIoT esp; 
SoftwareSerial serialEsp(11, 12);


//  Esp8266EasyIoTMsg(uint8_t sensor, uint8_t type);
Esp8266EasyIoTMsg correntekw(CORRENTE, V_PRESSURE);
Esp8266EasyIoTMsg corrente(CORRENTE, V_FORECAST);

//Calibrations
const int volt = 210;
const float ct_calibration = 29.75; //orig 29
//Nel caso specifico, leggo un consumo di 260w, mentre in realtà in mio lettore di consumi ne registra 220w. Quindi:
//nuova_calibrazione = (220 / 260) * 29 = 24.5

//Sensor pins
const int currentSensorPin = A0;

float Irms = 0;

// Create an Emon instance
EnergyMonitor emon1;                   

void setup() {
  // start serial port:
  Serial.begin(115200);
  Serial.println("DomoDesk Energy Monitor Start...");

  //initialize Emon instance
  emon1.current(currentSensorPin, ct_calibration); 


 serialEsp.begin(9600);
  Serial.begin(115200);  

  Serial.println("EasyIoTEsp init");

  esp.begin(NULL, 13, &serialEsp, &Serial);
  
  pinMode(A0, INPUT);

  esp.present(CORRENTE,S_BARO);
  //void present(uint8_t sensorId, uint8_t sensorType, bool ack=false);
}

void loop() {
  
  //read sensors
  Irms = emon1.calcIrms(1480);

  while(!esp.process());


  float value  = (Irms*volt) ; 

    
  if (isnan(value)) {
    Serial.println("Failed reading value from SCT");
  } 
  else if (value != lastvalue ) 
  {
    lastvalue = value;
        valuekw = value / 1000 ;

  }
    esp.send(correntekw.set(valuekw, 1));
    esp.send(corrente.set(value, 2));
    
    //print values
    Serial.print("Consumo in W/h ");
    Serial.println(value);
    Serial.print("Consumo in KW/h ");
    Serial.println(valuekw);

    delay(8000);
  }

Sorry for Italian in code.

If MR.EasyIoT resolve Wire.h conflict we can add a beautiful LCD display. And if Mr.EasyIoT create a widget with 2 lines that accept unit (different from pressure one) we can read W/h and Kw/h ...

Dario Cdj

P.S. If there's too low energy it gives small value but not 0. If you power up for example 1kw of vacuum cleaner it gives correct value.
The following user(s) said Thank You: matteo_vr

Please Log in or Create an account to join the conversation.

8 years 6 months ago #2421 by cdj
Replied by cdj on topic Cdj Energy Monitor
If someone could be interested there's a link to use it only with ESP but my technical skill is not sufficient to modify it.
www.esp8266.com/viewtopic.php?f=32&t=3112

Please Log in or Create an account to join the conversation.

8 years 5 months ago #2426 by EasyIoT
Replied by EasyIoT on topic Cdj Energy Monitor

cdj wrote: If someone could be interested there's a link to use it only with ESP but my technical skill is not sufficient to modify it.
www.esp8266.com/viewtopic.php?f=32&t=3112


I will probably build one in future. I have all materials, but time is problem...

Please Log in or Create an account to join the conversation.

Time to create page: 0.248 seconds

Forum latest

  • No posts to display.