Usage of Charts or how to make it right


#1

Hi All,

I use:
Device: Arduino Uno with W5100 ethernet shield
Dashboard: Web or/and Android

I decide to make a logger for heating boiler.
I use two DS18B20 sensors attached to arduino digital port2 to measure heating and returning pipe water temperature.
Also have attached on arduino digital port3 sensing for when the heating element is on and when off.
Its made by relay 220V that is turned on when the heater is on and it relaying 5V and its connected by the following way:
5V -> relay -> 1k resistor -> Arduino Digital port3
and for keeping steady levels - Ground -> 10k resistor -> Arduino digital port3

The DS18B20 charts are working very good. I see all the drops of the heat and rises in all the ranges (date, hour, minute), but I can’t make the same with the on/off indicator. For all I use Virtual ports (see code below). I use various dashboard items but none of them work correct. As example:
some times not showing the correct live value (on or off; true or false; 1 or 0; 1024 or 0;)
I have an LCD that shows the values and when the heater is on or off. This Lcd is updating info when cayenne requires info from the device (or I think that is working by this way), but it’s showing correct values each time and very fast updated (less than 2 seconds when the state is changed).
I any case or after a long period (more than an hour) the charts are reports no data or reports only one point (measurement) of data. Am I making something wrong or there is some kind of limits of 2 charts per device or just a bug?

Here is the Code (I remove the hashtags before define and include just to show it correctly here):

define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
include OneWire.h
include DallasTemperature.h
include Wire.h
include LiquidCrystal_I2C.h  // F Malpartida's NewLiquidCrystal library
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

// If you're not using the Ethernet W5100 shield, change this to match your connection type. See Communications examples.
include CayenneEthernet.h

// Virtual Pin of the DS18B20 widget.
define VIRTUAL_PIN1 V1
define VIRTUAL_PIN2 V2
define VIRTUAL_PIN3 V3

// Digital pin the DS18B20 is connected to. Do not use digital pins 0 or 1 since those conflict with the use of Serial.
const int tmpPin = 2;
float cap1;
float cap2;
int valOnOff = 0;
OneWire oneWire(tmpPin);
DallasTemperature sensors(&oneWire);

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "l0gigkpdla";

void setup()
{
  Serial.begin(9600);
  Cayenne.begin(token);
  sensors.begin();
  lcd.begin (16,2);  // initialize the lcd
  lcd.backlight();
  pinMode(3, INPUT);
}

void loop()
{
  Cayenne.run();
}

// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN1)
{
  // Send the command to get temperatures.
  sensors.requestTemperatures();
  // This command writes the temperature in Celsius to the Virtual Pin.
  cap1 = sensors.getTempCByIndex(0);
  Cayenne.celsiusWrite(VIRTUAL_PIN1, cap1);
  // To send the temperature in Fahrenheit use the corresponding code below.
  //Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
  lcd.setCursor(0,0);
  lcd.write("          ");
  lcd.setCursor(0,0);
  lcd.write("B=");
  lcd.print(cap1);
  lcd.write((char)223);
  lcd.write("C");
}

CAYENNE_OUT(VIRTUAL_PIN2)
{
  // Send the command to get temperatures.
  sensors.requestTemperatures();
  // This command writes the temperature in Celsius to the Virtual Pin.
  cap2 = sensors.getTempCByIndex(1);
  Cayenne.celsiusWrite(VIRTUAL_PIN2, cap2);
  // To send the temperature in Fahrenheit use the corresponding code below.
  //Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
  lcd.setCursor(0,1);
  lcd.write("          ");
  lcd.setCursor(0,1);
  lcd.write("A=");
  lcd.print(cap2);
  lcd.write((char)223);
  lcd.write("C");
}

CAYENNE_OUT(VIRTUAL_PIN3)
{
    valOnOff = digitalRead(3);
    Cayenne.virtualWrite(VIRTUAL_PIN3, valOnOff);
    lcd.setCursor(10,1);
    lcd.write("    ");
    lcd.setCursor(10,1);
    if (valOnOff == HIGH) {lcd.write("ON");} else {lcd.write("OFF");}
}

#3

Welcome to Cayenne!

Can you post a screen shot of your graph and the widget settings?


#4

It’s the same no matter if I create generic sensor widget or custom line chart or custom 2 state widget.
I try any combination with any settings.
After an hour I will make recompile and upload the sketch again with updated arduino cayenne libraries.
I make sketch recompile and upload with updated liblaries - now waiting to pass more than 10 minutes to see if there is some change.

On the live chart there is only one point or few. but after I click on minute, hour or something other there is nothign, no matter how long the device is online.

Results after update and uploading the recompiled sketch and recreate general sensor digital widget…
All the same. On live chart there is some data coming frequently. After more than 10 minutes - on “m” there is only one value, on “h” and further - nothing. After additional 10 minutes on “m” - no data on “h” - the same value that was on “m” before this 10 minutes.


#5

Any suggestions?!


#6

I try this in the sketch + adding virtual pin 3 like a temperature sensor, because I suppose if the two sensors work good, this also should work:

CAYENNE_OUT(VIRTUAL_PIN3)
{
_ valOnOff = digitalRead(3);_
_ lcd.setCursor(10,1);_
_ lcd.write(" ");_
_ lcd.setCursor(10,1);_
_ if (valOnOff == HIGH) {lcd.write(“ON”);cap3=10;} else {lcd.write(“OFF”);cap3=0;}_
_ //Cayenne.virtualWrite(VIRTUAL_PIN3, valOnOff);_
_ Cayenne.celsiusWrite(VIRTUAL_PIN3, cap3);_
}
But no result - all the same.
Live chart is showing incoming data, but the 10minutes, hour and etc. reports no data.


#7

Currently using triggers alert on e-mail to catch the on and off of the heating elements.
The Idea of whole project is to analyze the work of the heating system and to make in at one moment controlled from the arduino + controlling of the 3way valve with a servo motor. The main thing that I should know is what percentage of the whole time the heating element is working.
Any Ideas how to eliminate the charts problem? Or is there any restrictions how much charts or sensors I should use?!


#8

There shouldn’t be any restrictions, and everything looks right to me. @bestes any ideas?


#9

Ok. Please describe me all the procedure if I have two working temperature sensors with showing correct online charts and history charts and I want to add one of the digital i/o my of arduino as input to check when it’s high and when it’s low and the most important part to get a chart with history on it. The input is well connected with 10k resistor to the ground and with 1k resistor to the relay that push 5V from the same arduino to the pin. All seems working but not the charts of the On/Off pin. I thin I try all variants. That’s why please inform me the way how you will add it to the dashboard (no matter virtual pin or digital pin).


#10

@kiril.tonev @adam There should not be any restrictions, everything looks right to me.

Thank you @kiril.tonev for continuing to post the tests that you performed throughout the process. This looks like a bug. If the data is streaming in live, then it should be stored and able to be viewed by the minute, hour, etc. Let us look into this and we will push a fix soon. @kiril.tonev I will use the code you provided to replicate setup on my end and see if I can produce similar results too. Sorry about this, with the holidays coming up, we may not push a fix until 2017. Hang in there!

-B


#11

Thanks for your support and especially that you confirm that it looks like a but. The delay in fix is not a problem. I just wondering if I made something wrong, but the cayenne project is very simple to use and there is not so much to be made wrong.


#12

Thanks for understanding @kiril.tonev :slight_smile: Hope to keep seeing you around the Cayenne community!

-B