Esp8266 & ds18b20

I’m connecting ESP8266 with waterproof temperature sensor DS18B20 but I’m always getting 185 F, I don’t know why… Can you please help me

have a look at this example Converting Cayenne Arduino LIbrary sketches to Cayenne MQTT Arduino - #2 by rsiegel

1 Like

Hello, I have also had many problems to reconnect with my arduino + ESP8266, I tried to follow the tutorial to update to MQTT but I do not achieve it, help pls

We need more info. Errors? Code?

1 Like

I was using the following connection and skecth for a long time without problems, now I do not know how to update to the new cayenne change to continue uploading the temperature data via WIFI. I would appreciate any advice or suggestion.

Greetings.

//#define CAYENNE_DEBUG         // Uncomment to show debug messages
//#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneESP8266Shield.h>
#include <ESP8266_HardSer.h>
#include <OneWire.h>
#include <DallasTemperature.h>


// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "urkpwh44hq";
char ssid[] = "HTC";
char password[] = "aa7aac1f75d1";

#define VIRTUAL_PIN1 V1
#define VIRTUAL_PIN2 V2
#define VIRTUAL_PIN3 V3
#define VIRTUAL_PIN4 V4
#define VIRTUAL_PIN5 V5

 
// 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 tmpPin1 = 2;
const int tmpPin2 = 3;
const int tmpPin3 = 4;
const int tmpPin4 = 5;
const int tmpPin5 = 6;



OneWire oneWire1(tmpPin1);
OneWire oneWire2(tmpPin2);
OneWire oneWire3(tmpPin3);
OneWire oneWire4(tmpPin4);
OneWire oneWire5(tmpPin5);


DallasTemperature sensors1(&oneWire1);
DallasTemperature sensors2(&oneWire2);
DallasTemperature sensors3(&oneWire3);
DallasTemperature sensors4(&oneWire4);
DallasTemperature sensors5(&oneWire5);



// Set ESP8266 Serial object
#define EspSerial Serial

ESP8266 wifi(EspSerial);

void setup()
{
  EspSerial.begin(115200);
  delay(10);
  Cayenne.begin(token, wifi, ssid, password);
  sensors1.begin();
   sensors2.begin();
}

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.
	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(0));
  // 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(0));
  // To send the temperature in Fahrenheit use the corresponding code below.
  //Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}

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(0));
  // 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(0));
  // To send the temperature in Fahrenheit use the corresponding code below.
  //Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));

The token connection method has been disabled, you will have to use MQTT. It looks like your code was cut off a bit at the end, but this link should help you.

Do you know what this error is?

" Not used: C:\Users\Ricardo\Documents\Arduino\libraries\Cayenne-MQTT-ESP8266-master "

follow this step by step Cayenne-MQTT-Arduino/ESP8266Shield.ino at master · myDevicesIoT/Cayenne-MQTT-Arduino · GitHub and here is old tutorial Beginning IoT with ESP8266-01 Wifi Module and Cayenne IoT Platform – Eldontronics: Electronics Hobbyist

Thank you it works

1 Like