Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. OliverDog
    3. Topics
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Topics created by OliverDog

    • OliverDog

      RGB Leds Light - Mood Light
      Development • • OliverDog  

      6
      0
      Votes
      6
      Posts
      2185
      Views

      OliverDog

      I tried another sketch from https://forum.mysensors.org/topic/6765/rgb-led-strip It worked with HASS but there is no response based on transitions time. /** * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * LED STRIP sketch for Mysensors ******************************* * * REVISION HISTORY * 1.0 * Based on the example sketch in mysensors * 1.1 * fadespeed parameter (send as V_VAR1 message) * HomeAssistant compatible (send status to ack) */ #define MY_NODE_ID AUTO #define MY_DEBUG #define MY_RADIO_NRF24 #include <MySensors.h> #define CHILD_ID_LIGHT 1 #define SN "LED Strip" #define SV "1.1" MyMessage lightMsg(CHILD_ID_LIGHT, V_LIGHT); MyMessage rgbMsg(CHILD_ID_LIGHT, V_RGB); MyMessage dimmerMsg(CHILD_ID_LIGHT, V_DIMMER); byte red = 255; byte green = 255; byte blue = 255; byte r0 = 255; byte g0 = 255; byte b0 = 255; char rgbstring[] = "ffffff"; int on_off_status = 0; int dimmerlevel = 100; int fadespeed = 0; #define REDPIN 6 #define GREENPIN 5 #define BLUEPIN 3 void setup() { // Fix the PWM timer. Without this the LEDs will flicker. TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00); // Output pins pinMode(REDPIN, OUTPUT); pinMode(GREENPIN, OUTPUT); pinMode(BLUEPIN, OUTPUT); } void presentation() { // Send the Sketch Version Information to the Gateway sendSketchInfo(SN, SV); present(CHILD_ID_LIGHT, S_RGB_LIGHT); } void loop() { static bool first_message_sent = false; if ( first_message_sent == false ) { Serial.println( "Sending initial state..." ); set_hw_status(); send_status(); first_message_sent = true; } } void receive(const MyMessage &message) { int val; if (message.type == V_RGB) { Serial.println( "V_RGB command: " ); Serial.println(message.data); long number = (long) strtol( message.data, NULL, 16); // Save old value strcpy(rgbstring, message.data); // Split it up into r, g, b values red = number >> 16; green = number >> 8 & 0xFF; blue = number & 0xFF; send_status(); set_hw_status(); } else if (message.type == V_LIGHT || message.type == V_STATUS) { Serial.println( "V_LIGHT command: " ); Serial.println(message.data); val = atoi(message.data); if (val == 0 or val == 1) { on_off_status = val; send_status(); set_hw_status(); } } else if (message.type == V_DIMMER || message.type == V_PERCENTAGE) { Serial.print( "V_DIMMER command: " ); Serial.println(message.data); val = atoi(message.data); if (val >= 0 and val <=100) { dimmerlevel = val; send_status(); set_hw_status(); } } else if (message.type == V_VAR1 ) { Serial.print( "V_VAR1 command: " ); Serial.println(message.data); val = atoi(message.data); if (val >= 0 and val <= 2000) { fadespeed = val; } } else { Serial.println( "Invalid command received..." ); return; } } void set_rgb(int r, int g, int b) { analogWrite(REDPIN, r); analogWrite(GREENPIN, g); analogWrite(BLUEPIN, b); } void set_hw_status() { int r = on_off_status * (int)(red * dimmerlevel/100.0); int g = on_off_status * (int)(green * dimmerlevel/100.0); int b = on_off_status * (int)(blue * dimmerlevel/100.0); if (fadespeed >0) { float dr = (r - r0) / float(fadespeed); float db = (b - b0) / float(fadespeed); float dg = (g - g0) / float(fadespeed); for (int x = 0; x < fadespeed; x++) { set_rgb(r0 + dr*x, g0 + dg*x, b0 + db*x); delay(100); } } set_rgb(r, g, b); r0 = r; b0 = b; g0 = g; } void send_status() { send(rgbMsg.set(rgbstring)); send(lightMsg.set(on_off_status)); send(dimmerMsg.set(dimmerlevel)); }
    • OliverDog

      RPi3 GPIO MySensors Gateway + LEDs + LNA Radio + DLink enclosure
      My Project • • OliverDog  

      3
      2
      Votes
      3
      Posts
      1675
      Views

      OliverDog

    • OliverDog

      [SOLVED] Multisensor Node stops working after some days...
      Troubleshooting • • OliverDog  

      6
      0
      Votes
      6
      Posts
      1772
      Views

      gohan

      Arduino does not require a lot of current so it could have been an issue with wiring or the charger wasn't very stable
    • OliverDog

      Multi RF433 Switches Node
      Development • • OliverDog  

      8
      0
      Votes
      8
      Posts
      2822
      Views

      OliverDog

      Perfect @BartE !!! Great job you did... you contributed greatly to a breakthrough in inexpensive home automation. Now we can buy the cheapest good finished glass RF in-wall home switches from Livolo and got total integration with All Home Automation Controllers, using one mysensors node. here is the final code, I added the remote code var // This skecth was created by @BartE from mysensors forum. // it was created to control 9 switches // livolo.h library necessary to work. // Just use a simple node + chinese cheap RF433 transmitter DATA plugged on Pin D8. #define MY_DEBUG #define MY_RADIO_NRF24 #include <SPI.h> #include <MySensors.h> #include <livolo.h> #define CHILD_ID 1 Livolo livolo(8); //Digital pin you plugged your transmitter // now config your remote and button codes. Livolo codes are composed by "remote code, button code" // There are many codes already discovered, and you can test new codes or get your remote's code using the daleldalel skectch bool initValSent[] = {false, false, false, false, false, false, false, false, false}; //as many as your switch number int livoloRemCode[] = {5504, 5504, 5504, 7849, 7849, 7849, 17035, 17035, 17035}; //set remote livolo codes here int livoloSensCode[] = {16, 56, 8, 16, 8, 56, 16, 56, 8}; // Set buttons livolo codes here MyMessage msg(CHILD_ID, V_STATUS); void setup() { } void presentation() { sendSketchInfo("Livolo", "1.0"); for (int sensor=1; sensor<=9; sensor++) { // change number 9 for the total switches number you want // (presents each sensor, S_BINARY type) present(sensor, S_BINARY); } } void loop() { for (int sensor=1; sensor<=9; sensor++) { // change number 9 for the total switches number you want if (!initValSent[sensor-1]) { msg.setSensor(sensor); send(msg.set(false)); Serial.print("Requesting initial value for sensor: "); Serial.println(sensor); request(sensor, V_STATUS); wait(2000, C_SET, V_STATUS); } } } void receive(const MyMessage &message) { switch (message.type) { case V_LIGHT: if (!initValSent[message.sensor-1]) { Serial.print("Receiving initial value from controller for sensor: "); initValSent[message.sensor-1] = true; } else { Serial.print("Receiving new value for sensor: "); livolo.sendButton(livoloRemCode[message.sensor-1], livoloSensCode[message.sensor-1]); // coded for each switch } Serial.println(message.sensor); break; } }