Hello @peter_dieck,
I’ll try to explain the whole method I used (guys please correct me if I say some barbarity )
There are multiple ways to integrate arduinos in Cayenne dashboard.
In cayenne if you go to Add New → Add Device/Widget → microcontrollers → Arduino, you will find all the possible connections to get your arduino connected to cayenne.
The method in the replies above describe how to connect your arduino to caynne, by connecting it to your PI by USB.
-
First you add a Arduino to your dashboard. Note that there is a token writen on upper right corner. When you choose usb connection there will be a popup with the example code, and after you will see a “Waiting for Board to connect” loading.
-
After you need to upload to your arduino the code regarding the Serial USB connection. ( It is in Ken’s reply or you can just upload the Sketch example).
(Also note that in this code you will need to write “YOURTOKEN”, the code regarding your sensors, and also add Cayenne Libraries. You can find the libraries here https://s3.amazonaws.com/mydevices-cayenne/arduino/lib/prod/Cayenne.zip)
Here is what I have uploaded to get a DHT11 sensor working:
define DHTTYPE DHT11
define DHTPIN 8
define VIRTUAL_PIN V1
include <CayenneSerial.h>
include “CayenneDefines.h”
include <DHT.h>
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “YOURTOKEN”;
float humidity, temp_f; // Values read from sensor
DHT dht(DHTPIN, DHTTYPE); // 11 works fine for ESP8266
void setup()
{
Serial.begin(9600);
Cayenne.begin(token);
dht.begin();
}
void loop()
{
Cayenne.run();
}
CAYENNE_OUT(V0){
// Send the command to get temperatures.
//sensors.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
//Cayenne.celsiusWrite(VIRTUAL_PIN, sensors.getTempCByIndex(0));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
// Check if any reads failed and exit early (to try again).
do {
humidity = dht.readHumidity(); // Read humidity (percent)
delay(1000);
} while (isnan(humidity));
Cayenne.virtualWrite(V0, humidity);
}
CAYENNE_OUT(V1){
// Send the command to get temperatures.
sensors.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN, sensors.getTempCByIndex(0));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
// Check if any reads failed and exit early (to try again).
do {
temp_f = dht.readTemperature(true); // Read temperature as Fahrenheit
delay(1000);
} while (isnan(temp_f));
Cayenne.virtualWrite(V1, temp_f);
}
After that, you download the script cayenne-ser.sh that Ken mention in his reply and run it. You will see a arduino connected to your dashboard (you can also find it in that link).
In the end you just add widgets regarding your project/sensors/actuators.
As response to your other question: Also if I added more Arduinos would they need to be individually registered?
I only have tried with different tokens, but I will try to register more than one arduino with just a single token and I will let you know.
Hope I was clear enough, and let me know if I can help you somehow.
BR