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");}
}