47
G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ Home Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with the vague idea of developing a controller for my lawn-watering hose. With one thing and another, that control system was never realized. In the meantime, components originally developed for the watering-control system were redirected toward implementation of a system for environmental monitoring. In general, the system consists of Windows application software, a base station, any number of peripheral stations, and any number of thermostats. A special-purpose peripheral station monitors my house’s furnace, central air conditioning, and the anemometer/wind vane. Each peripheral station includes a microprocessor, 1 a radio transmitter, and one or more sensors. According to its own schedule, each peripheral unit autonomously polls its sensor(s) and uses a radio transmitter to send the readings to the base station. The sensors now in use measure temperature, relative humidity, power consumption, rainfall, wind speed & direction, and the state of switched power-consuming devices. Each thermostat includes a microprocessor, a radio transceiver, and associated hardware allowing the microprocessor to control a relay. The microprocessor can run autonomously, maintaining a measured temperature via a simple dumb-thermostat algorithm, using a target temperature obtained from the base station. The base station includes a microprocessor, a radio transceiver, a battery-backed calendar clock, and storage capacity for many days of data. The base station runs continuously, time-stamping the received sensor readings and storing them or, when possible, passing them on to the Windows application through its dedicated serial port. In addition, the base station uses its radio transceiver to forward information between the Windows application and the thermostats. The application software instructs the thermostats, stores the sensor readings passed on by the base station into a relational database, and provides various facilities for graphical display and for configuration. The system described in this document is continually tweaked, and the document has not been conscientiously maintained. If you are interested in up-to-date 1 Some simple sensors (including photocells and temperature-sensing diodes) and some transmitters (including the XBee transceiver units that I use) could have been set up with each sensor connected directly to a transmitter, and with the transmitters maintaining their own schedules for reading the sensors at regular intervals. This scheme would have avoided the expense of per-peripheral-station microprocessors, but it was rejected because most sensors could not be so handled, and the microprocessors allow for greater flexibility of configuration.

Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

Home Monitoring System Robert R. Fenichel

1. Introduction This document describes an ongoing project that began with the vague idea of

developing a controller for my lawn-watering hose. With one thing and another, that control system was never realized. In the meantime, components originally developed for the watering-control system were redirected toward implementation of a system for environmental monitoring.

In general, the system consists of Windows application software, a base station, any number of peripheral stations, and any number of thermostats. A special-purpose peripheral station monitors my house’s furnace, central air conditioning, and the anemometer/wind vane.

Each peripheral station includes a microprocessor,1 a radio transmitter, and one or more sensors. According to its own schedule, each peripheral unit autonomously polls its sensor(s) and uses a radio transmitter to send the readings to the base station. The sensors now in use measure temperature, relative humidity, power consumption, rainfall, wind speed & direction, and the state of switched power-consuming devices.

Each thermostat includes a microprocessor, a radio transceiver, and associated hardware allowing the microprocessor to control a relay. The microprocessor can run autonomously, maintaining a measured temperature via a simple dumb-thermostat algorithm, using a target temperature obtained from the base station.

The base station includes a microprocessor, a radio transceiver, a battery-backed calendar clock, and storage capacity for many days of data. The base station runs continuously, time-stamping the received sensor readings and storing them or, when possible, passing them on to the Windows application through its dedicated serial port. In addition, the base station uses its radio transceiver to forward information between the Windows application and the thermostats.

The application software instructs the thermostats, stores the sensor readings passed on by the base station into a relational database, and provides various facilities for graphical display and for configuration.

The system described in this document is continually tweaked, and the document has not been conscientiously maintained. If you are interested in up-to-date

1 Some simple sensors (including photocells and temperature-sensing diodes) and some transmitters

(including the XBee transceiver units that I use) could have been set up with each sensor connected directly to a transmitter, and with the transmitters maintaining their own schedules for reading the sensors at regular intervals. This scheme would have avoided the expense of per-peripheral-station microprocessors, but it was rejected because most sensors could not be so handled, and the microprocessors allow for greater flexibility of configuration.

Page 2: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

2

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

schematics, PCB layouts, code, and operational notes, you’ll need to get in touch with me directly.

2. Hardware Components

2.1. Sensors

2.1.1. current transformers Current transformers (CTs) 2 are step a large alternating current (say,

100A) down to a much smaller one (say, 20 mA). Some CTs include internal shunt resistors of a few ohms, so that the measurable output is a small AC voltage (say, 200 mV), while others must be shunted so that the voltage can be measured across an external resistor.

A CT must physically surround the conductor whose current it is monitoring. With some models of CT, it’s necessary to thread the conductor through the circular opening in the transformer. Other CTs (slightly less accurate in their operation) can pull apart or swing open, so they can be snapped onto the monitored conductors without disturbing them.

CTs are used here (one on each hot side of the 230-volt service) to measure the electric power used by the house. Another CT is used to detect the operation of a space heater in my workshop.

2 See http://www.ccontrolsys.com/w/current_transformers (link last reviewed 26 November 2011).

Page 3: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

3

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

2.1.2. temperature-humidity sensors The temperature-humidity sensor I originally used was a SparkFun

board3 supporting a SHT15 sensor chip. I have now completely switched over to the DHT22 device from MaxDetect.4 This device seems to be a little more rugged than the SHT15, and it's cheaper, too. The DHT22 needs power connections and a single data-line connection to the peripheral-station microcomputer.

2.1.3. temperature-pressure sensor The temperature-pressure sensor I use is a board5 supporting a BMP085

sensor chip. This board needs power connections (VCC and GND) and two connections (SCK and DATA) to the peripheral-station microcomputer.

These units are said to operate with reduced accuracy when exposed to light, so the hole in the top of the metal chip should be shaded (not plugged) during use.

2.1.4. photocell A cadmium-sulfide photocell has electrical resistance that varies with the

light striking the cell (the more light, the lower the resistance). The photocell

3 See http://www.sparkfun.com/products/8257 (link last reviewed 26 November 2011).

4 See http://www.sparkfun.com/products/10167 (link last reviewed 9 February 2012).

5 See http://www.sparkfun.com/products/9694 (link last reviewed 26 November 2011).

Page 4: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

4

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

