Navigation

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

    xydix

    @xydix

    7
    Reputation
    68
    Posts
    889
    Profile views
    0
    Followers
    1
    Following
    Joined Last Online

    xydix Follow

    Best posts made by xydix

    • Smart button / scene controller

      The idea started when i bought a flic smart button.
      Today i use it to raise, lower and play/pause my chromecast audio.
      I want more buttons, actually a want more buttons doing the same thing.
      I have my flic in my kitchen. But when i am at my table? or in my couch?
      Of course, i could buy more flics. But..... Mysensors....
      To start with i will put these button under my tables for easy volume control.

      This is a sleeping node presenting it self as a scene controller.

      If someone want to try a sleeping mysensors smart button. Version 2.X compatible.
      Three functions from one button. Single click, double click and hold.
      You will need to install an external library called Onebutton. This is available in the library manager.

      This have been done before by @dakipro but that thread isn't that easy to find it you search and isn't 2.X compatible.
      By finding that very thread i solved the sleep.

      /*
        Mysensors Smart Button
      */
      
      #define MY_DEBUG
      #define MY_RADIO_NRF24
      
      #include "OneButton.h"
      #include <SPI.h>
      #include <MySensors.h>
      
      #define SN "MySmartButton"
      #define SV "1.0"
      #define CHILD_ID 1
      #define SLEEP_PIN 2
      // Setup a new OneButton on pin D2. true will set pin high (internal pull up), false will set pin low.
      OneButton button(2, true);
      unsigned long previousMillis = 0;
      unsigned long currentMillis = 0;
      const long interval = 5000;
      
      MyMessage on(CHILD_ID, V_SCENE_ON);
      
      // setup code here, to run once:
      void setup() {
      
        // link the doubleclick function to be called on a doubleclick event.
        button.attachClick(click);
        button.attachDoubleClick(doubleclick);
        button.attachPress(press);
      
      } // setup
      
      void presentation()  {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo(SN, SV);
        present(CHILD_ID, S_SCENE_CONTROLLER);
      }
      
      int messageA = 1;
      int messageB = 2;
      int messageC = 3;
      
      
      void loop() {
        currentMillis = millis();
        // keep watching the push button:
        button.tick();
      
        if (currentMillis - previousMillis >= interval) {
          Serial.println("Sleep");
          previousMillis = currentMillis;
          sleep(SLEEP_PIN - 2, CHANGE, 0);
        }
      } // loop
      // this function will be called when the button was pressed one time
      
      void click() {
        send(on.set(messageA));
      }
      // this function will be called when the button was pressed 2 times in a short timeframe.
      void doubleclick() {
        send(on.set(messageB));
      } // doubleclick
      // this function will be called when the button was pressed for about one second
      void press() {
        send(on.set(messageC));
      }
      

      It isn't reporting battery state yet.
      I will add that to the sketch later when i build my button node.
      Maybe i update this thread later when that is done if someone is interested.

      EDIT 2017-06-26
      Some pics.
      0_1498514681220_IMG_20170619_234627.jpg
      0_1498514728022_IMG_20170622_225859.jpg
      0_1498514691129_IMG_20170622_225651.jpg
      0_1498514754436_IMG_20170622_225715.jpg

      posted in My Project
      xydix
      xydix
    • RE: πŸ’¬ Dimmable Led Strip board (MysX)

      FYI...
      12v = Mosfet = irlz44n, Voltage Reg (12 to 5v) = LM2940CT-5
      24v = Mosfet = ???, Voltage reg (24 to 5v) = ???

      I think IRZL44N will handle 24V.

      posted in OpenHardware.io
      xydix
      xydix
    • RE: New nodes, new problems :/ Motion sensor [Solved]

      Thank you @martinhjelmare for that answer. It explains it. i Can confirm this is the issue.
      The pir i am using is this one, the mini pir.
      http://www.ebay.com/itm/121880058682?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

      I tried another pir, the HC-SR501 (http://www.ebay.com/itm/201414880948?rmvSB=true)
      This pir is working ok with the node as it is.
      First i tried an 100uF capacitor as @gohan suggested, but it didn't help.
      Now i tried an 470uF capacitor and it seems to be fine with the mini pir.

      @Vladimir-Dobrikov my radio already got an 100uF for the 3,3V circuit.
      Im am still testing but the node it seems fine for now.
      Thank you all for the help.

      posted in Home Assistant
      xydix
      xydix
    • RE: Pro mini

      @Oitzu
      Thanks for the quick reply.
      Nice to got that sorted out.
      Thank you.

      posted in Hardware
      xydix
      xydix
    • RE: πŸ’¬ MyPulse Sensor

      Hi. Thank you for sharing your board. It seems awesome. I got a question. When I read the BOM, I think I should use 100 ohm, 330 ohm and 1500 ohm resistor. When I look at the schematic picture it says 100k 330k. What resistor should I use?

      posted in OpenHardware.io
      xydix
      xydix
    • RE: New nodes, new problems :/ Motion sensor [Solved]

      I guess this thread should be in the hardware forum.
      But if someone find this thread i can share some pictures and the idea with this node.
      I built it as a USB-stick with a USB-connector on a prototype PCB.
      Not good looking but when i get my TV up on the wall you can't see it.
      I use it to turn on light in the bathroom at night if my kids visit the toilet.
      0_1491467736631_IMG_20170406_102320.jpg
      0_1491467746038_IMG_20170406_102342.jpg

      posted in Home Assistant
      xydix
      xydix
    • RE: Arduino UNO R3 maximum current?

      0_1485424008444_IMG_20170125_205415.jpg
      Not so fancy but this is how I did. It will do for now.
      This is the 5V pin under the USB connector.
      Now I get 5V directly from my USB power supply.

      posted in Hardware
      xydix
      xydix

    Latest posts made by xydix

    • RE: Curtain Control Node.

      @adds666
      I am still in "testing mode".
      I had some problems with the node, it stoped receiving messages but did always work with the button.
      Yesterday i built a new node and uploaded the sketch and it seems to work better.
      Here is the sketch i use, I changed the pin for the button due to missing digital pins on my pcb.
      And I am back on using digital pins for the stepper driver for the same reason.
      I greyed out buttonpin 2. I don't think it is needed.
      I also greyed out the heartbeat-part as I had problems. Just for testing. Don't know if it is suitable when using Home Assistant.

      /*
       PROJECT: MY Sensors curtain controller
       PROGRAMMER: AWI
       DATE: march 11, 2016
       FILE: AWI stepper1.ino
       LICENSE: Public domain
      
       Hardware: ATMega328p board w/ NRF24l01
        and MySensors 2.0 (Development)
          
      Special:
        uses AccelStepper library
        
      Summary:
        Curtain control with stepper motor. 
        Manual operation with 1 push button 
        Calibration with manual button
      
      Remarks:
        Fixed node-id
        
      Change log:
      20160312 - Cleanup
      */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      #define MY_NODE_ID 8                     // fixed node number
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      #define MY_RF24_PA_LEVEL RF24_PA_HIGH
      //#define MY_RADIO_RFM69
      
      #include <SPI.h>
      #include <MySensors.h> 
      
      // stepper library
      #include <AccelStepper.h>                   // http://www.airspayce.com/mikem/arduino/AccelStepper/
      #define HALFSTEP 8                        // Stepper uses "Halfstep" mode
      
      // button library
      // used for:
      // - manual open close - single click: close/ stop/ open/ stop
      // - calibration  - after long press: open calibarion- until single press - closed calibration - until single press (stop)
      #include <Button.h>                       // https://github.com/JChristensen/Button - AnvΓ€nd gammal version. testat med V0.9 och det funkar
      
      #define CHILD_ID 1                        // Id of the sensor child
      
      #define SN "Curtain control"
      #define SV "1.0"
      
      #define buttonPin1 A0                        // Arduino pin connected to buttonPin1
      //#define buttonPin2 A0                       // Arduino pin connected to buttonPin2 (fixed to ground)
      
      // Motor pin definitions
      #define motorPin1  2                        // IN1 on the ULN2003 driver 1
      #define motorPin2  3                        // IN2 on the ULN2003 driver 1
      #define motorPin3  5                        // IN3 on the ULN2003 driver 1
      #define motorPin4  6                        // IN4 on the ULN2003 driver 1
      
      //const unsigned long heartbeatInterval = 1 * 3600UL * 1000UL ; // heartbeatinterval
      //unsigned long heartbeatCounter = 0 ;
      
      //
      // helper routines to store and retrieve long in mysensors EEPROM
      union {                             // used to convert long to bytes for EEPROM storage
        long longInt;
        uint8_t LongByte[4];
        } convLongInt ;
      
      void saveStateL(int EEposition, long StateL){
        convLongInt.longInt = StateL ;
        for (int y = 0; y < 4 ; y++){               // convert to bytes
          saveState(EEposition + y , convLongInt.LongByte[y]) ;
          }
        Serial.print("State saved: "); Serial.println(StateL);
        }
          
      long loadStateL(int EEposition){
        for (int y = 0; y < 4 ; y++){               // convert from bytes
          convLongInt.LongByte[y] = loadState(EEposition + y) ;
          }
        Serial.print("State read: "); Serial.println(convLongInt.longInt);
        return convLongInt.longInt ;
        }
        
      
      // Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
      AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
      // Initialize button active low, debounce and internal pull-up
      Button myBtn(buttonPin1, true, true, 40);           // Initiate the button (pin, pull_up, invert, debounce_ms)
      
      MyMessage percentageMsg(CHILD_ID, V_PERCENTAGE);        // used to send updates to controller
      
      const long maxRun = 4000000L ;                  // maximum runway
      long setPosition = 0 ;                      // remembers set position, need to be saved in EEPROM
      const int setPositionEE = 4 ;                 // eeprom location
      long openPosition = 0 ;                     // Position at open, need to be saved in EEPROM?
      const int openPositionEE = setPositionEE + 4 ;          // eeprom location
      long closedPosition = 120000UL ;                // Position at full close, need to be saved in EEPROM
      const int closedPositionEE = openPositionEE + 4 ;       // eeprom location
      
      unsigned long idleTimer = millis() ;              // return to idle timer
      unsigned long idleTime = 100000UL ;               // return to idle after 100 secs
      
      unsigned long printTimer = millis() ;             // print timer
      unsigned long printTime = 1000UL ;                // print after 1 secs
      
      enum position_t {Open, Close, Idle, Running} ;
      position_t lastDirection = Open ;                 // lastDirection only for buttonpress
      position_t runStatus = Idle ;                 // indicates current status for running motor. used for status reporting to controller
      
      enum State_t {sIdle, sCalibrateOpen, sCalibrateClose} ;
      State_t State = sIdle ;
      
      
      void setup() {
        // setup buttons
        pinMode(buttonPin1, OUTPUT);
        stepper1.setMaxSpeed(1000.0);
        stepper1.setAcceleration(1000.0);
        //saveStateL(closedPositionEE, closedPosition) ;      // INIT: save closed position in EEPROM
        closedPosition = loadStateL(closedPositionEE) ;       // need to get last values from EEPROM and assume the current position is correct
        setPosition = loadStateL(setPositionEE) ;
        stepper1.setCurrentPosition(setPosition );
      }//--(end setup )---
      
      void presentation() {
        present(CHILD_ID, S_COVER, "Curtain");            // Window Cover sub-type, commands: V_UP, V_DOWN, V_STOP
      
        // Register the LED Dimmable Light with the gateway
        sendSketchInfo(SN, SV);
      }
      
      
      void loop() {
      unsigned int now = millis() ;               // current time for loop
      // simple state machine for button press
        myBtn.read();  
        switch (State) {
              // Idle state, waiting for some action
          // - button press
          // - idleTimer
              case sIdle:                
                  if (myBtn.wasReleased()){           // idle
              Serial.println("Button release") ;
              // if running stop
              if (stepper1.isRunning()){
                setPosition = stepper1.currentPosition();
                stepper1.moveTo(setPosition) ;      // move to current position (was already there..)
              } else if (lastDirection == Open) {
                stepper1.moveTo(closedPosition) ;
                lastDirection = Close ;
              } else {                  // lastDirection == Close
                stepper1.moveTo(openPosition) ;
                lastDirection = Open ;
              } 
            } else if (myBtn.pressedFor(3000)){       // move to calibratete state with long press
              Serial.println("Button press long") ;
              idleTimer = now ;             // return to idle after ...
              State = sCalibrateOpen ;
              stepper1.move(-maxRun) ;          // let the stepper open with maximum
              }
            break ;
          // if not running and last action was open close ;  else open
          // if longpress Calibrate open
              case sCalibrateOpen:                      // calibration going on     
            if (myBtn.wasPressed()){
              stepper1.setCurrentPosition(0 );    // set new 0 position ??
              openPosition = setPosition = 0 ;
              State = sCalibrateClose ;         // next is close calibarion
              stepper1.move(maxRun) ;           // let the stepper close with maximum
            } else if (now > idleTimer + idleTime) {    // timer expired -> abort calibration
              State = sIdle ;
            }
            break ;
              case sCalibrateClose:               // calibrate closed position, end with keypress
            if (myBtn.wasPressed()) {
              closedPosition = setPosition = stepper1.currentPosition() ;
              saveStateL(closedPositionEE, closedPosition) ; // save closed position in EEPROM
              State = sIdle ;
              stepper1.moveTo(openPosition) ;       // return to open after calibration
            } else if (now > idleTimer + idleTime) {    // timer expired -> abort calibration
              State = sIdle ;
            }
            break ;
          default :
            break ;
          }
        // power off stepper if not running (no need to reenable))
        if (!stepper1.isRunning()){
          if (runStatus != Idle){               // there was a change in runningstatus, so report to controller
            setPosition = stepper1.currentPosition() ;    // store in EEPROM and report ready to controller
            saveStateL(setPositionEE, setPosition) ;
            send( percentageMsg.set((100 * setPosition)/(closedPosition - openPosition))) ;
            runStatus = Idle ;
          }
          stepper1.disableOutputs();
        } else {
          runStatus = Running ;
        }
        stepper1.run();
        /*
        if (printTimer++ > now + printTime){
          printTimer = now ;
          Serial.println(stepper1.currentPosition());
          }
        */
      }
      
      // This is called when a message is received 
      void receive(const MyMessage &message) {
      // We only expect few types of messages from controller, check which
        switch (message.type) {
        case V_PERCENTAGE:
        // Curtain should be opened
        stepper1.moveTo(message.getInt() * (closedPosition - openPosition)/100);
        Serial.print("Message: "); Serial.print(message.sensor); Serial.print(" , value: % "); Serial.println( message.getInt());
        Serial.print("Moving to: "); Serial.println(message.getInt() * (closedPosition - openPosition)/100);
        break ;
        case V_STATUS:
        // Curtain should be opened or closed full
        stepper1.moveTo((message.getInt() == HIGH)?openPosition:closedPosition);
        Serial.print("Message - valid: ");
        Serial.print(message.sensor);
        Serial.print(" , value: % ");
        break ;
        default : 
        // not recognizable message
        Serial.print("Message - valid: ");
        Serial.print(message.sensor);
        Serial.print(", Unrecognized ");
        break ;
        }
        }
      
      posted in My Project
      xydix
      xydix
    • RE: Curtain Control Node.

      @adds666 What i can tell it was a long time since @AWI was active here.
      I use this sketch with my first bild since a couple of days.
      For me it works like a charm. But in my case I control the motor from analog pins just to test and it seems OK.
      No problem with the button.
      The only thing I don't like, is the calibration.
      I my case, using this on a blind, when calibrating, first it goes down, then i press the button, the blind stops at once and change it's direction and goes up. But when i reach the top level and want to stop it and save the state, it stops slow and pass the point i pressed the button and then reverse to the right spot. Problem is, the blind can't go further because it is in the top position.
      If it would be the other way around it wouldn't be a problem.
      Maybe i have the motor one the "wrong" side of the blind but when it is down the "downkey" in my HA is greyed out.
      When it i up the "upkey" it greyed out so that seems right.

      What is not working in your case?
      What motor do you use? I use 28BYJ-48 with ULN2003 and had to set stepper1.setMaxSpeed(2000.0); to stepper1.setMaxSpeed(1000.0); because the motor "slipped" at a speed of 2000.
      Like i wrote earlier in the thread I tried to figure out how to "dublicate" the sketch and ute it for two motors.
      I really don't know where to start to get this done. It would be awesome to use one arduino with two blinds.

      posted in My Project
      xydix
      xydix
    • RE: Problem with Wind Speed sensor

      Anyone got a working sketch for a pulse anenometer?
      I printed this. https://www.thingiverse.com/thing:2523343
      I used it with ESPHome as testing it and I got OK values.
      Now i would like to use it with mysensors.
      I tried @AWI s sketch but I get stange readings.
      Sometimes I get a very high value when is turns slow.

      posted in Troubleshooting
      xydix
      xydix
    • RE: Curtain Control Node.

      @xydix
      To answer my own question the stepper runs fine from the analog pins.
      Next step is to find some intersted in the same thing and see if we could get the sketch adjusted to run two steppers.
      I will try when i get some time but I guess I will have problem to clone the calibration and store-to-eerprom-part.

      posted in My Project
      xydix
      xydix
    • RE: Curtain Control Node.

      @ton-rijnaard
      Hi. This was a problem for me to. The reason is the library changed name and updates was made.
      I use the library version 0.9.
      I have like zero skills in arduino. If you use the old library the button will work with the sketch i posted a moth ago.
      Looke here: https://github.com/JChristensen/JC_Button/releases
      Maybe some of the other older releases will work. Don't remember why o choose V0.9
      Look at 2.0.0, "This is a major release that is not backwards-compatible with previous releases."

      posted in My Project
      xydix
      xydix
    • RE: πŸ’¬ MyPulse Sensor

      @scalz
      I guess you have the answer to that questionπŸ‘†?

      posted in OpenHardware.io
      xydix
      xydix
    • RE: Curtain Control Node.

      Okey. This is an old thread but I hope it's ok I keep it alive.
      I just printed som parts for my blinds.
      I use a stepper motor (28BYJ-48 with ULN2003 Driver board) and this sketch found in this thread.
      The sketch is awesome.
      To my quiestion.
      I want to run 2 blinds at the same time from ONE node. Synchronized or maybe individual.
      Is this possible?
      There isn't any digital pins over for this when using button(s).
      I think i saw someone using analog pin connected to the ULN2003 someware.
      Is it possible to run 2 motors on one board?
      Really hope somone can answer som of my question.
      What modifications is needed in the sketch if this is possible.
      This is the sketch I use.

      /*
       PROJECT: MY Sensors curtain controller
       PROGRAMMER: AWI
       DATE: march 11, 2016
       FILE: AWI stepper1.ino
       LICENSE: Public domain
      
       Hardware: ATMega328p board w/ NRF24l01
      	and MySensors 2.0 (Development)
      		
      Special:
      	uses AccelStepper library
      	
      Summary:
      	Curtain control with stepper motor. 
      	Manual operation with 1 push button 
      	Calibration with manual button
      
      Remarks:
      	Fixed node-id
      	
      Change log:
      20160312 - Cleanup
      */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      #define MY_NODE_ID 13											// fixed node number
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_RFM69
      
      #include <SPI.h>
      #include <MySensors.h> 
      
      // stepper library
      #include <AccelStepper.h>										// http://www.airspayce.com/mikem/arduino/AccelStepper/
      #define HALFSTEP 8  											// Stepper uses "Halfstep" mode
      
      // button library
      // used for:
      // - manual open close - single click: close/ stop/ open/ stop
      // - calibration  - after long press: open calibarion- until single press - closed calibration - until single press (stop)
      #include <Button.h>												// https://github.com/JChristensen/Button
      
      #define CHILD_ID 1   											// Id of the sensor child
      
      #define SN "Curtain control 13"
      #define SV "1.0"
      
      #define buttonPin1 7  											// Arduino pin connected to buttonPin1
      #define buttonPin2 A0  											// Arduino pin connected to buttonPin2 (fixed to ground)
      
      // Motor pin definitions
      #define motorPin1  3     										// IN1 on the ULN2003 driver 1
      #define motorPin2  4     										// IN2 on the ULN2003 driver 1
      #define motorPin3  5     										// IN3 on the ULN2003 driver 1
      #define motorPin4  6     										// IN4 on the ULN2003 driver 1
      
      const unsigned long heartbeatInterval = 1 * 3600UL * 1000UL ;	// heartbeatinterval
      unsigned long heartbeatCounter = 0 ;
      
      //
      // helper routines to store and retrieve long in mysensors EEPROM
      union {															// used to convert long to bytes for EEPROM storage
      	long longInt;
      	uint8_t LongByte[4];
      	} convLongInt ;
      
      void saveStateL(int EEposition, long StateL){
      	convLongInt.longInt = StateL ;
      	for (int y = 0; y < 4 ; y++){								// convert to bytes
      		saveState(EEposition + y , convLongInt.LongByte[y]) ;
      		}
      	Serial.print("State saved: "); Serial.println(StateL);
      	}
      		
      long loadStateL(int EEposition){
      	for (int y = 0; y < 4 ; y++){								// convert from bytes
      		convLongInt.LongByte[y] = loadState(EEposition + y) ;
      		}
      	Serial.print("State read: "); Serial.println(convLongInt.longInt);
      	return convLongInt.longInt ;
      	}
      	
      
      // Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
      AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
      // Initialize button active low, debounce and internal pull-up
      Button myBtn(buttonPin1, true, true, 40);						// Initiate the button (pin, pull_up, invert, debounce_ms)
      
      MyMessage percentageMsg(CHILD_ID, V_PERCENTAGE);				// used to send updates to controller
      
      const long maxRun = 4000000L ;									// maximum runway
      long setPosition = 0 ; 											// remembers set position, need to be saved in EEPROM
      const int setPositionEE = 4 ;									// eeprom location
      long openPosition = 0 ; 										// Position at open, need to be saved in EEPROM?
      const int openPositionEE = setPositionEE + 4 ;					// eeprom location
      long closedPosition = 120000UL ; 								// Position at full close, need to be saved in EEPROM
      const int closedPositionEE = openPositionEE + 4 ;				// eeprom location
      
      unsigned long idleTimer = millis() ;							// return to idle timer
      unsigned long idleTime = 100000UL ;								// return to idle after 100 secs
      
      unsigned long printTimer = millis() ;							// print timer
      unsigned long printTime = 1000UL ;								// print after 1 secs
      
      enum position_t {Open, Close, Idle, Running} ;
      position_t lastDirection = Open ; 								// lastDirection only for buttonpress
      position_t runStatus = Idle ;									// indicates current status for running motor. used for status reporting to controller
      
      enum State_t {sIdle, sCalibrateOpen, sCalibrateClose} ;
      State_t State = sIdle ;
      
      
      void setup() {
      	// setup buttons
      	pinMode(buttonPin1, OUTPUT);
      	stepper1.setMaxSpeed(2000.0);
      	stepper1.setAcceleration(1000.0);
      	//saveStateL(closedPositionEE, closedPosition) ; 			// INIT: save closed position in EEPROM
      	closedPosition = loadStateL(closedPositionEE) ;				// need to get last values from EEPROM and assume the current position is correct
      	setPosition = loadStateL(setPositionEE) ;
      	stepper1.setCurrentPosition(setPosition );
      }//--(end setup )---
      
      void presentation() {
        present(CHILD_ID, S_COVER, "Curtain");						// Window Cover sub-type, commands: V_UP, V_DOWN, V_STOP
      
        // Register the LED Dimmable Light with the gateway
        sendSketchInfo(SN, SV);
      }
      
      
      void loop() {
      unsigned int now = millis() ;								// current time for loop
      // simple state machine for button press
      	myBtn.read();  
      	switch (State) {
              // Idle state, waiting for some action
      		// - button press
      		// - idleTimer
              case sIdle:                
                  if (myBtn.wasReleased()){						// idle
      				Serial.println("Button release") ;
      				// if running stop
      				if (stepper1.isRunning()){
      					setPosition = stepper1.currentPosition();
      					stepper1.moveTo(setPosition) ;			// move to current position (was already there..)
      				} else if (lastDirection == Open) {
      					stepper1.moveTo(closedPosition) ;
      					lastDirection = Close ;
      				} else {									// lastDirection == Close
      					stepper1.moveTo(openPosition) ;
      					lastDirection = Open ;
      				}	
      			} else if (myBtn.pressedFor(3000)){				// move to calibratete state with long press
      				Serial.println("Button press long") ;
      				idleTimer = now ;							// return to idle after ...
      				State = sCalibrateOpen ;
      				stepper1.move(-maxRun) ;					// let the stepper open with maximum
      				}
      			break ;
      		// if not running and last action was open close ;  else open
      		// if longpress Calibrate open
              case sCalibrateOpen:           						// calibration going on     
      			if (myBtn.wasPressed()){
      				stepper1.setCurrentPosition(0 );		// set new 0 position ??
      				openPosition = setPosition = 0 ;
      				State = sCalibrateClose ;					// next is close calibarion
      				stepper1.move(maxRun) ;						// let the stepper close with maximum
      			} else if (now > idleTimer + idleTime) {		// timer expired -> abort calibration
      				State = sIdle ;
      			}
      			break ;
              case sCalibrateClose:								// calibrate closed position, end with keypress
      			if (myBtn.wasPressed())	{
      				closedPosition = setPosition = stepper1.currentPosition() ;
      				saveStateL(closedPositionEE, closedPosition) ; // save closed position in EEPROM
      				State = sIdle ;
      				stepper1.moveTo(openPosition) ;				// return to open after calibration
      			} else if (now > idleTimer + idleTime) {		// timer expired -> abort calibration
      				State = sIdle ;
      			}
      			break ;
      		default :
      			break ;
      		}
      	// power off stepper if not running (no need to reenable))
      	if (!stepper1.isRunning()){
      		if (runStatus != Idle){								// there was a change in runningstatus, so report to controller
      			setPosition = stepper1.currentPosition() ;		// store in EEPROM and report ready to controller
      			saveStateL(setPositionEE, setPosition) ;
      			send( percentageMsg.set((100 * setPosition)/(closedPosition - openPosition))) ;
      			runStatus = Idle ;
      		}
      		stepper1.disableOutputs();
      	} else {
      		runStatus = Running ;
      	}
      	stepper1.run();
      	/*
      	if (printTimer++ > now + printTime){
      		printTimer = now ;
      		Serial.println(stepper1.currentPosition());
      		}
      	*/
      }
      
      // This is called when a message is received 
      void receive(const MyMessage &message) {
      // We only expect few types of messages from controller, check which
        switch (message.type) {
      	case V_PERCENTAGE:
      	// Curtain should be opened
      	stepper1.moveTo(message.getInt() * (closedPosition - openPosition)/100);
      	Serial.print("Message: "); Serial.print(message.sensor); Serial.print(" , value: % "); Serial.println( message.getInt());
      	Serial.print("Moving to: "); Serial.println(message.getInt() * (closedPosition - openPosition)/100);
      	break ;
      	case V_STATUS:
      	// Curtain should be opened or closed full
      	stepper1.moveTo((message.getInt() == HIGH)?openPosition:closedPosition);
      	Serial.print("Message - valid: ");
      	Serial.print(message.sensor);
      	Serial.print(" , value: % ");
      	break ;
      	default : 
      	// not recognizable message
      	Serial.print("Message - valid: ");
      	Serial.print(message.sensor);
      	Serial.print(", Unrecognized ");
      	break ;
      	}
        }
      
      posted in My Project
      xydix
      xydix
    • RE: πŸ’¬ MyPulse Sensor

      Hi. Thank you for sharing your board. It seems awesome. I got a question. When I read the BOM, I think I should use 100 ohm, 330 ohm and 1500 ohm resistor. When I look at the schematic picture it says 100k 330k. What resistor should I use?

      posted in OpenHardware.io
      xydix
      xydix
    • RE: πŸ’¬ Battery operated rain-gauge

      @heizelmann Hi. Sorry if I wake an old thread.
      Do you still have your code?
      I am about to build a rain gauge and want it to run on battery.
      Your way to handle things is what I am looking for.
      Would you like to share your code?

      posted in OpenHardware.io
      xydix
      xydix
    • smartSleep with 2.3.0, missing messages

      Hi.
      I went from 2.1.1 to 2.3.0 hoping I would get a more stable network.
      When i did this I tried some OTA and went from sleep to smartSleep in some sketches.
      My problem. it's a binary sensor node reading a blinking LED.
      But if the LED blink too fast the node won't send the state change.
      I only get:

      718	2018-10-05 21:59:52	RX	5 - Pannrum	INTERNAL	C_INTERNAL	NO	I_POST_SLEEP_NOTIFICATION	0
      719	2018-10-05 21:59:52	RX	5 - Pannrum	1 - S_DOOR	C_SET	NO	V_TRIPPED	0
      720	2018-10-05 21:59:52	RX	5 - Pannrum	INTERNAL	C_INTERNAL	NO	I_BATTERY_LEVEL	100
      721	2018-10-05 21:59:52	RX	5 - Pannrum	INTERNAL	C_INTERNAL	NO	I_PRE_SLEEP_NOTIFICATION	50
      722	2018-10-05 21:59:53	RX	5 - Pannrum	INTERNAL	C_INTERNAL	NO	I_POST_SLEEP_NOTIFICATION	0
      723	2018-10-05 21:59:53	RX	5 - Pannrum	INTERNAL	C_INTERNAL	NO	I_BATTERY_LEVEL	100
      724	2018-10-05 21:59:53	RX	5 - Pannrum	INTERNAL	C_INTERNAL	NO	I_PRE_SLEEP_NOTIFICATION	50
      725	2018-10-05 21:59:54	RX	5 - Pannrum	INTERNAL	C_INTERNAL	NO	I_POST_SLEEP_NOTIFICATION	0
      726	2018-10-05 21:59:54	RX	5 - Pannrum	1 - S_DOOR	C_SET	NO	V_TRIPPED	1
      727	2018-10-05 21:59:54	RX	5 - Pannrum	INTERNAL	C_INTERNAL	NO	I_BATTERY_LEVEL	100
      728	2018-10-05 21:59:54	RX	5 - Pannrum	INTERNAL	C_INTERNAL	NO	I_PRE_SLEEP_NOTIFICATION	50
      

      This is from MYSController, what the gateway see.
      As you see sometimes i Only get the presleep, postsleep and battery, not the C_SET/ Value.

      Some from serial monitor but not the exact same time as the log above.

      51511 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=2,st=OK:
      53624 !TSM:FPAR:NO REPLY
      53641 TSM:FPAR
      53706 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      55246 TSF:MSG:READ,4-4-5,s=255,c=3,t=8,pt=1,l=1,sg=0:1
      55312 TSF:MSG:FPAR OK,ID=4,D=2
      55803 TSM:FPAR:OK
      55820 TSM:ID
      55836 TSM:ID:OK
      55853 TSM:UPL
      55902 TSF:MSG:SEND,5-5-4-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      56213 !TSF:SND:TNR
      56229 !TSF:SND:TNR
      57999 TSM:UPL
      58032 TSF:MSG:SEND,5-5-4-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      60129 TSM:UPL
      60178 !TSF:MSG:SEND,5-5-4-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1
      61276 !TSF:SND:TNR
      62275 TSM:UPL
      62308 TSF:MSG:SEND,5-5-4-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=1,st=OK:1
      64405 !TSM:UPL:FAIL
      64421 TSM:FPAR
      64471 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      64667 TSF:MSG:READ,4-4-5,s=255,c=3,t=8,pt=1,l=1,sg=0:1
      64733 TSF:MSG:FPAR OK,ID=4,D=2
      66322 !TSF:SND:TNR
      66584 TSM:FPAR:OK
      66600 TSM:ID
      66617 TSM:ID:OK
      66633 TSM:UPL
      66682 TSF:MSG:SEND,5-5-4-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      68763 TSM:UPL
      68780 TSF:MSG:SEND,5-5-4-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      70877 TSM:UPL
      70893 TSF:MSG:SEND,5-5-4-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      70975 TSF:MSG:READ,0-4-5,s=255,c=3,t=25,pt=1,l=1,sg=0:2
      71041 TSF:MSG:PONG RECV,HP=2
      71073 TSM:UPL:OK
      71106 TSM:READY:ID=5,PAR=4,DIS=2
      71368 TSF:MSG:SEND,5-5-4-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:100
      71450 MCO:SLP:MS=0,SMS=1,I1=0,M1=1,I2=1,M2=1
      71516 TSF:MSG:SEND,5-5-4-0,s=255,c=3,t=32,pt=5,l=4,sg=0,ft=0,st=OK:100
      71712 TSF:TDI:TSL
      

      The sketch.

      /**
         The MySensors Arduino library handles the wireless radio link and protocol
         between your home built sensors/actuators and HA controller of choice.
         The sensors forms a self healing radio network with optional repeaters. Each
         repeater and gateway builds a routing tables in EEPROM which keeps track of the
         network topology allowing messages to be routed to nodes.
      
         Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
         Copyright (C) 2013-2015 Sensnology AB
         Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
      
         Documentation: http://www.mysensors.org
         Support Forum: http://forum.mysensors.org
      
         This program is free software; you can redistribute it and/or
         modify it under the terms of the GNU General Public License
         version 2 as published by the Free Software Foundation.
      
       *******************************
      
         DESCRIPTION
      
         Interrupt driven binary switch example with dual interrupts
         Author: Patrick 'Anticimex' Fallberg
         Connect one button or door/window reed switch between
         digitial I/O pin 3 (BUTTON_PIN below) and GND and the other
         one in similar fashion on digital I/O pin 2.
         This example is designed to fit Arduino Nano/Pro Mini
      
      */
      
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      #define MY_BAUD_RATE 9600
      #define MY_SMART_SLEEP_WAIT_DURATION_MS 100
      
      #define MY_NODE_ID 5
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      #define MY_RF24_PA_LEVEL RF24_PA_MAX
      
      #include <SPI.h>
      #include <MySensors.h>
      #include <Vcc.h>
      
      #define SKETCH_NAME "Pannrum"
      #define SKETCH_MAJOR_VER "1"
      #define SKETCH_MINOR_VER "0"
      
      #define PRIMARY_CHILD_ID 1
      #define SECONDARY_CHILD_ID 2
      
      #define PRIMARY_INPUT_PIN 2   // Arduino Digital I/O pin for button/reed switch
      #define SECONDARY_INPUT_PIN 3
      
      const float VccMin   = 1.9;           // Minimum expected Vcc level, in Volts. (NRF can only go to 1.9V)
      const float VccMax   = 3.3;           // Maximum expected Vcc level, in Volts.
      const float VccCorrection = 1.0 / 1.0; // Measured Vcc by multimeter divided by reported Vcc
      
      Vcc vcc(VccCorrection);
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED);
      MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED);
      
      void setup()
      {
      
        // Setup the buttons
        pinMode(PRIMARY_INPUT_PIN, INPUT);
        pinMode(SECONDARY_INPUT_PIN, INPUT);
      
        // Activate internal pull-ups
        //  digitalWrite(INPUT1_PIN, HIGH);
      
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
      
        // Register binary input sensor to sensor_node (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.
        present(PRIMARY_CHILD_ID, S_DOOR);
        present(SECONDARY_CHILD_ID, S_DOOR);
      }
      
      // Loop will iterate on changes on the BUTTON_PINs
      void loop()
      {
        uint8_t value;
        static uint8_t sentValue = 2;
        static uint8_t sentValue2 = 2;
      
        // Short delay to allow buttons to properly settle
        wait(5);
      
        value = digitalRead(PRIMARY_INPUT_PIN);
      
        if (value != sentValue) {
          // Value has changed from last transmission, send the updated value
          send(msg.set(value == HIGH));
          sentValue = value;
        }
      
        value = digitalRead(SECONDARY_INPUT_PIN);
      
        if (value != sentValue2) {
          // Value has changed from last transmission, send the updated value
          send(msg2.set(value == HIGH));
          sentValue2 = value;
        }
      
      
        float  p = vcc.Read_Perc(VccMin, VccMax);
        sendBatteryLevel((uint8_t)p);
      
      
      // Sleep until something happens with the sensor
      if (isTransportReady()) {
        smartSleep(PRIMARY_INPUT_PIN-2, CHANGE, SECONDARY_INPUT_PIN-2, CHANGE, 0); // transport is OK, node can sleep
      }
      else {
        wait(5000); // transport is not operational, allow the transport layer to fix this
      }
      
      
      } 
      

      I tried This, just replacing all three files in the RF24 folder. Loading this to the sensor but it didn't help.

      posted in Troubleshooting
      xydix
      xydix