automatic window

Hello I have two electic skylights each controlled by a 2 wire DC motor at home, but the system that should currently open and close the window is somehow broken, so i thought why not try to controll it with an arduino.

But i dare not start before i figured out one part can i somehow tell the board to stop the motor when the window is fully closed/opened? i did some measuring and when the window hits the frame as it closes the current goes from ~0.4A to ~1A(tho it might be more, depends on how good and fast that multimeter was)

i spent a lot of time looking around and solutions i found so far either contained stepper motors or were time controlled but i don't want the motor to just run X seconds and then stop cause i also want to add the possibility to like half open the window and i only have the dc motor

PS. what motor driver would you suggest so i can run the 2 motors at the same time Currently they only run seperately and with 21V and 0.4A (~1A when they are stopped by the frame)

An L298 should work fine for your application; there are tons of L298 boards available on Ebay cheaply - you can also find shields, as well. Download the L298 datasheet (, and study it. Basically, it will be able to supply up to 2A per motor (the L298 contains two h-bridges, so you can control each motor separately); it also has a pin to monitor the current of each motor (pins 1 and 15 on the Multiwatt15 package). You can put a low-ohm, high wattage resistor on these pins, and measure the voltage rise using the ADC inputs on the Arduino (you’ll want to keep the voltage between 0-5 volts, of course). The higher the voltage, the more current being drawn (so monitor and check for a “spike” - when that occurs, you know you’re at the end of travel and can cut the motor).

Most of the time, the boards or shields you can purchase have the sense pins grounded or something; sometimes they are brought out and hooked to the proper resistors. Just something to keep in mind - you might have to do a bit of hacking.

If you intend to build your own L298 driver board or such, here’s some tips:

  1. You’ll probably use the Multiwatt15 version of the IC (as the PowerSO20 is an SMT part, but large pitch) - note that this package -does not- have a standard 0.1" pin spacing layout.

  2. The L298N does not have build in flyback diodes to protect the chip from the motor coil EMF; you’ll need to supply some high-speed fast-recovery diodes (trr <= 200ns) - Shottky diodes are preferred (from the datasheet). IIRC, there is an L298D version that includes the diodes internally to the IC - but generally, you’ll only find the L298N - if in doubt, add the diodes.

  3. You will probably need to add a heatsink to the IC - heatsinks for the Multiwatt15 package, for some reason, are not easy to source (I’ve looked and looked, and have yet to find anything - I’ve found things that seem close, but without a picture to check the profile of the extrusion, I don’t trust it). Somehow, though, the chinese suppliers of L298 boards have no problem getting them (Terry - if you see this, can you help?).

If - despite all of the above - you decide to go thru with it, but don’t want to custom etch your own PCB to fit the package - this guy has adapter boards that break out the pins in a nice fashion:

He also sells an L298 PC board if you want to build your own motor driver board and have the parts needed lying around:

I’m only a satisfied customer of his, nothing more.

Good luck, hope this helps your project!

Thanks for the information so far after reading it twice i think i start to understand more and more :D

i already looked into the L298 H Bridge since it's on a shield i first intended to use, but turns out it's not what i want

so with the sense pins the arduino can detect a peak? according to the datasheet the sense pins have voltage from min -1 to max 2 is the -1 a problem here? besides that, a range of 3V seems fine to me, why would i need a resistor here? (i feel like i'm missing a part here)

about the heat sink, i found this one for multiwatt packages and they list the L298N, that should do the trick, what do you think?