I use6 is connected to the peripheral board. These photocells can be disabled if they stay wet; the occasional raindrop seems to be less harmful than confinement in a near-closed container with the potential for accumulated condensate. Sometimes they recover after being allowed to dry out, and sometimes they don't. Fortunately, they cost less than a dollar apiece.

2.1.5. rain gauge A typical commercial rain gauge briefly closes a switch as each

successive 0.005" or 0.01” of rain accumulates. The one I now use7 has held up well and gives believable results. One of the two connections for the rain-gauge switch goes to ground, and the other to the peripheral-station microcomputer.

The switch in the rain gauge may remain closed for long periods. Usually this is harmless, but when it is observed during continuous rain, it is diagnostic of a mechanical jam.

2.1.6. alternating-current detector I designed a special-purpose PC board8 to detect the operation of my

house’s furnace and central air conditioner. There’s not much to it beyond a pair of Fairchild MID400 line-monitoring chips; the input resistors are chosen to fit the 26 VAC that is switched by the (commercial) programmed thermostat.

2.1.7. wind vane and anemometer I am using a wind vane and anemometer from Argent Data Systems.9

Their promoted product is a complete weather station (adapted for amateur-radio enthusiasts), but they are willing to sell the wind vane and anemometer separately.

The anemometer closes a switch on every revolution of its shaft, so this switch can be connected to an interrupt at the peripheral station. The wind vane switches a its twisted-pair cable among 16 different fixed resistors as

6 Photocells are available from many sources; see, for example,

http://search.digikey.com/us/en/products/PDV-P8104/PDV-P8104-ND/480611 (link last reviewed 26 November 2011).

7 See http://www.beezwaxproducts.com/index.php?cPath=56_57 (link last reviewed 26 November 2011).

8 See http://www.fenichel.net/papers/home control project/hc PCBs.zip for the schematic.

9 See https://www.argentdata.com/index.html (link last reviewed 5 November 2015).

Page 5: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

5

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

the wind direction changes, so the peripheral station can determine the wind direction by using the wind-vane cable as part of a simple voltage divider.

2.1.8. auxiliary sensors The system allows for two auxiliary sensors of undetermined purpose to

be connected to each peripheral board, where each will be expected to express itself by providing a voltage between ground and +5 V. For example, if the furnace operation were to be detected without using a CT, it might be possible to connect the detection device to one of the auxiliary inputs, and then to connect the peripheral board’s corresponding auxiliary output to the furnace input of the peripheral-station microcomputer.

2.2. infrastructure

2.2.1. clock The clock component used in the base station is a board10 supporting a

DS1307 clock chip, with a back-up CR1225 battery that should keep the clock going for years. The clock needs power connections (5V and GND) and 2 connections (SCL and SDA) to the base-station microcomputer. A DS1307 will typically gain or lose several seconds per day, and it does not adjust itself for Daylight Savings Time.11 The application software allows the DS1307 to be calibrated and semi-automatically synchronized with the outside world as needed. 12

As is discernible in the upper right of the picture, one of the mounting holes in this little board is badly placed in relation to the battery holder on the underside of the board, so this mounting hole must be used with care (with a notched standoff, or after nibbling the battery holder) or not used at all.

10 See http://www.sparkfun.com/products/99 (link last reviewed 26 November 2011).

11 In hindsight, the system might have been better designed with the base station permanently set to GMT, and the data adjusted for local time as they are received by the Windows application.

12 See Section 5.6.2 below.

Page 6: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

6

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

2.2.2. XBee transceivers The peripheral station(s) communicate with the base station using XBee

radio transceivers.13 Each transceiver needs power connections (+5 V and ground) and 2 connections (RX and TX) to the microcomputer. The transceiver can fit on its carrier board two ways, but only one way (pointy end away from the connector) is correct.

2.2.3. display units LCD display units are included in the design of the base station and

peripheral stations. The system will run without them, but they greatly simplify debugging and calibration. Each display unit needs power connections (+5 V and ground) and a single connection to the microcomputer.

The available display units are similar (4 rows, 20 columns), but those from different manufacturers have different interfaces. The microprocessors must be configured to take account of the differences.

Some display units require more current in their signal inputs than some microprocessor boards are able to supply. To help in this situation, the base-station and power-supply boards hold "boost in/boost out" connectors through which a microprocessor's signal may be routed on its way to the display.

These displays are designed to be usable with multiple different communication protocols (RS232 at various baud rates, SPI, or I²C), but the consequence is that they all can unpredictably fail by shifting into a different protocol from the one in use. Some manufacturers recommend means of restoring the display to a default state.

13 There are many different models of XBee receivers and carrier boards. I use the wire-antenna XB

