How to Display two values under a sensor

8 years 11 months ago #2337 by cdj
Hi people,
Someone know how to display two values under same sensor ?
I've add a field Sensor.AnalogValue2 to EasyIot node config but how to assign to this field a value?

this is my sketch, something is wrong, i know...
/*
  Arduino & OpenEnergyMonitor 
  Test & Calibration sketch
  author Mirco Piccin aka pitusso
*/

// Include Emon Library
#include <Esp8266EasyIoT.h>
#include <SoftwareSerial.h> 
#include "EmonLib.h"                   

#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define ANALOGSENSORPIN A0
float lastvalue;
float valuekw;

Esp8266EasyIoT esp; 
SoftwareSerial serialEsp(11, 12);


//DHT dht;
//float lastTemp;
//float lastHum;
//Esp8266EasyIoTMsg msgHum(CHILD_ID_HUM, V_HUM);
//  Esp8266EasyIoTMsg(uint8_t sensor, uint8_t type);
Esp8266EasyIoTMsg corrente(CHILD_ID_HUM, V_ANALOG_VALUE);
Esp8266EasyIoTMsg correntekw(CHILD_ID_HUM, V_ANALOG_VALUE);

//Calibrations
const int volt = 220;
const float ct_calibration = 29;

//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("Sensors test starting...");

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


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

  Serial.println("EasyIoTEsp init");


  esp.begin(NULL, 13, &serialEsp, &Serial);
  //esp.begin(NULL, &serialEsp);
//  dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 

  pinMode(A0, INPUT);

//  Serial.println("present S_HUM");
  esp.present(CHILD_ID_HUM,S_ANALOG_INPUT);
  //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) ; //diviso 10 per leggere Kw/h

  if (isnan(value)) {
    Serial.println("Failed reading value from SCT");
  } 
  else if (value != lastvalue) 
  {
    lastvalue = value;
    valuekw = value / 1000 ;
    esp.send(corrente.set(value, 1));
    esp.send(correntekw.set(value, 1));
    //print values
    Serial.print("Power W ");
    Serial.println(value);
    Serial.print("Power KW ");
    Serial.println(valuekw);

    delay(5000);
  }
}

Thanks
Dario

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

8 years 11 months ago #2346 by EasyIoT

cdj wrote: Hi people,
Someone know how to display two values under same sensor ?
I've add a field Sensor.AnalogValue2 to EasyIot node config but how to assign to this field a value?

this is my sketch, something is wrong, i know...

/*
  Arduino & OpenEnergyMonitor 
  Test & Calibration sketch
  author Mirco Piccin aka pitusso
*/

// Include Emon Library
#include <Esp8266EasyIoT.h>
#include <SoftwareSerial.h> 
#include "EmonLib.h"                   

#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define ANALOGSENSORPIN A0
float lastvalue;
float valuekw;

Esp8266EasyIoT esp; 
SoftwareSerial serialEsp(11, 12);


//DHT dht;
//float lastTemp;
//float lastHum;
//Esp8266EasyIoTMsg msgHum(CHILD_ID_HUM, V_HUM);
//  Esp8266EasyIoTMsg(uint8_t sensor, uint8_t type);
Esp8266EasyIoTMsg corrente(CHILD_ID_HUM, V_ANALOG_VALUE);
Esp8266EasyIoTMsg correntekw(CHILD_ID_HUM, V_ANALOG_VALUE);

//Calibrations
const int volt = 220;
const float ct_calibration = 29;

//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("Sensors test starting...");

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


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

  Serial.println("EasyIoTEsp init");


  esp.begin(NULL, 13, &serialEsp, &Serial);
  //esp.begin(NULL, &serialEsp);
//  dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 

  pinMode(A0, INPUT);

//  Serial.println("present S_HUM");
  esp.present(CHILD_ID_HUM,S_ANALOG_INPUT);
  //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) ; //diviso 10 per leggere Kw/h

  if (isnan(value)) {
    Serial.println("Failed reading value from SCT");
  } 
  else if (value != lastvalue) 
  {
    lastvalue = value;
    valuekw = value / 1000 ;
    esp.send(corrente.set(value, 1));
    esp.send(correntekw.set(value, 1));
    //print values
    Serial.print("Power W ");
    Serial.println(value);
    Serial.print("Power KW ");
    Serial.println(valuekw);

    delay(5000);
  }
}

Thanks
Dario


You can not send two values to one node in EasyIoT server. You need two nodes. EasyIoT Cloud support this.

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

8 years 11 months ago #2349 by cdj
But in thermostat you print forecast in a second line...
i need only same value of first line (w) /1000....

So is it possible to send only one value and print a line with same value/1000 ?

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

8 years 11 months ago #2350 by EasyIoT

cdj wrote: But in thermostat you print forecast in a second line...
i need only same value of first line (w) /1000....

So is it possible to send only one value and print a line with same value/1000 ?


Yes, Pressure widget supports this, but Temperature and Humidity not. Maybe you can try with Generic sensor widget.
The following user(s) said Thank You: cdj

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

8 years 11 months ago #2353 by cdj
Thanks done with pressure widget, only Unit doesn't show in forecast row....

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

Time to create page: 0.173 seconds

Forum latest

  • No posts to display.