hello @bestes, I am still having problems with the connection (I am using nodemcu esp8266-12). It manteins connected by 30-40 minutes and then go down.
In android, last version of Cayenne not connect my devices here with me.
Can you think what would do?
my sketch: (all sensors and buttons is working fine untill I lose connection. the only way to reconnected is clicking RESET on board.)
thanks man!
/*
Cayenne DS18B20 Example
This sketch shows how to send temperature data to a DS18B20 Sensor in the Cayenne Dashboard.
The Cayenne Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.
Steps:
- Install the OneWire library (OneWire Arduino Library, connecting 1-wire devices (DS18S20, etc) to Teensy) from the Arduino Library Manager.
- Install the DallasTemperature library (Miles Burton - Innovative engineering for pretty much anything) from the Arduino Library Manager.
- In the Cayenne Dashboard add a new DS18B20 widget.
- Set the widget to Value Display.
- Select Virtual Pins and a virtual pin number.
- Set VIRTUAL_PIN to the pin number you selected.
- Attach a DS18B20 to an digital pin on your Arduino.
Schematic:
[Ground] – [DS18B20] – [4.7k resistor] – [5V]
|______________|
|
Digital Pin
- Set the tmpPin variable to match the pin used to connect the DS18B20.
- Set the token variable to match the Arduino token from the Dashboard.
- Compile and upload this sketch.
- Once the Arduino connects to the Dashboard it should automatically update the DS18B20 widget with data.
*/
//#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <OneWire.h>
#include <DallasTemperature.h>
#include “CayenneDefines.h”
#include “BlynkSimpleEsp8266.h”
#include “CayenneWiFiClient.h”
#include <ESP8266WiFi.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
// 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;
OneWire oneWire(tmpPin);
DallasTemperature sensors(&oneWire);
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “teoiptfsvt”;
char ssid = “WiFi”;
char wifiPassword = “tr06703798”;
void setup()
{
Serial.begin(115200);
Cayenne.begin(token, ssid, wifiPassword);
sensors.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.
sensors.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.virtualWrite(VIRTUAL_PIN1, sensors.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.
sensors.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.virtualWrite(VIRTUAL_PIN5, sensors.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.
sensors.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.virtualWrite(VIRTUAL_PIN2, sensors.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.
sensors.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.virtualWrite(VIRTUAL_PIN3, sensors.getTempCByIndex(2));
// 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.
sensors.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.virtualWrite(VIRTUAL_PIN4, sensors.getTempCByIndex(3));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}