sorry my english is bad
/*
This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
The CayenneMQTT 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:
1. If you have not already installed the ESP8266 Board Package install it using the instructions here: https://github.com/esp8266/Arduino#installing-with-boards-manager.
2. Select your ESP8266 board from the Tools menu.
3. Set the Cayenne authentication info to match the authentication info from the Dashboard.
4. Set the network name and password.
5. Compile and upload the sketch.
6. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
*/
//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#include <Servo.h>
// WiFi network info.
char ssid[] = "kopiyen";
char wifiPassword[] = "bebas123";
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "0f3d2bb0-fe1b-11e9-84bb-8f71124cfdfb";
char password[] = "4f7d89bc3da5581de2a04b1f9750da8430591389";
char clientID[] = "0aefc090-0153-11eb-a67f-15e30d90bbf4";
#define VIRTUAL_CHANNEL 5
#define ACTUATOR_PIN D2
#define VIRTUAL_CHANNEL1 6
#define ACTUATOR_PIN1 D7
Servo s1;
Servo s2;
void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
s1.attach(ACTUATOR_PIN);
s2.attach(ACTUATOR_PIN1);
}
void loop() {
Cayenne.loop();
}
CAYENNE_IN(VIRTUAL_CHANNEL)
{
// Determine angle to set the servo.
int position = getValue.asDouble() * 180;
// Move the servo to the specified position.
s1.write(position);
}
CAYENNE_IN(VIRTUAL_CHANNEL1)
{
// Determine angle to set the servo.
int position = getValue.asDouble() * 180;
// Move the servo to the specified position.
s2.write(position);
}
// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(0, millis());
// Some examples of other functions you can use to send data.
//Cayenne.celsiusWrite(1, 22.0);
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}
// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}
i used this and in data is sending the data but if i sliding on dashboard my servo is cannot rotating.
i use wemos d1 r1 and wemos d1 r2, sorry i cannot show my sketch cause i cannot find wemos d1 r1 or wemos d1 r2 on fritzing.