Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Hardware
    4. Hilfe beim Programmieren mit Arduino

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Hilfe beim Programmieren mit Arduino

    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      HauptstadtRocker last edited by

      Hallo Liebe ioBrokler,

      kann mir jemand helfen in einen Bestehenden Sketch MQTT einzubinden? Ich schaffe es nicht allein!

      1 Reply Last reply Reply Quote 0
      • Thisoft
        Thisoft last edited by

        hmm - sollten wir hinbekommen. Ich hab paar so Dinger laufen 😉

        Wo genau ist dein Problem?

        1 Reply Last reply Reply Quote 0
        • H
          HauptstadtRocker last edited by

          guck mal ich habe diesen Sketch hier und da würde ich gerne MQTT einbinden um das letzendlich über den ioBroker zu steuern und es im VIS anzeigen zu lassen.

          das ist der code:

          /**********************************************************************************
             Code for controlling RGB Strip using Amazon Echo and NodeMCU
             Written by Sid for Sid's E Classroom
             https://www.youtube.com/c/SidsEClassroom
           *********************************************************************************/
          #include <arduino.h>
          #include <esp8266wifi.h>
          #include "fauxmoESP.h"
          #include <adafruit_neopixel.h>
          
          #define WIFI_SSID "***********"//Set your Wifi name
          #define WIFI_PASS "**********"//Set your Wifi Password
          #define SERIAL_BAUDRATE                 115200
          
          fauxmoESP fauxmo;
          //declare switching pins
          #define RGBCTL D7 //Change pins according to your NodeMCU/ESP pinouts
          
          int numPixels = 41;
          int i;
          //-----------------------------------------------------------------------------------------------
          //Pixel initialization for Google's Colours
          //Divide the total number of pixels in the stip by 4 and set pixel increments starting from zero
          //If num of Pixels is not perfectly divisible by 4, consider the nearest multiple of 4
          //eg: 28 in case of 29,30 and 31 pixels, 32 in case of 33,34 and 35 pixels.
          //-----------------------------------------------------------------------------------------------
          int start1 = 0;
          int start2 = 3;
          int start3 = 6;
          int start4 = 9;
          
          // Parameter 1 = number of pixels in strip
          // Parameter 2 = Arduino pin number (most are valid)
          // Parameter 3 = pixel type flags, add together as needed:
          //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
          //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
          //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
          //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
          //   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
          Adafruit_NeoPixel strip = Adafruit_NeoPixel(numPixels, RGBCTL,NEO_RGB + NEO_KHZ800);
          // -----------------------------------------------------------------------------
          // Wifi Setup
          // -----------------------------------------------------------------------------
          
          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());
            Serial.println("Nach der Verbindung mit %s, sag Alexa 'Schalte <devicename> An' oder 'Aus'");
          }
          // -----------------------------------------------------------------------------
          // Device callback and printing response in serial monitor
          // -----------------------------------------------------------------------------
          void callback(uint8_t device_id, const char * device_name, bool state) {
            Serial.print("Device "); Serial.print(device_name);
            Serial.print(" state: ");
            if (state) {
              Serial.println("ON");
            } else {
              Serial.println("OFF");
            }
            //------------------------------------------------------------------------------
            //Switching action on detection of device name
            //------------------------------------------------------------------------------
          
            //Turns strip RED
            if ( (strcmp(device_name, "Rot") == 0) ) {
              if (state) {
                i = 1;
              }
              else {
                allOff();
                i = 0;
              }
            }
            //Turns strip GREEN
            if ( (strcmp(device_name, "Grün") == 0) ) {
              if (state) {
                i = 2;
              }
              else {
                allOff();
                i = 0;
              }
            }
            //Turns strip BLUE
            if ( (strcmp(device_name, "Blau") == 0) ) {
              if (state) {
                i = 3;
              }
              else {
                allOff();
                i = 0;
              }
            }
            //RAINBOW pattern on the strip
            if ( (strcmp(device_name, "Regenbogen") == 0) ) {
              if (state) {
                i = 8;
              }
              else {
                allOff();
                i = 0;
              }
            }
            //Turns strip WHITE
            if ( (strcmp(device_name, "STRIPE") == 0) ) {
              if (state) {
                i = 4;
              }
              else {
                allOff();
                i = 0;
              }
            }
            //Turns strip into Google's colours
            if ( (strcmp(device_name, "GOOGLE LIGHTS") == 0) ) {
              if (state) {
                i = 9;
              }
              else {
                allOff();
                i = 0;
              }
            }
            //Turns strip into Pink colours
            if ( (strcmp(device_name, "Pink") == 0) ) {
              if (state) {
                i = 11;
              }
              else {
                allOff();
                i = 0;
              }
            }
            //Turns strip into Pink colours
            if ( (strcmp(device_name, "Violet") == 0) ) {
              if (state) {
                i = 12;
              }
              else {
                allOff();
                i = 0;
              }
            }    
            //Turns strip into Pink colours
            if ( (strcmp(device_name, "50") == 0) ) {
              if (state) {
                i = 13;
              }
              else {
                allOff();
                i = 0;
              }
            }
          }
          
          void setup() {
            //Initialize pins to Low on device start
            pinMode(RGBCTL, OUTPUT);
            digitalWrite(RGBCTL, LOW);
          
            // Init serial port and clean garbage
            Serial.begin(SERIAL_BAUDRATE);
            Serial.println("FauxMo demo sketch");
          
            // Wifi
            wifiSetup();
          
            // Device Names for RGB Patterns
          
            i = 0;
            fauxmo.addDevice("Rot");
            fauxmo.addDevice("Grün");
            fauxmo.addDevice("Blau");
            fauxmo.addDevice("Regenbogen");
            fauxmo.addDevice("STRIPE");
            fauxmo.addDevice("GOOGLE LIGHTS");
            fauxmo.addDevice("Pink");
            fauxmo.addDevice("Violet");
            fauxmo.addDevice("50");
            fauxmo.onMessage(callback);
          
            strip.begin();
            strip.show();
            strip.setBrightness(100);
          
          }
          
          void loop() {
            fauxmo.handle();
            startShow(i);
          }
          
          //Case for strip patterns. Add a new case or pattern if you wish
          void startShow(int i) {
            switch (i) {
              case 0: colorWipe(strip.Color(0, 0, 0), 50);          // Black/Off
                break;
              case 1: colorWipe(strip.Color(255, 0, 0), 50);        // Red
                break;
              case 2: colorWipe(strip.Color(0, 255, 0), 50);        // Green
                break;
              case 3: colorWipe(strip.Color(0, 0, 255), 50);        // Blue
                break;
              case 4: colorWipe(strip.Color(255, 255, 255), 20);    // White
                break;
              case 5: theaterChase(strip.Color(127, 127, 127), 50); // White Chase
                break;
              case 6: theaterChase(strip.Color(127,   0,   0), 50); // Red Chase
                break;
              case 7: theaterChase(strip.Color(  0,   0, 127), 50); // Blue Chase
                break;
              case 8: rainbow(20);
                break;
              case 9: google();
                break;
              case 10: theaterChaseRainbow(50);
                break;
              case 11: colorWipe(strip.Color(  199, 21, 133), 50); // Pink
                break;
              case 12: colorWipe(strip.Color( 255, 0, 255), 50); // Violett
                break;    
              case 13: strip.setBrightness(50); // Violett
                break;
            }
          }
          
          // Fill the dots one after the other with a color
          void colorWipe(uint32_t c, uint8_t wait) {
            for (uint16_t i = 0; i < strip.numPixels(); i++) {
              strip.setPixelColor(i, c);
              strip.show();
              delay(wait);
            }
          }
          //Rainbow pattern
          void rainbow(uint8_t wait) {
            uint16_t i, j;
          
            for (j = 0; j < 256; j++) {
              for (i = 0; i < strip.numPixels(); i++) {
                strip.setPixelColor(i, Wheel((i + j) & 255));
              }
              strip.show();
              delay(wait);
            }
          }
          //Rainbow equally distributed throughout
          void rainbowCycle(uint8_t wait) {
            uint16_t i, j;
          
            for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
              for (i = 0; i < strip.numPixels(); i++) {
                strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
              }
              strip.show();
              delay(wait);
            }
          }
          //Theatre-style crawling lights
          void theaterChase(uint32_t c, uint8_t wait) {
            for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
              for (int q = 0; q < 3; q++) {
                for (int i = 0; i < strip.numPixels(); i = i + 3) {
                  strip.setPixelColor(i + q, c);  //turn every third pixel on
                }
                strip.show();
          
                delay(wait);
          
                for (int i = 0; i < strip.numPixels(); i = i + 3) {
                  strip.setPixelColor(i + q, 0);      //turn every third pixel off
                }
              }
            }
          }
          //Theatre-style crawling lights with rainbow effect
          void theaterChaseRainbow(uint8_t wait) {
            for (int j = 0; j < 256; j++) {   // cycle all 256 colors in the wheel
              for (int q = 0; q < 3; q++) {
                for (int i = 0; i < strip.numPixels(); i = i + 3) {
                  strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
                }
                strip.show();
          
                delay(wait);
          
                for (int i = 0; i < strip.numPixels(); i = i + 3) {
                  strip.setPixelColor(i + q, 0);      //turn every third pixel off
                }
              }
            }
          }
          //Fill strip with Google's Colour
          void google() {
            //Set initial couple of pixels to match Google Blue
            for ( int i = 0; i < 0 + 10; i++ ) {
              strip.setPixelColor(i, 66, 133, 244 );
            }
            //Set initial couple of pixels to match Google Red
            // next 3 pixels = color set #2
            for ( int i = 10; i < 10 + 10 ; i++ ) {
              strip.setPixelColor(i, 234, 67, 53 );
            }
            //Set initial couple of pixels to match Google Orange
            // next 3 pixels = color set #3
            for ( int i = 20; i < 20 + 10; i++ ) {
              strip.setPixelColor(i, 251, 188, 5 );
            }
            //Set initial couple of pixels to match Google Green
            // last 3 pixels = color set #3
            for ( int i = 30; i < 30 + 10; i++ ) {
              strip.setPixelColor(i, 52, 168, 83 );
            }
          
            strip.show();
          }
          //Turns all pixels OFF
          void allOff() {
            for ( int i = 0; i < numPixels; i++ ) {
              strip.setPixelColor(i, 0, 0, 0 );
            }
            strip.show();
          }
          
          // Input a value 0 to 255 to get a color value.
          // The colours are a transition r - g - b - back to r.
          uint32_t Wheel(byte WheelPos) {
            WheelPos = 255 - WheelPos;
            if (WheelPos < 85) {
              return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
            }
            if (WheelPos < 170) {
              WheelPos -= 85;
              return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
            }
            WheelPos -= 170;
            return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
          }</devicename></adafruit_neopixel.h></esp8266wifi.h></arduino.h>
          
          1 Reply Last reply Reply Quote 0
          • Thisoft
            Thisoft last edited by

            so, ich hab mal das Grundgerüst in deinen Sketch eingebaut. Damit sollte sich dein ESP erstmal beim ioBroker anmelden und einen State "Color" anlegen.

            Kommst du mit der Arduino-Programmierung soweit zurecht um da selber noch das ein oder andere anzupassen etc.? Weil - ich hab das ja sozusagen "blind" geschrieben, könnte mal noch ein Tippfehler drin sein. Und wenn das Anmelden klappt dann muss das ja noch weiter ausgebaut werden, sinnvolle Werte in den States übertragen, Callback-Funktion einbauen für die Steuerung ioBroker->ESP usw. und da wird's dann langsam kritisch wenn ich nichts testen kann…

            ! ````
            /**********************************************************************************
               Code for controlling RGB Strip using Amazon Echo and NodeMCU
               Written by Sid for Sid's E Classroom
               https://www.youtube.com/c/SidsEClassroom
             **********************************************************/
            #include <arduino.h>
            #include <esp8266wifi.h>
            #include "fauxmoESP.h"
            #include <adafruit_neopixel.h>
            #include <pubsubclient.h>
            ! #define WIFI_SSID "
            "//Set your Wifi name
            #define WIFI_PASS "
            "//Set your Wifi Password
            #define SERIAL_BAUDRATE                 115200
            ! //// MQTT-Settings
            IPAddress mqtt_server(192, 168, xxx, xxx); // IP-MQTT-Broker
            const char
            mqtt_username = "ioBroker"; // MQTT-User
            const char
            mqtt_key = "iobroker"; // MQTT-Password
            PubSubClient mqttClient(mqtt_server,1883);
            ! #define BASE "RGBbyESP" // <---------------!!Entsprechend f�r jeden Sensor anpassen!!
            #define mqtt_client_id BASE
            #define mqtt_topics_ip BASE "/IP"
            #define mqtt_topics_color BASE "/Color"
            ! char message_color[20];
            ///// End MQTT-Settings
            ! fauxmoESP fauxmo;
            //declare switching pins
            #define RGBCTL D7 //Change pins according to your NodeMCU/ESP pinouts
            ! int numPixels = 41;
            int i;
            //-----------------------------------------------------------------------------------------------
            //Pixel initialization for Google's Colours
            //Divide the total number of pixels in the stip by 4 and set pixel increments starting from zero
            //If num of Pixels is not perfectly divisible by 4, consider the nearest multiple of 4
            //eg: 28 in case of 29,30 and 31 pixels, 32 in case of 33,34 and 35 pixels.
            //-----------------------------------------------------------------------------------------------
            int start1 = 0;
            int start2 = 3;
            int start3 = 6;
            int start4 = 9;
            ! // Parameter 1 = number of pixels in strip
            // Parameter 2 = Arduino pin number (most are valid)
            // Parameter 3 = pixel type flags, add together as needed:
            //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
            //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
            //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
            //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
            //   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
            Adafruit_NeoPixel strip = Adafruit_NeoPixel(numPixels, RGBCTL,NEO_RGB + NEO_KHZ800);
            // -----------------------------------------------------------------------------
            // Wifi Setup
            // -----------------------------------------------------------------------------
            ! 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());
              Serial.println("Nach der Verbindung mit %s, sag Alexa 'Schalte <devicename> An' oder 'Aus'");
            }
            // -----------------------------------------------------------------------------
            // Device callback and printing response in serial monitor
            // -----------------------------------------------------------------------------
            void callback(uint8_t device_id, const char * device_name, bool state) {
              Serial.print("Device "); Serial.print(device_name);
              Serial.print(" state: ");
              if (state) {
                Serial.println("ON");
              } else {
                Serial.println("OFF");
              }
              //------------------------------------------------------------------------------
              //Switching action on detection of device name
              //------------------------------------------------------------------------------
            !   //Turns strip RED
              if ( (strcmp(device_name, "Rot") == 0) ) {
                if (state) {
                  i = 1;
                }
                else {
                  allOff();
                  i = 0;
                }
              }
              //Turns strip GREEN
              if ( (strcmp(device_name, "Grün") == 0) ) {
                if (state) {
                  i = 2;
                }
                else {
                  allOff();
                  i = 0;
                }
              }
              //Turns strip BLUE
              if ( (strcmp(device_name, "Blau") == 0) ) {
                if (state) {
                  i = 3;
                }
                else {
                  allOff();
                  i = 0;
                }
              }
              //RAINBOW pattern on the strip
              if ( (strcmp(device_name, "Regenbogen") == 0) ) {
                if (state) {
                  i = 8;
                }
                else {
                  allOff();
                  i = 0;
                }
              }
              //Turns strip WHITE
              if ( (strcmp(device_name, "STRIPE") == 0) ) {
                if (state) {
                  i = 4;
                }
                else {
                  allOff();
                  i = 0;
                }
              }
              //Turns strip into Google's colours
              if ( (strcmp(device_name, "GOOGLE LIGHTS") == 0) ) {
                if (state) {
                  i = 9;
                }
                else {
                  allOff();
                  i = 0;
                }
              }
              //Turns strip into Pink colours
              if ( (strcmp(device_name, "Pink") == 0) ) {
                if (state) {
                  i = 11;
                }
                else {
                  allOff();
                  i = 0;
                }
              }
              //Turns strip into Pink colours
              if ( (strcmp(device_name, "Violet") == 0) ) {
                if (state) {
                  i = 12;
                }
                else {
                  allOff();
                  i = 0;
                }
              }   
              //Turns strip into Pink colours
              if ( (strcmp(device_name, "50") == 0) ) {
                if (state) {
                  i = 13;
                }
                else {
                  allOff();
                  i = 0;
                }
              }
            }
            ! void connect_MQTT() {
            Serial.print("Attempting MQTT connection...");
            // Attempt to connect
            if (mqttClient.connect(mqtt_client_id,mqtt_username,mqtt_key)) {
            Serial.println("MQTT connected");
            // IP-Adresse umwandeln und publish
            IPAddress localAddr = ip;
            char s[16];
            sprintf(s, "%d.%d.%d.%d", localAddr[0], localAddr[1], localAddr[2], localAddr[3]);
            Serial.println("MQTT publish: " + String(s));
            mqttClient.publish(mqtt_topics_ip,s);
            } else {
            Serial.print("failed, rc=");
            Serial.println(mqttClient.state());
            }
            }
            ! void setup() {
              //Initialize pins to Low on device start
              pinMode(RGBCTL, OUTPUT);
              digitalWrite(RGBCTL, LOW);
            !   // Init serial port and clean garbage
              Serial.begin(SERIAL_BAUDRATE);
              Serial.println("FauxMo demo sketch");

            !   // Wifi
              wifiSetup();
            ! //MQTT
            mqttClient.setServer(mqtt_server, 1883);
            mqttClient.setCallback(callback);
            if (!mqttClient.connected()) {
            connect_MQTT();
            }
            String Null_String = "0";
            Null_String.toCharArray(message_red, Null_String.length()+1);
            mqttClient.subscribe("#/"+BASE+"/#");
            mqttClient.publish(mqtt_topics_color,message_color);
            !   // Device Names for RGB Patterns

            i = 0;
              fauxmo.addDevice("Rot");
              fauxmo.addDevice("Grün");
              fauxmo.addDevice("Blau");
              fauxmo.addDevice("Regenbogen");
              fauxmo.addDevice("STRIPE");
              fauxmo.addDevice("GOOGLE LIGHTS");
              fauxmo.addDevice("Pink");
              fauxmo.addDevice("Violet");
              fauxmo.addDevice("50");
              fauxmo.onMessage(callback);

            strip.begin();
              strip.show();
              strip.setBrightness(100);

            ! }
            ! void loop() {
            mqttClient.loop();//MQTT
              fauxmo.handle();
              startShow(i);
            }
            ! //Case for strip patterns. Add a new case or pattern if you wish
            void startShow(int i) {
              switch (i) {
                case 0: colorWipe(strip.Color(0, 0, 0), 50);          // Black/Off
                  break;
                case 1: colorWipe(strip.Color(255, 0, 0), 50);        // Red
                  break;
                case 2: colorWipe(strip.Color(0, 255, 0), 50);        // Green
                  break;
                case 3: colorWipe(strip.Color(0, 0, 255), 50);        // Blue
                  break;
                case 4: colorWipe(strip.Color(255, 255, 255), 20);    // White
                  break;
                case 5: theaterChase(strip.Color(127, 127, 127), 50); // White Chase
                  break;
                case 6: theaterChase(strip.Color(127,   0,   0), 50); // Red Chase
                  break;
                case 7: theaterChase(strip.Color(  0,   0, 127), 50); // Blue Chase
                  break;
                case 8: rainbow(20);
                  break;
                case 9: google();
                  break;
                case 10: theaterChaseRainbow(50);
                  break;
                case 11: colorWipe(strip.Color(  199, 21, 133), 50); // Pink
                  break;
                case 12: colorWipe(strip.Color( 255, 0, 255), 50); // Violett
                  break;   
                case 13: strip.setBrightness(50); // Violett
                  break;
              }
            }
            ! // Fill the dots one after the other with a color
            void colorWipe(uint32_t c, uint8_t wait) {
              for (uint16_t i = 0; i < strip.numPixels(); i++) {
                strip.setPixelColor(i, c);
                strip.show();
                delay(wait);
              }
            }
            //Rainbow pattern
            void rainbow(uint8_t wait) {
              uint16_t i, j;
            !   for (j = 0; j < 256; j++) {
                for (i = 0; i < strip.numPixels(); i++) {
                  strip.setPixelColor(i, Wheel((i + j) & 255));
                }
                strip.show();
                delay(wait);
              }
            }
            //Rainbow equally distributed throughout
            void rainbowCycle(uint8_t wait) {
              uint16_t i, j;
            !   for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
                for (i = 0; i < strip.numPixels(); i++) {
                  strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
                }
                strip.show();
                delay(wait);
              }
            }
            //Theatre-style crawling lights
            void theaterChase(uint32_t c, uint8_t wait) {
              for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
                for (int q = 0; q < 3; q++) {
                  for (int i = 0; i < strip.numPixels(); i = i + 3) {
                    strip.setPixelColor(i + q, c);  //turn every third pixel on
                  }
                  strip.show();
            !       delay(wait);
            !       for (int i = 0; i < strip.numPixels(); i = i + 3) {
                    strip.setPixelColor(i + q, 0);      //turn every third pixel off
                  }
                }
              }
            }
            //Theatre-style crawling lights with rainbow effect
            void theaterChaseRainbow(uint8_t wait) {
              for (int j = 0; j < 256; j++) {   // cycle all 256 colors in the wheel
                for (int q = 0; q < 3; q++) {
                  for (int i = 0; i < strip.numPixels(); i = i + 3) {
                    strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
                  }
                  strip.show();
            !       delay(wait);
            !       for (int i = 0; i < strip.numPixels(); i = i + 3) {
                    strip.setPixelColor(i + q, 0);      //turn every third pixel off
                  }
                }
              }
            }
            //Fill strip with Google's Colour
            void google() {
              //Set initial couple of pixels to match Google Blue
              for ( int i = 0; i < 0 + 10; i++ ) {
                strip.setPixelColor(i, 66, 133, 244 );
              }
              //Set initial couple of pixels to match Google Red
              // next 3 pixels = color set #2
              for ( int i = 10; i < 10 + 10 ; i++ ) {
                strip.setPixelColor(i, 234, 67, 53 );
              }
              //Set initial couple of pixels to match Google Orange
              // next 3 pixels = color set #3
              for ( int i = 20; i < 20 + 10; i++ ) {
                strip.setPixelColor(i, 251, 188, 5 );
              }
              //Set initial couple of pixels to match Google Green
              // last 3 pixels = color set #3
              for ( int i = 30; i < 30 + 10; i++ ) {
                strip.setPixelColor(i, 52, 168, 83 );
              }
            !   strip.show();
            }
            //Turns all pixels OFF
            void allOff() {
              for ( int i = 0; i < numPixels; i++ ) {
                strip.setPixelColor(i, 0, 0, 0 );
              }
              strip.show();
            }
            ! // Input a value 0 to 255 to get a color value.
            // The colours are a transition r - g - b - back to r.
            uint32_t Wheel(byte WheelPos) {
              WheelPos = 255 - WheelPos;
              if (WheelPos < 85) {
                return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
              }
              if (WheelPos < 170) {
                WheelPos -= 85;
                return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
              }
              WheelPos -= 170;
              return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
            }</devicename></pubsubclient.h></adafruit_neopixel.h></esp8266wifi.h></arduino.h>

            1 Reply Last reply Reply Quote 0
            • H
              HauptstadtRocker last edited by

              Hallo Thisoft,

              leider hatte ich noch nicht die zeit das zu testen. ich habe gestern Abend mal schnell meine Daten eingegeben und den Sketch versucht zu kompilieren und leider lag da schon ein Fehler vor. Mir fehlen bis jetzt auch die Kenntnisse um das alleine zu Programmieren. Meine bisherigen Projekte habe ich immer mehr mit glück zusammen bekommen als können. Damit möchte ich sagen das ich wahrscheinlich nicht alleine klar komme.

              Wenn ich es heute abend schaffe kann ich gerne mal den Fehler posten. Ich selber werde parallel versuchen den Fehler zu verstehen.

              Ich danke Dir trotzdem sehr das du mir hilfst. das ist leider nicht mehr so normal sonder eher eine seltenheit…..

              NOCHMALS FETTES DANKESCHÖN

              1 Reply Last reply Reply Quote 0
              • Thisoft
                Thisoft last edited by

                Hallo,

                kannst ja einfach mal den Kompilierfehler posten. Bei mir ist zumindest die Syntaxprüfung ohne Fehler durchgelaufen, deshalb sagt meine Glaskugel dass der Fehler deshalb kommen könnte weil du die Library für den MQTT-Client nicht in deiner Arduino-IDE installiert hast. Würde dann die Codezeile

                #include 
                

                betreffen. Wenn das so sein sollte musst du einfach mal noch mit Hilfe von Tante Google diese Library installieren 😉 Keine Angst - das ist nur beim ersten Mal ein Problem :lol:

                1 Reply Last reply Reply Quote 0
                • H
                  HauptstadtRocker last edited by

                  Soo ich habe es mal schnell kompiliert und das ist der Fehler.

                  Er wird in Zeile 20 angezeigt:

                  ~~![](</s><URL url=)<link_text text="http://forum.iobroker.net/download/file ... 2428fa57b1">http://forum.iobroker.net/download/file.php?mode=view&id=20077&sid=5c726fdb951608500e66292428fa57b1</link_text>" />

                  ! ````
                  Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "WeMos D1 R2 & mini, 80 MHz, 921600, 4M (3M SPIFFS)"
                  ! ws2812_iobroker:20: error: no matching function for call to 'PubSubClient::PubSubClient(IPAddress&, int)'
                  ! PubSubClient mqttClient(mqtt_server,1883);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:20:41: note: candidates are:
                  ! In file included from C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:10:0:
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:116:4: note: PubSubClient::PubSubClient(const char*, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&, Stream&)
                  ! PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:116:4: note: candidate expects 5 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:115:4: note: PubSubClient::PubSubClient(const char*, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&)
                  ! PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:115:4: note: candidate expects 4 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:114:4: note: PubSubClient::PubSubClient(const char*, uint16_t, Client&, Stream&)
                  ! PubSubClient(const char*, uint16_t, Client& client, Stream&);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:114:4: note: candidate expects 4 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:113:4: note: PubSubClient::PubSubClient(const char*, uint16_t, Client&)
                  ! PubSubClient(const char*, uint16_t, Client& client);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:113:4: note: candidate expects 3 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:112:4: note: PubSubClient::PubSubClient(uint8_t*, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&, Stream&)
                  ! PubSubClient(uint8_t , uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:112:4: note: candidate expects 5 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:111:4: note: PubSubClient::PubSubClient(uint8_t
                  , uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&)
                  ! PubSubClient(uint8_t , uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:111:4: note: candidate expects 4 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:110:4: note: PubSubClient::PubSubClient(uint8_t
                  , uint16_t, Client&, Stream&)
                  ! PubSubClient(uint8_t , uint16_t, Client& client, Stream&);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:110:4: note: candidate expects 4 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:109:4: note: PubSubClient::PubSubClient(uint8_t
                  , uint16_t, Client&)
                  ! PubSubClient(uint8_t , uint16_t, Client& client);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:109:4: note: candidate expects 3 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:108:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, std::function<void(char
                  , unsigned/char*,/int)="">, Client&, Stream&)
                  ! PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:108:4: note: candidate expects 5 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:107:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&)
                  ! PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:107:4: note: candidate expects 4 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:106:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, Client&, Stream&)
                  ! PubSubClient(IPAddress, uint16_t, Client& client, Stream&);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:106:4: note: candidate expects 4 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:105:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, Client&)
                  ! PubSubClient(IPAddress, uint16_t, Client& client);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:105:4: note: candidate expects 3 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:104:4: note: PubSubClient::PubSubClient(Client&)
                  ! PubSubClient(Client& client);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:104:4: note: candidate expects 1 argument, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:103:4: note: PubSubClient::PubSubClient()
                  ! PubSubClient();
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:103:4: note: candidate expects 0 arguments, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:83:7: note: PubSubClient::PubSubClient(const PubSubClient&)
                  ! class PubSubClient {
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:83:7: note: candidate expects 1 argument, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:83:7: note: PubSubClient::PubSubClient(PubSubClient&&)
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:83:7: note: candidate expects 1 argument, 2 provided
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino: In function 'void connect_MQTT()':
                  ! ws2812_iobroker:193: error: 'ip' was not declared in this scope
                  ! IPAddress localAddr = ip;
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino: In function 'void setup()':
                  ! ws2812_iobroker:219: error: no matching function for call to 'PubSubClient::setCallback(void (&)(uint8_t, const char*, bool))'
                  ! mqttClient.setCallback(callback);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:219:34: note: candidate is:
                  ! In file included from C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:10:0:
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:121:18: note: PubSubClient& PubSubClient::setCallback(std::function<void(char*, unsigned/char*,/int)="">)
                  ! PubSubClient& setCallback(MQTT_CALLBACK_SIGNATURE);
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\PubSubClient\src/PubSubClient.h:121:18: note: no known conversion for argument 1 from 'void(uint8_t, const char*, bool) {aka void(unsigned char, const char*, bool)}' to 'std::function<void(char*, unsigned/char*,/int)="">'
                  ! ws2812_iobroker:224: error: 'message_red' was not declared in this scope
                  ! Null_String.toCharArray(message_red, Null_String.length()+1);
                  ! ^
                  ! ws2812_iobroker:22: error: invalid operands of types 'const char [3]' and 'const char [9]' to binary 'operator+'
                  ! #define BASE "RGBbyESP" // <---------------!!Entsprechend f�r jeden Sensor anpassen!!
                  ! ^
                  ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:225:29: note: in expansion of macro 'BASE'
                  ! mqttClient.subscribe("#/"+BASE+"/#");
                  ! ^
                  ! exit status 1
                  no matching function for call to 'PubSubClient::PubSubClient(IPAddress&, int)'
                  ! Dieser Bericht wäre detaillierter, wenn die Option
                  "Ausführliche Ausgabe während der Kompilierung"
                  in Datei -> Voreinstellungen aktiviert wäre.</void(char*,></void(char*,></void(char*,></void(char*,></void(char*,></void(char*,></void(char*,></void(char*,>

                  
                  PubSubClient.h ist auch vorhanden…. hmmpppfff ich verstehe nur noch Bahnhof.... auweia~~
                  1 Reply Last reply Reply Quote 0
                  • Thisoft
                    Thisoft last edited by

                    Tja, ja - ein kleiner Tippfehler bzw. vergessen umzuschreiben. Du musst die folgende Zeile:

                      Null_String.toCharArray(message_red, Null_String.length()+1);
                    

                    durch diese ersetzen:

                      Null_String.toCharArray(message_color, Null_String.length()+1);
                    
                    1 Reply Last reply Reply Quote 0
                    • H
                      HauptstadtRocker last edited by

                      soo ich habe es mal geändert leider immernoch ein fehler… bzw. denke es ist der selbe

                      ! ````
                      Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "WeMos D1 R2 & mini, 80 MHz, 921600, 4M (3M SPIFFS)"
                      ! ws2812_iobroker:21: error: no matching function for call to 'PubSubClient::PubSubClient(IPAddress&, int)'
                      ! PubSubClient mqttClient(mqtt_server,1883);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:21:41: note: candidates are:
                      ! In file included from C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:10:0:
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:116:4: note: PubSubClient::PubSubClient(const char*, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&, Stream&)
                      ! PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:116:4: note: candidate expects 5 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:115:4: note: PubSubClient::PubSubClient(const char*, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&)
                      ! PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:115:4: note: candidate expects 4 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:114:4: note: PubSubClient::PubSubClient(const char*, uint16_t, Client&, Stream&)
                      ! PubSubClient(const char*, uint16_t, Client& client, Stream&);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:114:4: note: candidate expects 4 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:113:4: note: PubSubClient::PubSubClient(const char*, uint16_t, Client&)
                      ! PubSubClient(const char*, uint16_t, Client& client);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:113:4: note: candidate expects 3 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:112:4: note: PubSubClient::PubSubClient(uint8_t*, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&, Stream&)
                      ! PubSubClient(uint8_t , uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:112:4: note: candidate expects 5 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:111:4: note: PubSubClient::PubSubClient(uint8_t
                      , uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&)
                      ! PubSubClient(uint8_t , uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:111:4: note: candidate expects 4 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:110:4: note: PubSubClient::PubSubClient(uint8_t
                      , uint16_t, Client&, Stream&)
                      ! PubSubClient(uint8_t , uint16_t, Client& client, Stream&);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:110:4: note: candidate expects 4 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:109:4: note: PubSubClient::PubSubClient(uint8_t
                      , uint16_t, Client&)
                      ! PubSubClient(uint8_t , uint16_t, Client& client);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:109:4: note: candidate expects 3 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:108:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, std::function<void(char
                      , unsigned/char*,/int)="">, Client&, Stream&)
                      ! PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:108:4: note: candidate expects 5 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:107:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&)
                      ! PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:107:4: note: candidate expects 4 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:106:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, Client&, Stream&)
                      ! PubSubClient(IPAddress, uint16_t, Client& client, Stream&);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:106:4: note: candidate expects 4 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:105:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, Client&)
                      ! PubSubClient(IPAddress, uint16_t, Client& client);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:105:4: note: candidate expects 3 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:104:4: note: PubSubClient::PubSubClient(Client&)
                      ! PubSubClient(Client& client);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:104:4: note: candidate expects 1 argument, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:103:4: note: PubSubClient::PubSubClient()
                      ! PubSubClient();
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:103:4: note: candidate expects 0 arguments, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:83:7: note: PubSubClient::PubSubClient(const PubSubClient&)
                      ! class PubSubClient {
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:83:7: note: candidate expects 1 argument, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:83:7: note: PubSubClient::PubSubClient(PubSubClient&&)
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:83:7: note: candidate expects 1 argument, 2 provided
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino: In function 'void connect_MQTT()':
                      ! ws2812_iobroker:194: error: 'ip' was not declared in this scope
                      ! IPAddress localAddr = ip;
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino: In function 'void setup()':
                      ! ws2812_iobroker:220: error: no matching function for call to 'PubSubClient::setCallback(void (&)(uint8_t, const char*, bool))'
                      ! mqttClient.setCallback(callback);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:220:34: note: candidate is:
                      ! In file included from C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:10:0:
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:121:18: note: PubSubClient& PubSubClient::setCallback(std::function<void(char*, unsigned/char*,/int)="">)
                      ! PubSubClient& setCallback(MQTT_CALLBACK_SIGNATURE);
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:121:18: note: no known conversion for argument 1 from 'void(uint8_t, const char*, bool) {aka void(unsigned char, const char*, bool)}' to 'std::function<void(char*, unsigned/char*,/int)="">'
                      ! ws2812_iobroker:23: error: invalid operands of types 'const char [3]' and 'const char [9]' to binary 'operator+'
                      ! #define BASE "RGBbyESP" // <---------------!!Entsprechend f�r jeden Sensor anpassen!!
                      ! ^
                      ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:226:29: note: in expansion of macro 'BASE'
                      ! mqttClient.subscribe("#/"+BASE+"/#");
                      ! ^
                      ! exit status 1
                      no matching function for call to 'PubSubClient::PubSubClient(IPAddress&, int)'
                      ! Dieser Bericht wäre detaillierter, wenn die Option
                      "Ausführliche Ausgabe während der Kompilierung"
                      in Datei -> Voreinstellungen aktiviert wäre.</void(char*,></void(char*,></void(char*,></void(char*,></void(char*,></void(char*,></void(char*,></void(char*,>

                      
                      es tut mir echt leid das ich dich damit so belaste… leider kann ich es nicht alleine.... :cry:
                      1 Reply Last reply Reply Quote 0
                      • Thisoft
                        Thisoft last edited by

                        Kannst dich trösten - es ist nicht der gleiche 😉 Maßgeblich in der Fehlermeldung ist diese Zeile:

                        ws2812_iobroker:194: error: 'ip' was not declared in this scope
                        
                               IPAddress localAddr = ip;
                        

                        ersetze mal die Zeile durch:

                        IPAddress localAddr = WiFi.localIP();
                        

                        Da bin ich mir allerdings nicht 100%ig sicher da ich immer feste IP's verwende. Falls das nicht klappt schreibe mal testweise:

                        IPAddress localAddr = { 255, 255, 255,255 };
                        

                        btw. - hast du in der folgenden Zeile die Adresse deines MQTT-Servers eingetragen?

                        //// MQTT-Settings
                        IPAddress mqtt_server(192, 168, xxx, xxx); // IP-MQTT-Broker
                        
                        1 Reply Last reply Reply Quote 0
                        • H
                          HauptstadtRocker last edited by

                          @Thisoft

                          leider hatte ich sehr wenig Zeit das nocmal zu testen. Jetzt sitze ich seit heute morgen daran und komme nicht weiter. Ich habe immer noch einen Fehler oder sogar mehrere. Ich kann verstehen wenn du mir nicht mehr helfen willst und aufgibst. Ich bedanke mich bis hierher auf jedenfall sehr bei dir. Solltest du doch noch lust haben hier mal mein Fehler den ich noch habe:

                          ! ````
                          Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "WeMos D1 R2 & mini, 80 MHz, 921600, 4M (3M SPIFFS)"
                          ! ws2812_iobroker:21: error: no matching function for call to 'PubSubClient::PubSubClient(IPAddress&, int)'
                          ! PubSubClient mqttClient(mqtt_server,1883);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:21:41: note: candidates are:
                          ! In file included from C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:10:0:
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:116:4: note: PubSubClient::PubSubClient(const char*, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&, Stream&)
                          ! PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:116:4: note: candidate expects 5 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:115:4: note: PubSubClient::PubSubClient(const char*, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&)
                          ! PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:115:4: note: candidate expects 4 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:114:4: note: PubSubClient::PubSubClient(const char*, uint16_t, Client&, Stream&)
                          ! PubSubClient(const char*, uint16_t, Client& client, Stream&);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:114:4: note: candidate expects 4 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:113:4: note: PubSubClient::PubSubClient(const char*, uint16_t, Client&)
                          ! PubSubClient(const char*, uint16_t, Client& client);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:113:4: note: candidate expects 3 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:112:4: note: PubSubClient::PubSubClient(uint8_t*, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&, Stream&)
                          ! PubSubClient(uint8_t , uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:112:4: note: candidate expects 5 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:111:4: note: PubSubClient::PubSubClient(uint8_t
                          , uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&)
                          ! PubSubClient(uint8_t , uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:111:4: note: candidate expects 4 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:110:4: note: PubSubClient::PubSubClient(uint8_t
                          , uint16_t, Client&, Stream&)
                          ! PubSubClient(uint8_t , uint16_t, Client& client, Stream&);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:110:4: note: candidate expects 4 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:109:4: note: PubSubClient::PubSubClient(uint8_t
                          , uint16_t, Client&)
                          ! PubSubClient(uint8_t , uint16_t, Client& client);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:109:4: note: candidate expects 3 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:108:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, std::function<void(char
                          , unsigned/char*,/int)="">, Client&, Stream&)
                          ! PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:108:4: note: candidate expects 5 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:107:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, std::function<void(char*, unsigned/char*,/int)="">, Client&)
                          ! PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:107:4: note: candidate expects 4 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:106:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, Client&, Stream&)
                          ! PubSubClient(IPAddress, uint16_t, Client& client, Stream&);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:106:4: note: candidate expects 4 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:105:4: note: PubSubClient::PubSubClient(IPAddress, uint16_t, Client&)
                          ! PubSubClient(IPAddress, uint16_t, Client& client);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:105:4: note: candidate expects 3 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:104:4: note: PubSubClient::PubSubClient(Client&)
                          ! PubSubClient(Client& client);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:104:4: note: candidate expects 1 argument, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:103:4: note: PubSubClient::PubSubClient()
                          ! PubSubClient();
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:103:4: note: candidate expects 0 arguments, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:83:7: note: PubSubClient::PubSubClient(const PubSubClient&)
                          ! class PubSubClient {
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:83:7: note: candidate expects 1 argument, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:83:7: note: PubSubClient::PubSubClient(PubSubClient&&)
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:83:7: note: candidate expects 1 argument, 2 provided
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino: In function 'void setup()':
                          ! ws2812_iobroker:220: error: no matching function for call to 'PubSubClient::setCallback(void (&)(uint8_t, const char*, bool))'
                          ! mqttClient.setCallback(callback);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:220:34: note: candidate is:
                          ! In file included from C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:10:0:
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:121:18: note: PubSubClient& PubSubClient::setCallback(std::function<void(char*, unsigned/char*,/int)="">)
                          ! PubSubClient& setCallback(MQTT_CALLBACK_SIGNATURE);
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:121:18: note: no known conversion for argument 1 from 'void(uint8_t, const char*, bool) {aka void(unsigned char, const char*, bool)}' to 'std::function<void(char*, unsigned/char*,/int)="">'
                          ! ws2812_iobroker:23: error: invalid operands of types 'const char [3]' and 'const char [9]' to binary 'operator+'
                          ! #define BASE "RGBbyESP" // <---------------!!Entsprechend f�r jeden Sensor anpassen!!
                          ! ^
                          ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:226:29: note: in expansion of macro 'BASE'
                          ! mqttClient.subscribe("#/"+BASE+"/#");
                          ! ^
                          ! Mehrere Bibliotheken wurden für "PubSubClient.h" gefunden
                          Benutzt: C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-master
                          Nicht benutzt: C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-2.6
                          exit status 1
                          no matching function for call to 'PubSubClient::PubSubClient(IPAddress&, int)'
                          ! Dieser Bericht wäre detaillierter, wenn die Option
                          "Ausführliche Ausgabe während der Kompilierung"
                          in Datei -> Voreinstellungen aktiviert wäre.</void(char*,></void(char*,></void(char*,></void(char*,></void(char*,></void(char*,></void(char*,></void(char*,>

                          
                            ` > ersetze mal die Zeile durch:
                          > 
                          > Code:
                          > 
                          > IPAddress localAddr = WiFi.localIP();
                          > 
                          > Da bin ich mir allerdings nicht 100%ig sicher da ich immer feste IP's verwende. Falls das nicht klappt schreibe mal testweise:
                          > 
                          > Code:
                          > 
                          > IPAddress localAddr = { 255, 255, 255,255 }; <–-- 255,255,255,0 `  
                          Habe ich gemacht! keine Änderung leider
                          
                            ` > btw. - hast du in der folgenden Zeile die Adresse deines MQTT-Servers eingetragen?
                          > 
                          > Code:
                          > 
                          > //// MQTT-Settings
                          > 
                          > IPAddress mqtt_server(192, 168, xxx, xxx); // IP-MQTT-Broker `  
                          Auch das heb ich eingetragen und trotzdem keine veränderung :-(
                          
                          Wenn Du das kompilierst geht das ohne probleme durch?
                          1 Reply Last reply Reply Quote 0
                          • Thisoft
                            Thisoft last edited by

                            Warum sollte ich dir denn nicht mehr helfen wollen? Ist doch kein Problem. KAnn nur sein dass ich zwischendurch auch mal den Überblick verliere 😉

                            Jetzt mach mal noch einen Versuch indem du den kompletten Abschnitt "////MQTT-Settings" durch das Folgende ersetzt. KAnn sein dass eigentlich nur die Zeile "WiFiClient client;" gefehlt hatte…

                            //// MQTT-Settings
                            IPAddress mqtt_server(192, 168, xxx, xxx); // IP-MQTT-Broker
                            const char* mqtt_username = "ioBroker"; // MQTT-User
                            const char* mqtt_key = "iobroker"; // MQTT-Password
                            WiFiClient client;
                            PubSubClient mqttClient(mqtt_server,1883, client);
                            

                            Wenn das jetzt auch noch nicht hilft dann poste bitte wieder die Fehlermeldungen und dazu bitte den momentanen Code dass ich erstmal wieder "auf Stand" bin.

                            1 Reply Last reply Reply Quote 0
                            • H
                              HauptstadtRocker last edited by

                              ich bin mir nicht sicher aber ich glaube es ist schon besser aber leider noch ein fehler drin

                              ! ````
                              Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "WeMos D1 R2 & mini, 80 MHz, 921600, 4M (3M SPIFFS)"
                              ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino: In function 'void setup()':
                              ! ws2812_iobroker:220: error: no matching function for call to 'PubSubClient::setCallback(void (&)(uint8_t, const char*, bool))'
                              ! mqttClient.setCallback(callback);
                              ! ^
                              ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:220:34: note: candidate is:
                              ! In file included from C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:10:0:
                              ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-2.6\src/PubSubClient.h:121:18: note: PubSubClient& PubSubClient::setCallback(std::function<void(char*, unsigned/char*,/int)="">)
                              ! PubSubClient& setCallback(MQTT_CALLBACK_SIGNATURE);
                              ! ^
                              ! C:\Users\HauptstadtRocker\Documents\Arduino\libraries\pubsubclient-2.6\src/PubSubClient.h:121:18: note: no known conversion for argument 1 from 'void(uint8_t, const char*, bool) {aka void(unsigned char, const char*, bool)}' to 'std::function<void(char*, unsigned/char*,/int)="">'
                              ! ws2812_iobroker:23: error: invalid operands of types 'const char [3]' and 'const char [9]' to binary 'operator+'
                              ! #define BASE "RGBbyESP" // <---------------!!Entsprechend f�r jeden Sensor anpassen!!
                              ! ^
                              ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:226:29: note: in expansion of macro 'BASE'
                              ! mqttClient.subscribe("#/"+BASE+"/#");
                              ! ^
                              ! exit status 1
                              no matching function for call to 'PubSubClient::setCallback(void (&)(uint8_t, const char*, bool))'
                              ! Dieser Bericht wäre detaillierter, wenn die Option
                              "Ausführliche Ausgabe während der Kompilierung"
                              in Datei -> Voreinstellungen aktiviert wäre.</void(char*,></void(char*,>

                              
                              der dazugehörige code ist aktuell dieser hier
                              
                              >! ````
                              /**********************************************************************************
                                 Code for controlling RGB Strip using Amazon Echo and NodeMCU
                                 Written by Sid for Sid's E Classroom
                                 https://www.youtube.com/c/SidsEClassroom
                               *********************************************************************************/
                              #include <arduino.h>
                              #include <esp8266wifi.h>
                              #include "fauxmoESP.h"
                              #include <adafruit_neopixel.h>
                              #include <pubsubclient.h>
                              >! #define WIFI_SSID "*********"//Set your Wifi name
                              #define WIFI_PASS "*********"//Set your Wifi Password
                              #define SERIAL_BAUDRATE                 115200
                              >! //// MQTT-Settings
                              IPAddress mqtt_server(192, 168, 178, 45); // IP-MQTT-Broker
                              const char* mqtt_username = "*******"; // MQTT-User
                              const char* mqtt_key = "*******"; // MQTT-Password
                              WiFiClient client;
                              PubSubClient mqttClient(mqtt_server,1883, client);
                              >! #define BASE "RGBbyESP"  // <---------------!!Entsprechend f�r jeden Sensor anpassen!!
                              #define mqtt_client_id  BASE
                              #define mqtt_topics_ip  BASE "/IP"
                              #define mqtt_topics_color  BASE "/Color"
                              >! char message_color[20];
                              ///// End MQTT-Settings
                              >! fauxmoESP fauxmo;
                              //declare switching pins
                              #define RGBCTL D7 //Change pins according to your NodeMCU/ESP pinouts
                              >! int numPixels = 41;
                              int i;
                              //-----------------------------------------------------------------------------------------------
                              //Pixel initialization for Google's Colours
                              //Divide the total number of pixels in the stip by 4 and set pixel increments starting from zero
                              //If num of Pixels is not perfectly divisible by 4, consider the nearest multiple of 4
                              //eg: 28 in case of 29,30 and 31 pixels, 32 in case of 33,34 and 35 pixels.
                              //-----------------------------------------------------------------------------------------------
                              int start1 = 0;
                              int start2 = 3;
                              int start3 = 6;
                              int start4 = 9;
                              >! // Parameter 1 = number of pixels in strip
                              // Parameter 2 = Arduino pin number (most are valid)
                              // Parameter 3 = pixel type flags, add together as needed:
                              //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
                              //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
                              //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
                              //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
                              //   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
                              Adafruit_NeoPixel strip = Adafruit_NeoPixel(numPixels, RGBCTL,NEO_RGB + NEO_KHZ800);
                              // -----------------------------------------------------------------------------
                              // Wifi Setup
                              // -----------------------------------------------------------------------------
                              >! 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());
                                Serial.println("Nach der Verbindung mit %s, sag Alexa 'Schalte <devicename> An' oder 'Aus'");
                              }
                              // -----------------------------------------------------------------------------
                              // Device callback and printing response in serial monitor
                              // -----------------------------------------------------------------------------
                              void callback(uint8_t device_id, const char * device_name, bool state) {
                                Serial.print("Device "); Serial.print(device_name);
                                Serial.print(" state: ");
                                if (state) {
                                  Serial.println("ON");
                                } else {
                                  Serial.println("OFF");
                                }
                                //------------------------------------------------------------------------------
                                //Switching action on detection of device name
                                //------------------------------------------------------------------------------
                              >!   //Turns strip RED
                                if ( (strcmp(device_name, "Rot") == 0) ) {
                                  if (state) {
                                    i = 1;
                                  }
                                  else {
                                    allOff();
                                    i = 0;
                                  }
                                }
                                //Turns strip GREEN
                                if ( (strcmp(device_name, "Grün") == 0) ) {
                                  if (state) {
                                    i = 2;
                                  }
                                  else {
                                    allOff();
                                    i = 0;
                                  }
                                }
                                //Turns strip BLUE
                                if ( (strcmp(device_name, "Blau") == 0) ) {
                                  if (state) {
                                    i = 3;
                                  }
                                  else {
                                    allOff();
                                    i = 0;
                                  }
                                }
                                //RAINBOW pattern on the strip
                                if ( (strcmp(device_name, "Regenbogen") == 0) ) {
                                  if (state) {
                                    i = 8;
                                  }
                                  else {
                                    allOff();
                                    i = 0;
                                  }
                                }
                                //Turns strip WHITE
                                if ( (strcmp(device_name, "STRIPE") == 0) ) {
                                  if (state) {
                                    i = 4;
                                  }
                                  else {
                                    allOff();
                                    i = 0;
                                  }
                                }
                                //Turns strip into Google's colours
                                if ( (strcmp(device_name, "GOOGLE LIGHTS") == 0) ) {
                                  if (state) {
                                    i = 9;
                                  }
                                  else {
                                    allOff();
                                    i = 0;
                                  }
                                }
                                //Turns strip into Pink colours
                                if ( (strcmp(device_name, "Pink") == 0) ) {
                                  if (state) {
                                    i = 11;
                                  }
                                  else {
                                    allOff();
                                    i = 0;
                                  }
                                }
                                //Turns strip into Pink colours
                                if ( (strcmp(device_name, "Violet") == 0) ) {
                                  if (state) {
                                    i = 12;
                                  }
                                  else {
                                    allOff();
                                    i = 0;
                                  }
                                }    
                                //Turns strip into Pink colours
                                if ( (strcmp(device_name, "50") == 0) ) {
                                  if (state) {
                                    i = 13;
                                  }
                                  else {
                                    allOff();
                                    i = 0;
                                  }
                                }
                              }
                              >! void connect_MQTT() {
                                  Serial.print("Attempting MQTT connection...");
                                  // Attempt to connect
                                  if (mqttClient.connect(mqtt_client_id,mqtt_username,mqtt_key)) {
                                    Serial.println("MQTT connected");
                                    // IP-Adresse umwandeln und publish
                                   IPAddress localAddr = (255, 255, 255, 0);
                                    char s[16]; 
                                    sprintf(s, "%d.%d.%d.%d", localAddr[0], localAddr[1], localAddr[2], localAddr[3]); 
                                    Serial.println("MQTT publish: " + String(s));  
                                    mqttClient.publish(mqtt_topics_ip,s);     
                                  } else {
                                    Serial.print("failed, rc=");
                                    Serial.println(mqttClient.state());
                                  }
                              }
                              >! void setup() {
                                //Initialize pins to Low on device start
                                pinMode(RGBCTL, OUTPUT);
                                digitalWrite(RGBCTL, LOW);
                              >!   // Init serial port and clean garbage
                                Serial.begin(SERIAL_BAUDRATE);
                                Serial.println("FauxMo demo sketch");
                              
                              >!   // Wifi
                                wifiSetup();
                              >!   //MQTT
                                mqttClient.setServer(mqtt_server, 1883);
                                mqttClient.setCallback(callback);
                                if (!mqttClient.connected()) {
                                  connect_MQTT(); 
                                 }
                                String Null_String = "0";
                                Null_String.toCharArray(message_color, Null_String.length()+1);
                                mqttClient.subscribe("#/"+BASE+"/#");
                                mqttClient.publish(mqtt_topics_color,message_color);
                              >!   // Device Names for RGB Patterns
                              
                                i = 0;
                                fauxmo.addDevice("Rot");
                                fauxmo.addDevice("Grün");
                                fauxmo.addDevice("Blau");
                                fauxmo.addDevice("Regenbogen");
                                fauxmo.addDevice("STRIPE");
                                fauxmo.addDevice("GOOGLE LIGHTS");
                                fauxmo.addDevice("Pink");
                                fauxmo.addDevice("Violet");
                                fauxmo.addDevice("50");
                                fauxmo.onMessage(callback);
                              
                                strip.begin();
                                strip.show();
                                strip.setBrightness(100);
                              
                              >! }
                              >! void loop() {
                                mqttClient.loop();//MQTT
                                fauxmo.handle();
                                startShow(i);
                              }
                              >! //Case for strip patterns. Add a new case or pattern if you wish
                              void startShow(int i) {
                                switch (i) {
                                  case 0: colorWipe(strip.Color(0, 0, 0), 50);          // Black/Off
                                    break;
                                  case 1: colorWipe(strip.Color(255, 0, 0), 50);        // Red
                                    break;
                                  case 2: colorWipe(strip.Color(0, 255, 0), 50);        // Green
                                    break;
                                  case 3: colorWipe(strip.Color(0, 0, 255), 50);        // Blue
                                    break;
                                  case 4: colorWipe(strip.Color(255, 255, 255), 20);    // White
                                    break;
                                  case 5: theaterChase(strip.Color(127, 127, 127), 50); // White Chase
                                    break;
                                  case 6: theaterChase(strip.Color(127,   0,   0), 50); // Red Chase
                                    break;
                                  case 7: theaterChase(strip.Color(  0,   0, 127), 50); // Blue Chase
                                    break;
                                  case 8: rainbow(20);
                                    break;
                                  case 9: google();
                                    break;
                                  case 10: theaterChaseRainbow(50);
                                    break;
                                  case 11: colorWipe(strip.Color(  199, 21, 133), 50); // Pink
                                    break;
                                  case 12: colorWipe(strip.Color( 255, 0, 255), 50); // Violett
                                    break;    
                                  case 13: strip.setBrightness(50); // Violett
                                    break;
                                }
                              }
                              >! // Fill the dots one after the other with a color
                              void colorWipe(uint32_t c, uint8_t wait) {
                                for (uint16_t i = 0; i < strip.numPixels(); i++) {
                                  strip.setPixelColor(i, c);
                                  strip.show();
                                  delay(wait);
                                }
                              }
                              //Rainbow pattern
                              void rainbow(uint8_t wait) {
                                uint16_t i, j;
                              >!   for (j = 0; j < 256; j++) {
                                  for (i = 0; i < strip.numPixels(); i++) {
                                    strip.setPixelColor(i, Wheel((i + j) & 255));
                                  }
                                  strip.show();
                                  delay(wait);
                                }
                              }
                              //Rainbow equally distributed throughout
                              void rainbowCycle(uint8_t wait) {
                                uint16_t i, j;
                              >!   for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
                                  for (i = 0; i < strip.numPixels(); i++) {
                                    strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
                                  }
                                  strip.show();
                                  delay(wait);
                                }
                              }
                              //Theatre-style crawling lights
                              void theaterChase(uint32_t c, uint8_t wait) {
                                for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
                                  for (int q = 0; q < 3; q++) {
                                    for (int i = 0; i < strip.numPixels(); i = i + 3) {
                                      strip.setPixelColor(i + q, c);  //turn every third pixel on
                                    }
                                    strip.show();
                              >!       delay(wait);
                              >!       for (int i = 0; i < strip.numPixels(); i = i + 3) {
                                      strip.setPixelColor(i + q, 0);      //turn every third pixel off
                                    }
                                  }
                                }
                              }
                              //Theatre-style crawling lights with rainbow effect
                              void theaterChaseRainbow(uint8_t wait) {
                                for (int j = 0; j < 256; j++) {   // cycle all 256 colors in the wheel
                                  for (int q = 0; q < 3; q++) {
                                    for (int i = 0; i < strip.numPixels(); i = i + 3) {
                                      strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
                                    }
                                    strip.show();
                              >!       delay(wait);
                              >!       for (int i = 0; i < strip.numPixels(); i = i + 3) {
                                      strip.setPixelColor(i + q, 0);      //turn every third pixel off
                                    }
                                  }
                                }
                              }
                              //Fill strip with Google's Colour
                              void google() {
                                //Set initial couple of pixels to match Google Blue
                                for ( int i = 0; i < 0 + 10; i++ ) {
                                  strip.setPixelColor(i, 66, 133, 244 );
                                }
                                //Set initial couple of pixels to match Google Red
                                // next 3 pixels = color set #2
                                for ( int i = 10; i < 10 + 10 ; i++ ) {
                                  strip.setPixelColor(i, 234, 67, 53 );
                                }
                                //Set initial couple of pixels to match Google Orange
                                // next 3 pixels = color set #3
                                for ( int i = 20; i < 20 + 10; i++ ) {
                                  strip.setPixelColor(i, 251, 188, 5 );
                                }
                                //Set initial couple of pixels to match Google Green
                                // last 3 pixels = color set #3
                                for ( int i = 30; i < 30 + 10; i++ ) {
                                  strip.setPixelColor(i, 52, 168, 83 );
                                }
                              >!   strip.show();
                              }
                              //Turns all pixels OFF
                              void allOff() {
                                for ( int i = 0; i < numPixels; i++ ) {
                                  strip.setPixelColor(i, 0, 0, 0 );
                                }
                                strip.show();
                              }
                              >! // Input a value 0 to 255 to get a color value.
                              // The colours are a transition r - g - b - back to r.
                              uint32_t Wheel(byte WheelPos) {
                                WheelPos = 255 - WheelPos;
                                if (WheelPos < 85) {
                                  return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
                                }
                                if (WheelPos < 170) {
                                  WheelPos -= 85;
                                  return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
                                }
                                WheelPos -= 170;
                                return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
                              }</devicename></pubsubclient.h></adafruit_neopixel.h></esp8266wifi.h></arduino.h>
                              
                              1 Reply Last reply Reply Quote 0
                              • Thisoft
                                Thisoft last edited by

                                Sieht doch schon besser aus.

                                Dann lasse vorerst mal die Zeile

                                mqttClient.setCallback(callback);
                                

                                ganz raus bzw. kommentiere die aus.

                                Weiterhin anstelle der Zeile:

                                #define BASE "RGBbyESP"
                                

                                diese

                                const char* BASE = "RGBbyESP"
                                

                                Dann sollte die Sache erstmal laufen - allerdings ohne den Arduino steuern zu können…

                                1 Reply Last reply Reply Quote 0
                                • H
                                  HauptstadtRocker last edited by

                                  leider immernoch ein fehler…. 😮

                                  ! Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "WeMos D1 R2 & mini, 80 MHz, 921600, 4M (3M SPIFFS)" ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino: In function 'void connect_MQTT()': ! ws2812_iobroker:26: error: expected ')' before string constant ! #define mqtt_topics_ip BASE "/IP" ! ^ ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:199:26: note: in expansion of macro 'mqtt_topics_ip' ! mqttClient.publish(mqtt_topics_ip,s); ! ^ ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino: In function 'void setup()': ! ws2812_iobroker:227: error: invalid operands of types 'const char [3]' and 'const char*' to binary 'operator+' ! mqttClient.subscribe("#/"+BASE+"/#"); ! ^ ! ws2812_iobroker:27: error: expected ')' before string constant ! #define mqtt_topics_color BASE "/Color" ! ^ ! C:\Users\HauptstadtRocker\Documents\Arduino\ws2812_iobroker\ws2812_iobroker.ino:228:22: note: in expansion of macro 'mqtt_topics_color' ! mqttClient.publish(mqtt_topics_color,message_color); ! ^ ! exit status 1 expected ')' before string constant ! Dieser Bericht wäre detaillierter, wenn die Option "Ausführliche Ausgabe während der Kompilierung" in Datei -> Voreinstellungen aktiviert wäre. !

                                  1 Reply Last reply Reply Quote 0
                                  • T
                                    tedesco last edited by

                                    Hallo,

                                    läuft dein Programm jetzt?

                                    Gruß

                                    Toni

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post

                                    Support us

                                    ioBroker
                                    Community Adapters
                                    Donate

                                    790
                                    Online

                                    31.7k
                                    Users

                                    79.8k
                                    Topics

                                    1.3m
                                    Posts

                                    3
                                    16
                                    2723
                                    Loading More Posts
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    Community
                                    Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                    The ioBroker Community 2014-2023
                                    logo