Navigation

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

    moskovskiy82

    @moskovskiy82

    5
    Reputation
    174
    Posts
    1091
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    moskovskiy82 Follow

    Best posts made by moskovskiy82

    • RE: Several dimmers

      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 );
        }
      }```
      posted in General Discussion
      moskovskiy82
      moskovskiy82
    • RE: Water Sensor

      @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?

      posted in Hardware
      moskovskiy82
      moskovskiy82
    • RE: Which pin can be moved off the PWM

      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

      posted in Development
      moskovskiy82
      moskovskiy82
    • RE: RGB LED strip

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

      posted in My Project
      moskovskiy82
      moskovskiy82

    Latest posts made by moskovskiy82

    • RE: Water Sensor

      @hard-shovel said in Water Sensor:

      typical types are H11AA1 or LTV814 etc

      Thank you! Seems like the best way to for me than. Will order and wait for them to arrive

      posted in Hardware
      moskovskiy82
      moskovskiy82
    • RE: Water Sensor

      @hard-shovel said in Water Sensor:

      Your diagram is reversed as you need to drive the led in the optocoupler from the relay coil connections.

      Your ingenious scheme worked like a charm. Thank you!
      Don't want to push but in such a rare possibility when you have access to such a marvelous help...

      The fan is of asynchronous type with 3 wires (neutral and 2 speeds). Currently i have just connected the output for speed1 to relay NC contact and speed2 to fan to NO contact. So it looks like this.

      alt text

      With such connection i still have the manual switch to off - 1st speed. But with such connection i cannot use manual switch on humidifier to choose the second switch. I have already use a multi meter to find out contacts

      i was thinking of making my sensors node completely parallel to the board and use 4n35 to sense 220V AC on different rotary switch positions and drive relays appropriately. All the schematics i found on the web use bridge rectifier. Wonder if there is any way to go without one - and if not - what to order from aliexpress?

      posted in Hardware
      moskovskiy82
      moskovskiy82
    • RE: Water Sensor

      @neverdie Do o really need the TLP222A as i already have 4N35 lying around

      posted in Hardware
      moskovskiy82
      moskovskiy82
    • RE: Water Sensor

      @hard-shovel said in Water Sensor:

      If you have the arduino analogue pin connected to Pin3, where do you have the arduino GND connected?

      Well actually nowhere 🙂 Thought that as the analogue pin is pulled to ground that will suffice.
      Was happy at first but still seems the readings are erratic. So will follow your great advice with the optocoupler.
      Do i get the connection scheme correctly?

      alt text

      posted in Hardware
      moskovskiy82
      moskovskiy82
    • RE: Water Sensor

      @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?

      posted in Hardware
      moskovskiy82
      moskovskiy82
    • RE: Water Sensor

      @hard-shovel said in Water Sensor:

      Wow! Thank you! You just made a lot of stuff clear.
      On the upper left part of the pannel - is actually a status LED. Which turns red when no water detected and green when it is. So i believe i should just dump the idea of getting anything from the water sensor and turn my view on the LED? This is the backside of the board.
      AC is totally confusing me. Especially the LED part. When trying to measure ac voltage with my multimeter i have seen something like 30V between the live neutral and one of the LED legs. So any recommendation is very appreciated

      alt text

      posted in Hardware
      moskovskiy82
      moskovskiy82
    • RE: Water Sensor

      Nope. Will it help in any way?

      The chip on the original circuit reads HEF4093BT

      posted in Hardware
      moskovskiy82
      moskovskiy82
    • Water Sensor

      I have an Electrolux air washer which i decided to convert to a smart one. So i have already added necessary relays and can control fan speed and power... One thing left. It has a water control built in. I want to keep the original functionality of the board so i need to connect to the water sensor in parallel.

      This water control consists of two metal pieces submerged in water. And 2 wires going to the control board (from now on let's call them water wires)

      I have taken the pic of the board and highlighted the part where this water wires connect. This circuit is driven by a 9V ac-ac transformer. Multimeter shows around 1,5-3V of AC current on the metal plates.

      alt text

      So going the easy way i've just connected to the metal plates +3,3V from arduino and then to the analog pin (pulled to ground via 10k). Actually it almost worked. Had reading of around 158 when water present and 60 when not.

      But i lost the functionality of the control board. With +3,3V from arduino connected it always "detected" water even when there was none. (i have tried switching sides with no luck).

      So i removed the 3,3V from arduino and just left the analogue pin connected to one of the metal plates. This gives me fluctuation reading from 2 to 30.

      So i wonder what is the correct way to go?

      posted in Hardware
      moskovskiy82
      moskovskiy82
    • RE: RGB LED strip

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

      posted in My Project
      moskovskiy82
      moskovskiy82
    • Fighting off a relay module

      Need a node with a button input (doesn't do anything to relay state) and a single relay. As this is connected to Home Assistant have to provide feedback and present the relay.
      The problem is with the code below it just starts sending the relay state in a loop without stopping.
      mys-out/67/1/1/0/2 1
      Tried everything and seems got stuck somewhere

      #define SN "MYS Vannaya Gidro"
      #define SV "2.1.1"
      
      //System settings
      #define MY_NODE_ID 67
      #define MY_RADIO_NRF24
      #define MY_DEBUG
      
      #include <Bounce2.h>
      #include <math.h>
      #include <MySensors.h>
      #include <SPI.h>
      #include <Wire.h>
      
      //SETUP PINS
      #define BUTTON_PIN1 7
      const int MQ_Pin = A3;
      #define RELAY_1  5
      
      
      //Define CHILD_IDS
      #define CHILD_ID_RELAY 1
      #define CHILD_ID_BUT1 2
      #define CHILD_ID_MQ 3
      
      //Relay VARS
      #define RELAY_ON 1
      #define RELAY_OFF 0
      //SENSORS
      
      long SENSOR_Millis = 0;
      long SENSOR_interval = 60000;
      //Buttons
      Bounce debouncer1 = Bounce(); 
      int oldValue1=-1;
      bool state;
      //Messages
      MyMessage msgRelay(CHILD_ID_RELAY, V_STATUS);
      MyMessage msgMQ(CHILD_ID_MQ, V_LEVEL);
      MyMessage msgBut1(CHILD_ID_BUT1,V_TRIPPED);
      
      //Initial for HA
      bool initialValueSent = false;
      
      void before() 
      {
        pinMode(BUTTON_PIN1, INPUT_PULLUP);
        debouncer1.attach(BUTTON_PIN1);
        debouncer1.interval(5);
        pinMode(RELAY_1, OUTPUT);
        digitalWrite(RELAY_1, loadState(1)?RELAY_ON:RELAY_OFF);
      } 
      
      void setup()  
      {  Serial.begin(115200); }
      void presentation()  
      { 
        sendSketchInfo(SN, SV);
        wait(50);
        present(CHILD_ID_RELAY, S_BINARY);
        wait(50);
        present(CHILD_ID_MQ, S_AIR_QUALITY);
        wait(50);
        present(CHILD_ID_BUT1, S_WATER_LEAK);
      }
      
      void loop() 
      {
      if (!initialValueSent) 
        {
          send(msgRelay.set(loadState(1)?RELAY_OFF:RELAY_ON));
        }
        unsigned long SENSOR_Current_Millis = millis();
        if((unsigned long)(SENSOR_Current_Millis - SENSOR_Millis) >= SENSOR_interval)
        {
          SENSOR_Millis = SENSOR_Current_Millis; 
          float mq_reading = analogRead(MQ_Pin);
          send(msgMQ.set(mq_reading, 1));
        }
      
          debouncer1.update();
            int value = debouncer1.read();
            if (value != oldValue1) 
            {
              // Send in the new value
              send(msgBut1.set(value==HIGH ? 1 : 0));
              oldValue1 = value;
            }
      }   
      
      void receive(const MyMessage &message) 
      {
        if (message.type==V_STATUS) 
        {
          if (!initialValueSent) 
          {
            initialValueSent = true;
          }
           // Update relay state to HA
        state = message.getBool();
        digitalWrite(RELAY_1, state?RELAY_ON:RELAY_OFF);
        saveState(CHILD_ID_RELAY, state);
        send(msgRelay.set(state?RELAY_ON:RELAY_OFF));
         }
      }
      
      posted in Troubleshooting
      moskovskiy82
      moskovskiy82