Navigation

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

    Best posts made by Moshe Livne

    • Mysensored Doorbell

      After a long and tedious war with this doorbell (current causalities: two dead arduinos, 1 dead relay and one dead optocoupler) I decided to stop trying to be too smart for my own good and do it in a way I can understand.
      upload_-1 (3).jpg

      The bell has two circuits. one is 9v ac that comes from a transformer inside the wall. this goes through a rectifier and buck converter into the arduino (yes, I know the buck converter is not needed. However, it works and without it two arduinos died on me). Ringing the doorbell ground pin 3. The sketch then activate the relay that close the original circuit.

      upload_-1 (2).jpg

      It is almost completely wire wrapped as I had to undo and redo the circuit so many times.

      upload_-1 (1).jpg

      It is hosted inside a standard surface mount power/light switch box with blank plate.
      As Marry Poppins said "A thing of beauty is a joy forever!"

      upload_-1.jpg

      Isn't it nice with everything covered?

      Here is the sketch:

      // Doorbell sensor
      // to ring, ground pin 3. connect the relay that close the original circuit to pin 4
      // 
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define CHILD_ID 3
      #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
      #define RELAY_PIN  4  // Arduino Digital I/O pin bell relay
      
      MySensor gw;
      Bounce debouncer = Bounce(); 
      int oldValue=-1;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(CHILD_ID,V_TRIPPED);
      
      void setup()  
      {  
        gw.begin();
      
       // Setup the button
        pinMode(BUTTON_PIN,INPUT);
        pinMode(RELAY_PIN,OUTPUT);
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN,HIGH);
        
        // After setting up the button, setup debouncer
        debouncer.attach(BUTTON_PIN);
        debouncer.interval(5);
        
        // Register binary input sensor to gw (they will be created as child devices)
        // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
        // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        gw.present(CHILD_ID, S_DOOR);  
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        debouncer.update();
        // Get the update value
        int value = debouncer.read();
       
        if (value != oldValue) {
           // Send in the new value
           Serial.println(value);
           gw.send(msg.set(value==HIGH ? 0 : 1));
           if (value == 0) {
           	Serial.println("activating rely for 1 sec");
           	digitalWrite(RELAY_PIN, HIGH);
           	delay(1000);
           	digitalWrite(RELAY_PIN, LOW);
           }
           oldValue = value;
        }
      } 
      
      

      Please feel free to comment - I am actually a bit disappointed that I didn't manage to do this the "right way" but it seems that the doorbell circuit is not "real" dc but half rectified AC. This is just a guess - I don't have the equipment to check this . As such it destroys components nicely, especially mechanical relays....
      The downside of doing it this way is that the doorbell will not ring if the arduino dies. well, they can always knock, can't they?

      posted in My Project
      Moshe Livne
      Moshe Livne
    • Air Conditioning state monitoring sensor

      First, special thanks to @Chester for thinking the way to do that and @Sparkman, my hero, for correcting my silly mistake.

      These sensors are for checking if the kids (or me, just hypothetically 🙂 ) left the air conditioning running in their rooms. What makes it work is that the flaps move in a particular way when you turn the air conditioning off in my wall unit and they "close down" to a position that is impossible while its running.
      This is the sensor (looks almost professional!):
      upload_-1 (4).jpg
      I have since added also battery monitoring although I have to tweak it a bit as it shows 66%.
      The reed sensor sense the presence of a magnet on the flap.

      This is the sensor in position. Couldn't find my kids blue tack so had to use blue tape.
      upload_-1 (5).jpg

      I have carefully measure everything to fit into one of the super cheap aliexpress project boxes. what I didn't take into account was that the battery adds extra 4mm to the height. Darn.

      Here you can see the magnet:upload_-1 (6).jpg

      and this is the sketch:

      #include <MySensor.h>
      #include <SPI.h>
      
      #define REED_PIN 3
      #define INTERRUPT REED_PIN-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 1
      #define SLEEP_TIME 28800000
      int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
      
      
      
      
      MySensor gw;
      MyMessage msg(CHILD_ID, V_LIGHT);
      
       
      void setup() {
        
        analogReference(INTERNAL);
      
        pinMode(REED_PIN, INPUT); 
        digitalWrite(REED_PIN, HIGH); //internal pullup
      //  pinMode(A0, INPUT); 
        Serial.begin(115200);
      
        gw.begin();
        
        gw.sendSketchInfo("AirCon Sensor", "1.0");
        gw.present(CHILD_ID, S_LIGHT);
        
      }
      
      int old_value = -1;
      int oldBatteryPcnt = 0;
      
      
      void loop() {
      	int value;  
      	int bValue;
        
        // Listen for any knock at all.
        
      ///  gw.process(); // Process incomming messages
        
      //  	t = analogRead(A0);
        	value = digitalRead(REED_PIN);
        	
      	Serial.println(value);
        	delay(500); //debounce
        	if (value != old_value){
        		old_value = value;
        		gw.send(msg.set(value));
        	}
      
      	//Battery
      	bValue = analogRead(BATTERY_SENSE_PIN);
          int batteryPcnt = bValue / 10;
          Serial.print("Battery : ");
      	Serial.print(batteryPcnt);
      	Serial.println("%");
      	if (oldBatteryPcnt != batteryPcnt) {
          	gw.sendBatteryLevel(batteryPcnt);
          	oldBatteryPcnt = batteryPcnt;
      	}
      
      	gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
       
      } 
      
      posted in My Project
      Moshe Livne
      Moshe Livne
    • RE: Air Conditioning state monitoring sensor

      And here they are, mounted properly:
      IMG_20150727_142235_HDR[1].jpg

      posted in My Project
      Moshe Livne
      Moshe Livne
    • "Washing machine ended" sensor

      2015-07-04.jpg

      Simple sensor using http://www.aliexpress.com/item/1pc-lot-SW-420-Normally-Closed-Alarm-Vibration-Sensor-Module-Vibration-Switch-30512/32259757483.html. the sensor is attached to the top of the machine with one of those sticky dots. I found out it achieves the best and most accurate readings this way. (http://www.aliexpress.com/item/100pcs-lot-Balloon-attachment-glue-dot-attach-balloons-to-ceiling-or-wall-Globo-paste/2029756655.html)

      The sketch is a bit messy and probably could use a little love and constants but it works for me.
      The basic logic is:

      1. check for vibrations every 100ms
      2. if vibrations were detected, mark the period as "vibration" (a period is 5 minutes)
      3. if there was a vibration period after long period of quiet report "start of cycle"
        4 if there was a longish period of quite after a vibration period, report "end of cycle"
      4. in domoticz the change of state trigger a hangouts message to me.

      the sketch was tested on almost all cycles in my machine. It might fail if i load the machine late at night for early morning start as the opening and closing of the door might be detected as false positive. i might add a big red reset button to clear the state if it bothers me too much.

      here is the sketch:

      // Sensor to detect washing machine end of cycle
      // Connect vibration sensor to digital pin 3 
      
      
      #include <MySensor.h>
      #include <SPI.h>
      
      
      #define CHILD_ID 3
      #define BUTTON_PIN  3  // Arduino Digital I/O pin for vibration sensor
      #define SAMPLING_PERIOD 300000 // 5 minutes period. YMMV
      MySensor gw;
      int oldValue=-1;
      unsigned long period_start = millis();
      int state = -1;
      
      
      MyMessage msg(CHILD_ID,V_TRIPPED);
      
      
      void setup()  
      {  
        gw.begin();
      
       // Setup the button
        pinMode(BUTTON_PIN,INPUT);  
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN,HIGH);
        
        gw.present(CHILD_ID, S_DOOR);  
      }
      
      void report_state(int state)
      {
      	  	Serial.print("reporting state: ");
      		Serial.println(state); 
      	    gw.send(msg.set(state));
      	
      }
      
      int prev_state = -1;
      int prev_state_length = 0;
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        // Get the update value
        int value = digitalRead(BUTTON_PIN);
      
        if (value != 0 && state != 1) { // vibration detected for the first time during the period
        	state = 1; 
        }
      
        if (millis() - period_start > SAMPLING_PERIOD) {
        	period_start = millis();
        	Serial.println(state);
          if (state != prev_state) {
        		if (state == 1 && prev_state_length > 4) { //a vibration period after long period of quiet means a cycle started
        	    	report_state(state);
      	    	prev_state_length = 1;
        		
        		} 
        	} else if (state == 0 && prev_state_length > 2) { // a long period of quiet means cycle ended
        		if (prev_state_length == 3)
        			report_state(state); // report only once 
        	}
        	
        	if (state != prev_state)
        		prev_state_length = 1;
        	else
        		prev_state_length++;
      	prev_state = state;
          state = 0;
        	
        }
        
       
        delay(100);
      } 
      
      
      posted in My Project
      Moshe Livne
      Moshe Livne
    • RE: Safe In-Wall AC to DC Transformers??

      @Didi it is cheaper to buy better fire and life insurance 😉

      posted in Hardware
      Moshe Livne
      Moshe Livne
    • Air conditioning/HVAC control - work in progress

      Following this instructable, I decided to invest 3$ in a 1000 in 1 remote (http://www.aliexpress.com/item/Lowest-profit-Universal-LCD-Display-AC-Remote-Control-Controller-For-Air-Conditioner-Conditioning-1000-in-1/1980863274.html)

      I ordered two kinds but this one was much better then the other one (i.e it worked 🙂 )

      Soldering to the copper lines the way the kid did in the instructable proved to be problematic (at least for me) and I ended up soldering to the contacts of the pressure sensitive pads. At first I thought to use it without LCD but ended up with it as otherwise I don't know what is the current setting.

      It actually work!!! I can turn my AC on and off!!! a dream comes true!!!
      However, turning it on will bring it to one preset. this is not too bad - I actually want only to heat the bedrooms before kids go there and turn off the ac that they left on....

      Here is a nude photo:
      upload_-1 (7).jpg

      I know there are some sharp eyed people in this forum, so yes, in the photo the remote is just powered by the arduino, i tested first by giving the transistor 5v manually.
      I have ordered 4 more of this remote and will do a cleaner work on the soldering

      posted in My Project
      Moshe Livne
      Moshe Livne
    • RE: Seamless Smart Home Interface

      whoever tells you integration will be seamless is trying to sell you something 🙂
      I believe that it will be seamless only with their sensors/actuators... I had ninjablock, which is similar (not that much, as its supposed to use generic 433mhz devices) and is now a pile of junk as they basically dropped support of it to move to their other project. never again! the beauty of mysensors is that you are not bound to any HA software, or any sensors maker. and you have full control of what your sensors are doing and how they are doing it. yes, we are control freaks 🙂

      posted in General Discussion
      Moshe Livne
      Moshe Livne
    • RE: Camera as a sensor

      assuming an rpi will act as the sensor backend, would it be possible to send it on the rf module and the current mysensors protocol? this would definitely bring the price and power consumption up but can still be an interesting idea IMHO.

      posted in Hardware
      Moshe Livne
      Moshe Livne
    • RE: Led Ring ideas?

      @tbowmo another option is mysensorized egg timer. mount it on some base with rotary encoder. turn with visual response to set timer. count down will turn off led by led and alarm will also trigger event in HA

      posted in My Project
      Moshe Livne
      Moshe Livne
    • RE: Seamless Smart Home Interface

      @Qu3Uk You are right... yes, they should have charged a small monthly fee... I really liked my Ninja other than the fact that it was cloud based and I always felt a bit reluctant to let the cloud reach into my network. Also 433mhz is problematic.
      It is funny how many bright ideas goes into the rubbish bin because of people who can't do the math 🙂
      I use domoticz. I tried openHAB and another 2 that I can't remember - they were all very hard to set up - openhab has a challenging learning curve, and that's an understatement

      posted in General Discussion
      Moshe Livne
      Moshe Livne
    • RE: Measuring low current

      @tbowmo Thanks. As i said - very little background so didn't even know about the option. seems very accurate and cheap! I wish someone knowledgeable will write a complete tutorial about increasing battery life. currently there are some very good threads but they mention for example removing the LED and voltage regulator without much details and I am afraid to hurt my 2.5$ nano....

      posted in Hardware
      Moshe Livne
      Moshe Livne
    • RE: sensors in boxes

      @GuyP It does... Now I realize that if I knew what I was doing (and I don't) it could probably be made smaller and no need for soldering at all.

      Thanks! will let you know how it worked out. Might take a bit of time as I am now finishing my AirCon remote sensor.

      posted in My Project
      Moshe Livne
      Moshe Livne
    • RE: Decoding / converting IR-codes

      I have made some progress....
      Using IRScrutinizer (http://www.harctoolbox.org) and Uno with the irwidget sketch (http://www.mikrocontroller.net/articles/High-Speed_capture_mit_ATmega_Timer#Downloads) I managed to capture IR codes consistently. I am not sure I am able to capture the whole code. Now only to find a way to play these codes! they can be exported to all sorts of formats but i don't know anything that can play these formats.

      posted in Troubleshooting
      Moshe Livne
      Moshe Livne
    • RE: Using the NRF for presence detection

      Just to re-iterate my original question - does any of the forum heroes knows if the same nrf chip can be used for rfid detection of commercial active tags and for mysensors?

      posted in Hardware
      Moshe Livne
      Moshe Livne
    • RE: [SOLVED] strange problem with millis()

      @AWI Darn you are right!!!!! Thanks! Have been dealing with rpi and upwards lately so assumed it has some kind of internal clock.
      Thanks again!

      posted in Development
      Moshe Livne
      Moshe Livne
    • RE: Is this enough to get me started?

      @Daniel-Lindberg go wire wrap! Its the future! 😄

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

      @petewill got these http://www.aliexpress.com/item/Free-Shippingn-2pcs-lot-HLK-PM01-AC-DC-220V-to-5V-mini-power-supply-module-intelligent/32296988259.html in the mail today. not as sexy as the ones @Didi lists but maybe cheaper? Haven't tried them yet.

      posted in Hardware
      Moshe Livne
      Moshe Livne
    • RE: Air Conditioning state monitoring sensor

      @Sparkman I cater for the community members needs:
      IMG_20150729_131313[1].jpg

      posted in My Project
      Moshe Livne
      Moshe Livne
    • RE: Which are the *best* NRF24L01+ modules?

      @NeverDie No expert so just regurgitating what I read here on other threads:
      The capacitor serves two purposes:

      1. give the module extra juice while transmitting
      2. clean and smooth the noise on the power

      for (1), electrolite capacitor is good enough. for (2), people here said that ceramic is much better as it has all sorts of good qualities that has 3 or 4 letters acronyms. (not an expert!)

      the capacitor needs to be mounted as closely to the module otherwise the legs serves as antenna for interference or something.

      if you have a good power supply that produce good, clean 3.3v (a battery is a good example), connecting it directly to the nrf vcc is better than taking the 3v3 from the arduino.

      posted in Hardware
      Moshe Livne
      Moshe Livne