Hello.
I can add arduino nano with basic template to dashboard.
When I try to add a sensor, then it never connects again.
I upload the basic sketch to arduino nano and it connects again!
Example:
//this works
#include <CayenneSerial.h>
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “i*********p”;
void setup()
{
//Baud rate can be specified by calling Cayenne.begin(token, 9600);
Cayenne.begin(token);
}
void loop()
{
Cayenne.run();
}
//this doesn’t work
/*
Cayenne BMP180 Example
This sketch shows how to send luminosity data to a BMP180 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 Adafruit Unified Sensor library (GitHub - adafruit/Adafruit_Sensor: Common sensor library) from the Arduino Library Manager.
- Install the Adafruit BMP085 Unified library (GitHub - adafruit/Adafruit_BMP085_Unified: Unified sensor driver for Adafruit's BMP085 & BMP180 breakouts) from the Arduino Library Manager.
- In the Cayenne Dashboard add a new BMP180 widget.
- Set the widget to Value Display.
- Select Virtual Pins and select virtual pins for the barometer and temperature.
- Set BAROMETER_PIN to the pin number you selected for the barometer.
- Set TEMPERATURE_PIN to the pin number you selected for the temperature.
- Attach a BMP180 to your Arduino.
Schematic:
BMP180 Arduino
[VDD] — [3V3]
[GND] — [GND]
[SDA] — [Analog Pin 4] (The SDA may be different on some devices, e.g. for Arduino Mega the SDA pin is Digital Pin 20)
[SCL] — [Analog Pin 5] (The SCL may be different on some devices, e.g. for Arduino Mega the SCL pin is Digital Pin 21) - 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 BMP180 widget with data.
/
//#define CAYENNE_DEBUG
//#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>
#include <CayenneSerial.h>
#define BAROMETER_PIN V1
#define TEMPERATURE_PIN V2
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10180);
bool bmpSensorDetected = true;
char token[] = "k********q";
void setup()
{
Serial.begin(9600);
Cayenne.begin(token);
if (!bmp.begin())
{
CAYENNE_LOG(“No BMP sensor detected”);
bmpSensorDetected = false;
}
}
void loop()
{
Cayenne.run();
}
CAYENNE_OUT(BAROMETER_PIN)
{
if (bmpSensorDetected)
{
// Send the command to get data.
sensors_event_t event;
bmp.getEvent(&event);
if (event.pressure)
{
// Send the value to Cayenne in hectopascals.
Cayenne.hectoPascalWrite(BAROMETER_PIN, event.pressure);
}
}
else
{
CAYENNE_LOG(“No BMP sensor detected”);
}
}
CAYENNE_OUT(TEMPERATURE_PIN)
{
if (bmpSensorDetected)
{
float temperature;
bmp.getTemperature(&temperature);
// Send the value to Cayenne in Celsius.
Cayenne.celsiusWrite(TEMPERATURE_PIN, temperature);
}
else
{
CAYENNE_LOG(“No BMP sensor detected”);
}
}
cli output
Connecting device at COM3 to arduino.mydevices.com:8442…
OpenC0C(“\.\COM3”, baud=9600, data=8, parity=no, stop=1) - OK
Connect(“arduino.mydevices.com”, “8442”) - OK
InOut() START
DSR is OFF
Received EOF
EVENT_CLOSE
InOut() - STOP
Disconnect() - OK
Connect(“arduino.mydevices.com”, “8442”) - OK
InOut() START
DSR is OFF