I just received Wio Link. Didnât try it yet (else from the trivial). I used 1 software for arduino to receive the IR codes, which I saved from serialMonitor into a txt file. Afterwards, in another sketch I use the acquired IR codes (in timings format, not Hex). I think this sounds exactly the same you want to do, but with wio⌠Here goes the code for reading the on-off timings on arduino (I used the code from AnalysIR ):
[code]/*
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
Please refer to the blog posting for conditions associated with use.
http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/
Connections:
IR Receiver Arduino
V+ -> +5v
GND -> GND
Signal Out -> Digital Pin 2
(If using a 3V Arduino, you may connect V+ to +3V)
*/
#define LEDPIN 13
//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
}[/code]
And here goes the code to read the temperature and send commands to Carrier AC, using the txt-saved timing codes. It checks the temperature once every 60 secs, and if it is too high, it sends the on-command. If it is too low, it sends the off-command:
[code]#include âDHT.hâ
#include âIRremote.hâ
#define DHTPIN A0 // pino umidade e temperatura
// Grove DHT11
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);
IRsend irsend;
int khz=38; //Frequencia IR
unsigned t_off[] = {4440, 4400, 560, 1632, 556, 544, 556, 1640, 560, 1632, 556, 544, 556, 544, 568, 1624, 564, 536, 564, 540, 560, 1636, 564, 536, 564, 536, 560, 1632, 560, 1632, 564, 536, 564, 1632, 560, 544, 564, 1628, 560, 1632, 560, 1632, 556, 1632, 568, 532, 568, 1628, 560, 1636, 564, 1632, 564, 536, 564, 536, 564, 536, 564, 536, 564, 1628, 560, 540, 560, 544, 564, 1632, 560, 1632, 564, 1628, 564, 536, 564, 536, 564, 536, 560, 540, 560, 544, 556, 544, 568, 532, 564, 540, 564, 1632, 564, 1628, 560, 1632, 560, 1628, 560, 1636, 564, 5252, 4436, 4396, 564, 1628, 564, 536, 560, 1636, 564, 1624, 568, 532, 564, 536, 564, 1628, 564, 540, 560, 540, 568, 1628, 560, 540, 560, 544, 556, 1632, 568, 1624, 564, 536, 564, 1632, 568, 536, 564, 1628, 560, 1632, 568, 1624, 564, 1628, 560, 540, 560, 1636, 564, 1628, 560, 1640, 560, 540, 560, 540, 588, 512, 588, 512, 588, 1604, 584, 516, 584, 516, 596, 1604, 596, 1596, 560, 1632, 560, 540, 556, 544, 588, 512, 588, 512, 588, 512, 596, 508, 592, 508, 592, 508, 592, 1604, 564, 1628, 560, 1632, 556, 1636, 564, 1632, 608};
unsigned t_on[] = {4436, 4388, 568, 1624, 564, 536, 564, 1632, 568, 1624, 564, 536, 564, 540, 556, 1636, 564, 536, 564, 540, 560, 1636, 564, 536, 564, 536, 560, 1632, 560, 1632, 568, 532, 564, 1636, 564, 536, 564, 536, 564, 536, 564, 1628, 560, 1632, 568, 1624, 564, 1628, 564, 1656, 540, 1632, 568, 1624, 564, 1628, 560, 540, 560, 540, 560, 544, 556, 544, 564, 536, 564, 1632, 560, 1632, 564, 536, 564, 536, 564, 1628, 560, 540, 560, 540, 560, 544, 568, 532, 564, 540, 560, 1632, 560, 1632, 564, 536, 564, 1632, 560, 1632, 564, 1628, 564, 5228, 4440, 4396, 564, 1628, 564, 536, 560, 1636, 564, 1628, 564, 536, 560, 540, 560, 1632, 568, 536, 564, 540, 560, 1636, 564, 536, 560, 540, 560, 1632, 560, 1632, 564, 536, 564, 1636, 564, 540, 560, 540, 560, 540, 560, 1632, 564, 1628, 564, 1628, 560, 1632, 556, 1640, 560, 1636, 564, 1628, 560, 1632, 556, 544, 568, 532, 596, 504, 596, 504, 596, 508, 592, 1604, 592, 1600, 560, 540, 560, 540, 588, 1604, 568, 532, 588, 512, 588, 516, 592, 512, 588, 508, 592, 1604, 564, 1628, 560, 540, 560, 1636, 564, 1628, 560, 1636, 564};
int contador = 0;
int TMIN = 23;
int TMAX = 25;
void setup()
{
Serial.begin(9600);
Serial.println(âControle de Temperatura Carrierâ);
dht.begin();
}
void loop()
{
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to A0 seconds âoldâ (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h))
{
Serial.println("Failed to read from DHT");
}
else
{
Serial.print("umidade: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("temperatura: ");
Serial.print(t);
Serial.println(" *C");
if (t<TMIN && contador < 1){
Serial.print("Desligando... ");
irsend.sendRaw(t_off, sizeof(t_off)/sizeof(int), khz);
contador = 15;
}
if (t>TMAX && contador < 1){
Serial.print("Ligando... ");
irsend.sendRaw(t_on, sizeof(t_on)/sizeof(int), khz);
delay(10000);
contador = 15;
}
if (contador>0){
contador--;
}
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
delay(10000);
}
}[/code]