Last active
October 20, 2015 04:29
-
-
Save TACIXAT/14fa1b582a696cbb5a63 to your computer and use it in GitHub Desktop.
Single byte control heating using HVAC-IR-Control for Mitsubishi Mini Split
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* AUTHOR | |
** Douglas Goddard | |
** October 2015 | |
*/ | |
/* ABOUT | |
** This file is a simple set up for heating. | |
** There is a single byte for control. | |
** This allows temperature ranges 21c - 28c (~70f - 82f). | |
** Fan speeds 2, 3, 4 and silent. | |
** Vanne 3, 4, 5, and moving. | |
** You can, of course, turn the unit on and off. | |
** | |
** The idea is to hook this up to a rpi or beaglebone. | |
** That way we can write some complex scheduling | |
** as if we owned a real thermostat (or better)! | |
** | |
** Haven't tested this code yet, but it builds. | |
*/ | |
/* EXTERNAL | |
** This uses the HVAC-IR-Control library: | |
** https://github.com/r45635/HVAC-IR-Control | |
** Found via AnalysisIR: | |
** http://www.analysir.com/blog/2015/01/06/reverse-engineering-mitsubishi-ac-infrared-protocol/ | |
*/ | |
#include "IRremote2.h" | |
IRsend irsend; | |
void setup() { | |
Serial.begin(9600); | |
Serial.println("Alive!"); | |
} | |
void loop() { | |
// Single byte encoding | |
// 0bOVVFFTTT | |
// ON/OFF 0b10000000 (0x80) | |
// VANNE 0b01100000 (0x60) | |
// FAN SPEED 0b00011000 (0x18) | |
// TEMPERATURE 0b00000111 (0x7) | |
byte value = Serial.read(); | |
if(value != -1) { | |
// Start at min of 21c = 69.8f | |
// Range of 7, max 28c = 82.4f | |
int temp = 21; | |
temp += value & 0x7; | |
Serial.print("Temp: "); | |
Serial.print(temp); | |
Serial.println(" C"); | |
// My unit has 4 fan speeds + silent + auto | |
// This has range 1-5, using 2-4 because I don't know if 1 or 5 is missing | |
// Will test later... | |
// Fan speed 2, 3, 4 | |
// If 5, then set to silent | |
HvacFanMode fan = FAN_SPEED_2; | |
int fan_int = 2; | |
fan_int += (value >> 3) & 0x3; | |
Serial.print("Speed: "); | |
switch(fan_int) { | |
case 2: | |
fan = FAN_SPEED_2; | |
Serial.println("2"); | |
break; | |
case 3: | |
fan = FAN_SPEED_3; | |
Serial.println("3"); | |
break; | |
case 4: | |
fan = FAN_SPEED_4; | |
Serial.println("4"); | |
break; | |
case 5: | |
fan = FAN_SPEED_SILENT; | |
Serial.println("Silent"); | |
break; | |
} // end switch(fan_int) | |
// This is for heat so let's blow it at the ground | |
// Start at 3 and go up to 5 (most downward) + moving (6) | |
HvacVanneMode vanne = VANNE_H3; | |
int vanne_int = 3; | |
vanne_int += (value >> 5) & 0x3; | |
Serial.print("Vanne: "); | |
switch(vanne_int) { | |
case 3: | |
vanne = VANNE_H3; | |
Serial.println("3"); | |
break; | |
case 4: | |
vanne = VANNE_H4; | |
Serial.println("4"); | |
break; | |
case 5: | |
vanne = VANNE_H5; | |
Serial.println("5"); | |
break; | |
case 6: | |
vanne = VANNE_AUTO_MOVE; | |
Serial.println("Moving"); | |
break; | |
} // end switch(vanne_int) | |
// on / off | |
boolean off = (value >> 7) & 0x1; | |
// print actions | |
if(off) { | |
Serial.println("Switching OFF!"); | |
} | |
irsend.sendHvacMitsubishi(HVAC_HOT, temp, fan, vanne, off); | |
} // end if(value != -1) | |
} // end function loop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment