MySensors/RGB Stripe(DIODER)/ColorPicker

Begonnen von JasonMask, 20 Mai 2015, 00:36:39

Vorheriges Thema - Nächstes Thema

Hauswart

Wenn es der Sketch aus Link 1 ist habe ich den Fehler gefunden. Habe nur gerade leider keinen PC da zum korrigieren.

In Zeile 110: http://sourceforge.net/p/fhem/code/10593/tree/trunk/fhem/FHEM/10_MYSENSORS_DEVICE.pm#l110 Mitte: "receives => [V_VAR1],"
1. Installation:
KNX, Tasmota (KNX), Sonos, Unifi

2. Installation:
HM-CFG-USB, Unifi (, SIGNALduino 868, MySensors, SIGNALduino 433)

gloob

Hallo,

Ich würde gerne einen anderen Sketch nutzen und das neue Reading S_RGB.

Einen Sketch für den Arduino habe ich auch:

// Example sketch showing how to control an RGB Led Strip.
// This example will not remember the last rgb color set after power failure.

#include <MySensor.h>
#include <SPI.h>

#include "Adafruit_NeoPixel.h"

#define NUMPIXELS 4   // Number of connected pixels on a single datapin
#define PIN 4         // Digital output pin

#define node 254  //254 for testing purpose
#define CHILD_ID 0 


Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
long RGB_values[3] = {0,0,0};

MySensor gw;

void setup()
{
    gw.begin(incomingMessage, node, true);
    gw.sendSketchInfo("RGB Node", "1.0");
    gw.present(CHILD_ID, S_RGB_LIGHT);
    strip.begin();
    strip.show(); // Update the strip, to start they are all 'off'
}


void loop()
{
    gw.process();
}

void incomingMessage(const MyMessage &message) {
    if (message.type==V_RGB) {
  // starting to process the hex code
        String hexstring = message.getString(); //here goes the hex color code coming from through MySensors (like FF9A00)
        long number = (long) strtol( &hexstring[0], NULL, 16);
        RGB_values[0] = number >> 16;
        RGB_values[1] = number >> 8 & 0xFF;
        RGB_values[2] = number & 0xFF;

        colorWipe(Color(RGB_values[0],RGB_values[1],RGB_values[2]), 60);
     }
     
    if (message.type==V_DIMMER) {
      strip.setBrightness(round((2.55*message.getInt())));
      strip.show();
      }
     
    if (message.type==V_LIGHT) {
       if (message.getInt() == 0) {
        strip.clear();
        strip.show();
       }
    }
 
}

