Mysensored Garageport

  • Admin

    I've been working on adding mysensor support for my automatic garage ports.

    I started out with this port opener :

    popping the cover off, and started measuring in it, I found out that it has a PWM controlled motor, and two relays which reverses the power supply to the motor. Also there is an activate input, so you can have a switch on the wall to open the ports without a remote.

    Everything runs on 5V inside.

    So I created a quick sensor with one of my leftover boards for the sensebender micro, this one only got an atmega328 on it, since I am running on 5V, and sensor / eeprom is 3V only.

    D3 is input from the relay driver activated when OPENING the port
    D4 is input from the relay driver activated when CLOSING the port
    D5 is output controlling light in the controller
    D6 is output activate port pin (driving this to GND will start the motor)
    D7 is input from the original controller, that controls the light.

    With this setup, I can control the light from mysensor network, and can start / stop the motor. I can also detect if motor is opening or closing the port.



    And a "rough" sketch for the port controller firmware 🙂

    #include <MySensor.h>
    #include <SPI.h>
    MySensor gw;
    MyMessage msgPort(1, V_STOP);
    MyMessage msgLight(2, V_LIGHT);
    int direction = V_TEMP;
    #define CLOSE_PIN 3
    #define OPEN_PIN  4
    #define LIGHT_PIN    5
    #define ACTIVATE_PIN 6
    #define LIGHT_IN_PIN 7
    #define TIME_TO_ACTIVATE_PORT 30000
    bool last_light_state = false;
    void setup()  
      // Initialize library and add callback for incoming messages
      gw.begin(incomingMessage, 8, true);
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Garage", "1.0");
      // Fetch relay status
      pinMode(CLOSE_PIN, INPUT);
      pinMode(OPEN_PIN, INPUT);
      pinMode(LIGHT_PIN, OUTPUT);
      pinMode(ACTIVATE_PIN, INPUT);
      pinMode(LIGHT_IN_PIN, INPUT);
      gw.present(1, S_COVER); // GaragePort
      gw.present(2, S_LIGHT); // Light
      digitalWrite(LIGHT_PIN, LOW);
    void loop() 
      int incomming = 0;
      // Alway process incoming messages whenever possible
      if (digitalRead(OPEN_PIN)) {
      if (digitalRead(CLOSE_PIN)) {
      if (!digitalRead(OPEN_PIN) & !digitalRead(CLOSE_PIN)) {
      if (digitalRead(LIGHT_IN_PIN) != last_light_state) {
        Serial.print("Turning light ");
        digitalWrite(LIGHT_PIN, digitalRead(LIGHT_IN_PIN));
        last_light_state = digitalRead(LIGHT_IN_PIN);
    void sendPortState(int pState) {
      if (direction != pState) {
        switch (pState) {
          case V_UP:
          case V_DOWN:
          case V_STOP:
        direction = pState;      
    void incomingMessage(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.sensor == 1 & (message.type == V_UP | message.type == V_DOWN | message.type == V_STOP)) {
        direction = V_TEMP;
        Serial.println(F("Activate port!"));
      if (message.sensor == 2 & message.type == V_LIGHT ) {
        digitalWrite(LIGHT_PIN, message.getBool()?1:0);
        Serial.print (F("Lights "));
    void activatePort() {
      pinMode(ACTIVATE_PIN, OUTPUT);
      digitalWrite(ACTIVATE_PIN, LOW);
      digitalWrite(ACTIVATE_PIN, HIGH);
      pinMode(ACTIVATE_PIN, INPUT);

    *Updated sourcecode

  • Admin

    Pictures please 🙂

  • Contest Winner

    Pictures or it didn't happen 🙂

  • Admin

    @hek @Anticimex

    Keep calm, and don't panic 🙂 Something happened when I made the initial post, so I couldn't add pictures.. 🙂

  • Admin

    Looks great!

    Hmm.. I don't have a garage door opener... This is a good reason to get one 😉

  • Contest Winner

    And the datasheet is predictably veeery vague on the security aspects of that machinery...well, you got everything you need to fix that 😉
    Defining "locked" as when the door is closed and offer a completly unspecified remote dongle leaves some to be desired after all...but at least you should only need to secure the actuation of the motor to secure the garage.

  • Admin

    Only one problem left now, domoticz doesn't seem to support mysensored blinds (which I have set it up to mimick, as it has V_UP/V_DOWN/V_STOP as informed by @hek in another thread)

    Domoticz also spews out errors about unknown ID's when it received V_UP/V_DOWN/V_STOP. So I'll have to dig into the code of domoticz as well, to see if I can fix things. On that note, I decided to fetch the latest domoticz, but that is broken, and can't be build 😞

    Oh well, the fun life of being a hardware/software "hacker" 🙂

    @hek I have two ports.. Only one of them with a port opener at the moment, the one I have modified is for the second port, which had been put away since I bought it last year.

    Yes, it's a china remote keyfob thing. Also wondering about security. But since I can't lock down the garage fully (It's an old barn, that has a lot of other entries which can't be locked). It's not that big a concern right now.

  • Contest Winner

    @tbowmo well, that makes you the perfect guinea pig for practical security application for MySensors then 😄 you got nothing to loose if bugs are found 😉

  • Admin


    The normal remotes is still working as well (I have to make this as seamless as possible, as to not confuse the wife, and kids :))

  • Contest Winner

    @tbowmo perhaps we should design a MySensors keyfob 🙂 The sensebender board is a good base for that (although we probably want to offer RF69 variants as well in that case).

  • Admin

    now with Video, for @hek and @Anticimex, so they can see it in "motion"

    Mysensors garage port opener – 00:56
    — Thomas Bowman Mørch

  • Contest Winner

    @tbowmo Awesome! What approach did you take? Reverse-engineered the keyfob to route it through the MySensors network or do you use a separate keyfob for the "MySensor path" and retain the original?
    Or maybe I am reading it the wrong way; you detect the door action and send the status to your controller (Domoticz)?
    Anyway, it is hacking done properly 😄
    The light is an addition? Relay-actuator for that?

  • Admin


    It's integrated into the opener control box itself. By poking around with a multimeter, I figured out which signals I could use.

    For Open / Close / Stop status, I just look at the relay drivers, used for reversing the supply to the motor. It has two relays in it, one for each direction.

    When it opens, it turns on relay 1, start ramping up the PWM to the motor, and when stopping, it ramps down the PWM, and finally turning off relay 1.

    When it then closes again, it starts by turning on relay 2, ramping up / down PWM signals, and turn of relay 2 again.

    So it's a "simple" hack 🙂

    The unit has inputs for a wall switch, so you can operate it without a remote. This input happens to be 5V as well, that just needs to be grounded. So I have 1 pin for that.

    The light is a bit more "trickier" :), as it's a built in light (which I will replace with a LED floodlight when I get around to put it up). It's also a relay driver like the motor control. I have put the mysensors module in between the original controller (connected to an input pin on the mysensor module), and then an output to the relay driver. This way I can detect when light is turned on by the original controller, and also switch it on / off from remote.

    So you won't notice that it's there, until you activate it from domoticz (which I can't at the moment, as it is missing the V_UP/V_DOWN/V_STOP messages that I'm using)

  • Contest Winner

    @tbowmo Yes WAF is an important factor. Changes are usually accepted if they are not noticed 😄
    Good work!

  • Very nice work.
    I notice that there are a lot of parts missing in the sensbender I understand you took out sensor and eeprom but I notice some caps and resistors also not attach.
    can you specify what did you populate the board with only the atmega?

  • Admin


    On this one I only populated the atmega on the board. I removed the vcc pin on the radio module, before I soldered it back to back with the minimal sensebender module, and then put a le33 between vcc on sensebender board, and vcc on the radio (and added a capacitor on the radio, for good measures)

  • @tbowmo said:


    On this one I only populated the atmega on the board. I removed the vcc pin on the radio module, before I soldered it back to back with the minimal sensebender module, and then put a le33 between vcc on sensebender board, and vcc on the radio (and added a capacitor on the radio, for good measures)

    and did you flash the the "official" sensebender bootloader ?

  • Admin


    For this particular one, I haven't used a bootloader at all, as I'm using jtagice3 to download my sketches.

    I have a serial terminal attached all the time for debugging, and I find it a bit irritating having to start up the terminal every time I have uploaded a new sketch (using normal arduino serial upload).

    So I have this setup when fiddling with stuff 🙂 one window for serial terminal, one for shell where I upload using avrdude, and then the arduino env.

  • Admin

    Finally got around to mount the motor unit, after heavy modifications. Which also cut the standby power to under a 10th of the original unit.

    I ended up implementing my own 5v supply, that powers the logic in the original unit and my mysensor node, I then have a solid state relay, enabling / disabling the 38v rail for the engine part. This drops the standby from 7W to under 0.5W.

    I had to go a couple of loopholes to get it working, as the motor unit wouldn't respond to the remote when the 38v rail was missing. I then tapped into the remote signal, so when the remote is detected I power up the thing, I then need to press the button one more time to activate the opener. When the original unit switches of the light, I also power down the 38v rail.

    I can activate the port from domoticz, also the lights can be activated by domoticz. There are some small quirks, as the port is reported as open when the port actually is closed. I will have a look at the software for the next port that I have to modify

    And last a small demo video.

    From the outside with both ports in action (only the right port is mysensored for now)
    Garage port from outside – 00:46
    — Thomas Bowman Mørch

  • Hero Member

    @tbowmo Was the door on the left added after the building was built? Little strange for the garage door to "block" the smaller door.. 😀

  • I'd say more likely the garage doors were originally "barn" type swinging doors, rather than sliding doors, and that personnel door was original.

  • Admin

    @ServiceXp, @Chester

    The previous owner rebuild the entire side of the barn, originally there where only a single swinging port in the middle (where the "personnel door" is now). Have also been thinking it was peculiar choice he made with the door back then.

    Anyways, when the port is open, you don't need the door.. so its not a big loss for me.

    Now I just need to get my tractor running, so I can put it aside and make room for my car 🙂

  • Admin

    Hmm.. firmware updates in the field are not that easy, when you have to stand on a ladder to do the update. Luckily I can place my laptop on the top of the wall, just under the roof in the barn.

    Maybe I should do something about OTA firmware updates.. On the other hand, then I wouldn't see that the controller went haywire, and tried to close an already closed port, which almost broke the chain drive for the port..

    Updating mysensors in the field :) – 00:29
    — Thomas Bowman Mørch