Cov txheej txheem:

Récupérer Les Codes Infra-Rouge Et 433mhz: 4 Kauj Ruam
Récupérer Les Codes Infra-Rouge Et 433mhz: 4 Kauj Ruam

Video: Récupérer Les Codes Infra-Rouge Et 433mhz: 4 Kauj Ruam

Video: Récupérer Les Codes Infra-Rouge Et 433mhz: 4 Kauj Ruam
Video: Cyrob : Télécommandes radio, mesures et visualisation de code... 2024, Lub Xya hli ntuj
Anonim
Récupérer Les Codes Infra-Rouge Et 433mhz
Récupérer Les Codes Infra-Rouge Et 433mhz

Le tab sis yog qhov ua tau zoo dua cov lej des télécommandes du style commande de lampe, porte de garage et autre fonctionnant sous 433 mhz (RX433) mais aussi ceux des télécommandes infra-rouge de télévision au autre.

Nyob rau ntawm lub tsev kawm ntawv, tsis muaj kev cuam tshuam los ntawm tus kheej, tus neeg xa xov laij lej thiab tus tsav dav hlau n'importe quoi!

Kauj Ruam 1: Le Montage

Le Montage
Le Montage

Yooj yim, un Arduino Nano, une diode réceptrice infra-rouge et un récepteur 433 mhz.

Kauj ruam 2: Le Code Arduino

// InfraRouge

#suav nrog

int recvPin = 11; // pin Arduino pour récepteur InfraRouge (TOSP4838)

IRrecv irrecv (recvPin);

RX433

#suav nrog

RCSwitch mySwitch = RCSwitch ();

decode_results cov txiaj ntsig;

void teeb tsa ()

{

Serial.begin (9600);

irrecv.enableIRIn ();

irrecv.blink13 (muaj tseeb); // tag nrho cov LED interne lors de l'envoie InfraRouge

mySwitch.enableReceive (0); // Récepteur RX433 (XY-MK-5V) sur pin 2 de Arduino Uno et Nano

}

// affichage des cov lej InfraRouge

void ircode (decode_results *cov txiaj ntsig)

{

// Panasonic

yog (cov txiaj ntsig-> decode_type == PANASONIC) {

Serial.print (cov txiaj ntsig-> chaw nyob, HEX);

Serial.print (":");

}

Serial.print (cov txiaj ntsig-> tus nqi, HEX);

} // tsis muaj dabtsis

// afficahge des chaws encodés

void encoding (decode_results *cov txiaj ntsig)

{

hloov (cov txiaj ntsig-> decode_type) {

neej ntawd hais:

rooj UNKNOWN: Serial.print ("Inconnu"); tawg;

case NEC: Serial.print ("NEC"); tawg;

rooj plaub SONY: Serial.print ("SONY"); tawg;

rooj plaub RC5: Serial.print ("RC5"); tawg;

rooj plaub RC6: Serial.print ("RC6"); tawg;

rooj DISH: Serial.print ("DISH"); tawg;

rooj plaub SHARP: Serial.print ("SHARP"); tawg;

rooj plaub JVC: Serial.print ("JVC"); tawg;

rooj plaub SANYO: Serial.print ("SANYO"); tawg;

rooj MITSUBISHI: Serial.print ("MITSUBISHI"); tawg;

case SAMSUNG: Serial.print ("SAMSUNG"); tawg;

rooj plaub LG: Serial.print ("LG"); tawg;

rooj WHYNTER: Serial.print ("WHYNTER"); tawg;

rooj AIWA_RC_T501: Serial.print ("AIWA_RC_T501"); tawg;

rooj plaub PANASONIC: Serial.print ("PANASONIC"); tawg;

rooj plaub DENON: Serial.print ("Denon"); tawg;

}

}

// dump les résultats

void dumpInfo (decode_results *cov txiaj ntsig)

{

// Txheeb xyuas yog tias qhov tsis dhau

yog (cov txiaj ntsig-> ntab) {

Serial.println ("IR code ntev dhau lawm. Kho IRremoteInt.h thiab nce RAWBUF");

rov qab;

}

// Qhia tus qauv txheej txheem

Serial.print ("Encodage:");

encoding (cov txiaj ntsig);

Serial.println ("");

// Qhia Code & ntev

Serial.print ("Code:");

ircode (cov txiaj ntsig);

Serial.print ("("));

Serial.print (cov txiaj ntsig-> cov khoom, DEC);

Serial.println ("khoom)");

}

// qauv

void dumpRaw (decode_results *tau)

