Skip to content
  • 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
M

moskovskiy82

@moskovskiy82
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store
About
Posts
174
Topics
49
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Several dimmers
    M moskovskiy82

    Thank you for the help.

    Here is the final working code in case somebody needs it

    #define SN "DimmableLEDs"
    #define SV "1.0"
    
    #include <MySensor.h> 
    #include <SPI.h>
    
    #define LED_PIN_1 3
    #define LED_PIN_2 5
    #define LED_PIN_3 6
    #define FADE_DELAY 10
    #define DIMMER_NODE_1 0
    #define DIMMER_NODE_2 1
    #define DIMMER_NODE_3 2
    
    MySensor gw;
    
    byte currentLevel[3] = {0,0,0};
    MyMessage dimmerMsg0(0, V_DIMMER);
    MyMessage lightMsg0(0, V_LIGHT);
    MyMessage dimmerMsg1(1, V_DIMMER);
    MyMessage lightMsg1(1, V_LIGHT);
    MyMessage dimmerMsg2(2, V_DIMMER);
    MyMessage lightMsg2(2, V_LIGHT);
    
    
    
    void setup()  
    { 
      Serial.println( SN ); 
      gw.begin( incomingMessage );
      
      // Register the LED Dimmable Light with the gateway
      gw.present( DIMMER_NODE_1, S_DIMMER );
      gw.wait( 50 );
      gw.present( DIMMER_NODE_2, S_DIMMER );
      gw.wait( 50 );
      gw.present( DIMMER_NODE_3, S_DIMMER );
      gw.wait( 50 );
      
      gw.sendSketchInfo(SN, SV);
      gw.wait( 50 );
      // Pull the gateway's current dim level - restore light level upon sendor node power-up
      gw.request( DIMMER_NODE_1, V_DIMMER );
      gw.wait( 50 );
      gw.request( DIMMER_NODE_2, V_DIMMER );
      gw.wait( 50 );
      gw.request( DIMMER_NODE_3, V_DIMMER );
    }
    
    void loop() 
    {
      gw.process();
    }
    
    void incomingMessage(const MyMessage &message) {
      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 );
        
        // 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;
        
        Serial.print( "Changing level to " );
        Serial.print( requestedLevel );
        Serial.print( ", from " ); 
        Serial.println( currentLevel[message.sensor] );
    
        fadeToLevel( requestedLevel, message.sensor);
        
      // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
      // hek comment: Is this really nessesary?
    switch(message.sensor)
      {
        case 0:
          gw.send(lightMsg0.set(currentLevel[0] > 0 ? 1 : 0));
          gw.send( dimmerMsg0.set(currentLevel[0]) );
          break;
        case 1:
          gw.send(lightMsg1.set(currentLevel[1] > 0 ? 1 : 0));
          gw.send( dimmerMsg1.set(currentLevel[1]) );
          break;
        case 2:
          gw.send(lightMsg2.set(currentLevel[2] > 0 ? 1 : 0));
          gw.send( dimmerMsg2.set(currentLevel[2]) );
          break;  
      }
        
        }
    }
    
    void fadeToLevel( int toLevel, byte sensorId ) {
    
      int delta = ( toLevel - currentLevel[sensorId] ) < 0 ? -1 : 1;
      
      while ( currentLevel[sensorId] != toLevel ) {
        currentLevel[sensorId] += delta;
      
     switch(sensorId)
      {
        case 0:
          analogWrite( LED_PIN_1, (int)(currentLevel[sensorId] / 100. * 255) );
          break;
        case 1:
          analogWrite( LED_PIN_2, (int)(currentLevel[sensorId] / 100. * 255) );  
          break;
        case 2:
          analogWrite( LED_PIN_3, (int)(currentLevel[sensorId] / 100. * 255) );
          break;      
      }
        
        delay( FADE_DELAY );
      }
    }```
    General Discussion

  • Water Sensor
    M moskovskiy82

    @dbemowsk

    Ok took the measurements once again on the led. This time measuriong only LED pins and not the live neutral wire. Between 1 and 3 gave me 0,1AC and 1,8DC when red and 0,1AC and 0,1DC when green. So just connected the anlogue pin of arduino to pin3 of LED and it works. Readings 19-70 when red led turned on. And 0-3 when off.
    Just wonder how this led works from AC and is it still a good advice to put optocoupler into it?

    Hardware

  • Which pin can be moved off the PWM
    M moskovskiy82

    Yes it was. Was powering the radio off an Arduino Nano's 3,3V and found that it didn't provide enough power to the radio. Switched to another nano and everything was fine. Thank you.

    P.S. A capacitor on the nrf power line didn't help

    Development

  • RGB LED strip
    M moskovskiy82

    Thanks. Will await eagerly for v1.8 as it seems this is the only great RGB code left for mysensors

    My Project
  • Login

  • Don't have an account? Register

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