House contyrol project using webserver and OneWire - Project Showcase - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

House contyrol project using webserver and OneWire

onewire webserver ftp ntp

  • Please log in to reply
7 replies to this topic

#1 OZ8ET

OZ8ET

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts
  • LocationHundested, Denmark

Posted 29 December 2012 - 05:34 PM

My Home automation system  using OneWire and Web management.

My vacation house needs to be controlled for heating to avoid spending too much money on heating.

The control system has 2 states:

  • If the house is “in use”, heating must be on as long as the temperature is below a certain limit (“high-limit”). Furthermore a pump (fresh water) must be on between 06:30 and 22:30.
  • When the house is “Vacant” heating must be on only if temperature drops below a certain limit – “low-limit”. The pump must always be off.

These simple rules give us a couple of control-activators (relays). These are:

  • Relay 1 (R1) – heating on and off
  • Relay 2 (R2)– pump on and off

The rules also include a few control-indicators (Values). These are:

  • Current state (LED) –indicates if the house is “In Use” or “Vacant”
  • Temperature (TMP) – current temperature value (a measured value)
  • Low-Limit (LL) – a temperature value (a variable)
  • High-Limit (LH) – a temperature value (a variable)
  • Current time (NOW) – the time from the real-time clock
  • Pump-on (PON) – the time for pump to be switched on when “in use”
  • Pump off (POF) the time for the pump to be switched off when “in use”

In a generic forM, the rules can be set up as following:

R1 = (LED AND (TMP<=LH)) OR ((NOT LED) AND (Temp <=LL))
R2 = LED AND (NOW >=PON) AND (NOW < POF)

These rules are my “Engine” and the engine has to be run whenever en event occurs.

These events are:

  • Time change (minute interval) – from Real Time Clock
  • Temperature change (I chose 15 sec interval) from OneWire device
  • A threshold value change
  • Low Limit (LL) via the user interface (web or console)
  • High Limit (LH) via the user interface (web or console)
  • Pump-on (PON) via the user interface (web or console)
  • Pump-off (POF)  via the user interface (web or console)

From this we can see, that the “Engine” has to run whenever a time-interval of 15 sec or when a threshold change via the user interface (web or console).

Having defined the Engine, we have 2 more challenges:

  • The console: a minimal display showing the current status and a few buttons to change the threshold values.
  • The web server: a way to display the status and change the threshold values via a web browser.

The console is implemented with a display with 4 lines 20 char. Each and a 5-way button that gives me the following indications: Up, Down, Left, Right, Select.

The web server only needs to give one page. This page is a json structure with all the threshold variables  and information about connected OneWire devices and their values (temperature a.o.).

The main web page can reside on another server, but is also available in a simple form from the web server in the house automation controller.

Required changes to the threshold values, can be send as arguments with the json-request and thus be communicated to the “engine”.

The advantages of this setup are many:

  • The data on the web-page can be change without making a page request and there for looks more smooth.
  • The json request can be made from another  web server on an interval in order to collect information for later use in statistic and graphical presentations.
  • It is simple to implement, and the design of the page(s) can be changed when required without making changes to the house-controller hardware/software

Hardware design

This project has several generations behind. The following platforms has been developed and tested:

  • Single chip web-controller DK40 with one relay to control heating.
  • MSP400 based microcontroller from Olimex programmed in C++. Nice hardware but hard to program.
  • Netduino Plus with homemade Shield for display, key-control and relays.
  • Rapberry Pi with Linux and OneWire file system – easy to program – never completed the hardware required
  • Netduino Plus 2 – same hardware shields. This is the current implementation.

Netduino Plus 2:

Dot Net Micro Framwork (NETMF) with version 4.2 . Easy to program using Microsoft Visual Studio.

Homeautomation Shield:

The shield has the following facilities:

  • Connector for OneWire
  • 2 Relays with each 2 switches – Connectors
  • 4x20 LCD display
  • 5-way switch
  • Reset button
  • 2 Led’s showing Relay status.

Software design:

  • Engine
    • Main Engine logic
    • OneWire Engine
    • Engine related Web requester
  • Console
    • LCD driver
    • Keypad driver
    • Console logic/loop
  • Network
    • Http server
    • Ftp server
    • Name service
    • NTP server
  • Utilities
    • Extensions
    • Log system
    • Configuration management
  • Main
    • Initialization and main loop.

Production:

The shield was designed using Target 3001! V15 discover software for Schematic and PCB layout.

The PCB was manufactured as a prototype at Olimex.com.

Software written in Visual Studio 2010 using C#.

This version of the system has been in operation since early 2012. First using Netduino Plus FW 4.1 with CW2’s OneWire extension. After the arrival of Netduino Plus 2, the system is converted to the new platform using FW 4.2 and the build in OneWire Software.

 

 

Feel free to contact me for details.

Regards

Erik



#2 Gutworks

Gutworks

    Advanced Member

  • Members
  • PipPipPip
  • 363 posts
  • LocationOttawa, Ontario

Posted 29 December 2012 - 07:37 PM

Fantastic work Erik. Thank your for the all of the awesome details. I can't wait to see some pictures some day of your setup.

 

Steve



#3 Mike L

Mike L

    Advanced Member

  • Members
  • PipPipPip
  • 48 posts

Posted 30 December 2012 - 12:07 AM

Sounds like a very cool project Erik!  Thanks for sharing.  I never thought of using a 5 way switch for user input, that's a cool idea.  What are you using the FTP server for (log file xfer)? 



#4 OZ8ET

OZ8ET

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts
  • LocationHundested, Denmark

Posted 30 December 2012 - 05:57 AM

Thanks for nice comments.:)

What am I using the FTP for? - good question. I think it is there mostly because I got it working :), however I can also use it to download new webpages. The most important webpages are implemented as embedded resources in flash.

The Picture shows the 'thing' without cover inserted into a DIN-rail.

 

Posted Image



#5 OZ8ET

OZ8ET

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts
  • LocationHundested, Denmark

Posted 30 December 2012 - 09:55 AM

A few additional comments on the Console function:

 

The Console
Using a 4-line display and a 5-way button gives very limited options. I have tried to generalize the functionality by implementing Display modes.

The shift between display modes is done using up and down function on the button.
Changes within a display mode are made using the left and right function on the button.
Activating a change is done using the select function on the button.

Example:

One display mode is showing the individual temperature devices connected. Once the mode is selected using up/down, shift between the connected temperature devices is done using left/right. If the select function is used while displaying a particular temperature device, this device will be marked as the primary device used for heating control (the DS1820 being used).

If no key-press is mad within 10 seconds, the display mode will be set to the default display mode (Showing time, Temperature and tank level).

List of Modes and key functions:
 
Mode no Display   Up Down   Left    Right   Select  
0 (default   Time, Temp and tank level Mode 7 Mode 1 n/a    n/a n/a
1   Low threshold temperature  Mode 0 Mode 2   - 0.5C   + 0.5C   Activate change
2   High threshold temperature Mode 1 Mode 3   - 0.5C   + 0.5C   Activate change
3   Pump On time   Mode 2 Mode 4   - 10 min + 10 min Activate change
4   Pump Off time   Mode 3 Mode 5 - 10 min   + 10 min Activate change
5   OneWire devices and Temp Mode 4 Mode 6   Prev device Next device  Activate as used
6   Request Time from NTP Mode 5 Mode 7   n/a n/a Request time
7   Show SW version Mode 6 Mode 0   n/a n/a   n/a
 
Implementation:

The console has been implemented as classes with one class defining a mode.  Each mode has an entry for the following


    [*]modeOnEntry
    [*]modeOnExit
    [*]modeShow (called every 500 ms or if events happens)
    [*]modeKeyPress (called when key is activated or released)
    [/list]

    Each mode must define at least the modeShow and modeKeyPress functions.
    By having a collection of these mode classes, it is easy to implement new modes or make changes in existing.

    It is possible to enter a sub-mode within a mode.

    An example:

    Within a mode: first time your press the select function, the sub-mode goes into edit-mode. In edit-mode you can use the left/right to select a particular digit in a value and then use up/down to change the value of that digit. When you again press the select function, the sub-mode goes into display-mode from where you can use the up/down to change mode as described previously.



#6 iced98lx

iced98lx

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts
  • LocationSouth Dakota

Posted 30 December 2012 - 06:04 PM

Erik-

 can you detail the 1wire setup, specifically the phsycial connections/wiring diagram?



#7 OZ8ET

OZ8ET

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts
  • LocationHundested, Denmark

Posted 30 December 2012 - 07:50 PM

OneWire connection is very simple. Direct connect to a digital port (D13 in my case) with 1K8 resistor pulup to +5V.

I use parasit power but have 5 volt on the OneWire bus.

My OneWire bus is app. 50 meter with no problem.

By mistake I forgot the pullup at first, but the system worked well with the Netduino Plus 1.generation. When I changed to Netduino Plus 2, nothing worked - this was why I discovered my mistake. Now it Works fine.



#8 iced98lx

iced98lx

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts
  • LocationSouth Dakota

Posted 31 December 2012 - 10:40 PM

Thanks Erik!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.