{

// Luam cov ntaub ntawv nyoos

Serial.print ("Sijhawm [");

Serial.print (cov txiaj ntsig-> rawlen-1, DEC);

Serial.println ("]:");

rau (int kuv = 1; kuv rawlen; kuv ++) {

unsigned ntev x = results-> rawbuf * USECPERTICK;

yog (! (i & 1)) {// txawm tias

Serial.print ("-");

yog (x <1000) Serial.print ("");

yog (x <100) Serial.print ("");

Serial.print (x, DEC);

} lwm yam {// khib

Serial.print ("");

Serial.print ("+");

yog (x <1000) Serial.print ("");

yog (x <100) Serial.print ("");

Serial.print (x, DEC);

yog (kuv rawlen-1) Serial.print (","); // ',' tsis xav tau rau zaum kawg

}

yog (! (i % 8)) Serial.println ("");

}

Serial.println (""); // Newline cov

}

//+=============================================================================

// Tshem tawm cov txheej txheem decode_results.

//

void dumpCode (decode_results *cov txiaj ntsig)

{

// Pib tshaj tawm

Serial.print ("tsis tau kos npe rau hauv"); // yam hloov pauv

Serial.print ("rawData ["); // array npe

Serial.print (cov txiaj ntsig-> rawlen - 1, DEC); // array loj

Serial.print ("] = {"); // Pib tshaj tawm

// Tshem tawm cov ntaub ntawv

rau (int kuv = 1; kuv rawlen; kuv ++) {

Serial.print (cov txiaj ntsig-> rawbuf * USECPERTICK, DEC);

yog (kuv rawlen-1) Serial.print (","); // ',' tsis xav tau ntawm qhov kawg

yog (! (i & 1)) Serial.print ("");

}

// Xaus kev tshaj tawm

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

// Saib

Serial.print ("//");

encoding (cov txiaj ntsig);

Serial.print ("");

ircode (cov txiaj ntsig);

// Newline cov

Serial.println ("");

// Tam sim no pov tseg "paub" cov lej

yog (cov txiaj ntsig-> decode_type! = UNKNOWN) {

// Qee qhov kev cai muaj chaw nyob

yog (cov txiaj ntsig-> decode_type == PANASONIC) {

Serial.print ("unsigned int ntxiv = 0x");

Serial.print (cov txiaj ntsig-> chaw nyob, HEX);

Serial.println (";");

}

// Txhua txoj cai muaj cov ntaub ntawv

Serial.print ("unsigned int cov ntaub ntawv = 0x");

Serial.print (cov txiaj ntsig-> tus nqi, HEX);

Serial.println (";");

}

}

void lub voj ()

/********************************************************** *InfraRouge ******************************************/

{

decode_results cov txiaj ntsig; // Ib qhov twg los khaws cov txiaj ntsig

yog (irrecv.decode (& cov txiaj ntsig)) {// Lob tus lej IR

dumpInfo (& cov txiaj ntsig); // Tshaj tawm cov txiaj ntsig

dumpRaw (& cov txiaj ntsig); // Tshaj tawm cov txiaj ntsig hauv RAW hom

dumpCode (& cov txiaj ntsig); // Tshaj tawm cov txiaj ntsig raws li qhov chaws

Serial.println (""); // Kab dawb paug ntawm nkag

irrecv.resume (); // Npaj rau tus nqi tom ntej

}

/********************************************************** *** RX433 ********************************************/

yog (mySwitch.available ())

{

int tus nqi = mySwitch.getReceivedValue ();

Serial.println ("RX433");

yog (tus nqi == 0) {

Serial.print ("Codage inconnu");

lwm tus

{

Serial.print ("Reçu");

Serial.print (mySwitch.getReceivedValue ());

Serial.print (" /");

Serial.print (mySwitch.getReceivedBitlength ());

Serial.print ("ntsis");

Serial.print ("Protocole:");

Serial.println (mySwitch.getReceivedProtocol ());

}

mySwitch.resetAvailable ();

RX433

} // rov

Kauj Ruam 3: Infos Sur Les Codes Infra-Rouge

Cov txheej txheem ntxiv:

NEC: 32 khoom (cov ntsiab lus raws tu qauv)

Sony: 12 lossis 20 ntsis (cov ntsiab lus raws tu qauv) (Nkag siab txog Sony IR tej thaj chaw deb cov lej.)

RC5: 12 khoom (cov ntsiab lus raws tu qauv)

RC6: 20 ou 36 me ntsis (cov ntsiab lus raws tu qauv)

Ncuav Sony thiab RC5/6, chaque transmission doit être répétés 3 fois!

NCO TSEG: la librairie IRremote.h ne semble pas pouvoir envoyer des codes codés sur plus de 32bits. Les RC6, 36 doivent donc restres envoyer en raw, qui prennent ntxiv rau de taille mémoire.

L'envoie des codes se fera avec la librairie IRremote.h

Piv txwv li: (0x devant le code) et le nombre de bits irsend.sendNEC (0xA55A38C7, 32);

Kauj Ruam 4: Infos Sur Codes RX433

L'envoie se fera avec la librairie RCSwitch.h

Piv txwv mySwitch.send (1975778, 24);

On peut facilement piloter avec cela des prises commandés.

Pom zoo: