[Help Needed] Photon to Control Aircon Wirelessly

Hi all,

So i had this idea on creating a small box that i can place in my room to control my Aircon.
However, im having issue even at the start.

So before i being, here’s what i am going to do.
I have divided my project into 3 phase

  1. Decoding the IR Signals from my aircon REMOTE (Reverse Engineering method)
  2. Try sending the same signals from my photon via a IR Emitter
  3. Hooking it up to a Web service to change my aircon here and there.

So the problem is that, after spending hours, i still cant seemed to have any progress. I tried looking into codes from different site.Still no progress.

To begin now,
this is my current code below…

I have also attached the + pin into 3v3 instead of a 5v as i dun have one.

Any solutions here?

/*
Author: AnalysIR
Revision: 1.0

This code is provided to overcome an issue with Arduino IR libraries
It allows you to capture raw timings for signals longer than 255 marks & spaces.
Typical use case is for long Air conditioner signals.

You can use the output to plug back into IRremote, to resend the signal.

This Software was written by AnalysIR.

Usage: Free to use, subject to conditions posted on blog below.
Please credit AnalysIR and provide a link to our website/blog, where possible.

Copyright AnalysIR 2014

Connections:
IR Receiver      Arduino
V+          ->  +5v
GND          ->  GND
Signal Out   ->  Digital Pin 2
(If using a 3V Arduino, you may connect V+ to +3V)
*/

int LEDPIN = D0;
//you may increase this value on Arduinos with greater than 2k SRAM
.#define maxLen 800

volatile unsigned int irBuffer[maxLen]; //stores timings - volatile because changed by ISR
volatile unsigned int x = 0; //Pointer thru irBuffer - volatile because changed by ISR

void setup() {
  Serial.begin(9600); //change BAUD rate as required
  attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//set up ISR for receiving IR signal
}

void loop() {
  // put your main code here, to run repeatedly:

  Serial.println(F("Press the button on the remote now - once only"));
  delay(5000); // pause 5 secs
  if (x) { //if a signal is captured
    digitalWrite(LEDPIN, HIGH);//visual indicator that signal received
    Serial.println();
    Serial.print(F("Raw: (")); //dump raw header format - for library
    Serial.print((x - 1));
    Serial.print(F(") "));
    detachInterrupt(0);//stop interrupts & capture until finshed here
    for (int i = 1; i < x; i++) { //now dump the times
      if (!(i & 0x1)) Serial.print(F("-"));
      Serial.print(irBuffer[i] - irBuffer[i - 1]);
      Serial.print(F(", "));
    }
    x = 0;
    Serial.println();
    Serial.println();
    digitalWrite(LEDPIN, LOW);//end of visual indicator, for this time
    attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);//re-enable ISR for receiving IR signal
  }

}

void rxIR_Interrupt_Handler() {
  if (x > maxLen) return; //ignore if irBuffer is already full
  irBuffer[x++] = micros(); //just continually record the time-stamp of signal transitions

}

With that code you need to connect your IR receiver to D0. I'd recommend using the explicit pin names rather than anonymous numbers (as done on Arduino).
But D0 is a bad choice anyway :wink:

https://docs.particle.io/reference/firmware/photon/#interrupts

Also what are you using as IR receiver? A pure IR transistor or rather a dedicated receiver?
If the latter, you should take one that has the same carrier frequency as your signal source. But I'd go for a "dumb" IR transistor.

2 Likes

Hi there ScruffR!

So happy to see a respond.
Im actually using the keyes IR receiver.

Picture as attached.

With that code you need to connect your IR receiver to D0. I'd recommend using the explicit pin names rather than anonymous numbers (as done on Arduino).
But D0 is a bad choice anyway :wink:

I tried D1, D2, D3 too... No luck.
So u're trying to label as D0, D1, D2.. I label as Pin 1? like the arduino example? but how do i know which is which pin on the Photon?

If you look at the Photon from the top you can see the pin label (see the Photon datasheet for another reference).

When you say “no luck” are you ever getting your interrupt handler to fire?

As I said, your receiver needs to fit the signal source.
The sensor you’ve got there seems to be a 38kHz sensor (TSOP 1838)

If your source is not, you won’t get proper readings - or none at all.

What is the make and model of your Air conditioner?

If you look at the Photon from the top you can see the pin label (see the Photon datasheet for another reference).

Hmmm, according to what ScruffR said, i dont label D0, instead like PIN 1,2,3,4?
How does that work?

What is the make and model of your Air conditioner?

Im using Mitsubishi Heavy Electronics, should be SRK-ZM

I refer to that when i tried pressing a button, the IR Receiver has a LED that said it receive a signal, but nothing appears.

Hmmm, according to what ScruffR said, i dont label D0, instead like PIN 1,2,3,4?
How does that work?

He just mean that instead of putting 1, 2, etc in your code your should use D1, D2, etc

Im using Mitsubishi Heavy Electronics, should be SRK-ZM

Cool. I wasn't able to find a more technical manual. Could I get front and back pictures of your remote? Does it mention the IR frequency on the remote by chance? You might need to open it up to explore.

I refer to that when i tried pressing a button, the IR Receiver has a LED that said it receive a signal, but nothing appears.

We need to run down the IR frequency issue.

2 Likes

Noted! Will post the necessary updates for discussion.