A library to monitor the time that devices are active, using the Arduino input pins. Output pins can be set to On and automatically Off after a specified interval.
We can monitor the state of devices using the digital inputs. But is that all a monitoring system can do? Just incorporate the time dimension to a sensor state and we can have tons of additional information regarding the usage of our devices!
There are dozens of devices in the home or in a factory which are operated automatically by electronic, electrical or mechanical controllers, such as thermostats, piezostats etc. For example, a pump operates for a few seconds at a time in order to maintain the pressure in the fresh water plumbing system. I wanted to measure the total amount of time that such devices operate throughout a year, in order to organize their maintenance schedule. In addition, I wanted to know if devices in unmanned locations are set into operation by their local controllers without any particular (meaning intended) reason, consuming costly power. Or maybe pumps are operating because there is a leak which nobody can visually identify. Or lamps are operating at night controlled by a light sensor, in spite of the fact that we have left our summer house for the winter, just because we forgot to turn of the mains switch. And for hundreds of other reasons….
This library keeps a log of the time that devices became active for any reason. Hardware that monitors the voltage applied to the device or the current that flows through and indicate that the device is active, is a prerequisite.
For hobbyist projects, I assume that the user of this library must have adequate knowledge to wire a 0-5V signal to Arduino pins, using pull-down or pull-up resistors depending on the sensor logic (active-high or active-low). The electronic circuit for monitoring mains voltages will be published in another repository, because such a project which involves lethal voltages should be documented accordingly.
Digital Inputs which are monitored via this library keep a record of the time that were active.
Maintained information contains:
The state of Digital Outputs can be set using the
setOn(timer) function will set the output immediately to On and will set it to Off after timer milliseconds. The library does not use interrupts, therefore the user application must incorporate the
checkTimer() method in the loop().
Although time recording could be done for digital outputs in the exact same sense as with digital inputs, I do not consider it useful because the devices may be controlled additionally by manual methods, such as local power switches wired in parallel to the control relays. Our aim is to measure the time that a device was really active and not only the time we have set it active via the controller. Such devices should be monitored via a Digital Input instead. The drawback of course is that we need two pins per device.