Pro model (see http://search.digikey.com/scripts/dksearch/dksus.dll?x=14&y=12&lang=en&site=us&keywords=xbp24-awi-001-nd (link last reviewed 26 November 2011)) with the carrier boards from Sparkfun (http://www.sparkfun.com/products/9132 (link last reviewed 26 November 2011)). The carrier boards from AdaFruit (http://www.adafruit.com/products/127 (link last reviewed 26 November 2011)) are better designed in some respects, but their absence of mounting holes is inconvenient.

Page 7: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

7

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

o Units with the “New Haven” interface14 have 14 plated-through holes toward the left end of the upper edge, grouped 3-6-5. Only the leftmost three holes are used. There are eight different backlight levels.

o Units with the “Jameco” interface15 have 16 plated-through holes toward the left end of the upper edge, all of which are used. The backlight is either on or off.

o Units with the “SparkFun” interface16 have 16 plated-through holes toward the left end of the upper edge, but only the first 6 and the last 6 are used. There are 30 different backlight levels.

14 See http://search.digikey.com/us/en/products/nhd-0420dzw-ag5/nhd-0420dzw-ag5-nd/2626462

(link last reviewed 26 November 2011). The manufacturer of these display units is Newhaven Display International (Elgin, IL). The manufacturer's part number is NHD-0420D3Z-FL-GBW. These units can be reset by grounding two pads on the rear of the display, but these pads are so small (0402 size) that it's hard to attach leads to facilitate easy resetting. The manufacturer claims that the protocol-shift bug has been eliminated in the latest version (NHD-0420D3Z-FL-GBW-V3) of the display.

15 See http://www.jameco.com/webapp/wcs/stores/servlet/product_10001_10001_150957_-1 (link last reviewed 26 November 2011). The manufacturer of these display units is Parallax (Rocklin, CA). The manufacturer's part number is 27979. I don't know how to reset these displays except by power cycling several times. Don't use these displays.

16 See http://www.sparkfun.com/products/9568 (link last reviewed 26 November 2011). Resetting these displays is tricky, and my existing code is imperfectly successful. Don't use these displays.

Page 8: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

8

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

2.2.4. base-station board The base station makes use of a special-purpose printed-circuit board17 to

support a µSD card (or, with an adapter, a CF card) to store sensor readings that arrive when the Windows application is not in communication with the base station. The base-station board needs power connections and various connections to the base-station microcomputer.

Earlier versions of the base-station board used slightly different connections, as noted for historical reasons below.

The red LED on the base-station board indicates that the board is receiving power. The green LED denotes an active connection with the Windows application, and the blue LED is on when the board is storing one or more sensor readings awaiting uploading to the Windows application.

2.2.5. peripheral board As noted above, each peripheral station includes a special-purpose

printed-circuit board18 that contains

o switches to control which sensor(s) the attached microcomputer will attempt to read, and

o connections to allow passive sensors to be enclosed in voltage dividers.

The peripheral board needs power connections and various connections to the microcomputer.

As noted above, a special-purpose peripheral station is devoted to the house’s furnace, central air conditioner, and the anemometer/wind vane. This station consists of only a microcomputer, a commercial +5 VDC power

17 My design; see http://www.fenichel.net/papers/home control project/hc PCBs.zip for the design

files and here at BatchPCB (link last reviewed 20 July 2012) for the boards as products.

18 My design; see http://www.fenichel.net/papers/home control project/hc PCBs.zip for the design files and here at BatchPCB (link last reviewed 20 July 2012) for the boards as products.

Page 9: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

9

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

supply, an XBee transceiver, and an alternating-current-detector PCB, as described in Section 2.1.6 above.

Earlier versions of the peripheral board used slightly different connections, as noted for historical reasons below.

2.2.6. microcomputers The system makes use of one microcomputer at the base station and one

at each peripheral station and thermostat.

Some of the microprocessors used in the peripheral stations and thermostats are a version of the Sanguino,19 but the atmega644P CPU chips used here are mounted on special-purpose printed-circuit boards20 with screw terminals that couldn't fit on regular Sanguino boards. Each requires power connections (+5 V and ground) and other connections depending on the application.

The special peripheral station devoted to the furnace, central air conditioning, and wind vane/anemometer uses an Arduino Pro.

19 See http://sanguino.cc/ (link last reviewed 27 November 2011).

20 My design is a trivial variant of the Sanguino standard; see http://www.fenichel.net/papers/home control project/hc PCBs.zip for the design files and here at BatchPCB (link last reviewed 20 July 2012) for the boards as products.

Page 10: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

10

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

The button on the microcomputer board (circled in the picture) is meant to function as a reset button, but it is not reliable, and sometimes the only way to reset the board is to power cycle it. The "autoreset enable" jumper (upper left) should not be in place, and the "USB/ext" jumper (upper right) should be in the "ext" position.

The microprocessor used in the base station is an Arduino Mega2560.21 This board provides much more computing power than is strictly needed, but it was chosen because of its 4 UARTs, 3 of which are used by the application.

The Arduino Mega2560 will normally reset itself whenever a USB cable is newly connected to it, and the only way to disable this bug/feature is to use a sharp blade to cut the trace between the pads labeled "RESET-EN" (circled in the picture below).

21 See http://arduino.cc/it/Main/ArduinoBoardMega2560 (link last reviewed 20 July 2012).

Page 11: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

11

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

To facilitate downloading programs to the Mega2560, auto-reset can be re-enabled by reconnecting these two pads.

To provide screw-terminal connections, the microprocessor board is capped by a simple shield:22

These microcomputers can be at least temporarily deranged by electromagnetic pulses of the sort emitted by TIG welders.

22 My design; see http://www.fenichel.net/papers/home control project/hc PCBs.zip for the design

files and here at BatchPCB (link last reviewed 20 July 2012) for the boards as products.

Page 12: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

12

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

2.2.7. power-supply board The various hardware components need +5 V (display units, DS1307,

microprocessor, XBees) and +3.3 V (BMP085, SHT1523). A common power-supply board24 provides both voltages.25

The circled 2-pin connectors on the power-supply board are present to allow current measurement to be made. In normal use, each of these connectors should have its two conductors shorted together.

2.2.8. thermostat board The coil-current requirements and internal resistances of commodity

relays26 are such that these relays cannot by controlled directly by the microprocessors used here. A simple board27 contains a power transistor to

23 The SHT15 can use any power supply from +2.5 V to +5 V, with slight adjustment of the software

to correspond to the voltage chosen. The choice of +3.3 V was made to allow a single peripheral station to have both an SHT15 temperature/humidity sensor and a BMP085 pressure sensor. These devices would then share some electrical connections, and the BMP085 will not tolerate exposure to voltages above +3.5 V. Now that I have abandoned the SHT15, the system could be simpler.

24 My design; see http://www.fenichel.net/papers/home control project/hc PCBs.zip for the design files and here at BatchPCB (link last reviewed 20 July 2012) for the boards as products.

25 A -5 V supply is needed for AC-DC conversion, but this is generated internally by DC-DC conversion on the AC-DC converter board. In hindsight, it would probably have been more cost-effective to design the whole project around a single +5 V source, with DC-to-DC converters here and there to provide the milliamp currents needed at +3.3 V.

Page 13: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

13

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

provide adequate drive for the relay coil and, for convenience, connection blocks for power within the thermostat station.

2.2.9. level shifter As noted elsewhere,28 the power supplied to the BMP085 and SHT15 is

+3.3 V, but the most of the other components run on +5 V. To protect the BMP085 and SHT15, and to ensure successful communication with them, these peripherals are connected via level-shifter boards. Each of these boards29

is connected to ground, to the +3.3 V and + 5 V supplies, and to data and clock lines running to and from a peripheral and to and from a microcomputer.

26 For example, see http://www.futurlec.com/Relays/PR12VDCDPDT.shtml.

27 My design, see http://www.fenichel.net/papers/home control project/hc PCBs.zip for the design files.

28 See footnote 23.

29 See http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/PCA9306.pdf or http://www.sparkfun.com/products/10403 (links last reviewed 9 February 2012).

Page 14: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

14

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

2.2.10. AC-DC converter AC-DC converter boards30 are used to transform the AC output of

current transformers into DC voltage(s) compatible with the analog measuring capacity of the microprocessors. Each AC-DC converter board has two parallel channels of AC-DC conversion.

30 My design; see http://www.fenichel.net/papers/home control project/hc PCBs.zip for the design

files and here at BatchPCB (link last reviewed 20 July 2012) for the boards as products.

Page 15: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

15

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

2.3. module summary

2.3.1. peripheral station A peripheral station includes

� a power-supply board, connected to a 9 V power source,

� a microcomputer,

� a peripheral board,

� an XBee transceiver

� one or more sensors,

� for each BMP085 or SHT15 sensor, a level-shifter,

� for each pair of current transformers, an AC-DC converter, and

� optionally, a display unit.

The connections among these components are described in the Overview schematic in http://www.fenichel.net/papers/home control project/hc PCBs.zip.

2.3.2. thermostat A thermostat includes

� a microcomputer, connected to a 9 V power source,31

� a clock component,

� a thermostat board,

� a temperature sensor,

� an XBee transceiver, and

� optionally, a display unit.

The assumed environment includes a relay that can be turned on with a coil current of a few hundred milliamperes at +9 VDC. Connections among these components are described in the Overview schematic in http://www.fenichel.net/papers/home control project/hc PCBs.zip.

2.3.3. base station A base station includes

� a power-supply board, connected to a 9 V power source,

� a microcomputer,

� a clock component,

31 The thermostat board uses the microprocessor's 9 V Vin to drive the relay coils.

Page 16: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

16

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

� a base-station board,

� an XBee transceiver, and

� optionally, a display unit.

The connections among these components are described in the Overview schematic in Overview schematic in http://www.fenichel.net/papers/home control project/hc PCBs.zip.

3. Microprocessor programs All of the microprocessor software is written in the Arduino version of C++.

The radio communication among the base station, peripheral stations, and thermostats is all in ASCII at 9600 baud; each message includes a checksum of its numerical content.

3.1. peripheral stations The peripheral stations all run the same software.

Each message from a peripheral station contains just the originating XBee's ID, a code for the sensor type, the sensor reading (one or two integers), and the checksum. The base station prefixes a timestamp to each message before storing it or passing it on to the Windows application.

During initialization, the peripheral-station program interrogates option switches on the peripheral board to see what sensors are attached to it. It initializes the attached sensors, and it arms an interrupt to count closures of the rain-gauge's switch. It then enters a loop which includes a random delay that is usually in the range of 25-37 seconds, but can be made to be 12 times faster by the setting of an option switch on the peripheral board. On each circuit of the loop, the microprocessor reads one or more sensors and sends the received readings to the base station; the several sensors are read at intervals corresponding to my estimate of their normal rates of change:

• the rain-gauge trip count is reported whenever it is non-zero;

• the power sensor (CT output converted to DC by the peripheral board) is reported on every cycle;

• the auxiliary inputs (whatever they are) and the "furnace" input are reported on every other cycle;

• the photocell and BMP085 readings are reported on every fourth cycle;

• the SHT15 [not any more] and DHT22 inputs are reported on every 20th cycle. [To protect the SHT15 against condensation, the SHT15's internal heater is judiciously engaged from time to time.]

3.2. base station The base-station section of the program listens two serial ports, one connected to its

XBee transceiver and one connected to a serial port on the computer that may be running

Page 17: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

17

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

the Windows application. The Windows application advises the microprocessor program when it is active and when it is shutting down; the base-station program also regards the Windows program as inactive if it has been silent for more than a few minutes.

When the Windows application is not active, incoming sensor readings from the peripheral stations are stored on the base-station board's µSD (or CF) card. When the microprocessor decides that the Windows application has become active, it transmits the stored sensor readings, followed by newer sensor readings as they arrive.

The Windows application sometimes supplies the base station with an XBee address and a message to be transmitted, via the base station's XBee transceiver, to that address. This mechanism is used to provide settings to the thermostats.

3.3. thermostats The thermostats all run the same software. Their XBees provide a channel through

which the Windows application (using the base station as a forwarding agent) can set the thermostats' target temperatures and modes of operation.

The Windows program can assign a time window (say, 10 minutes) to each thermostat. The thermostat can then operate in two different modes. In the simplest mode, the Windows application tells the thermostat to turn its associated relay on for a certain fraction of each time window. In the other mode, the Windows application specifies a desired temperature, and the thermostat controls the relay so as to reach and hold that temperature.

4. Hardware assembly

4.1. peripheral station The power-supply board, microcomputer, display unit, peripheral board, and XBee

transceiver should be mounted together to a convenient surface. To facilitate occasional access to the microprocessor for upgrading, it’s probably best to mount the components to a box or board rather than directly to the wall at the station’s intended location. Also, mounting to a box or board means that a peripheral station with no complex connectivity (no current transformers, and all attached sensors mounted together with the microprocessor on the same board) can be casually moved around the house to monitor the environment in any locations of interest. Here’s one of mine, showing the display unit (A), XBee (B), microprocessor (C), level-shifter (D), BMP085 (E),

Page 18: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

18

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

peripheral board (F), AC-DC converter (G, with a CT connection entering from the left), and power supply (H).

Page 19: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

19

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

If the peripheral station is wired as shown in the Overview schematic in http://www.fenichel.net/papers/home control project/hc PCBs.zip, and if the sensor-associated switches are on, then at irregular, deliberately randomized intervals, the various sensors will contribute to displayed lines like

sensor typical line interpretation

(sign-on)* X 1 1320 4ABF main panel

XBee parameter value

MY 1

(serial number) 1320 4ABF

NI main panel

temperature & humidity

T 765 56 or U 765 56 temperature 76.5 °F, relative humidity 56%

t 865 56 temperature 86.5 °F, relative humidity 56%; reading biased by on-chip heater

temperature & pressure

D 765 2983 temperature 76.5 °F, pressure 29.83" Hg

CT/power P 98 85 left and right CT current readings as shown** CT/furnace F 654 CT reading as shown** photocell L 543 photocell reading as shown**

rain gauge R 18 18 rain-gauge counts since sign-on r 0 rain-gauge switch persistently closed

auxiliary A 123 456 (no fixed interpretation) * This line may be partially overwritten by others before it can be read from the display ** Interpretable only after calibration

4.2. base station The power-supply board, microcomputer, display unit, base-station board, clock, and

XBee transceiver should be mounted together to a convenient surface. To facilitate occasional access to the microprocessor for upgrading, it’s probably best to mount the components to a box or board rather than directly to the wall at the station’s intended location. Here’s mine, showing the display unit (A), base-station board (B), microprocessor and overlying shield (C, with a USB connection entering from the left, and two leads from the RESET-EN pads32 sneaking out at the bottom), power supply (D), patch panel (E, now just a place for the RESET-EN leads to rest), DS1307 clock (F), and XBee (G).

32 See Section 2.2.6 above.

Page 20: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

20

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

When the base station is wired as shown in the Overview schematic in http://www.fenichel.net/papers/home control project/hc PCBs.zip, data received from the

Page 21: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

21

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

peripheral stations will result in displayed lines similar to those shown in the table in Section 4.1 above, except that each line will

• be prefixed by a two-digit sequence number,

• include the MyID of the peripheral station's XBee just before the first numerical value, and

• be followed by a checksum, the simple sum of the numerical fields of the line.

Data received from the thermostats will result in displayed lines like

73 H 5 622 0 10 637 sequence number, XBee MyID 5, temperature 62.2 °F, relay on-time fixed at 10%, checksum

74 H 5 622 68 90 1397

sequence number, XBee MyID 5, temperature 62.2 °F, target temperature 68 °F, relay on-time now set by P-I-D algorithm at 90%, checksum

4.3. thermostat The microcomputer, display unit, thermostat board, temperature sensor, clock, and

XBee transceiver should be mounted together to a convenient surface. It's good practice to have the high-voltage, high-current components (that is, the relay and associated wiring) in a separate enclosure. To facilitate occasional access to the microprocessor for upgrading, it’s probably best to mount the components to a box or board rather than directly to the wall at the station’s intended location. Here’s how I’ve done the first of mine, showing the DHT22 sensor (A); the connections to the relay box (B); the connection to 9VDC power (C); the microprocessor (D), the DS1307 clock (E); the thermostat board (F); the XBee transceiver (G); the display unit (H); and the connections (I) that allow the display to be reset, as described in footnote 14 :

Page 22: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

22

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

The components of the thermostat should be wired together as shown in the Overview schematic in http://www.fenichel.net/papers/home control project/hc PCBs.zip. The connections from the thermostat board toward the relay provide ground, +9 V, and a conductor that is switched to ground just when the thermostat intends to switch the relay on. An on-off-on switch within the relay enclosure can then determine whether the relay is fixed on (+9 V/ground across the coil), fixed off (+9 V/NC), or under thermostat control (+9 V/switched ground).

5. Calibration & Configuration

5.1. Advantage database HomeControlProject.exe uses the infrastructure provided by the free version

of the Advantage database software. This software can be downloaded from my Web site at http://www.fenichel.net/papers/Install Advantage DB v 10.exe. The self-extracting

Page 23: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

23

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

program provides instructions for installing the database infrastructure, including the Advantage Data Architect program, arc32.exe.

A recent copy (hc database.zip ) of the home-control database should be downloaded from my site here; when everything seems to be working, all data from before any given day can be removed by using one of the utilities within HomeControlProject.exe (see Section 5.9 below). The files in this zip file should all be extracted to the same directory.

Then, the Advantage Data Architect must be run by

• choosing File/New Connection Wizard/Create a connection to an existing data dictionary/Next

• entering HomeControl as the DatabaseName

• clicking on the ConnectionPath field, hitting the down-arrow to select Browse for dictionary file, and finding & selecting the HomeControl.add file that was just installed from the ZIP file

• leaving ServerType at local

• leaving CommunicationType as default

• leaving Username as AdsSys

• changing BlankPassword to yes , and

• exiting.

5.2. HomeControlProject.exe This is the Windows application, available on my site in source and executable form.

Install HomeControlProject.exe to a directory of your choice. HomeControlProject.exe communicates with the base station, collects and displays sensor data, and maintains a database of those data. The application includes a main form,

one form associated with each sensor type, and other forms serving miscellaneous purposes.

Page 24: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

24

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

5.3. XBee transceivers One has one's choice of programs for testing and configuration of the XBee

transceivers.33

The settings stored within each XBee transceiver allow it to be used in any of a great variety of modes. Fortunately, the default settings are close to those needed for this project.

The ID setting (4 hex digits) must be the same in each of the system's XBee units, and with luck it will be different from those of XBee units used by any nearby XBee systems.

The MY setting (4 hex digits) is arbitrary, but each transceiver must have a different MY, and the MY of the base-station transceiver must be 2.

The NI string (up to 20 alphanumeric characters) provides each transceiver with a human-readable name. These strings are tabulated (but otherwise ignored) by HomeControlProject.exe

The PL setting (0 through 4) sets the power level of XBee transmissions. The default power level (0) seems to be adequate for only a few meters of line-of-sight communication. There is no good reason not to set PL to 4 in every unit.

Don't forget to flash your selected settings to the XBee's permanent storage, using the appropriate tools within X-CTU.exe or the Moltosenso program, or using an ATWR command if you are using a generic terminal emulator.

33 X-CTU.exe is a program provided by the manufacturer of the XBee transceivers (see

http://www.digi.com/support/kbase/kbaseresultdetl.jsp?kb=125 (link last reviewed 27 November 2011)). The code is not well maintained; it works under Windows XP and Windows 7/32, but not under Windows 7/64. Alternatively, moltosenso_network_manager_iron.exe is freely available from a third party (see http://www.moltosenso.com/client/fe/browser.php?pc=/client/fe/technology.php (link last reviewed 24 July 2012), and it appears to be more robust. Finally, all of an XBee's configuration can be set by connecting the transceiver to a generic terminal emulator and using the XBee's AT commands (ATID, ATMY, and so on).

Page 25: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

25

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

5.4. peripheral boards Each peripheral board contains 16 switches. Turning on a switch connects an

associated trace to ground, thereby informing the associated microprocessor of a user option. The switches with assigned functions are

label interpretation 1 speedup data should be sampled at high rate 2 aux "aux1” and “aux2” sensors in use here 3 light photocell in use here 4 SHT15 SHT15 in use here [obsolete] 5 power CT(s) for power measurement in use here 6 furnace CT detecting on-off status in use here 7 heat SHT15 SHT15 heater should be continuously on* [obsolete] 8 DHT22 DHT22 in use here 9 BMP085 BMP085 in use here

* [Turning on the heater should raise the sensor's temperature by 10-20 °F; if no such change is seen, then there's something wrong. SHT15 readings made while the heater is on are not stored in the database, and an SHT15 should not, in any event, be left with its heater on for more than a few minutes at a time.]

5.5. sensors When the base station passes a sensor reading (say, a temperature) in to the Windows

program, the only identifying information provided is the MyID of the XBee that transmitted the reading to the base station. Configuration information allows the Windows program to associate the originating XBee with the name of the location of the sensor.

From the main HomeControlProject.exe form,

Page 26: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

26

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

selecting view/sensors from the menu brings up a form

that provides a list of the known sensors, with a subsection that allows new sensors to be added to the list. Here and throughout, purple text on a green background is read-only. Some of the data collected and displayed here serve no purpose beyond inventory maintenance, but the observed field shows the name of each sensor's location, and the station field shows the name of the peripheral station or thermostat to which the sensor is attached. The observed and station names are used elsewhere, as described variously below. Changes made on this form will not take full effect until the next time the HomeControlProject.exe program is started.

5.5.1. current transformer for sensing switched-device operation When a current transformer is used only to sense whether a switched

device is on or off, the only necessary calibration is to choose a threshold to distinguish these states, based on the values shown on “F” lines when the device is known to be on and off. The chosen threshold value should be entered into the sensors table described in Section 5.4 above.

Page 27: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

27

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

5.5.2. current transformers for power-consumption measurement Measurement of AC electrical currents in this system entails

o current-to-voltage conversion by the current transformers,

o AC-to-DC voltage conversion by the AC-DC converter board, and

o DC voltage measurement by the peripheral-station microcomputer.

To compensate for uncontrollable component variance that affects the second and third of these steps, the HomeControlProject.exe program interprets current-measurement data by using calibration data that the user must obtain by using a multimeter and the calibrate HCS.xls spreadsheet.

5.5.2.1. recording data Using a digital multimeter that can read AC millivolts, on occasions

that cover a fair range of electrical consumption, with the peripheral board’s “speed” switch turned On, data must be recorded for each current transformer:

• the voltage at the input to the AC-DC converter board (probably in the range of 70-400 mV AC) and

• the simultaneous corresponding value in “P” lines in the peripheral-station display, in the base-station display, or in the log. Even before calibration, the values in the "P" lines should be close (say, within a factor of 4) to the measured mV readings.

5.5.2.2. computing calibration parameters The desired calibration parameters are obtained via the

calibrate HCS.xls spreadsheet, which can be downloaded from my site here. The spreadsheet computes the best linear fit to the data obtained with the multimeter. The spreadsheet assumes that the parameters that describe the current transformers (full-scale current input & corresponding voltage output) are correct. The multimeter data (mV and count) for the various electrical loads should be entered into the spreadsheet, overwriting the sample data provided. If there are not enough data to fill the data area, then either

• unused lines (not the first or last) may be deleted, or

• some data may be entered multiple times. Duplicated data pairs will increase the accuracy of the fit for values near the duplicated data, at the expense of the fit elsewhere.

Page 28: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

28

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

5.5.2.3. installing calibration parameters From the main HomeControlProject.exe form, selecting

view/stations from the menu brings up a form

that displays large amounts of data about each station, mostly for inventory-maintenance purposes. When you have determined the calibration parameters for a station, those parameters can be entered here.

Page 29: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

29

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

The other calibration component needed is the line voltage. From the main HomeControlProject.exe form, selecting sensors/power from the menu brings up a form

on which the line voltage can be entered.

5.5.3. photocells The values that appear on “L” lines will range between 0 and 1023, and

they will be scaled into the 0–100 range for graphing. Levels below some point (say, 70 out of 1023) may all look equally dark, and the graphs may look best if the area representing the light level never quite reaches the top. On the sensors form (see Section 5.5 above), the 0% on and 100% on fields should be filled in to allow for scaling of the photocell data.

Page 30: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

30

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

5.5.4. rain gauge Inexpensive rain gauges often report their findings in 0.01" units, but

some do this with one switch closure and some do it with two. Yet other rain gauges might use metric units. In HomeControlProject.exe , choosing sensors/rain gauge from the menu elicits a window like

Clicking on the Down button beneath the cyan block causes the window to expand to something like34

The inches-per-switch-closure description of the rain gauge should be entered in the box provided.

34 The table will be empty if the show log for above date button has not been used.

Page 31: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

31

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

5.6. base station

5.6.1. µSD card A µSD card on the base-station board is used to store sensor readings

received from the peripheral station when the base station does not have an open connection to the Windows application. A new, unlocked µSD card can be initialized in the base station by turning the first base-station dip switch to On and resetting the base-station microprocessor. The microprocessor will initialize the CF card, losing any data previously there. The dip switch should then be turned Off before resetting the microprocessor for normal operation.

5.6.2. clock The clock module will inevitably run faster or slower than the clock of

the PC, and large discrepancies will be seen when one of the two clocks shows Standard Time and the other is on Daylight Savings Time. In HomeControlProject.exe , choosing view/ base-station clock from the menu brings up a form like35

5.6.2.1. manual synchronization The set clock button can be used to set the base-station clock

module to a time that is x seconds faster than the clock of the PC, where x is specified in the spin-edit control near the button.

35 If a shorter version of the window appears, it can be expanded by clicking on the Down button

below the maroon block.

Page 32: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

32

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

5.6.2.2. correction for estimated recurring error If the base-station clock seems to be consistently losing (or gaining)

x seconds per day, then HomeControlProject.exe can be made to make an automatic adjustment whenever the estimated accumulated error y exceeds a specified threshold z. When the x and z parameters are supplied in the automatic setting group of controls, then whenever y > z, the base-station clock will be set to be y/2 seconds fast (or slow).

5.6.2.3. Daylight Savings Time When Daylight Savings Time starts or stops, the base-station clock

will for a while be time-stamping sensor readings with times that are an hour off. In the daylight savings time group of controls, HomeControlProject.exe finds data that allow it to correct for these periods of non-synchronization. The timestamps of readings stored by the base station when its clock was set to standard time36 but DST had started37 are automatically advanced by an hour, and, after all of these records have been processed, the base-station clock is advanced. Complementary actions occur as DST ends.

The 2nd Sunday next March and 1st Sunday next November buttons are shortcuts for setting the next DST start and next DST end boxes; these boxes can also be set manually.

5.7. display units The brightness of the display units' backlights can be adjusted by turning the

trimpots on the associated base-station and peripheral boards.

36 That is, when the base clock on DST box was not checked.

37 That is, when the computer's clock showed a timestamp after 0200 on the date shown in the next DST start box.

Page 33: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

33

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

5.8. log As messages are received from the base station, HomeControlProject.exe

transcribes them to a human-readable log, visible after view/log is selected from the menu.

The checkboxes at the top of this form allow messages to be logged selectively.

5.9. printer The form accessed via view/utilities

is used to specify the printer to be used when printing graphs.

Page 34: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

34

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

6. Operation When HomeControlProject.exe is started, a splash screen like

appears transiently, but this window is quickly replaced by the home window:

This window may be reduced in size or hidden, but minimizing it or closing it causes the whole HomeControlProject.exe application to be minimized or to be closed. When this window is hidden behind one of the other forms of the application, double-clicking on that other form will cause this window to come forward.

The other forms of the application are accessed by selecting menu entries from this form. Some of those other forms are not particularly useful until communication has been established with the base station, which is achieved by selecting a port from the list and clicking on the connect & listen button.

Page 35: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

35

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

When listening is started, the log window38 appears, and some time may be taken as sensor readings that had been waiting in the base station are downloaded ("dumped") to the Windows application and stored in the database. The contents of the listbox shown in the log window can at any time be cleared or saved to a file.

The µSD card at the base station will hold about 40 000 lines of data per megabyte, so capacity is not an issue, but it’s good to protect the data against power failures by draining the card (that is, by running the HomeControlProject.exe) at least every few days.

6.1. current sensor status The sensors menu gives access to forms corresponding to the various types of

sensors. There might be several different sensors of a given kind (for example, there might be several different SHT15/DHT22 temperature-humidity sensors). All of the data coming in from these sensors will be stored in the database and accessible to the graphing tools, but the form associated with a given sensor kind will show the most recent values from only a selected few (now always just one or two) of the sensors of that kind. This selection is hard-coded, but easily changed. For example, the values shown on the form associated with on-off devices

are (as shown) those collected from the furnace and the workroom heater. The sensors now specially handled in this way are

sensor type specially handled

on-off devices observed is 'furnace' or 'workroom heater'

photocell observed is 'outside'

power observed is 'house'

temperature & pressure observed is 'workroom'

temperature & relative humidity observed is 'outside' or station name is 'roaming'

Below the top portion, always devoted to current readings, some of the sensor-related forms provide access to other data related to the associated sensor(s). To show the additional components, these forms can be dragged open in the usual way, or more rapidly opened by using the down-arrow buttons provided as in the form shown above.

38 See Section 5.7 above.

Page 36: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

36

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

The sensor-related forms show the exact values received from the respective sensors, but the values of dew point, light level, pressure, relative humidity, and temperature are exponentially smoothed before being stored in the database.

6.1.1. on-off devices The on-off sensor whose observed field (see Section 5.5 above) is "furnace"

is specially treated. Expansion of the on-off devices form

reveals the furnace filter box, in which the compute service time button causes computation of how many hours the furnace has operated since a specified date.

6.1.2. power monitoring The power data can rapidly become voluminous. Because more recent data may

be expected to be accessed most often, it is efficient to partition the power data by age. Every few weeks, it is wise to bring up the power form (see Section 5.5.2.3 above), enter a date in the segregating old data box, click on the underlying button, and let more data be recategorized. The older data is used seamlessly in graphs, but only newer data is available for addition to the summary table described in Section 6.8 below.

Page 37: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

37

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

6.1.3. rain gauge Rain gauges occasionally generate false counts as a result of inadvertent

mechanical vibration. A more isolated mounting would be a good hardware solution, but a software solution has been provided. When the rain-gauge-related form is expanded,

it allows a date to be specified, the rain accumulation of that date examined, and spurious entries to be deleted.

Page 38: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

38

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

6.2. graphs In HomeControlProject.exe , the submenu below graphs allows you to

choose among

• a parameterized pre-defined graph, summarizing selected results by date;

• a form that lists all of the graphs that you have defined, and that allows you to modify or add to them; and

• graphs that you have defined.

6.2.1. results grouped by date The graphs/outside, grouped by date menu selection brings

up a pre-defined graph that can show various sensor readings, grouped by date. Checkboxes let you choose which sensor readings will be included, and the choose date range button brings up a specialized form through which you can specify the date range. When the plot button is clicked, you'll see a graph like

Page 39: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

39

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

For example, the image shown just above shows data from the fall of 2011. The photoperiod gradually shortened, with an offset when Daylight Savings Time stopped on 6 November (yellow); temperatures gradually fell (red); power usage gradually rose, except for a week of my absence (magenta); and so on. The graph could be printed by clicking on the labeled button; the printer was chosen as described in Section 5.9 above.

6.2.2. graph manager The graphs/graph manager menu selection brings up a form like

This form lists all of the user-defined graphs. As shown here, the first graph listed

• will be listed in the graphs submenu as today/outside, no power;

• will show results from the day on which it is invoked;

• will have outside as its caption;

• has not yet been created as a form (status = null);

• will show temperatures in °F and pressures in inches of mercury; and

• will not be created and displayed automatically when HomeControlProject.exe is started.

The scale of this graph's left-hand Y axis will be fixed (roughly 0 −100), while that of its right-hand Y axis will depend upon the data. The lower grid lists all of the series plotted on this graph; the entries in the appearance field shows that the graph's background is a medium gray, and the first few

Page 40: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

40

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

series will be plotted with red, blue, and green. When this graph is selected from the menu, it will look something like

The edit and new graph buttons allow graphs to be altered and defined, respectively. When either of these activities is begun, the program searches the accumulated database to find all of the possible combinations of sensor type and observed. This process can take some time, especially if (by checking the search . . . AddOrEditGraph box) you allow the search to include the older portion of the power log (see Section 6.1.2 above).

Page 41: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

41

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

Adding or editing a graph is accomplished through a 2-page form, the first of whose pages looks like this:

This page provides a list of all the possible series. Once a selection has been made and the freeze series button is pressed (or if one got here to edit an existing graph), the second page of the form appears:

Page 42: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

42

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

This page allows one to control how the various series will be plotted:

• all series are plotted with respect to the left-hand Y-axis scale by default, but this setting can be changed via the toggle Y scale button;

• double-clicking on a row of the grid allows a new color to be selected for the plotting of that series;

• the background color panel allows the background color of the graph to be selected, either arbitrarily (the change button) or to one of two preset options (the outside and workroom buttons);

• other controls allow one to specify whether the graph will be displayed automatically when HomeControlProject.exe is started, the left and right Y-axis scales, the description to be used as a menu entry, and so on.

To see the range of dates for which data exist in a given series, select the series in the grid and use the compute date range button.

6.3. base-station clock As noted in Section 5.6.2 above, the view/base-station clock

menu selection elicits a form that reports the status of the base-station clock.

Because the application checks its buffers for input at a frequency that adaptively rises or falls with the data rate from the base station, the degree to which the base-station clock is slow or fast (the discrepancy D) is only an estimate. When the application is checking its buffers every x seconds, the raw discrepancy d of the timestamp on a newly-arriving sensor reading must be estimated by comparing the timestamp to (the current time minus x/2 seconds). A more stable estimate of D is obtained by exponential damping of the series of raw discrepancies d. If the debug clock checkbox on the base-station clock form is checked, then some of the innards of the exponential damping process are displayed in the listbox just below it.

Page 43: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

43

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

6.4. notes The view/notes menu selection elicits a form

showing a table of notes that one may modify or extend.

Page 44: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

44

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

6.5. thermostats If the system includes more than one thermostat, then the

view/thermostats menu selection brings up a list of the thermostats. If — as in my current system — there is only one thermostat, then view/thermostats leads directly to a thermostat-specific form:

The thermostat form shows the state of the selected thermostat and allows its operation to be controlled. Global settings use the controls at the lower right:

• The thermostat's clock can be synchronized with that of the Windows computer by using the set thermostat time button, and

• the time window of the thermostat (see Section 3.3 above) can be set.

Then, the other controls allow one to initiate P-I-D-controlled or constant-percent-on operation, whichever is desired.

6.6. tweaks From time to time, HomeControlProject.exe reassures the base

station that it is still in operation. The tweaks/send 'Windows is listening' menu selection triggers a one-off extra message of reassurance.

Page 45: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

45

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

Garbled transmission between the base station and HomeControlProject.exe is annotated in the log (see Section 5.8 above), and a count of garbled messages is, when nonzero, displayed prominently on the main form. To reset the count to zero, and thereby to clear the displayed message, use the tweaks/acknowledge bad records menu selection.

6.7. XBees The view/XBees menu selection elicits a form

that shows, for each XBee at a peripheral station or the base station, its name (NI ), its address (MY), and its globally-unique serial number (SH & SL). The grid entry describing a peripheral station is added or updated when the station's microprocessor reboots; the entry describing the base station is updated whenever the base station acknowledges a transmission from HomeControlProject.exe.

Page 46: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

46

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

6.8. summary data The view/summary menu selection elicits a form

showing day-by-day summary data from the database. Data covering days before today are brought in to the summary by clicking the update summary button. To avoid summarizing days whose data are incomplete, the update summary button is enabled only when communication with the base station has been established, and any data that might have been waiting on the µSD card have been transferred to the database.

7. Troubles

7.1. microprocessor freezes Every now and then, one of the microprocessors freezes, and it must be

rebooted. These events probably reflect memory leaks, counter overflows, or the like; they are so rare (separated by months) that I have not tried to track them down. I routinely reboot the microprocessors every 6 weeks or so, but I am unsure that this makes any difference.

7.2. Windows application freezes Every now and then, HomeControlProject.exe freezes so solidly

that even the Task Manager will not kill it, and Windows must be restarted. These events occur at intervals of days to weeks. I suspect that the problem is related to the serial-port interface, which is ancient, public-domain code that I do not fully understand, and that in any event long predates Windows 7's sandboxing of its serial ports and other low-level hardware.

When the base-station microprocessor recognizes prolonged inactivity of the Windows application, it stops trying to transmit sensor readings, and reverts

Page 47: Home Monitoring System - Fenichel control project/Home Control.pdfHome Monitoring System Robert R. Fenichel 1. Introduction This document describes an ongoing project that began with

47

G:\electronics\projects\home control\Home Control.doc 5-Nov-15 @ 1756

to storing them until the Windows application returns. As a result, these application freezes generally result in minimal loss of data.

7.3. logging gaps Power failures and similar events can cause data to be lost. Graphs that

cover the gap period can be made to look slightly less strange if the gap is formally identified. On the window elicited by the view/utilities menu selection, the clean up after logging gap button provides access to a special-purpose form

When the limits of the gap have been specified (either manually, or by letting the application look forward & backward from a specified time), the OK button will cause appropriate adjustments to be made in the database.