Usage of Charts or how to make it right


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()
  lcd.begin (16,2);  // initialize the lcd
  pinMode(3, INPUT);

void loop()

// This function is called when the Cayenne widget requests data for the Virtual Pin.
  // Send the command to get temperatures.
  // 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.write("          ");

  // Send the command to get temperatures.
  // 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.write("          ");

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


Welcome to Cayenne!

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


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.


Any suggestions?!


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:

_ 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.


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?!


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


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).


@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!



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.


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