Ovládání klimatizace přes IR

Nedaří se vám s projektem a nenašli jste vhodné místo, kde se zeptat? Napište sem.
Pravidla fóra
Tohle subfórum je určeno pro konzultaci ucelených nápadů, popřípadě řešení komplexnějších projektů, které opravdu není možné rozdělit na menší části.
Většinu problémů jde rozdělit na menší a ptát se na ně v konkrétních subfórech.
Kony
Příspěvky: 382
Registrován: 09 dub 2020, 11:43
Reputation: 0

Ovládání klimatizace přes IR

Příspěvek od Kony » 23 čer 2020, 16:13

Ahoj, chtěl bych přes Arduino ovládat klimu, pomocí programu :
#include <IRremote.h> // use the IRRemote.h
const int irReceiverPin = 2; //the SIG of receiver module attach to pin2
IRrecv irrecv(irReceiverPin); //Creates a variable of type IRrecv
decode_results results; // define resultsas

void setup()
{
Serial.begin(9600); //initialize serial,baudrate is 9600
irrecv.enableIRIn(); // enable ir receiver module
}

void loop()
{
if (irrecv.decode(&results)) //if the ir receiver module receiver data
{
Serial.print("irCode: "); //print "irCode: "
Serial.print(results.value, HEX); //print the value in hexdecimal
Serial.print(", bits: "); //print" , bits: "
Serial.println(results.bits); //print the bits
irrecv.resume(); // Receive the next value
}
delay(600); //delay 600ms
}
se snažím vyčíst kódy .... váýpis mám tento, je to vždy opakování VYPNOUT/ZAPNOUT

Kód: Vybrat vše

16:07:08.623 -> irCode: 195A6272,  bits: 32
16:07:09.207 -> irCode: CD638DF9,  bits: 32
16:07:11.609 -> irCode: 4E779F07,  bits: 32
16:07:15.212 -> irCode: 3D126DD0,  bits: 32
16:07:18.217 -> irCode: 6C13F00B,  bits: 32
16:07:21.813 -> irCode: FB9899E1,  bits: 32
16:07:24.826 -> irCode: 8578F901,  bits: 32
16:07:27.245 -> irCode: 24985DB8,  bits: 32
16:07:29.061 -> irCode: 5F60F04,  bits: 32
16:07:29.661 -> irCode: 6A74DF83,  bits: 32
16:07:32.667 -> irCode: BF37AB7B,  bits: 32
16:07:35.670 -> irCode: CEF92A78,  bits: 32
16:07:38.694 -> irCode: 6FF3B1B6,  bits: 32
16:07:42.294 -> irCode: A9E043D0,  bits: 32
16:07:44.666 -> irCode: B01CFE59,  bits: 32
16:07:47.114 -> irCode: 78A27AAB,  bits: 32
tzn, že se žádný kód neopakuje...

zkoušel jsem i pomocí :
//------------------------------------------------------------------------------
// Include the IRremote library header
//
#include <IRremote.h>

//------------------------------------------------------------------------------
// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
//
int recvPin = 11;
IRrecv irrecv(recvPin);

//+=============================================================================
// Configure the Arduino
//
void setup ( )
{
Serial.begin(9600); // Status message will be sent to PC at 9600 baud
irrecv.enableIRIn(); // Start the receiver
}

//+=============================================================================
// Display IR code
//
void ircode (decode_results *results)
{
// Panasonic has an Address
if (results->decode_type == PANASONIC) {
Serial.print(results->address, HEX);
Serial.print(":");
}

// Print Code
Serial.print(results->value, HEX);
}

//+=============================================================================
// Display encoding type
//
void encoding (decode_results *results)
{
switch (results->decode_type) {
default:
case UNKNOWN: Serial.print("UNKNOWN"); break ;
case NEC: Serial.print("NEC"); break ;
case SONY: Serial.print("SONY"); break ;
case RC5: Serial.print("RC5"); break ;
case RC6: Serial.print("RC6"); break ;
case DISH: Serial.print("DISH"); break ;
case SHARP: Serial.print("SHARP"); break ;
case JVC: Serial.print("JVC"); break ;
case SANYO: Serial.print("SANYO"); break ;
case MITSUBISHI: Serial.print("MITSUBISHI"); break ;
case SAMSUNG: Serial.print("SAMSUNG"); break ;
case LG: Serial.print("LG"); break ;
case WHYNTER: Serial.print("WHYNTER"); break ;
case AIWA_RC_T501: Serial.print("AIWA_RC_T501"); break ;
case PANASONIC: Serial.print("PANASONIC"); break ;
case DENON: Serial.print("Denon"); break ;
}
}

