BuddyC
Published © GPL3+

OH HAI! on Windows 10 IoT Core

Open Hardware Home Automation Intelligence integrates multiple existing smart home systems for a more cohesive solution.

IntermediateWork in progress17,702
OH HAI! on Windows 10 IoT Core

Things used in this project

Hardware components

Raspberry Pi 2 Model B
Raspberry Pi 2 Model B
×1
Arduino Nano R3
Arduino Nano R3
×1
ESP8266 ESP-01
Espressif ESP8266 ESP-01
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
IR Transmitter
×1
Microchip ATtiny85
×1

Software apps and online services

Arduino IDE
Arduino IDE
Windows 10 IoT Core
Microsoft Windows 10 IoT Core
Visual Studio 2015
Microsoft Visual Studio 2015
Weather Underground API

Story

Read more

Schematics

Deployment Diagram

Example of how Hai can be integrated

AC IR Blaster Schematic

IR blaster that controls point of use Air Conditioning units. Controlled by an ATTiny85 or Arduino Nano, it uses a DHT22 or DHT11 to calculate the real feel (based on temperature and humidity) and then communicates using an ESP8266.

Rain Barrel Schematic

The Rain Barrel has a series of float switch to sense how full the barrel is. The Arduino can either be hard coded on a watering schedule or use the ESP8266 to receive weather forecasts from Hai. It uses a relay to switch on/off a bilge pump powered by the same solar connected 12v battery source as the rest of the system. Since I'm powering the ESP8266 from the 3.3v bus on the arduino, I have a capacitor in parallel to help with the surge when first transmitting.

AC IR Blaster Schematic

IR blaster that controls point of use Air Conditioning units. Controlled by an ATTiny85 or Arduino Nano, it uses a DHT22 or DHT11 to calculate the real feel (based on temperature and humidity) and then communicates using an ESP8266.

Code

Dumb AC Controller

C/C++
This is the code for the 'Dumb' Air Conditioning Controller. It basically takes the average temp and humidity over a 30 second window and turns on the AC if it's over a certain temp. You can either use an IR receiver to get the raw codes from your remote, or wire the controller directly to the factory remote and simulate button presses with the arduino. This is just the generic outline since every application will be different.
// IR blaster to control AC unit
// Stand alone based on time
// This code assumes there are different IR codes for On/Off
// If your AC just has a power button, additional logic will be needed to remember current unit state
// The Hai smart integration is based off this code and looks for additional Manual On and Manual Off commands before going through the thermostat logic
// Hai integration version also reports ave temp and humidity every minute
    
int ACTEMP = 85;      // Default temp at which the AC turns on (85*F)
const int numReadings = 10;  // Readings used for average
// DHTPIN = 2;        (defined below)
int IRPIN = 4;        // Pin for IR LED

#include "DHT.h"        // Written by ladyada, public domain
#define DHTPIN 2        // DHT Sensor

// Uncomment whatever type you're using!
#define DHTTYPE DHT11   // DHT 11 
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
// NOTE: For working with a faster chip, like an Arduino Due or Teensy, you
// might need to increase the threshold for cycle counts considered a 1 or 0.
// You can do this by passing a 3rd parameter for this threshold.  It's a bit
// of fiddling to find the right value, but in general the faster the CPU the
// higher the value.  The default for a 16mhz AVR is a value of 6.  For an
// Arduino Due that runs at 84mhz a value of 30 works.
// Example to initialize DHT sensor for Arduino Due:
//DHT dht(DHTPIN, DHTTYPE, 30);

// Set variables to zero
float avetemp = 0;                
float temp = 0;
float checkdelay = 0;   
        
void setup() {
  Serial.begin(9600);

  delay(2000);
  dht.begin();

  Serial.println("IR controlled AC Started");
  
  dht.begin();
  pinMode(IRPIN,OUTPUT); 
}

void loop() {
  delay(5000);                 // Wait a few seconds between measurements
  temp = 0;

  Serial.print("Realtime Temp: \t");

  // Average temp over numReadings * delay
  for (int x = 0; x < numReadings; x++){
    float f = dht.readTemperature(true);            // Read temperature as Fahrenheit
    Serial.print(f);
    Serial.print("\t");
    temp = f + temp;
    delay(3000);                                    // delay in between reads for stability  
  }    
  Serial.println();

  avetemp = temp / numReadings;                    // calculate the average
    int h = dht.readHumidity();
    float hi = dht.computeHeatIndex(avetemp, h);  // convert to 'feels like' temp (heat index based on humidity)
  Serial.print("Average Temp is ");
  Serial.println(hi);                         // send it to the computer as ASCII digits

     // Check if any reads failed and exit early (to try again).
  if (isnan(hi)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

// Turn on AC if room is too warm
  if (avetemp>ACTEMP) {
    // Send IR signal to turn AC Unit ON
    checkdelay = 300000;
    Serial.print("Temperature is over ");
    Serial.print(ACTEMP);
    Serial.print(", AC is on (for ");
    Serial.print(checkdelay / 1000 / 60);
    Serial.println(" minutes)");
    delay(checkdelay);                               // turn on minimum of 5 min
   } else {
    // Send IR signal to turn AC Unit OFF
    Serial.print("Temperature is under ");
    Serial.print(ACTEMP);
    Serial.println(", AC is off");                   // When AC is off, Temp is read every 30 seconds
    checkdelay = 30000;    
  }

  Serial.println();
  Serial.println();
  
}

Credits

BuddyC

BuddyC

10 projects • 102 followers
I collect hobbies.

Comments