Home

Awesome

<div align = center>

OpenWindowAlarm

Place this gadget on a windowsill and you will be alarmed if you leave the window open longer than five minutes. It senses the falling temperature and thus works best in winter. It requires only 0.026 milliampere. This means one battery will last the whole winter.

Badge License: GPLv3     Badge Version     Badge Commits since latest     Badge Build Status     Badge Hit Counter <br/> <br/> Stand With Ukraine

</div>

Available as "OpenWindowAlarm" example of Arduino library "ATtinySerialOut"

If you find this library useful, please give it a star.

🌎 Google Translate

<br/>

Driver installation ->

Sourcecode

Der Sourcecode kann von hier kopiert werden.<br/> Das Programm ist auch als Beispiel der Arduino "ATtinySerialOut" Bibliothek - unter Datei -> Beispiele -> Beispiele aus eigenen Bibliotheken - ATtinySerialOut -> OpenWindowAlarm verf�gbar. Die Bibliothek kann mit Werkzeuge -> Bibliotheken verwalten... oder Strg+Umschalt+I geladen werden. Dabei "SerialOut" als Suchstring benutzen.

The sourcecode can be copied from here.<br/> The application is also available as an example of the Arduino ATtinySerialOut library - use File -> Examples -> Examples from Custom Libraries - ATtinySerialOut -> OpenWindowAlarm. You can load the library with Tools -> Manage Libraries... or Ctrl+Shift+I. Use "SerialOut" as filter string.<br/>

YouTube videoInstructable
YouTube video<br/> OpenWindowAlarm on a windowsillInstructable

Functional overview

Every 24 seconds a reading is taken of the ATtiny internal temperature sensor which has a resolution of 1 degree. If temperature is lower than the "old" temperature value, an alarm is issued five minutes later if by then the condition still holds true.<br/> Detection of an open window is indicated by a longer 20 ms blink and a short click every 24 seconds. Low battery is indicated by beeping and flashing the LED every 24 seconds. The beep and the flash are longer than for an open window detection.

How to make your own

The parts you need:

Parts

Add one of the power supplies

AAA battery caseCR2032 caseLiPo battery
AAA battery caseCR2032 holderLiPo battery

Programming the Digispark board

Installation of the core for Digispark boards for the Arduino IDE

Install the Digispark board for the Arduino IDE as described in http://digistump.com/wiki/digispark/tutorials/connecting. Instead of http://digistump.com/package_digistump_index.json you must use http://drazzy.com/package_drazzy.com_index.json as Digispark board URL in Arduino File/Preferences. In the Boards Manager install the latest ATTinyCore version.<br/> Since we want to save power, the board clock is 1 MHz so you must choose ATTinyCore->ATtiny85 (Micronucleus / DigiSpark) as board in the Tools menu and set the clock to 1MHz (no USB). Board settings

Driver installation

For Windows you must install the Digispark driver before you can program the board.<br/> if you have the Digistump AVR Boards already installed, then the driver is located in %UserProfile%\AppData\Local\Arduino15\packages\ATTinyCore\tools\micronucleus\2.5-azd1b. Just execute the Install_Digistump_Drivers.bat file.<br/> Or download it here, open it and run InstallDrivers.exe.

German instructions

Leider muss der Treiber f�r das Digispark Board manuell installiert werden. Der Digispark Treiber kann von hier heruntergeladen werden. Dann die Datei �ffnen und InstallDrivers.exe ausf�hren.<br/> Wenn die Digispark Boards in der Arduino IDE schon installiert sind, ist der Treiber bereits auf der Platte unter %UserProfile%\AppData\Local\Arduino15\packages\ATTinyCore\tools\micronucleus\2.5-azd1b. Am einfachsten installiert man ihn, wenn man das Board einsteckt und wenn das unbekannte Ger�t im Ger�te-Manager auftaucht, Treiber aktualisieren ausw�hlt. Dann Auf dem Computer nach Treibersoftware suchen w�hlen, C:\Users\<username> w�hlen und Weiter klicken.<br/> Bei der Nachfrage M�chten sie diese Ger�tesoftware installieren auf installieren klicken.

Wenn das Board nicht erkannt wird (kein Ger�usch beim Einstecken) kann es daran liegen, dass die Buchse zu tief ist, dann eine ander Buchse oder ein USB Verl�ngerungskabel benutzen.

Compile and upload the program to the board

Install the Arduino library ATtinySerialOut and select the OpenWindowsAlarm example with File -> Examples -> Examples from Custom Libraries -ATtinySerialOut -> OpenWindowAlarm<br/> OR<br/> create a new sketch with File -> New and name it OpenWindowAlarm in the Arduino IDE and copy the code from OpenWindowAlarm.ino.

Compile and upload it. Keep in mind, that upload will not work if the speaker is connected.<br/> If everything works well, the built-in LED of the Board will blink 5 times (for the 5 minutes alarm delay) and then start flashing after 8 seconds with an interval of 24 seconds to signal each temperature reading.

