Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
J

Jan Gatzke

@Jan Gatzke
About
Posts
185
Topics
8
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • New version of the MySensors adapter
    J Jan Gatzke

    @raig would you sage share your sketch?

    IOBroker

  • New version of the MySensors adapter
    J Jan Gatzke

    @Raig I must confest I have no clue what these custom values are good for and should look like. What kind of values do you expect? Strings? Numbers?

    Out of the API description for V_Custom: "Custom messages used for controller/inter node specific commands"

    So it seems totally unspecified what commands or data is inside a V_Custom message.

    IOBroker

  • 💬 Sonoff relay using MySensors ESP8266 wifi or mqtt gateway
    J Jan Gatzke

    @gohan won't this option miss some features? :D

    OpenHardware.io mqtt sonoff home assistan esp8266

  • 💬 Sonoff relay using MySensors ESP8266 wifi or mqtt gateway
    J Jan Gatzke

    @gohan I know some controller are aware of ESP Easy via MQTT. If you controller does not support this directly, you have to integrate it manually (with node red). In my opinion scenarios, where MySensors with ESP Easy frontend would be of use, do still exist.

    OpenHardware.io mqtt sonoff home assistan esp8266

  • 💬 Sonoff relay using MySensors ESP8266 wifi or mqtt gateway
    J Jan Gatzke

    @dbemowsk You cannot because MQTT is just a transport and not a strict data format. You can however use MySenSors MQTT + ESP Easy MQTT + a broker + node red + a controller. Node Red can do data conversions and integrate everything.

    OpenHardware.io mqtt sonoff home assistan esp8266

  • 💬 Sonoff relay using MySensors ESP8266 wifi or mqtt gateway
    J Jan Gatzke

    It's a shame that we cannot have both, mysensors and the ESP Easy stuff. There has been a project for this: https://github.com/letscontrolit/ESPEasyMySensors :disappointed_relieved:

    OpenHardware.io mqtt sonoff home assistan esp8266

  • New version of the MySensors adapter
    J Jan Gatzke

    I have just commited some changes to the iobroker MySensors Adapter on github. All set command are send with ack flag now and the states in iobroker get an ack on successful transmission, too. The new version is not being published via the iobroker admin, yet. You have to download it from github and copy it to your iobroker directory. Please test and report any problems you are facing.

    IOBroker

  • 💬 OH MySensors RGBW Controller
    J Jan Gatzke

    @Sergio-Rius

    The problem with the linear fading was that a value of 100 almost looked the same as 150. So the goal was to make the fading look more linear. The logarythmic calculations needed for this cannot be done on an atmega 328p. (I tried it)
    This is why I calculated the values with MS Excel and put them in an array.

    Making the fading process alway take the same time would be nice. Feel free to post your implementation. ;)

    OpenHardware.io mysensors pcb rgbw controller

  • 💬 OH MySensors RGBW Controller
    J Jan Gatzke

    @LastSamurai

    I am using Domoticz. This was the only way reading initial values from the controller. Directly requesting the value of a child did not work for me. Meanwhile MySensors support in Domoticz seems extremly bugy and uncomplete to me. I am going to give OpenHAB2 a try.

    OpenHardware.io mysensors pcb rgbw controller

  • 💬 OH MySensors RGBW Controller
    J Jan Gatzke

    @LastSamurai

    Yes, I did! This sketch is working for me:

    /**
      Based on the MySensors Project: http://www.mysensors.org
    
      This sketch controls a (analog)RGBW strip by listening to new color values from a (domoticz) controller and then fading to the new color.
    
      Version 1.1 - Added save/restore of values to/from controller, removed non linear fading code
      Version 1.0 - Changed pins and gw definition
      Version 0.9 - Oliver Hilsky
    
    **/
    #define MY_DEBUG
    
    #define SN   "RGBW 01"
    #define SV   "1.1"
    #define MY_RADIO_NRF24
    #define MY_PARENT_NODE_ID 10
    // change the pins to free up the pwm pin for led control
    #define MY_RF24_CE_PIN 4 //<-- NOTE!!! changed, the default is 9
    #define MY_RF24_CS_PIN 10 // default is 10
    // Set LOW transmit power level as default, if you have an amplified NRF-module and
    // power your radio separately with a good regulator you can turn up PA level.
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    //Uncomment to enable repeater mode
    //#define MY_REPEATER_FEATURE
    //Uncomment to assign static node ID
    //#define MY_NODE_ID 9
    
    
    // Load mysensors library
    #include <MySensors.h>
    // Load Serial Peripheral Interface library
    #include <SPI.h>
    
    // Arduino pin attached to driver pins
    #define RED_PIN 3
    #define WHITE_PIN 9
    #define GREEN_PIN 5
    #define BLUE_PIN 6
    #define NUM_CHANNELS 4 // how many channels, RGBW=4 RGB=3...
    #define CHILD_ID 1
    
    // Smooth stepping between the values
    #define STEP 1
    #define INTERVAL 10
    
    MyMessage lastvalueMsg(CHILD_ID, V_VAR1);
    MyMessage lastisonMsg(CHILD_ID, V_VAR2);
    MyMessage lastdimmMsg(CHILD_ID, V_VAR3);
    
    // Stores the current color settings
    byte channels[4] = {RED_PIN, GREEN_PIN, BLUE_PIN, WHITE_PIN};
    byte values[4] = {0, 0, 0, 0};
    byte target_values[4] = {0, 0, 0, 0};
    //Stores corrected values for each step from 0 to 255. See https://diarmuid.ie/blog/pwm-exponential-led-fading-on-arduino-or-other-platforms/
    byte converted_values[256] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,13,13,13,13,14,14,14,15,15,15,16,16,17,17,17,18,18,19,19,20,20,20,21,21,22,22,23,23,24,24,25,26,26,27,27,28,29,29,30,31,31,32,33,34,34,35,36,37,38,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,54,55,56,57,58,60,61,62,64,65,67,68,70,71,73,75,76,78,80,81,83,85,87,89,91,93,95,97,99,101,104,106,108,111,113,116,118,121,123,126,129,132,135,138,141,144,147,150,154,157,161,164,168,171,175,179,183,187,191,195,200,204,209,213,218,223,228,233,238,243,249,255};
    
    
    // stores dimming level
    byte dimming = 100;
    byte target_dimming = 100;
    
    // tracks if the strip should be on of off
    boolean isOn = false;
    // tracks if the strip's last status was off. This overrides isOn at startup
    boolean wasOff = true;
    //tracks if the old values have bben requested from the controller. This prevents the request from being send multipßle times in the main loop.
    boolean valuesrequested = false;
    // time tracking for updates
    unsigned long lastupdate = millis();
    
    void setup()
    {
      // Set all channels to output (pin number, type)
      for (int i = 0; i < NUM_CHANNELS; i++) {
        pinMode(channels[i], OUTPUT);
      }
      // debug
      if (isOn) {
        Serial.println("RGBW is running...");
      }
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo(SN, SV);
    
      // Register this device as Waterflow sensor
      present(CHILD_ID, S_RGBW_LIGHT, SN, true);
    }
    
    void loop()
    {
      if (!valuesrequested) {
        // get old values if this is just a restart
        Serial.println("Requesting old values...");
        //Request RGBW values
        request( CHILD_ID, V_VAR1 );
        wait(200);
        //Request Status
        request( CHILD_ID, V_VAR2 );
        wait(200);
        //Request dimm level
        request( CHILD_ID, V_VAR3 );
        valuesrequested = true;
      }
    
      // set the new light colors
      if (millis() > lastupdate + INTERVAL) {
        updateLights();
        lastupdate = millis();
      }
    }
    
    // callback function for incoming messages
    void receive(const MyMessage &message) {
    
      Serial.print("Got a message - ");
      Serial.print("Messagetype is: ");
      Serial.println(message.type);
    
      // acknoledgment
      if (message.isAck())
      {
        Serial.println("Got ack from gateway");
      }
    
      // new dim level
      else if (message.type == V_DIMMER or message.type == V_VAR3) {
        Serial.println("Dimming to ");
        Serial.println(message.getString());
        target_dimming = message.getByte();
        send(lastdimmMsg.set(target_dimming));
    
        if (!wasOff) {
          // a new dimmer value also means on, no seperate signal gets send (by domoticz)
          isOn = true;
          send(lastisonMsg.set(isOn));
        }
      }
    
      // on / off message
      else if (message.type == V_STATUS or message.type == V_VAR2) {
        Serial.print("Turning light ");
    
        isOn = message.getInt();
    
        if (isOn) {
          Serial.println("on");
          wasOff = false;
        } else {
          Serial.println("off");
        }
        send(lastisonMsg.set(isOn));
      }
    
      // new color value
      else if (message.type == V_RGBW or message.type == V_VAR1) {
        const char * rgbvalues = message.getString();
        send(lastvalueMsg.set(rgbvalues));
        inputToRGBW(rgbvalues);
        if (!wasOff) {
          // a new color also means on, no seperate signal gets send (by domoticz); needed e.g. for groups
          isOn = true;
          send(lastisonMsg.set(isOn));
        }
      }
    }
    
    // this gets called every INTERVAL milliseconds and updates the current pwm levels for all colors
    void updateLights() {
      int convertedvalue=0;
      // update pin values -debug
      //Serial.println(greenval);
      //Serial.println(redval);
      //Serial.println(blueval);
      //Serial.println(whiteval);
    
      //Serial.println(target_greenval);
      //Serial.println(target_redval);
      //Serial.println(target_blueval);
      //Serial.println(target_whiteval);
      //Serial.println("+++++++++++++++");
    
      // for each color
      for (int v = 0; v < NUM_CHANNELS; v++) {
        if (values[v] < target_values[v]) {
          values[v] += STEP;
          if (values[v] > target_values[v]) {
            values[v] = target_values[v];
          }
        }
    
        if (values[v] > target_values[v]) {
          values[v] -= STEP;
          if (values[v] < target_values[v]) {
            values[v] = target_values[v];
          }
        }
      }
    
    
      // dimming
      if (dimming < target_dimming) {
        dimming += STEP;
        if (dimming > target_dimming) {
          dimming = target_dimming;
        }
      }
      if (dimming > target_dimming) {
        dimming -= STEP;
        if (dimming < target_dimming) {
          dimming = target_dimming;
        }
      }
    
      /*
        // debug - new values
        Serial.println(greenval);
        Serial.println(redval);
        Serial.println(blueval);
        Serial.println(whiteval);
    
        Serial.println(target_greenval);
        Serial.println(target_redval);
        Serial.println(target_blueval);
        Serial.println(target_whiteval);
        Serial.println("+++++++++++++++");
      */
    
      // set actual pin values
      for (int i = 0; i < NUM_CHANNELS; i++) {
        if (isOn) {
          // normal fading
          //analogWrite(channels[i], dimming / 100.0 * values[i]);
          //Fading with corrected values see https://diarmuid.ie/blog/pwm-exponential-led-fading-on-arduino-or-other-platforms/
          analogWrite(channels[i], dimming / 100.0 * converted_values[values[i]]);
          
        } else {
          analogWrite(channels[i], 0);
        }
      }
    }
    
    // converts incoming color string to actual (int) values
    // ATTENTION this currently does nearly no checks, so the format needs to be exactly like domoticz sends the strings
    void inputToRGBW(const char * input) {
      Serial.print("Got color value of length: ");
      Serial.println(strlen(input));
    
      if (strlen(input) == 6) {
        Serial.println("new rgb value");
        target_values[0] = fromhex (& input [0]);
        target_values[1] = fromhex (& input [2]);
        target_values[2] = fromhex (& input [4]);
        target_values[3] = 0;
      } else if (strlen(input) == 9) {
        Serial.println("new rgbw value");
        target_values[0] = fromhex (& input [1]); // ignore # as first sign
        target_values[1] = fromhex (& input [3]);
        target_values[2] = fromhex (& input [5]);
        target_values[3] = fromhex (& input [7]);
      } else {
        Serial.println("Wrong length of input");
      }
    
    
      Serial.print("New color values: ");
      Serial.println(input);
    
      for (int i = 0; i < NUM_CHANNELS; i++) {
        Serial.print(target_values[i]);
        Serial.print(", ");
      }
    
      Serial.println("");
      Serial.print("Dimming: ");
      Serial.println(dimming);
    
    }
    
    // converts hex char to byte
    byte fromhex (const char * str)
    {
      char c = str [0] - '0';
      if (c > 9)
        c -= 7;
      int result = c;
      c = str [1] - '0';
      if (c > 9)
        c -= 7;
      return (result << 4) | c;
    }
    
    
    OpenHardware.io mysensors pcb rgbw controller

  • Scene controller: how to do it bidirectional
    J Jan Gatzke

    @gohan I do! The scene controller activates domoticz scenes. Like this one: https://www.mysensors.org/build/scene_controller

    Domoticz

  • Scene controller: how to do it bidirectional
    J Jan Gatzke

    @gohan The sonoff touch switch. (Based on esp8266)

    Domoticz

  • Scene controller: how to do it bidirectional
    J Jan Gatzke

    I have built a scene controller based on an sonoff touch switch. When I do a long press it cycles through the scenes. The devices created in domoticz are used as activation devices for several scenes. (color / brightness of my TV back light) So fa so good. Sometimes I use my smartphone to activate a scene. After this domoticz and the scene controller are out of sync. How do I update it's state? Domoticz does not send a status back to the activation device, right? So what's the best way? Lua?

    Domoticz

  • Your workshop :)
    J Jan Gatzke

    I've got the feeling this thread is going to be extreme expensive for me. :)

    General Discussion

  • Your workshop :)
    J Jan Gatzke

    @AWI Troubleshooting power probolems with the nrf24 is a good example, thx. I think at the beginning it is more a nice to have than a must have. I am always curios for such things. Still I don't want to buy trash. I will read a bit and watch ebay for good offers. Thx for your explanation.

    General Discussion

  • Your workshop :)
    J Jan Gatzke

    I noticed the many of you have an oscilloscope on their desk. What exactly do you use these for? There seems to be nothing under 200$ and I wonder if it is worth it.

    General Discussion

  • When powered from usb, nrf24I01 is ok, from external Power not
    J Jan Gatzke

    @mfalkvidd I bet the serial gateway. 2.1.1 is bugy. I solved this problem by upgrading to the 2.2 beta from github.

    Troubleshooting

  • Your workshop :)
    J Jan Gatzke

    @Yveaux I saw that thing on Amazon. There was a review saying the brackets would melt easily when using hot air. Did you use this with hot air?

    General Discussion

  • Your workshop :)
    J Jan Gatzke

    @gohan Then you can safely lean back and wait for my review. ;)

    General Discussion

  • Your workshop :)
    J Jan Gatzke

    @gohan You are right. I just ordered the thing. With the case and the builtin battery it looks like a real tool. The price seems to be a promotion. Normal price is >30$.
    You shoult by the way fix the link. Makes it easier for others to order it.

    I am looking for a soldering vise. Has anyone tested this one: https://www.amazon.de/dp/B00196RV9C/ref=wl_it_dp_o_pC_S_ttl?_encoding=UTF8&colid=2COJS1QZ6SUVJ&coliid=IQEGMI1GM2R46 ?

    General Discussion
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular