www.mgdengineering.com
www.mgdengineering.com

Marc Daigneault - 2014

Featured on Hackaday.com!

This project involved making a S.M.A.R.T (Self-Monitoring, Analysis, and Reporting Technology) Thermostat which could be accessible over the internet. This project combines several elements of embedded electronics, all while keeping on the theme of Home Automation. This page is a quick overview of the project; full documentation including EagleCAD board schematic & layout, as well as the Source code, can be found at the bottom of the page.

When designing this project, I wanted it to conform to these requirements:

  • Remote control and monitoring via Web
  • Upfront control and monitoring via LCD and pushbuttons
  • Remote Monitoring, Data Logging & Graphing

This Web-Enabled thermostat offers full remote control, a full upfront user interface with pushbuttons and LCD & remote monitoring and logging of temperature history using simple bash and Perl scripts running on a VM Linux server.

www.mgdengineering.com

High Level Design

Below you'll find the block diagram, which gives an idea of what this project consist of. The Ethernet Development Board is an Olimex PIC-WEB, based on Microchip's PIC microcontroller. The I/O Expansion board is the daughter board which I've designed and created to be matched with the PIC-WEB, to allow for full control of the I/O board using the 20 pin extension header of the Olimex board.

Ethernet Development Board

To simplify the whole online process, an Ethernet development board was chosen, and for one good reason: When troubleshooting problems, if it was both hardware and software that I've made, it would've been much more work to troubleshoot, as the problem can be either hardware, software or both. By taking hardware that I know works, and writing my own code, I'd be able to troubleshoot in no time. The Olimex PIC-WEB board worked great: low-cost, uses the easy to program Microchip 18F series microcontroller, and has a nice 20 pin extension header, allowing me to interface with the HVAC board that I've made specifically for this application. The 20 pin header equally has +5V and GND, so I could use the power supply of the PIC-WEB to power my daughter board.

Although Olimex includes a 20 pin header for their PIC-WEB board, they don't manufacture any daughter boards, so I took upon the task of making my own. My board includes LCD Display, Push Buttons, Relay's for HVAC, and an LM35 temperature sensor. The PIC-WEB does have a thermistor on-board, but I found it to be inaccurate and slow to react to changing temperature, so an LM35 was added onto the daughterboard. It was much more reliable.

HVAC Daughter Board

This was the main portion of the project, making a daughter board able to control the HVAC side of the project all while keeping it compatible with the PIC-WEB. Initially, the circuit was put together on perforated board, however, the mess of wires it created demanded the creation of a PCB.

www.mgdengineering.com
www.mgdengineering.com

The problem is the 20 pin header that connects to the PIC-WEB: 20 wires in such a dense location demanded many wires, on both the top and bottom layer of the board, and made for a very messy board of intertwined wires. Troubleshooting wasn't very pleasant, but this board did function, and was used to debug the code while I impatiently awaited my EagleCAD board's from SpeedyPCB.

The EaglePCB has only 2 vias for a 2 layer board, pretty good considering the number of traces going to the 20 pin header.

www.mgdengineering.com

Picking components for the daughter board

Although the 18F452 used on the PIC-WEB is capable of using the standard 2-wire hardware I2C, these pins were not made available on the extension header, as the PIC-WEB uses I2C on-board to communicate with an EEPROM used for storing web pages.

So, for temperature sensing, since I2C was out of the question, both because the hardware lines weren’t available, and also because it required two pins, I decided to get a high accuracy analog temperature sensor, such as the LM35DZ from Microchip. This device was chosen because of its compact TO-92 package, low self heating (<0.1°C), which is very important in temperature sensing applications, and ease of use (10mV/ºC). As well, this device would only require one pin of the microcontroller, where as an I2C device would have required two. Had I had more I2C devices, that would have justified using that bus, but in my case, it wasn’t necessary.

For relays, I had decided to use 5v SPST SRS-05VDC-SL relays by Songle, as I was looking for something that could handle 24VAC for the HVAC side of things, but as well work well interfaced with a PIC microcontroller. Although I could potentially power these relays directly using the output of a PIC, I had examined all the possible states, and noticed that it was possible for 3 or more relays to be powered synchronously, which would put an unnecessary strain on the PIC. So, to still be able to switch these devices using a PIC, I implemented a Darlington array driver, ULN2803, which acts as open collector output, allowing me to sink a fairly large amount of current while sourcing a small amount from the PIC. As well, this Darlington driver also has built in clamp diodes to help eliminate the noise caused by devices on its outputs, which is great, as it would suppress the inductive kick of the relays. This IC was perfect for the application needed in my circuit.

The LCD module uses in all 6 pins from the IC as it runs in 4-bit mode to help reduce the number of pins required. We can count 4 data pins, 1 register select, and 1 enable pin. The LCD is the sole device to use the most pins on the daughter board; however it was determined necessary as I wanted to integrate both a visual interface as well as the web one. Three standard single pole push buttons were used to allow some user interface. For the thermostat application, this would allow to increase the set point, reduce the set point, and switch between heating and cooling modes.

