Hello,
I got a esp8266 up with one temp.sensor (DS18B20).
It works very well, but when i was trying to use one more sensor, then i got some trouble.
How can i insert one more DS18B20 in this code:
#include <CayenneMQTTESP8266.h>
#include <CayenneMQTTWiFiClient.h>
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
//For temperaturføler
#include <DallasTemperature.h>
#include<OneWire.h>
char ssid = “”;
char password = “”;
char username = “”;
char mqtt_password = “”;
char client_id = “”;
//temperatur
#define ONE_WIRE_BUS 12
OneWire onewire(ONE_WIRE_BUS);
DallasTemperature sensors(&onewire);
float Celcius=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Cayenne.begin(username, mqtt_password, client_id, ssid, password);
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
sensors.begin();
}
void loop() {
// put your main code here, to run repeatedly:
sensors.requestTemperatures();
Celcius=sensors.getTempCByIndex(0);
Serial.print(" C ");
Serial.println(Celcius);
Cayenne.loop();
sensors.requestTemperatures();
Cayenne.celsiusWrite(1, sensors.getTempCByIndex(0));
}
CAYENNE_IN(0)
{
digitalWrite(2, !getValue.asInt());
}