Welcome, Guest
Username: Password: Remember me

TOPIC: How to Display two values under a sensor

How to Display two values under a sensor 1 year 6 months ago #2337

  • cdj
  • cdj's Avatar
  • Offline
  • Elite Member
  • Posts: 250
  • Thank you received: 25
  • Karma: 6
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
The administrator has disabled public write access.

How to Display two values under a sensor 1 year 6 months ago #2346

  • EasyIoT
  • EasyIoT's Avatar
  • Offline
  • Administrator
  • Posts: 809
  • Thank you received: 252
  • Karma: 23
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.
The administrator has disabled public write access.

How to Display two values under a sensor 1 year 6 months ago #2349

  • cdj
  • cdj's Avatar
  • Offline
  • Elite Member
  • Posts: 250
  • Thank you received: 25
  • Karma: 6
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 ?
The administrator has disabled public write access.

How to Display two values under a sensor 1 year 6 months ago #2350

  • EasyIoT
  • EasyIoT's Avatar
  • Offline
  • Administrator
  • Posts: 809
  • Thank you received: 252
  • Karma: 23
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 administrator has disabled public write access.
The following user(s) said Thank You: cdj

How to Display two values under a sensor 1 year 6 months ago #2353

  • cdj
  • cdj's Avatar
  • Offline
  • Elite Member
  • Posts: 250
  • Thank you received: 25
  • Karma: 6
Thanks done with pressure widget, only Unit doesn't show in forecast row....
The administrator has disabled public write access.
Time to create page: 0.249 seconds
Powered by Kunena Forum