Hi all,
Sorry,I am a beginner,and this job is a first for me.
I am using temperature with DS18B20 8 sensors sketch file.
Sketch with DS18B20 X8 working fine,in next step I add in dashboard two signaling light-
(add new-sensors- generic-digital input-connectivity digital-pin D5 and second pin D8, 2 state.I will use it how door open alarm swtch, when door is open swich is on and 5v through 10k resistor going in arduino uno digital pins 5 or 8,and then in dashboard lights green,and I know that door is open).Widget set in Integrated GPIO channel 5 second 8.
Also I add in dashboard two light switch (add new-actuators-light-light swtch-digital pin D3 and D4- widget Button.Widget set in Integrated GPIO chanel 3 second 4.When I push button on dashboard I get 5v output in it (3 or 4 pin).
With one sketch file from Cayenne all this working good:
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
// If you're not using the Ethernet W5100 shield, change this to match your connection type. See Communications examples.
#include <CayenneEthernet.h>
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "xxxxxj167";
void setup()
{
Serial.begin(9600);
Cayenne.begin(token);
}
void loop()
{
Cayenne.run();
}
But when I tried use this sketch and ds18b20 x8 both I get error from arduino- temperature working ok, signaling light ok, but lamp switch not working.
In IDE I am doing : new-sketch-add file-add ds18b20 x8 sketch-add file-add sketch which is above-verify-upload`.
Why I can upload these two sketchs in arduino,that all (temperature,signaling light and light switch) will work correctly?
ds18b20 x8 sketch:
#include <DallasTemperature.h>
#include <OneWire.h>
#include <CayenneEthernet.h>
// Virtual Pin of the DS18B20 widget.
#define VIRTUAL_PIN1 V1
#define VIRTUAL_PIN2 V2
#define VIRTUAL_PIN3 V3
#define VIRTUAL_PIN4 V4
#define VIRTUAL_PIN5 V5
#define VIRTUAL_PIN6 V6
#define VIRTUAL_PIN7 V7
#define VIRTUAL_PIN8 V8
const int tmpPin1 = 2;
OneWire oneWire1(tmpPin1);
OneWire oneWire2(tmpPin1);
OneWire oneWire3(tmpPin1);
OneWire oneWire4(tmpPin1);
OneWire oneWire5(tmpPin1);
OneWire oneWire6(tmpPin1);
OneWire oneWire7(tmpPin1);
OneWire oneWire8(tmpPin1);
DallasTemperature sensors1(&oneWire1);
DallasTemperature sensors2(&oneWire2);
DallasTemperature sensors3(&oneWire3);
DallasTemperature sensors4(&oneWire4);
DallasTemperature sensors5(&oneWire5);
DallasTemperature sensors6(&oneWire6);
DallasTemperature sensors7(&oneWire7);
DallasTemperature sensors8(&oneWire8);
char token[] = "xxxx167";
void setup()
{
Serial.begin(9600);
Cayenne.begin(token);
sensors1.begin();
sensors2.begin();
sensors3.begin();
sensors4.begin();
sensors5.begin();
sensors6.begin();
sensors7.begin();
sensors8.begin();
}
void loop()
{
Cayenne.run();
sensors1.requestTemperatures();
float temperatura1 = sensors1.getTempCByIndex(0);
sensors2.requestTemperatures();
float temperatura2 = sensors2.getTempCByIndex(1);
sensors4.requestTemperatures();
float temperatura3 = sensors3.getTempCByIndex(2);
sensors4.requestTemperatures();
float temperatura4 = sensors4.getTempCByIndex(3);
sensors5.requestTemperatures();
float temperatura5 = sensors5.getTempCByIndex(4);
sensors6.requestTemperatures();
float temperatura6 = sensors6.getTempCByIndex(5);
sensors7.requestTemperatures();
float temperatura7 = sensors7.getTempCByIndex(6);
sensors8.requestTemperatures();
float temperatura8 = sensors8.getTempCByIndex(7);
}
// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN1)
{
// Send the command to get temperatures.
sensors1.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN1, sensors1.getTempCByIndex(0));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN2)
{
// Send the command to get temperatures.
sensors2.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN2, sensors2.getTempCByIndex(1));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN3)
{
// Send the command to get temperatures.
sensors3.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN3, sensors3.getTempCByIndex(2));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN4)
{
// Send the command to get temperatures.
sensors4.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN4, sensors4.getTempCByIndex(3));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN5)
{
// Send the command to get temperatures.
sensors5.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN5, sensors5.getTempCByIndex(4));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN6)
{
// Send the command to get temperatures.
sensors6.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN6, sensors6.getTempCByIndex(5));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN7)
{
// Send the command to get temperatures.
sensors7.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN7, sensors7.getTempCByIndex(6));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN8)
{
// Send the command to get temperatures.
sensors8.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN8, sensors8.getTempCByIndex(7));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
Thanks,