void colorWipe(uint32_t c, uint8_t wait) {
  int i;

  for (i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

    /* Helper functions */

// Create a 15 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
  uint32_t c;
  c = r;
  c <<= 8;
  c |= g;
  c <<= 8;
  c |= b;
  return c;
}
   


Ich glaube das mir nur die richtige Integration in FHEM fehlt. Das Modul sollte eigentlich so passen.
Raspberry Pi 3 | miniCUL 433MHz | nanoCUL 868 MHz | nanoCUL 433 MHz | MySensors WLAN Gateway | LaCrosse WLAN Gateway | SignalESP 433 MHz | SignalESP 868 MHz | HM-MOD-UART WLAN Gateway | IR - 360 Grad WLAN Gateway

gloob

Hallo,

Also am Arduino Sketch scheint es nicht zu liegen. Wenn ich mit einem anderen Controller die Daten schicke, werden sie richtig vom Arduino Empfangen und ausgewertet.

Es kann also nur noch am Gateway oder an FHEM liegen.
Raspberry Pi 3 | miniCUL 433MHz | nanoCUL 868 MHz | nanoCUL 433 MHz | MySensors WLAN Gateway | LaCrosse WLAN Gateway | SignalESP 433 MHz | SignalESP 868 MHz | HM-MOD-UART WLAN Gateway | IR - 360 Grad WLAN Gateway

gloob

Es scheint an meinem Gateway gelegen zu haben. Ich hatte einen Sensebende Micro direkt an die RX und TX Leitung vom Raspberry Pi geklemmt und scheinbar hat die TX Leitung nicht funktioniert.
FHEM konnte zwar alles vom Gateway empfangen und somit gingen die Sensoren auch aber senden ging irgendwie nicht und die Nachrichten für die RGB Werte wurden garnicht gesendet.

Jetzt habe ich aktuell einen Arduino Nano als Gateway benutzt und damit geht es. Mal gucken ob ich den Sensebender irgendwie als Gateway trotzdem benutzen kann.
Raspberry Pi 3 | miniCUL 433MHz | nanoCUL 868 MHz | nanoCUL 433 MHz | MySensors WLAN Gateway | LaCrosse WLAN Gateway | SignalESP 433 MHz | SignalESP 868 MHz | HM-MOD-UART WLAN Gateway | IR - 360 Grad WLAN Gateway

Hauswart

Mmh also mir ist klar, wieso du einige Werte nicht senden kannst.

Der Sensor gibt sich als RGB light zu erkennen:
S_RGB_LIGHT             => { receives => [V_RGB,V_WATT], sends => [V_RGB,V_WATT] }, # RGB light

Dein Sketch arbeitet aber mit folgenden Variablen:
V_DIMMER
V_RGB
V_LIGHT

Ist die ein Standard Sketch? Ich denke nein?

Daher würde es wahrscheinlich Sinn machen den Sketch anzupassen. Ich habe gerade an Norbert eine Anpassung des MySensors-Modul geschickt, ich hoffe diese ist bald im FHEM-Update enthalten.

So lange könntest du folgendes testen: https://raw.githubusercontent.com/Kolbi/fhem-mirror/master/fhem/FHEM/10_MYSENSORS_DEVICE.pm

Und diesen Sketch:

// Example sketch showing how to control an RGB Led Strip.
// This example will not remember the last rgb color set after power failure.

#include <MySensor.h>
#include <SPI.h>

#include "Adafruit_NeoPixel.h"

#define NUMPIXELS 4   // Number of connected pixels on a single datapin
#define PIN 4         // Digital output pin

#define node 254  //254 for testing purpose
#define CHILD_ID 0 


Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
long RGB_values[3] = {0,0,0};

MySensor gw;

void setup()
{
    gw.begin(incomingMessage, node, true);
    gw.sendSketchInfo("RGB Node", "1.0");
    gw.present(CHILD_ID, S_CUSTOM);
    strip.begin();
    strip.show(); // Update the strip, to start they are all 'off'
}


void loop()
{
    gw.process();
}

void incomingMessage(const MyMessage &message) {
//if (message.type==V_RGB) {
    if (message.type==V_VAR1) {
  // starting to process the hex code
        String hexstring = message.getString(); //here goes the hex color code coming from through MySensors (like FF9A00)
        long number = (long) strtol( &hexstring[0], NULL, 16);
        RGB_values[0] = number >> 16;
        RGB_values[1] = number >> 8 & 0xFF;
        RGB_values[2] = number & 0xFF;

        colorWipe(Color(RGB_values[0],RGB_values[1],RGB_values[2]), 60);
     }
   
//if (message.type==V_DIMMER) {
    if (message.type==V_VAR2) {
      strip.setBrightness(round((2.55*message.getInt())));
      strip.show();
      }
   
//if (message.type==V_LIGHT) {
    if (message.type==V_VAR3) {
       if (message.getInt() == 0) {
        strip.clear();
        strip.show();
       }
    }
 
}

void colorWipe(uint32_t c, uint8_t wait) {
  int i;

  for (i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

    /* Helper functions */

// Create a 15 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
  uint32_t c;
  c = r;
  c <<= 8;
  c |= g;
  c <<= 8;
  c |= b;
  return c;
}
1. Installation:
KNX, Tasmota (KNX), Sonos, Unifi

2. Installation:
HM-CFG-USB, Unifi (, SIGNALduino 868, MySensors, SIGNALduino 433)