Glaube habe ich hinbekommen ? aber nun ja es ist ein NodeMCU Lolin V3
Jetzt hängt es an der Servo lib glaube ich, vermutlich weil kein ESP32 ist
#include <Servo.h>
#include <ArduinoWiFiServer.h>
#include <BearSSLHelpers.h>
#include <CertStoreBearSSL.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiGeneric.h>
#include <ESP8266WiFiGratuitous.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266WiFiSTA.h>
#include <ESP8266WiFiScan.h>
#include <ESP8266WiFiType.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiClientSecureBearSSL.h>
#include <WiFiServer.h>
#include <WiFiServerSecure.h>
#include <WiFiServerSecureBearSSL.h>
#include <WiFiUdp.h>
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"
// edit it according to your router configuration
#define WIFI_SSID "xxxx"
#define WIFI_PASS "xxx"
fauxmoESP fauxmo;
#include <ESP3266Servo.h>
constexpr byte servoPin = D4;
constexpr int servoPosLinks = 0;
constexpr int servoPosRechts = 90;
Servo servo;
// -----------------------------------------------------------------------------
#define SERIAL_BAUDRATE 115200
#define ID_RITTER_RECHTS "Ritter rechts"
#define ID_RITTER_LINKS "Ritter links"
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Wifi
// -----------------------------------------------------------------------------
void wifiSetup() {
// Set WIFI module to STA mode
WiFi.mode(WIFI_STA);
// Connect
Serial.printf("[WIFI] Connecting to %s ", WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASS);
// Wait
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(100);
}
Serial.println();
// Connected!
Serial.printf("[WIFI] STATION Mode, SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
}
void setup() {
// Init serial port and clean garbage
Serial.begin(SERIAL_BAUDRATE);
Serial.println();
Serial.println();
// Hier den Servo einbinden
servo.attach(servoPin);
// Wifi
wifiSetup();
// By default, fauxmoESP creates it's own webserver on the defined port
// The TCP port must be 80 for gen3 devices (default is 1901)
// This has to be done before the call to enable()
fauxmo.createServer(true); // not needed, this is the default value
fauxmo.setPort(80); // This is required for gen3 devices
// You have to call enable(true) once you have a WiFi connection
// You can enable or disable the library at any moment
// Disabling it will prevent the devices from being discovered and switched
fauxmo.enable(true);
// You can use different ways to invoke alexa to modify the devices state:
// "Alexa, Ritter rechts"
// "Alexa, Ritter links"
// Add virtual devices
fauxmo.addDevice(ID_RITTER_RECHTS);
fauxmo.addDevice(ID_RITTER_LINKS);
fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
// Callback when a command from Alexa is received.
// You can use device_id or device_name to choose the element to perform an action onto (relay, LED,...)
// State is a boolean (ON/OFF) and value a number from 0 to 255 (if you say "set kitchen light to 50%" you will receive a 128 here).
// Just remember not to delay too much here, this is a callback, exit as soon as possible.
// If you have to do something more involved here set a flag and process it in your main loop.
Serial.printf("[MAIN] Device #%d (%s) state: %s value: %d\n", device_id, device_name, state ? "ON" : "OFF", value);
// Checking for device_id is simpler if you are certain about the order they are loaded and it does not change.
// Otherwise comparing the device_name is safer.
if (strcmp(device_name, ID_RITTER_RECHTS) == 0) {
servo.write(servoPosRechts);
}
if (strcmp(device_name, ID_RITTER_LINKS) == 0) {
servo.write(servoPosLinks);
}
});
}
void loop() {
fauxmo.handle();
}
Fehlermeldung
C:\Users\Dave\Documents\Arduino\sketch_dec21bServo123\sketch_dec21bServo123.ino:32:10: fatal error: ESP3266Servo.h: No such file or directory
32 | #include <ESP3266Servo.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
Mehrere Bibliotheken wurden für "Servo.h" gefunden
Benutzt: C:\Users\Dave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\Servo
Nicht benutzt: C:\Users\Dave\AppData\Local\Arduino15\libraries\Servo
exit status 1
Compilation error: ESP3266Servo.h: No such file or directory