Power reduction

Before power reduction changes Final power reduction

We now have a Digispark board that consumes 6 mA at 1MHz and 3,7 volt. With a battery of 2000 mAh it will run for 14 days. But it is possible to reduce power consumption to 27 �A in 3 Steps.

  1. Disabling the power LED by breaking the copper wire that connects the power LED to the diode with a knife or removing / disabling the 102 resistor saves 2/2.2 mA.
  2. Removing the VIN voltage regulator saves 1.5/3.0 mA.<br/> The board now needs 3/4.3 mA at 3.7/5 volt and the 2000mAh battery will last for 28 days.
  3. Disconnecting the USB D- Pullup resistor (marked 152) from 5 volt (VCC). Disconnect it by breaking the copper wire on the side of the resistor that points to the ATtiny.<br/> This disables the USB interface and in turn the possibility to program the Digispark board via USB. To enable it again, but still save power, connect the resistor (marked 152) directly to the USB V+ that is easily available at the outer side of the diode.<br/> The correct side of the diode can be found by using a continuity tester. One side of this diode is connected to pin 8 of the ATtiny (VCC) and Digispark 5V. The other side is connected to the USB V+.

Now the USB pullup resistor is only activated if the Digispark board is connected to USB e.g. during programming.<br/> The board now consumes 27 �A during sleep.

The software loop needs 2.1 ms (plus 3 times 64 ms startup time) => active time is around 1/125 of total time. During the loop the power consumption is 100 times the sleep current => Loop adds 80% to total power consumption.<br/> We now have an average current consumption of 75 �A and the 2000mAh battery will last for 3 years.

The BOD current of 20 �A can only be disabled by setting fuses via ISP programmer](https://www.google.de/search?q=arduino+as+isp) and a connecting adapter. We can also reduce the start-up time from sleep from 64 to to 5 ms. For reprogramming the fuses, you can use this script.<br/> Without BOD and with fast startup we have an average current consumption of 9 �A and are still able to program the ATtiny by USB.

Reset button

If you do not want to remove power to reset the alarm, connect a reset button between PB5 and ground. I did this by connecting the unconnected VIN copper surface to PB5 and soldering the reset button directly to the VIN pin hole and the big ground surface of the removed VIN voltage regulator.<br/><br/> If you want to get rid of the 5 seconds wait for USB connection after reset, you can change the micronucleus kernel on the ATtiny85.

After power reduction changes and reset button assembly

Both patches on frontReset connection on back
Final power reductionPatch front
Final power reductionReset connection on back
Mini-USB module

Loudspeaker disassembly

Part 1Part 2
Loudspeaker disassemblyLoudspeaker disassembly

Module samples

OpenWindowAlarm circuit with AAA batteries<br/>Powered by 2 AAA batteriesOpenWindowAlarm circuit by CR2032<br/>Powered by CR2032 coin cell
OpenWindowAlarm circuit with LiPo battery<br/>Powered by LiPo batteryOpenWindowAlarm circuit by CR2032<br/>Back viev with CR2032 coin cell
OpenWindowAlarm circuit with buzzer<br/>With 16 Ω buzzer from an old PcOpenWindowAlarm circuit compact version<br/>Compact version

Different reset buttons and connectors OpenWindowAlarm circuit by CR2032

Placement

Place the board on a windowsill and connect it to the supply. If the temperature on the sill is lower than the temperature where the board was originally located, it will take additional 5 minutes to adopt to the new start value to avoid false alarm. OpenWindowAlarm circuit with LiPo battery

Internal operation

Revision History

Version 1.3.3

Version 1.3.2

Version 1.3.1

Version 1.3.0

Version 1.2.2

Version 1.2.1

Version 1.2

Sample TRACE output after reset

Changed OSCCAL from 0x52 to 0x4e
START ../src/OpenWindowAlarm.cpp
Version 1.2.1 from Nov  5 2019
Alarm delay = 5 minutes
MCUSR=0x2 LFuse=0x225 WDTCR=0x0 OSCCAL=0x78
Booting from reset 
VCC=4022mV - LIPO detected
Temp=300 Old=0 New=300
Temp=298 Old=0 New=598
Temp=298 Old=0 New=596
Temp=297 Old=0 New=595
Temp=296 Old=0 New=593
Temp=296 Old=0 New=592
Temp=296 Old=0 New=592
Temp=296 Old=0 New=592
Temp=296 Old=0 New=592
Temp=296 Old=0 New=592
Temp=296 Old=300 New=592
Detected porting to a colder place -> reset
Temp=296 Old=0 New=296
Temp=296 Old=0 New=592
...
Temp=296 Old=0 New=592
Temp=296 Old=296 New=592
Temp=296 Old=592 New=592
Temp=296 Old=592 New=592

If you find this program useful, please give it a star.