Control lights and intencidad with Vera and arduino



  • Hello I would like to make the following project:

    Control lights and intencidad with Vera and arduino. On, off and control its intencidad . It will be possible?
    Can you help me with components and code?

    Thanks guys.

    Forgive my English , I'm using google translate .



  • @conde said:

    Hello I would like to make the following project:

    Control lights and intencidad with Vera and arduino. On, off and control its intencidad . It will be possible?
    Can you help me with components and code?

    Thanks guys.

    Forgive my English , I'm using google translate .
    Conde
    Yes you can do all of the above,turn lights on/off ,control Intensity and many more things. You didn't say whether you already own a Vera but if you do and you already have some light modules or appliance modules or switch modules then it is a matter of programming your Vera. If you don't have any modules then you will to have the
    1....Vera
    2... Serial or Ethernet gateway that you build yourself
    3... Light dimmer you will build
    4.. Outlet controller you will build
    the list just depends upon your needs and imitation.
    All of these builds are well documented on the Mysensor website.
    So good luck and keep up the dreaming that is where all this stuff comes from someone having a need or a dream or both.



  • Hello. Thanks for reply.

    This is my first project witn arduino. I'm learning. xD
    For this project i have:

    • the vera edge;
    • arduino uno;
    • NRF24L01+ 2.4GHz Wireless Transceiver;
    • Relays;

    So my question is. It's possible wiht this components? I need another?

    You say: (All of these builds are well documented on the Mysensor website.) - can you please send me de link? because i can't found.

    Thank you.


  • Admin

    You should use an Arduino Nano for the Vera gateway as it has a hard time recognising the Uno board.

    http://www.mysensors.org/build/serial_gateway

    and

    http://www.mysensors.org/build/relay



  • @hek said:

    You should use an Arduino Nano for the Vera gateway as it has a hard time recognising the Uno board.

    http://www.mysensors.org/build/serial_gateway

    and

    http://www.mysensors.org/build/relay

    Are you sure?
    An edge is running ui7 and then a serial gateway will not work. I had one running fine on my VeraLite until I 'upgraded' it to ui7. I never got it working until I built an Ethernet gateway.
    Did this with an uno with 5100 shield. Runs perfectly, still hate ui7 though...


  • Admin

    Have a vague memory they got this fixed in a FW update... Haven't heard any problems from UI7 users lately... so I just assumed it wasn't a problem any more.



  • @hek
    Ok, I missed that news than. Will try that one of these days because have it still laying around. I remember the serial port was there but the device disapeard in the UI.


  • Admin

    Ok, report back.



  • It just works now!
    I removed the Ethernet gateway device from the UI and added the new device as per description on the webside. For a short while I had the error ComFailure but found on the forum that in advanced this must be altered from 1 to 0.



  • @conde said:

    Hello. Thanks for reply.

    This is my first project witn arduino. I'm learning. xD
    For this project i have:

    • the vera edge;
    • arduino uno;
    • NRF24L01+ 2.4GHz Wireless Transceiver;
    • Relays;

    So my question is. It's possible wiht this components? I need another?

    You say: (All of these builds are well documented on the Mysensor website.) - can you please send me de link? because i can't found.

    Thank you.

    Conde
    Here is an Example of a battery Operated wireless door sensor it uses a 18560 li-ion battery for power.Wireless_Door_Sensor.jpg Battery_Wireless_Door_Sensor.jpg
    The project cost me about $8-$10.00 to build you might find parts cheaper or have some of your own but this uses a nRF24l01= transceiver and an ATtiny 85 mcu ,2- 22ufd caps a 3.3 volts LDO regulator.
    If interested I can supply BOM and sketch.



  • I would greatly appreciate it. I like your project.

    Thanks for your help.



  • / MySensorsDoor/Window sensor
    // Based on Attiny85
    // Author: Wiebe Nieuwenhuis
    // these are suggested wire colors but you can use any color you want,  just be consistent on all sensors
    //                    +-\/-+
    //  ORANGE   CE      1|o   |8  VCC   RED
    //  YELLOW   CSN     2|    |7  SCK   GREEN
    //  -        SENSOR  3|    |6  MOSI  BLUE
    //  BLACK    GND     4|    |5  MISO  VIOLET
    //                    +----+
    
    #include <MySensor.h>
    #include <Bounce2.h>
    
    #define SENSOR_INFO "Door sensor"
    #define NODE_ID 1 // Start numbering by 1 adding 1 each time you upload to new attiny85
    #define CHILD_ID 1 // this number must match above number
    #define INPUT_PIN 4 // This is ATiny input number pin # 3 is the physical pin
    
    MySensor gw;
    Bounce debouncer = Bounce(); 
    int oldValue = -1;
    
    MyMessage msg(NODE_ID, V_TRIPPED);
    
    void setup()
    {
      pinMode(INPUT_PIN, INPUT);
      digitalWrite(INPUT_PIN, HIGH);
      
      debouncer.attach(INPUT_PIN);
      debouncer.interval(5);
      
      gw.begin(NULL, NODE_ID, false, 0);
      gw.sendSketchInfo(SENSOR_INFO, "1.15");
      gw.present(CHILD_ID, S_DOOR);
    }
    
    
    void loop()
    {
      debouncer.update();
      int value = debouncer.read();
      if (value != oldValue) {
         gw.send(msg.set(value==HIGH ? 1 : 0));
         oldValue = value;
      }
    }
    
    


  • @conde said:

    I would greatly appreciate it. I like your project.

    Thanks for your help.

    Top_View_Reg.brd.jpg Top_View AVR.brd.jpg Bottom_View_Reg.brd.jpg Bottom_View AVR_Brd.jpg
    Area in yellow will cut off and the 2 boards will be joined together, to make 1 board.



  • @mntlvr said:

    / MySensorsDoor/Window sensor
    // Based on Attiny85
    // Revision 9/28/15 by BW
    // Author: Wiebe Nieuwenhuis
    // these are suggested wire colors but you can use any color you want,  just be consistent on all sensors
    //                    +-\/-+
    //  ORANGE   CE      1|o   |8  VCC   RED
    //  YELLOW   CSN     2|    |7  SCK   GREEN
    //  -        SENSOR  3|    |6  MOSI  BLUE
    //  BLACK    GND     4|    |5  MISO  VIOLET
    //                    +----+
    
    #include <MySensor.h>
    #include <Bounce2.h>
    
    #define SENSOR_INFO "Door sensor"
    #define NODE_ID 1 // Start numbering by 1 adding 1 each time you upload to new attiny85
    #define CHILD_ID 1 // this number must match above number
    #define INPUT_PIN 4 // This is ATiny input number pin # 3 is the physical pin
    
    MySensor gw;
    Bounce debouncer = Bounce(); 
    int oldValue = -1;
    
    MyMessage msg(NODE_ID, V_TRIPPED);
    
    void setup()
    {
      pinMode(INPUT_PIN, INPUT);
      digitalWrite(INPUT_PIN, HIGH);
      
      debouncer.attach(INPUT_PIN);
      debouncer.interval(5);
      
      gw.begin(NULL, NODE_ID, false, 0);
      gw.sendSketchInfo(SENSOR_INFO, "1.15");
      gw.present(CHILD_ID, S_DOOR);
    }
    
    
    void loop()
    {
      debouncer.update();
      int value = debouncer.read();
      if (value != oldValue) {
         gw.send(msg.set(value==HIGH ? 1 : 0));
         oldValue = value;
      }
    }
    
    

    Now if you eliminate the 3.3v regulator and run your Attiny off of just the battery you will save about 20ma. Now you will have to place a 1n4007 diode in series with the batteries + terminal and the sensors + input wire, having the cathode of the diode going to the battery +
    I am still working on a way to power down the nRF24l01+ transceiver. I have asked the members on this site for some help with this project..
    now I do power my units with a 5 vdc phone charger so right now I have to leave the 3.3 vdc regulator in the circuit.
    I also have modified the original sketch to put the Attiny85 to sleep for 2 to 4 sec. You would not what the door switch being left unmonitored for more time than that. Now I may also change this to use a pin change to immediately wake unit.
    Here is the code I am running as of now.

    *
     * Watchdog Sleep
     * Modified on 5 Feb 2011 by InsideGadgets (www.insidegadgets.com)
     * to suit the ATtiny85 and removed the cbi( MCUCR,SE ) section 
     * in setup() to match the Atmel datasheet recommendations
     */
    
    #include <avr/sleep.h>
    #include <avr/wdt.h>
    #include <MySensor.h>
    #include <Bounce2.h>
    
    #ifndef cbi
    #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
    #endif
    #ifndef sbi
    #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
    #endif
    
    #define SENSOR_INFO "Door sensor"
    #define NODE_ID 14 // Start numbering by 1 adding 1 each time you upload to new attiny85
    #define CHILD_ID 14 // this number must match above number
    #define INPUT_PIN 4
    
    // int pinLed = 0;
    volatile boolean f_wdt = 1;
    MySensor gw;
    Bounce debouncer = Bounce(); 
    int oldValue = -1;
    MyMessage msg(NODE_ID, V_TRIPPED);
    
    void setup(){
      pinMode(INPUT_PIN, INPUT);
      digitalWrite(INPUT_PIN, HIGH);
     
      setup_watchdog(8); // approximately 4 seconds sleep
      debouncer.attach(INPUT_PIN);
      debouncer.interval(5);
      gw.begin(NULL, NODE_ID, false, 0);
      gw.sendSketchInfo(SENSOR_INFO, "1.15");
      gw.present(CHILD_ID, S_DOOR);
    }
    
    void loop(){
      if (f_wdt==1) {  // wait for timed out watchdog / flag is set when a watchdog timeout occurs
        f_wdt=0;       // reset flag
      debouncer.update();
      int value = debouncer.read();
      if (value != oldValue) {
         gw.send(msg.set(value==HIGH ? 1 : 0));
         oldValue = value;
        system_sleep();
      }
    }
    }
    // set system into the sleep state 
    // system wakes up when wtchdog is timed out
    void system_sleep() {
      cbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter OFF
    
      set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
      sleep_enable();
    
      sleep_mode();                        // System sleeps here
    
      sleep_disable();                     // System continues execution here when watchdog timed out 
      sbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter ON
    }
    
    // 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms
    // 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec
    void setup_watchdog(int ii) {
    
      byte bb;
      int ww;
      if (ii > 9 ) ii=9;
      bb=ii & 7;
      if (ii > 7) bb|= (1<<5);
      bb|= (1<<WDCE);
      ww=bb;
    
      MCUSR &= ~(1<<WDRF);
      // start timed sequence
      WDTCR |= (1<<WDCE) | (1<<WDE);
      // set new watchdog timeout value
      WDTCR = bb;
      WDTCR |= _BV(WDIE);
    }
      
    // Watchdog Interrupt Service / is executed when watchdog timed out
    ISR(WDT_vect) {
      f_wdt=1;  // set global flag
    }```


  • @mntlvr I'm excited to see that mysensors is working with attiny. However, when I compile your code for UNO (can't compile for attiny85 on my IDE), I see the code is about 16kb, much larger than the size of the available memory in attiny85. Did you use a different library?



  • @ted said:

    @mntlvr I'm excited to see that mysensors is working with attiny. However, when I compile your code for UNO (can't compile for attiny85 on my IDE), I see the code is about 16kb, much larger than the size of the available memory in attiny85. Did you use a different library?
    Yes a mysensor library written for the Attiny85 chip. And also remember you need to either make a Attiny85 programmer or buy one. I think the 1st choice is the best. There are many articles on the Web that will guide you on how to build your own peogrammer. So do a little research and you will be greatly rewarded. Patience and perseverance will get you what you need and want.


Log in to reply
 

Suggested Topics

  • 1
  • 3
  • 3
  • 1
  • 2
  • 6

14
Online

11.4k
Users

11.1k
Topics

112.7k
Posts