arduino-shutters icon indicating copy to clipboard operation
arduino-shutters copied to clipboard

Calibration during the runtime

Open jmvaz opened this issue 3 years ago • 4 comments

How can we force one full calibration during the runtime? As an example, I have one contact sensor and I want to perform one reset/calibration of the shutter when this sensor is triggered. Is there a good way to do it? I tried calling shutters.reset() but nothing happens... Whats the purpose of this method?

jmvaz avatar Jul 30 '20 10:07 jmvaz

Hi, Every time when rollershuters reach 0% or 100% calibration is triggered, but You can setLevel(0) , wait at least upCourseTime + upCourseTime * _calibrationRatio and then setLevel(100) and wait at least downCourseTime + downCourseTime * _calibrationRatio.
reset() set courseTime to 0 and also erase storedState so shutters will stop working

klaudiusz223 avatar Jul 30 '20 20:07 klaudiusz223

My problem is the following I have an awning which has a wind sensor integrated. When he detects wind above the threshold he closes automatically. I want to put one magnetic sensor, which will detect when the awning closed in that particular situation. So, when the sensor closes, the shutter should be inicialized to 0 again. What I need to do to achieve this? I want to avoid setLevel (0) to avoid waiting for the closing time.

jmvaz avatar Jul 30 '20 22:07 jmvaz

What kind of signal gives this sensor?

  1. The awning has been closed after strong wind.
  2. The awning is closing because of strong wind
  3. The awning has started closing because of strong wind.

For the 2-nd and 3-rd option I would simply invoke shutters.setLevel(0) and maybe I would block manual steering of the awning for closing time. This solution could be also sufficient for first option but you could also try to modify library in Shutters::loop() . AFAIK there is no public method in the library to change level without invoking operationHandling method. So if above solution is not sufficient for the first option You can try something like that (arroud 202 line in Shutters.cpp):

if (awningClosedBecauseOfStrongWind) {  
      _currentLevel = 0;
      _storedState.setLevel(_currentLevel);
      _writeStateHandler(this, _storedState.getState(), STATE_LENGTH);
      _notifyLevel();
}

klaudiusz223 avatar Jul 31 '20 19:07 klaudiusz223

@klaudiusz223 thanks a lot for your help! My situation is the first option. I know that the awning is closed and is at position 0. Your code is very welcome, and I believe it works for my use case. But there is any way to do it without messing with the source code? I was thinking in inicialize the shutter again but passing the position as 0.

jmvaz avatar Jul 31 '20 21:07 jmvaz