As well, standard screw terminals were implemented on the board, allowing for the relay’s to switch each individual channel on or off. Since a 24v HVAC systems are all feed from the same power source, the board is setup in a way where each output of the screw terminals are either connected or disconnected from the +24V common, all depending on the state of the relay.

Interfacing with residential / commercial HVAC system

I designed the board so that it could be interfaced with a residential/commercial 24Vac HVAC system. 24Vac systems are an industry standard, so if you're wondering what you're running at home, chances are it's what this board was designed for. I wanted the HVAC side of the project to be plug and play, so finding the correct ASHRAE naming and color code for the wires was a necessity. The naming was silkscreened on the board, next to the correct screw terminal. You could potentially connect this up to your HVAC system and it would be fully compatible.

www.mgdengineering.com

This board can run systems that use single stage cooling & single or dual stage heating, with full Heat Pump control. It can be customized to whatever the application is, however it is limited to 5 relay's for controlling whichever 5 devices the user wants. 5 Relays is enough for most if not all residential/commercial applications (Unless you've got a million dollar residence), however some industrial applications run on 220Vac and use a totally different type of system.

Software - Getting the board online

Olimex does give a fair amount of documentation about making your own web pages and how to interface them with the microcontroller. You can fairly easily display on the web page output states, integer values and such. Equally, you can create pushbutton that call up specific function prototypes, again totally customizable, so you can switch output states, increment/decrement integer values, or what ever you want to do.

www.mgdengineering.com

Getting online is fairly straight forward, as this board uses the messy but reliable TCP/IP stack by Microchip. This stack is basically the software that run the HTTP Server, FTP Server, SMTP Server & DHCP Client. Simply plugging the board into you house network should allow it to pickup an IP, which you can then access through a web browser. I have the IP displayed on the LCD screen of the daughter board whenever the board starts up, so I know exactly what IP the board has taken. You can also disable DHCP, and force the device to take on any IP you want.

The webpage that I put together allows the user to see the set point, current temperature and the state of all the outputs. As well, the use has control over the set point, with the possibility to increase/decrease it and see it change in real time, and as well switch from heating to cooling mode and vice-versa. The nicest feature is the graphing, which shows both Set Point and Current Temperature on a daily and weekly basis.

www.mgdengineering.com

A remote VM Linux server is simply polling the site every 5 minutes and registering the Current and Set Point Temperature, then using bash and Perl scripts, simply graphing it out with the help of Munin and Monit (Google it!), which creates a .PNG of the history and host it locally. So, the site on the PIC-WEB doesn't actually host the graphs, they are simply hyperlinked from the VM server. A plugging had to be created for Munin, as it's not made to graph out temperature but rather computer loads and specs.

The nice part about using an external Linux server is that I can graph out and monitor multiple devices. Say you own a 12 story commercial building, and have a web-enabled thermostat on each floor. You could monitor and control them all from one central location, and keep history of the temperature and set point, which all building owners know is a good thing. (People complain the most about temperature in a building...you now have proof of temperature on every floor at every hour of the day, with databases going back months if not years.)

Below, you can see how Monit can be implemented to monitor multiple devices, and see which are functioning and which are not:

www.mgdengineering.com

So, the final product: a fully automated S.M.A.R.T system (Again, that's Self-Monitoring, Analysis, and Reporting Technology), with the possibility of having these devices spread out over hundreds of locations, thousands of miles away, all being able to monitor them from one centralized controller.

This Thermostat is only one application for this device; It totally programmable to do anything and everything for almost any application. With the ease of use of setting up the websites and coding in MPLAB, a web-enabled control and monitoring device could be produced for custom applications, with quick turnaround, relatively low cost compared to other devices on the market and easy implementation at the job site.

Special thanks to Nick Dinel from Nickdinelservers.com for hosting the VM server and setting up the graphing.

Feel free to comment about the project here or email me

//////////**May 19th, 2009***////////////

I've updated the site with the bill of material and schematic for the daughter board. Unfortunately the parts were purchased locally, so I don't have the Digikey equivalent. All footprints are standard; only the relays would need to be looked into.

You can figure out the relays from the board layout, or go to the poorly documented datasheet.

www.mgdengineering.com

Click for full resolution (.PDF Format) or download the .ZIP file containing the EagleCAD Files. (Below)

Schematic:

www.mgdengineering.com

Layout:

www.mgdengineering.com

As well, here is the exact pinout of the 20 pin extension header, and how each pin is used on the daughter board:

www.mgdengineering.com
www.mgdengineering.com

As well, note that all the code was written in C using the latest build of MPLAB IDE and the C18 Compiler.

Attachments:

EagleCAD Board & Schematic

PowerPoint Presentation (PDF Format)

Source + Webpage (C18 Compiler)

Let me know if you use any of this in your projects, or tell me about them and I'll host them on the site! Always glad to hear about different projects and help out if I can!

Feel free to comment about the project here or email me

www.mgdengineering.com.

© MGD Engineering 2014 A Mobile Ready Website by jwbiz.com