Arduino based AC remote
In the bedroom we have a portable AC to cool of the room. It creates some noice, and therefor we prefer to run it at daytime and shut it off at bedtime. But how to remember to start the AC in the morning? The AC has a remote controller, so the plan is to build a Arduino-based remote capable of imitating the stock remote. The Arduino has a IR-transmitter and a RTC (Real Time Clock). In that way the Arduino can power on the AC at a preset time and power off at bedtime. The design is based on schematics and info from https://learn.sparkfun.com/tutorials/ir-communication. First the IR-receiver (a one like this was connected to the Arduino and the IRrecvDemo sketch from the IR library was loaded. The power key on the AC remote was pressed, and the sketch tried to decode the signal. That failed, the remote obviously not using a standard protocol. Instead the IRrecvdump was loaded instead. This code don't just try to decode the signal, it also shows the raw undecoded values (duration of high and low pulses in the signal sent from the remote). I modified the code a bit to get suitable values to send later with the IR library function irsend.sendraw. The modification looks like this: for (int i = 0; i < count; i++) { /*if ((i % 2) == 1) { Serial.print(results->rawbuf[i]*USECPERTICK, DEC); } else { Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC); }*/ Serial.print(results->rawbuf[i]*USECPERTICK, DEC); Serial.print(","); This way the digits are printed as only positive values which is what sendraw want. The result from this code was as follows: ... Could not decode message Raw (200): 6914,4500,4300,650,1550,650,450,650,1550,650,1550,600,500,600,500,600,1550,650,500,600,450,650,1550,650,450,650,450,650,1550,650,1550,600,500,600,1600,600,500,600,450,650,1550,650,1550,650,1550,650,1550,600,1600,600,1550,650,1550,650,1550,650,450,650,450,600,500,600,500,600,500,600,500,600,1600,600,1550,650,1550,650,450,650,450,650,1550,650,450,650,450,600,500,600,500,600,500,600,1600,600,1550,650,450,650,1550,650,1550,650,5100,4500,4300,650,1550,650,450,650,1550,650,1550,600,500,600,500,600,1550,650,450,650,450,650,1550,650,450,650,450,650,1550,650,1550,600,500,600,1600,600,500,600,500,600,1550,650,1550,650,1550,650,1550,600,1600,600,1550,650,1550,650,1550,650,450,650,450,650,450,650,450,600,500,600,500,600,1600,600,1550,650,1550,650,450,650,450,650,1550,650,450,650,450,650,450,650,450,650,450,600,1600,600,1550,650,450,650,1550,650,1550,650, The last "," and the first digit was removed. The number after "Raw" (200) indicates the number of digits that should be used in the transmitting code. Resend the code In the transmitter an array is created with the values from above. First the IR send code is initialized: // IR library #include IRsend irsend; Then the array is created: unsigned int powerOn[200] = {4500,4300,650,1550,600,500,600,1600,600,1550,650,450,650,450,650,1550,650,450,650,450,650,1550,650,450,600,500,600,1600,600,1550,650,500,600,1550,600,500,650,450,650,1550,650,1550,600,1600,600,1550,650,1550,650,1550,650,1550,600,1600,600,500,600,500,600,500,600,500,600,500,600,500,600,1550,650,1550,650,1550,650,450,650,450,600,1600,600,500,600,500,600,500,600,500,600,500,600,1550,650,1550,650,500,600,1550,650,1550,600,5150,4500,4300,650,1550,650,450,600,1600,600,1550,650,500,600,500,600,1550,650,500,600,450,650,1550,650,450,650,450,650,1550,600,1600,600,500,600,1550,650,450,650,500,600,1550,650,1550,600,1600,600,1550,650,1550,650,1550,650,1550,650,1550,600,500,600,500,600,500,600,500,600,500,600,500,600,1550,650,1550,650,1550,650,450,600,500,600,1600,600,500,600,500,600,500,600,500,600,500,600,1550,650,1550,650,500,600,1550,600,1600,600}; Then, in "loop", we send the value: void loop() { irsend.sendRaw(powerOn,200,38); delay(5000); } Time for a test. With the mobile phone camera I first checked that the IR diode is transmitting, a weak pink/red flash is visible (flashing) when the camera is focused straight into the diode. Then I put the Arduino in front of the AC. Sadly the AC just beeped but didn't power on. I pushed the power button on the device, and after a few seconds the AC turned off. I then figured that the AC remote's power button send different codes each time it's pressed, one code for on and a different one for off. So I got back to IRrecvdump and recorded both codes. Then in the sender code an array named "powerOff" was created. Now I can send codes for both on and off, time(!) to move on to the RTC code. Edit: This is now finished and seems to work well. More explanation about the code and hardware is in the source, found at https://github.com/bphermansson/AC-Remote.