with reference to the drawings which show an exemplary embodiment of the energy management system according to the present invention , the entire micro controller based unit may be housed in a relatively small enclosure which may be easily retrofit in existing buildings . like reference numerals in the various drawings designate corresponding parts . the main functions of the system are monitored by a micro controller 10 which may be pre - programmed for a predetermined long period of time such as twenty years . the system is provided with a rectification filter 11 which can be fed by a wide range of voltages , for example , from 16 volts to 30 volt dc , and from 16 volts to 24 volts ac . such provision alleviates any problems for an inexperienced installer of the system to reverse the polarity of the system input erroneously . the rectification filter 11 as more specifically shown in fig2 c , 2f , and 2i is provided with an oversized bridge rectifier 12 and capacitive filters 13 connected across its output terminals . typically , a 1 amp rating bridge rectifier 12 is used although only 200 mamp is required . this provision safeguards the integrity of the rectification filter 11 . the voltage from the rectification filter 11 is fed to a switching power supply 14 through a current limiting resistor 15 . the role of the current limiting resistor 15 is to limit the current in case of a short circuit in the system . in such event , the voltage drop across the resistor 15 will be high and the switching power supply will automatically limit the current according to the voltage drop across the current limiting resistor 15 . the output of the switching power supply incorporates a fast recovery diode 16 , an inductor 17 and a large value electrolytic capacitor 18 to smooth out the current and voltage , a low value ceramic capacitor 19 is also included in the circuit to take care of high frequency noise . part of the output voltage is re - injected to the switching power supply via a divider 20 for a precise control of the output voltage . the filtered output supplies all the 12 volt circuitry in the system including the relays , op - amp , analog switch as well as part of the circuitry feeding a 5 volts voltage regulator 14 which provides the operating 5 volts voltage for all the logic integrated circuits . to further enhance the reliability of the circuitry , a power supply monitoring circuit 21 is provided on the 5 volts power supply . if the voltage deviates beyond a predetermined tolerance , the monitoring circuit 21 automatically generates a reset . the reset may also be initiated manually by actuating a push button on the main board or by a watchdog circuit 22 which ensures the reset functions at the correct timing . in common energy management systems , motion detectors are usually employed to initiate the operations of the lighting and heating in a building . the main drawback of such known systems is that the motion detectors would turn off the lighting or heating when there is not sufficient motion detected . such motionless condition often occurs , for example , when a person within the sensing area remains at the same location in the room and is seemingly motionless such as working with a computer , or when a teacher is sitting at a desk for a relatively long period of time correcting papers . the energy management system of the present invention obviates the above drawback by operating a presence detection device or other similar proximity sensor in conjunction with a door contact . after the entrance door of a room is closed , the presence detection device is given a predetermined period of time , for example , 10 minutes , to detect the presence of a person in the room . if no presence has been detected during such 10 minute duration , the micro controller determines that there is no person present in the room , and it turns off the lights , external ventilation etc in the room . depending on the time of day and day of the week , it will either leave the heating at the normal setting ( e . g . from 08 : 00 to 15 : 30 ) or set back the heating ( e . g . after 15 : 30 ). on the other hand , if the slightest presence is detected during the predetermined time , then the fact that the room is occupied is memorized by the micro controller 10 ; the system does not take any further action as far as occupancy is concerned until the door is opened then closed again at which time the occupancy condition is reassessed . the micro controller 10 memorizes the status of the door contact ; if the door is closed , the micro controller 10 checks in its memory if it was closed before ; if yes , that means there is no change ; if no , then it updates its memory that the door is now closed , and resets the timers . it functions similarly when the door opens . since only simple presence is to be detected , any common motion detector may be employed . alternatively , a mat pad , or beam detector , or proximity sensor may be employed in place of the motion detector . on the other hand , some known energy management systems require the use of expensive pulse duration motion detectors which produces an out pulse of specific duration . the motion detector 23 in the present invention may be either an integral part of the main board or mounted on the front panel of the unit enclosure or at a suitable remote location at which the motion detector senses the entire area of the room . a plurality of door contacts 24 and / or window contacts may be connected to a signal conditioning and preprocessor so that the inputs of these devices are filtered and debounced and fed to the micro controller 10 . these inputs also generate a signal which is amplified in order to switch on a relay 18 to interface with an optional alarm system 27 . the temperature in the room is measured with a conventional sensor 28 such as a thermistor probe which provides a temperature signal to the micro controller 10 via a temperature processing module 29 which may be an analog to digital converter . the temperature signal from the temperature sensor 28 may be fed to a capacitor and generating an interrupt to the micro controller 10 which measures the time it takes for the capacitor to charge to a preset level . the capacitor is then discharged , then it is charged by a 1 % reference resistor . the micro controller 10 measures the time it takes for the capacitor to charge to the preset level and compares it to a table stored in its memory to arrive at a temperature value . the advantages of this circuitry are that since the capacitor and preset level are used to process both the reference resistor and the probe , any error in these components nullified . to further minimize any reading errors , several readings are taken then averaged by the micro controller 10 before the sensed ambient temperature value is determined by the system . one or a plurality of temperature probes may be employed to provide temperature input to the micro controller 10 . the plurality of temperature probes may be remotely located from the unit housing of the system . this arrangement allows for better and more accurate control of the various ambient control devices of the room such as ventilators or inside air ducts in which the return air temperature therein may be directly sensed inside the device if desired . an outside temperature sensor 30 may be connected to the system to enable exact control of the heat damper and / or air conditioning of the room as well as control of the amount of storage on thermal storage units . for example , according to the above , on ambient temperature rise , the modulator of the damper would normally try to open the damper to maintain the temperature of the room . with the outside temperature sensor 30 in place the system may determine actually if the opening or closing of the damper can maintain the desired ambient temperature , or if the outside temperature is above the desired pre - set temperature such that it would be futile to open the damper . accordingly , the damper would be maintained closed or in minimum position while the air conditioning is started immediately . similarly , the outside temperature of the building might be 19 c . while the ambient temperature might be 21 c ., and as soon as 30 persons come inside the room , the temperature might rise to 24 c . instead of starting the air conditioning , the system can react to the situation in a better way by modulating the damper only . a plurality of dip switches 31 and 32 are provided for selecting various pre - set conditions stored in the memory of the micro controller 10 of the system . such dip switches selection eliminates the necessity for the user to select and vary the conditions through front panel push buttons or similar devices . studies have been found that users usually do not know how thermostat programming functions and erroneous selections often result in inefficient operation of the energy management system . the following functions of the micro controller 10 may be selected with the several banks of dip switches 31 and 32 provided , as an example : ( a ) ambient temperature heat : the &# 34 ; occupied &# 34 ; temperature setting may be selected from 17 to 24 degrees c . ( 63 to 76 degrees f .) for heating . ( b ) ambient temperature cool : is always automatically adjusted to 3 c . above the heat set point . ( c ) set back temperature : may be selected to turn off the system at 2 , 5 , 7 , 10 , 13 , 15 , or 17 degrees c . ( 35 , 40 , 45 , 50 , 55 , 60 , or 64 degrees f .). ( d ) start time : to select the time at which the desired ambient comfort temperature of the room should be reached . this could be set in increments of one hour intervals between 06 : 00 to 09 : 00 daily . ( e ) stop time : to select the time at which the system would reverse to temperature set back if the room is not occupied . if the room is occupied then the system would wait for the room to become unoccupied before reversing to the set back . this temperature could be set in increments of one half hour between 15 : 00 to 17 : 00 daily . ( f ) ten minute door open : this dip switch enables a function which allows the system to turn the hvac off if the doors and / or windows have been left open for more than ten minutes . ( g ) door close : 10 / 50 minute dip switches instruct the system to use for example either a 10 minute or a 50 minute time delay when the door is closed . the 10 minutes is commonly used . the 50 minute is usually used when the door contact in not installed , in that particular case the &# 34 ; motion &# 34 ; input of the system is jumpered to ground while the motion is wired directly to the door input . therefore every time the motion detector is triggered , a 50 minutes time delay is reset , to provide enough time to detect the occupancy of the room and to maintain the lights and the hvac on . ( h ) motion by : the system has the capability of knowing if somebody enters the room ( via the door contact ); if the door has not been opened by either 09 : 30 or 10 : 30 daily the system reverses automatically to the temperature set back . if this situation occurs two days in a row the system would determine that it is a vacation time which has not been pre - programmed and the system would not start the third day . this cycle is automatically reset the following week - end or if somebody opens the door . ( i ) daylight savings : this dip switch allows the system to automatically adjust for daylight savings or to ignore any change in time . ( j ) test fast speed : this dip switch instructs the system to operate in normal speed , or to switch the 10 or 50 minute door closed timer and the one hour heat timer in a speed 60 times faster than normal . this feature is particularly useful for installers who can check the operation of the full system , including occupied or unoccupied condition within minutes following installation . ( k ) pwm / 0 → 10v : this dip switch instructs the system to output either a pulse width modulation or 0 to 10v according to the requirement of the heater connected on the system output . the 0 to 10v output is also used in conjunction with a relay board to generate from 1 to 4 stages of heat . the pulse width modulation ( pwm ) mode would for example turn the heat on for 6 seconds and turn it off for 14 seconds . this mode as well as the 0 to 10v mode allow for an extremely precise control of the temperature , always modulating and adjusting in real time . ( l ) warm up multiplier : the dip switch selects the warm up multiplier . for example , the warm up period may be multiplied to 1 , 1 . 5 , 2 , or 3 times the normal period . the various warm up period selections also compensate for the heat retaining efficiency of a room which has very poor insulation or leaking doors or windows . ( m ) 20 min / 1 hour time delay : this dip switch is equipped in a system having a water management function so as to permit selection between a 20 min . or 1 hour time delay to fill up the water tanks of the water management system . ( n ) a / c : this dip switch informs the system if the room is fitted with an air conditioning device . on most installations this does not change anything but some heat sources are equipped with an outside air damper as well as an air conditioning device . therefore , when the temperature rises , the system first modulates the damper opening condition according to the temperature differential between the desired temperature point and the selected ambient temperature . this is also referred to as free cooling . if the temperature continues to rise with such damper control only if the room is also equipped with an air conditioning device , then the system would close the damper to a minimum position and turn on the air conditioning device . if there is no air conditioning device , the damper will be maintained at its maximum opened condition . ( o ) correction : these dip switches are used to easily correct any error in the readings of the temperature sensor , temperature adjustment can also be made via programming . ( p ) override : these dip switches can be actuated to adjust the normally selected ambient temperature by plus or minus 1 or 2 degrees c . these dip switches can be bypassed by providing an override external switch which can be operated for the same function by the user . the micro controller 10 is also preprogrammed for all weekends , holidays and statutory holidays forever except for easter which is only pre - programmed for the next 20 years ( i . e . heating will not be turned on weekends , during easter vacation etc . date and time run continuously and are protected by a ten year battery back - up . additional banks of dip switches 33 and 34 may be provided to input other control information to the micro controller 10 . in order to check the memory status , or to add extra programming , the micro controller 10 emulates any type of programming device 35 such as a hand - held programmer , laptop computer or other systems which can communicate with that format on the logic level with an rs232 circuit which converts this logic level voltage into a standard rs232 voltage level . the output of this circuit may be supplied through an rj11 ( phone jack type ) plug 36 which is directly mounted on the main board of the micro controller 10 . additional programming for vacation days , special days off may be easily achieved with such programming devices . the micro controller 10 is also pre - set so that the extra programming may be automatically erased after a particular predetermined date . the micro controller 10 is operated with an external clock 10t which may be composed of a crystal and two capacitors , while the system is provided with an operating clock 37 with a 10 - year back up battery , so that the date and time always run continuously , even when the system is not connected to a power supply source . leap years are automatically accounted for . a dip switch is provided to allow the daylight savings hour change to take place automatically or to be bypassed . the watchdog timer 22 may be built in one of two ways . a signal is either directly taken on the output of the micro controller 10 or on the output of the interface circuitry 38 . in both cases it is then fed via a capacitor to a nand gate . the capacitor ensures that if the micro controller 10 locks up either in &# 34 ; 0 &# 34 ; or &# 34 ; 1 &# 34 ; position a reset will happen , while the nand gate is used to shape the signal to a logic level square wave signal . the output of this nand gate goes via diode to an oscillator composed of another nand gate , a capacitor and a resistor . the resistor charges the capacitor , a negative pulse coming from the previous nand gate ( via the diode ) is supposed to discharge the capacitor . if the pulse is missing , the output of the second nand gate goes to a low logic level which originates a reset on the reset circuit . the input of this reset circuit receives another signal from the reset push button . both signals are selected at the entrance of the reset circuit . the heat output of the room being controlled is maintained by an interface heat circuitry 39 which operates to provide the following functions : ( 1 ) direct heat output , one stage : a heat output is provided at a 5v logic level . this signal is then amplified and used to control a relay together with an led . the contacts of this relay go to the connector for direct interface with a relay part of the heating system . ( 2 ) direct heat output , two stages : same as ( 1 ) except that two outputs and two stages are provided . ( 3 ) pulse width modulation : the pwm is typically used with types of heaters which incorporate a solid state type of relay or other devices which turn on and off a great number of times without affecting their longevity . ( 4 ) the 0 to 10v output is used either directly with 0 to 10v control heaters , or can be interfaced to give 4 to 20 ma , or other types of analog signals , to control different types of heaters , or it is used to drive a comparator which can generate several stages of heat : i . e . 0v to 2 . 5v = stage 1 , 2 . 5v to 5v = stage 2 , 5v to 7 . 5v = stage 3 , 7 . 5v to 10v = stage 4 . in the case of the pwm output , the micro controller 10 generates a 5v level when the heat source must be turned on and a 0v level when it should be turned off . this 5v is then amplified to have a more powerful output with a higher voltage . any type of linearization can be chosen , for example , a period of 20 seconds with a differential of 2 degrees c . in temperature linearly . if for example the set temperature is 20 c . : if the ambient temperature is 18 below , the heat will be on all the time ; if it is 18 . 1 c ., the heat will be on for 19 seconds and off for 1 second ; if it is 19 . 5 c ., the heat will be on for 5 seconds and off for 15 seconds and so on . this modulation allows for an extremely precise temperature control . ( 5 ) 0 to 10v : in the 0 to 10v mode , the micro controller outputs a 0 to 1 khz frequency proportional to a certain difference between the ambient temperature and the required temperature . any type of linearization can be chosen , for example , a 2 degrees c . bandwidth linearly for a 0 to 1 khz change . therefore , when the temperature difference is 2 c . or more the micro controller output is 1 khz , when the difference is 0 or more the frequency is 0 hz and the relation is linear between the two extremes . this frequency is sent to a voltage to frequency converter 40 , any value could be chosen for example , 0v at 0 hz and 5v at 1 khz ( linear in between ). this 0 to 5v is then amplified by two to give a 0 to 10v output , this signal goes into a follower such as an operational amplifier , to boost it and is passed on to the heat / damper switching circuitry 30 to initiate the heating operation . if , for example , the set temperature is 20 c . ; if the ambient temperature is 18 or below , the output voltage will be 10v ; if it is 18 . 1 c ., the output voltage will be 9 . 5v ; and if it is 19 . 6 c ., the output voltage will be 2v . this linearization allows for an extremely precise temperature control . the micro controller 10 also outputs to the damper through the frequency to voltage converter 40 and heat / damper switching circuitry 41 and a damper interface circuitry 42 . the damper output functions in one of two ways : either 0 to 10v or dry contact . an output is provided by the micro controller 10 at a 5v logic level for the dry contact circuitry . the signal is then amplified and used to control a relay together with an indicating led . the contacts of this relay go directly to the pcb connector for direct interface with an outside device . the 0 to 10v output operates in a similar manner to the heat circuit in that a 0 to 1 khz output provides a 0 to 10v output . however , as soon as the room is occupied the damper output produces a voltage to adjust the damper to a minimum position . when the ambient temperature increases , the voltage produced by the frequency to voltage converter is added to this minimum opening voltage to modulate the damper . this modulation serves the purpose of free cooling for allowing in more or less outside air according to the difference in temperature between the set point and the ambient temperature . if air conditioning is available , the damper will modulate fully open before turning on the air conditioning , and if the temperature continues to rise then the damper output would go to minimum position while the air conditioning starts . the micro controller 10 controls analog switches to redirect the 0 to 10v output to either the heat circuit when in the heat mode , or to the damper when it is not in the heat mode . a status display such as an led is provided to show the mode in which the system is functioning . the micro controller 10 controls the air conditioning 43 through an air conditioning interface 44 which operates in either a single stage , if no damper is available , to turn on the air conditioning device at the pre - set temperature , or in two stages if a damper is available with free cooling as the first stage of cooling in which the opening of the damper is adjusted to maintain the ambient temperature to the pre - set temperature . an led may be incorporated in the air conditioning interface 44 , which will be lighted to indicate the system is functioning in the air conditioning mode . the micro controller 10 sends an output signal to turn on or off the lighting equipment in the room through a light control interface 45 according to the occupancy of the room . an led is incorporated in the light control interface 45 , which will be lighted to indicate that the lighting control mode is on . for maximum energy savings , the lighting does not follow the heating pattern . it turns on when the door is opened , it then stays on for as long as the room is occupied or the door is open . if the room is unoccupied , the lighting turns off after the 10 or 50 minute time delay as instructed by the dip switches . this enables all the lighting to be turned off even during a break or lunch hour when the room is empty . the micro controller 10 provides an output signal through the fan control interface 46 to operate a ventilation fan according to the occupancy of the room and heat requirement . an led is incorporated in the fan control interface 46 , which will be lighted to indicate the fan control mode is on . the micro controller 10 may also provide output signals to various other loads such as a wall - mounted air conditioning device , through an occupancy interface 47 . a led in this interface will be lighted to indicate its operation . thermal storage heaters may be operated by the micro controller 10 through a storage interface 48 which also has an led to indicate its operation . when used in conjunction with water energy management , a solenoid valve interface 49 will receive the output signal from the micro controller 10 to control the operation of the water supply according to pre - set conditions . it turns on during working days according to the start time and stays on until either room , typically a washroom , is not occupied or until stop time . it also comes on and stays on for the time delay duration after hours or on non - working days . every day at midnight this output is activated for the duration of the time delay to fill the j - trap of the water system so as to compensate for evaporation and to prevent hazardous gas from entering the building . windows can also be wired to the system , and the heating / cooling of the room is stopped after 10 minutes of the window or windows being left open , as in some buildings the door might be left open for long periods . this feature can also be enabled or disabled with a dip switch provided . wiring windows to the system not only enables a closer hvac control if the windows are left open but also serves other purposes such as turning the lights on if a burglar tries to enter the room . an alarm contact output can also be interconnected with existing alarm system . while the preferred embodiments of the invention have been described above , it will be recognized and understood that various modifications may be made therein and the appended claims are intended to cover all such modifications which may fall within the spirit and scope of the invention .