Navigation

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

    rvendrame

    @rvendrame

    Hero Member

    36
    Reputation
    353
    Posts
    2257
    Profile views
    0
    Followers
    4
    Following
    Joined Last Online
    Location Jundiai, SP

    rvendrame Follow
    Hero Member

    Best posts made by rvendrame

    • RE: 3.3 or 5v tranformer for mysensors projects

      @Tmaster , we have discussed the LNK302 chip a while ago, it may be interesting to check: https://forum.mysensors.org/search?term=lnk302&in=titlesposts

      I did POC here, and it does work, but I was a bit afraid of non-isolation so I decided to use the Hi-Link, assuming it would be more safe (and less components to assembly). I'm running a couple of nodes with Hi-Link for ~2 years without a glitch.

      The classic transformer approach for sure brings more isolation and safety. Also it is a good choice if you want to detect zero-cross (for AC dimmers) and measure real power consumption (by reading the real AC voltage from the transformer's AC output). On the other hand I see the bigger footprint as well as more components to assembly.

      Just my two cents...

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Transformer-less power supply

      Despite the security (which of course is the most important aspect here), such kind of circuit usually consumes from 2 to 10w (depending on AC voltage and C1 value), no matter in standby or not. I did some testing in the past and at end I dropped in favor of hi-link and similar small PSUs.

      posted in My Project
      rvendrame
      rvendrame
    • RE: Safe In-Wall AC to DC Transformers??

      The review of the hlktech's HLK-PM01 is available here!

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Transformer-less power supply

      You can find "Hi-link like" PSUs at Aliexpress for less than $2 USD. Not sure how less you can reach by producing them by yourself.

      posted in My Project
      rvendrame
      rvendrame
    • RE: Sensebender Micro

      Batteries usually provide a 'clean' power supply. The capacitor is more useful when there is ripple from the AC adapter.

      posted in Announcements
      rvendrame
      rvendrame
    • RE: Difficulties compiling Nodemcu 1.0 (ESP-12 module) as a 8266 Gateway.

      @ramwal Thanks for the hint, it made the trick here too!

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Multi Button Relay switch

      @jeylites you can also try adding some delay between each gw.send or gw.present. In my case it did the difference.

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Trying to do a 3 dimmer Led controller with motion

      By using built-in PWM you are limited to 3 outputs (3, 5 and 6), as pins 9, 10 and 11 are being used to connect to nRF radio).

      To read the rotaries you need at least two pins for each ( = "2-bit gray code"). Most rotaries have a 3rd microswitch, and work as a push-button as well, so a extra pin will allow you to have a on-off switch by pushing (instead turning) the rotary .

      Below is my sketch with 3 dimmers (using timers). If you implement timers, you can use any pin. (and it also works with AC-Triacs --- Be careful!!!) . If you are dimming AC bulbs, you need to adjust the 'freqStep' variable according to the AC frequency of your region.

       int freqStep = 84;                   // Microseconds of each tic  =  1s / 60Hz * 100 steps 
      

      I also recommend a 16Mhz Arduino, so you have enough speed to achieve good fade effects in all 3 channels while not missing any radio message.

      Dimmer 1 & 2 can be controlled by rotaries connected on (A3,A4) and (A5,A6). I also use A0 and A1 to immediate on/off by pushing each rotary. Dimmer 3 can only be increased/decreased via Incoming message (although it has a local on/off switch on pin A2).

      Hope it helps!

      /*** 
       * 
       * 3x Bulb/Led dimmer
       * 
       ***/
      
      #include <TimerOne.h> 
      #include <MySensor.h> 
      #include <SPI.h>
      #include <IRLib.h>
      
      #define SN "theDimmer"
      #define SV "1.3"
      
      // Version history
      // 1.2 4-Apr-15: Include "fade to level" logic
      // 1.3 11-Apr-15:  Changed A0-A6 input pins order; code cleanup
      
      // MySensor gateway, dimmer & light messages
      MySensor gw; 
      MyMessage msg1[3];
      MyMessage msg2[3]; 
      
      // Infrared Send module 
      IRsend irsend;
      
      // Warning message
      MyMessage var1( 0 , V_VAR1); 
      volatile boolean AC_found = false; 
      
      // Dim Level 
      int level[3] ;    // Current dim level on OUTPUT pins (0 to 100)
      int level_gw[3];  // Current dim level at Controller 
      int level_tg[3];  // Current dim level (target)
      float gap; 
      
      // Output pins (to Triacs / MOSFETs)
      int out_pin[3] = { 5, 6, 7 };  // Output PINS
      
      // Input: local rotary encoders (only 2) - 2-bit gray code
      int a,b,oldA[2],oldB[2];
      int rotary[2][2] = {  { A3 , A4 }  ,  { A5, A6 } };  // INPUT PINS
      
      // Input: local switches
      boolean newSw, oldSw[3]; 
      long lastSw[3];  
      int sw[3] = { A0, A1, A2 };  // INPUT PINS 
      
      // Infrared Emiiter Pin
      #define IR_PIN 3
      unsigned long raw[400];   // raw sequence of IR codes
      
      // Clock ticker (100 tics = 1 AC wave cycle = 1s / 120Hz = 8333 milisecs
      volatile int counter = 100;          // Timer tick counter
      int freqStep = 84;                   // Microseconds of each tic  =  1s / 60Hz * 100 steps 
      volatile boolean zero_cross = false; // Zero-cross flag
      int zero_cross_pin = 2;             // Input PIN for zero-cross detection 
      volatile int int_ct = 0 ; 
      
      // Idle counter (for gw update); 
      boolean idle; 
      int idle_ct; 
      
      void setup() { 
      
        // Serial init
        Serial.begin(115200); 
        
        // Start radio Controller
        gw.begin( incomingMessage );
        gw.sendSketchInfo( SN, SV );
      
        // IR output available? 
        pinMode( IR_PIN, INPUT );
        delay(50); 
        if ( digitalRead( IR_PIN ) == LOW ) { 
          pinMode( IR_PIN , OUTPUT );   
          gw.present( 4 , S_IR ); 
          Serial.println("IR init"); 
        } 
      
        // Setup IN/OUT pins
        for (int i = 0; i < 3; i++ ) { 
      
          // levels / step
          level[i] = 0;
          level_gw[i]=0;
          level_tg[i]=0; 
          
          // Create return messages
          msg1[i] = MyMessage( i , V_DIMMER ) ; 
          msg2[i] = MyMessage( i , V_LIGHT ) ; 
      
          // Rotary Encoders
          if ( i < 2) { 
            pinMode( rotary[i][0] , INPUT_PULLUP );
            pinMode( rotary[i][1] , INPUT_PULLUP ); 
            oldA[i] = digitalRead( rotary[i][0] );
            oldB[i] = digitalRead( rotary[i][1] );
          } 
      
          // Input Switches/PBs
          pinMode( sw[i] , INPUT_PULLUP );
          oldSw[i] = digitalRead( sw[i] ); 
          lastSw[i] = millis(); 
      
          // Triac/MOSFET out
          pinMode( out_pin[i], INPUT ); 
          delay(50);
          if ( digitalRead( out_pin[i] ) == LOW ) { 
      
            pinMode( out_pin[i] , OUTPUT ); 
            digitalWrite( out_pin[i], LOW );  
      
            // Register Dimmable Lights with the gateway
            gw.present( i, S_DIMMER );
           
            // Fetchs previous state from controller
            gw.request( i , V_DIMMER ); 
      
            Serial.print("Dimmer init CH "); 
            Serial.println( i );  
      
          } 
      
        } 
      
        // Zero-cross detection on Pin 2 
        pinMode( zero_cross_pin , INPUT_PULLUP);
        attachInterrupt( 0, zero_cross_detect, RISING );  
      
        // Clock ticker
        Timer1.initialize(); 
        Timer1.attachInterrupt( dim_check , freqStep ); 
      
      } 
      
      // Zero-cross
      void zero_cross_detect() { 
        
        zero_cross = true;
        AC_found = true; 
        counter = 100; 
        for (int i=0; i<3; i++)  digitalWrite( out_pin[i], LOW ) ; 
      
      } 
      
      // Timer Ticker - check
      void dim_check() { 
      
        int j = 0; 
      
        if ( zero_cross == true ) { 
      
          for (int i=0; i<3; i++)  
            if ( counter <= level[i] ) { 
              digitalWrite( out_pin[i] , HIGH ); 
              j++;
            } 
         
      
          // If all 3 output fires, avoid further checks... 
          if ( j == 3) zero_cross = false; 
        } 
      
        // Tic-tac...
        counter--; 
      
        // No zero-cross circuit?  As contingency, emulate it based on timer 
        // (Should work at least for PWM led running by  MOSFET )
        if ( counter == 0 ) { 
      
          zero_cross = true;
          counter = 100; 
          for (int i=0; i<3; i++)  digitalWrite( out_pin[i], LOW ) ; 
        } 
      
      }
      
      void loop() { 
      
        // Automation controller
        gw.process();
      
        // Idle flag
        idle = true; 
      
        // gap step calculation 
        gap = 0.0; 
        
        // Smooth transition to target level 
        for (int i=0; i<3; i++) { 
          if ( level[i] != level_tg[i] )  { 
             gap = ( ( level_tg[i] - level[i] ) / 25.0 );
             if ( gap > 0.0 && gap < 1.0 ) gap = 1.0 ;
             if ( gap < 0.0 && gap > -1.0 ) gap = -1.0;        
                   level[i] += gap;              
          } 
        }  
        
        // Small delay to produce the fade effect 
        if ( gap != 0 )   delay(27);  // Aprox. .7s  (=700/25) of ramp up/down 
             
        // Read the Rotary Encoders
        for (int i=0; i<2; i++) { 
      
          // Read current state
          a = digitalRead( rotary[i][0] );
          b = digitalRead( rotary[i][1] ); 
      
          // Any change? 
          if ( a != oldA[i] || b != oldB[i] ) { 
      
            idle = false; 
            idle_ct = 0; 
      
            if ( oldA[i] == LOW && oldB[i] == LOW ) {  
      
              a == HIGH ?  level[i]-=8 : level[i]+=8 ; 
      
              if ( level_tg[i] > 100 )  level_tg[i] = 100; 
              if ( level_tg[i] < 0 )    level_tg[i] = 0; 
      
            }
        
            // Save to use later... 
            oldA[i] = a;
            oldB[i] = b; 
            delay(3);  
          }  
        } 
      
        // Read local Push button
        for (int i=0; i<3; i++) { 
          
          // Check SWs
          newSw = digitalRead( sw[i] ); 
      
          // Any change? 
          if ( newSw != oldSw[i] ) { 
      
            // Not idle anymore... 
            idle = false; 
            idle_ct =  0; 
      
            // Minimum push to swap state
            if ( millis() - lastSw[i] > 500 ) { 
      
              level_tg[i] > 0 ? level_tg[i] = 0 : level_tg[i] = 100; 
      
            } 
      
            // Save to use later... 
            oldSw[i] = newSw; 
            lastSw[i] = millis();
            delay(50); 
      
          } 
      
        }
      
        if (idle) { 
      
          if ( ++idle_ct > 15000 ) {   // (about 1s) 
      
            // Check for not-updated levels on GW-controller
            for (int i=0; i<3; i++) { 
      
              // Update Level in GW-controller
              if ( level_gw[i] != level[i] ) { 
      
                // update GW-controller
                // Send new state and request ack back
                gw.send( msg1[i].set( level[i] ) ); 
                gw.send( msg2[i].set( level[i] > 0 ? true : false ) );  
                level_gw[i] = level[i]; 
      
              } 
      
              // Warning message for no zero-cross detected 
              if ( !AC_found ) { 
                gw.send( var1.set( "No AC?") ) ; 
                AC_found = true ; 
              } 
            }
      
            // Reset idle counter
            idle_ct = 0; 
          } 
      
        } 
      
      } 
      
      
      void incomingMessage(const MyMessage &message)
      {
      
        // ACK
        if (message.isAck()) {
          // Nothing to do, just ACK from Gateway
          //irsend.send(NEC, 0x1EE17887, 32); // Vol up yamaha ysp-900
         // irsend.send(NEC, 0x1EE1F807, 32); // Vol down yamaha ysp-900
        } 
        else { 
      
          // IR Output 
          if ( message.type == V_IR_SEND )
          { 
            
           // TO DO 
            
          } 
          
          // Light/Dimmer messages 
          if ( message.type == V_LIGHT || message.type == V_DIMMER ) 
          {
      
            //  Retrieve the power or dim level from the incoming request message
            int requestedLevel = atoi( message.data );
      
            // Channel
            int i = message.sensor; 
      
            // Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
            requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 );
      
            // Clip incoming level to valid range of 0 to 100
            requestedLevel = requestedLevel > 100 ? 100 : requestedLevel;
            requestedLevel = requestedLevel < 0   ? 0   : requestedLevel;
      
            // Set new level
            level_tg[i] = requestedLevel; 
            level_gw[i] = requestedLevel; 
      
          }
        }
      }
      
      
      posted in My Project
      rvendrame
      rvendrame
    • RE: MyS not working on solar sensor board

      @ramwal

      f6eeb556-f957-4f82-95d2-c8be09b606d3-image.png

      These boards use a different CE and CS pins in Arduino. Try to add this BEFORE the #include <MySensors.h>:

      #define MY_RF24_CE_PIN 7 // Ceech Arista board 
      #define MY_RF24_CS_PIN 8 // Ceech Arista board
      // Includes -------------------------------------------
      #include <MySensors.h> 
      
      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Safe In-Wall AC to DC Transformers??

      More from the 'guru'

      "There is no input fuse, that is the reason I recommend one and it has to be a real fuse that blows, not a fuse that will automatic recover. The only time it is supposed to blow is if the converter blows and then you want the mains permanently disconnected. Probably a 0.2A slow fuse will work."

      posted in Hardware
      rvendrame
      rvendrame

    Latest posts made by rvendrame

    • RE: Combining a motion sensor with an led on one node

      @TonicCorvid basically you just replace this line:

      sleep(digitalPinToInterrupt(MOTION_DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
      

      by this:

      wait( SLEEP_TIME );
      

      But as pointed by @rejoe2 , this will drain the battery quite fast, as the node will be always on-line. Usually for actuator nodes (such as lights), a power supply is used, instead of batteries.

      posted in Development
      rvendrame
      rvendrame
    • RE: Combining a motion sensor with an led on one node

      @TonicCorvid ,

      issue 1: The light node cannot receive messages from home assistant while it is sleeping. You may start by replacing the sleep command by a wait:

      wait( SLEEP_TIME );
      

      issue 2: Usually Home Assistant needs the light send its current status, in order to 'activate' it. Try adding a line in the end of presentation part:

      #ifdef ID_S_LIGHT
        Serial.println("  S_LIGHT");
        present(ID_S_LIGHT, S_LIGHT, "Kitchen Night Light");
        wait(SHORT_WAIT);
        send(msg_S_LIGHT.set(isLightOn));   <<<<<<<<<<<<<<
      #endif
      
      posted in Development
      rvendrame
      rvendrame
    • RE: Water level measurement - Ultrasonics V Pressure

      @zboblamont thanks a lot! I will try it and report back here.

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Water level measurement - Ultrasonics V Pressure

      @zboblamont may I ask you what pressure sensor have you choosen? My ultrassonic sensor suffers from the same plague as yours...

      posted in Hardware
      rvendrame
      rvendrame
    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      @Thomas-Weeks I'm looking for alternatives, as I started with JSN04T. Scope is to measure house's water tank (2000 litres). The sensor is fixed at a hole in the tank cover (on top).

      The tank stays at roof. Once sun in at its peak, a lot of vapor and condesantion appears in the tank, and the sensor face gets completely covered by water drops. Both JSN04T and VL5310X then start to give very out-of-range readings. (and this happens almost every day, for multiple hours).

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      @Thomas-Weeks , in your scenario do you have to deal with condensation (water vapor moisture) on sensor head? I replaced my ultrassonic SN04T by a time-of-flight VL5310X , but still getting many erratic readings when drips form on sensor face...

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: What I must buy in order to measure mAh please

      @DenisJ I built one of these some years ago and I'm still happy with

      https://www.openhardware.io/view/380/Micro-nano-ampere-meter-double

      It covers the range you mentioned at least. Hope it helps.

      posted in Hardware
      rvendrame
      rvendrame
    • RE: RGB Light: Custom Effects

      @electrik , thanks for the directions. Yes the S_CUSTOM does show up in HA --- But how to change its value there? I can set different values in dev tools UI, but that is known to be temporary (it lasts only until next refresh from integration), and changing it there does not trigger a V_VAR1 message from HA back to node...

      posted in Home Assistant
      rvendrame
      rvendrame
    • RGB Light: Custom Effects

      Anyone figured out how to trigger an update + sending of V_VAR1 / V_VAR2 from home assistant to a node?

      My goal is to trigger custom effects in a mysensor-RGB node.

      (Yes, I know my sketch could present switches to allow triggering of the effects but I wanted to learn more how HA mySensor integration works and maybe couple with HA's existing 'effect_list' attribute for RGB lights).

      posted in Home Assistant
      rvendrame
      rvendrame
    • RE: MH-Z14A CO2 senso

      @viti this forum is in English, please use that. For CO2 sensor you might starting looking at https://www.mysensors.org/build/gas

      posted in Hardware
      rvendrame
      rvendrame