//+=============================================================================
// Dump out the decode_results structure.
//
void dumpInfo (decode_results *results)
{
// Check if the buffer overflowed
if (results->overflow) {
Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWBUF");
return;
}

// Show Encoding standard
Serial.print("Encoding : ");
encoding(results);
Serial.println("");

// Show Code & length
Serial.print("Code : ");
ircode(results);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
}

//+=============================================================================
// Dump out the decode_results structure.
//
void dumpRaw (decode_results *results)
{
// Print Raw data
Serial.print("Timing[");
Serial.print(results->rawlen-1, DEC);
Serial.println("]: ");

for (int i = 1; i < results->rawlen; i++) {
unsigned long x = results->rawbuf * USECPERTICK;
if (!(i & 1)) { // even
Serial.print("-");
if (x < 1000) Serial.print(" ") ;
if (x < 100) Serial.print(" ") ;
Serial.print(x, DEC);
} else { // odd
Serial.print(" ");
Serial.print("+");
if (x < 1000) Serial.print(" ") ;
if (x < 100) Serial.print(" ") ;
Serial.print(x, DEC);
if (i < results->rawlen-1) Serial.print(", "); //',' not needed for last one
}
if (!(i % 8)) Serial.println("");
}
Serial.println(""); // Newline
}

//+=============================================================================
// Dump out the decode_results structure.
//
void dumpCode (decode_results *results)
{
// Start declaration
Serial.print("unsigned int "); // variable type
Serial.print("rawData["); // array name
Serial.print(results->rawlen - 1, DEC); // array size
Serial.print("] = {"); // Start declaration

// Dump data
for (int i = 1; i < results->rawlen; i++) {
Serial.print(results->rawbuf * USECPERTICK, DEC);
if ( i < results->rawlen-1 ) Serial.print(","); // ',' not needed on last one
if (!(i & 1)) Serial.print(" ");
}

// End declaration
Serial.print("};"); //

// Comment
Serial.print(" // ");
encoding(results);
Serial.print(" ");
ircode(results);

// Newline
Serial.println("");

// Now dump "known" codes
if (results->decode_type != UNKNOWN) {

// Some protocols have an address
if (results->decode_type == PANASONIC) {
Serial.print("unsigned int addr = 0x");
Serial.print(results->address, HEX);
Serial.println(";");
}

// All protocols have data
Serial.print("unsigned int data = 0x");
Serial.print(results->value, HEX);
Serial.println(";");
}
}

//+=============================================================================
// The repeating section of the code
//
void loop ( )
{
decode_results results; // Somewhere to store the results

if (irrecv.decode(&results)) { // Grab an IR code
dumpInfo(&results); // Output the results
dumpRaw(&results); // Output the results in RAW format
dumpCode(&results); // Output the results as source code
Serial.println(""); // Blank line between entries
irrecv.resume(); // Prepare for the next value
}
}


kde mě taky vždy vyjde jiný kód (to jsem zkoušel i na ovladači od TV)

Pokud jsem dle první varianty vyčetl HEXa kód na TV, tak jsem TV mohl ovládat, ale tam se aspoň při záznamu kodu opakoval semtam stejný kod.
Klimu jsem se snažil potom ovládat podle :

#include <IRremote.h>

IRsend irsend;

void setup()
{

}

void loop() {
int khz = 38; // 38kHz carrier frequency for the NEC protocol
unsigned int irSignal[] = {9000, 4500, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 39416, 9000, 2210, 560}; //AnalysIR Batch Export (IRremote) - RAW

irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.

delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
}

kde jsem doplnil sekvenci kodu dle výpisu, ale zase se to pokaždý mění

Uživatelský avatar
kiRRow
Příspěvky: 1152
Registrován: 07 kvě 2019, 07:03
Reputation: 0
Bydliště: Opava

Re: Ovládání klimatizace přes IR

Příspěvek od kiRRow » 23 čer 2020, 16:42

Zřejmě si narazil na něco čemu se říká plovoucí kód. Kód se při každém odvysílání mění. Kvůli bezpečnosti, nebo třeba k vůli tomu, aby jeden ovladač neovládal více zařízení najednou. Některé plovoucí kódy se po čase začnou opakovat a tudíž umíš sestavit nějakou tabulku všech kódů. Některé se mění neustále. Na tyhle se dá vyzrát tak, že odposlechneš 1. kód a zároveň znemožníš přijímači ho příjmout, kód si uložíš. Odposlechneš 2. kód a zároveň znemožníš přijímači ten kód příjmout, odvysíláš 1. kód a 2. kód si uložíš. Takto budeš o krok napřed a vědět jaký kód bude přijímač očekávat.

Kony
Příspěvky: 382
Registrován: 09 dub 2020, 11:43
Reputation: 0

Re: Ovládání klimatizace přes IR

Příspěvek od Kony » 23 čer 2020, 17:06

Mám doma dvě klimatizace a ty můžu klidně ovládat jedním ovladačem. Ale asi to bude tak jak píšeš.

Mohl by si mě npomoct s kodem jak to tedy vyřešit ???

Takže mám to tlačítko tak dlouho mačkat, až se začne nějaký kód opakovat ?

Uživatelský avatar
kiRRow
Příspěvky: 1152
Registrován: 07 kvě 2019, 07:03
Reputation: 0
Bydliště: Opava

Re: Ovládání klimatizace přes IR

Příspěvek od kiRRow » 23 čer 2020, 18:02

Možná ho čteč jenom špatně. Třeba vysílá jinačí frekvencí, než ti pracuje přijímač. To ti taky udělá takovou paseku.

Kony
Příspěvky: 382
Registrován: 09 dub 2020, 11:43
Reputation: 0

Re: Ovládání klimatizace přes IR

Příspěvek od Kony » 23 čer 2020, 18:05

no nastaveno 38 KHz což je správně.. na TV to normálně funguje


joooo ty myslíš ta klima...... no tak to nevím jak zjisitt

Uživatelský avatar
kiRRow
Příspěvky: 1152
Registrován: 07 kvě 2019, 07:03
Reputation: 0
Bydliště: Opava

Re: Ovládání klimatizace přes IR

Příspěvek od kiRRow » 23 čer 2020, 18:14

To je třeba zjistit. Nejsnadněji to půjde osciloskopem. Nebo zkusit vyhledat na netu všechny možné frekvence co různé ovladače používají a zkoušet. Něco jako když nevíš na jaké rychlosti jede seriová linka jiného přístroje, tak zkoušíš prostě známé rychlosti.

Kony
Příspěvky: 382
Registrován: 09 dub 2020, 11:43
Reputation: 0

Re: Ovládání klimatizace přes IR

Příspěvek od Kony » 23 čer 2020, 18:25

jenže jak zjistit že jsem práve správně ? Mimo ten osciloscop ?
Tohle je přímo ta moje klima :

Kód: Vybrat vše

toshiba ras-m13 skv-e

Uživatelský avatar
kiRRow
Příspěvky: 1152
Registrován: 07 kvě 2019, 07:03
Reputation: 0
Bydliště: Opava

Re: Ovládání klimatizace přes IR

Příspěvek od kiRRow » 23 čer 2020, 18:36

google : toshiba ras-m13 skv-e IR frequency -> hledat ... hned první odkaz : https://toshibaaircon.ru/storage/i/Inst ... V(R)-E.pdf ... strana 25 : REMOTE CONTROLLER -> Infrared Rays, 36.7kHz

Kony
Příspěvky: 382
Registrován: 09 dub 2020, 11:43
Reputation: 0

Re: Ovládání klimatizace přes IR

Příspěvek od Kony » 23 čer 2020, 18:44

supeeer dekuji

Uživatelský avatar
kiRRow
Příspěvky: 1152
Registrován: 07 kvě 2019, 07:03
Reputation: 0
Bydliště: Opava

Re: Ovládání klimatizace přes IR

Příspěvek od kiRRow » 23 čer 2020, 18:48

Tak pak pošli výsledek. Ať mám mít z čeho radost :)

Odpovědět

Kdo je online

Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 13 hostů