HT12E library

Good tips, I will try them

Hi,

I'd like to know what is necessary to make this code works with Holtek HT6P20 or HT6026. Is there any library for this chip available to download?

I'll appreciate any kind of help.

to make this code works with Holtek HT6P20 or HT6026

You need to check datasheets to see what needs to be changed. If handshakes/formulas are identical you would have a headstart, otherwise it is often better to start from scratch.
Tip: define the interface first, how do you want to instantiate the class, what parameters (pins?); how to read the wanted value? timing? formulas. ets

If you have a link to the datasheets please post them, allways informative :wink:

Better make a new topic of this with a title that reflect the sensor type (get more focussed feedback)

The datasheet for the HT6026 is http://www.cikaeletronica.com/Produtos/Data%20Sheet/6026.PDF

It looks very similar, you could easliy write a sketch to send to these, but you need the extra pattern for the "open circuit" option for the trinary code ( its either Vcc, Ground, or open circuit - " floating" )

Hi Guys,

Thank you for the prompt response.

In fact I'd like decode the HT6P20 (learning code), but I know this chip is not so easy to unveil. As I'm still learning, I don't have advanced knowledge to create this decode.

The idea is to press learning button on Arduino that can store the code sent by the chip (HT6P20) . After that, this remote control registered on Arduino is able to execute some actions.

I have this decode in ASM (ASM51 • Exibir tópico - HT6P20 "CHEGA PELO AMOR DE DEUS".), but I can not translate to Arduino.

Datasheet:
http://www.datasheetcatalog.org/datasheets/120/170613_DS.pdf

Thanks in advance (again) :slight_smile:

BR,

Manoel

The HT6P20 chip is more complicated, I don't know how you can decode that one.

/ *
ARDUINO HT6P20B DECODER WITH RESISTOR IN OSC 2M2.
THIS CODE NO TIMER USA, INTERRUPTION OR FOREIGN AND PIN SET INPUT.
IT MEASURES OF PILOT TIME PERIOD AND IF YOU COMPARE TO TRACK SET,
IF HE GOES TO CODE AND MAKE THE PERIOD OF TIME IN MEDIDÇÕES HIGH LEVEL
IF YOU HAVE INSIDE TRACK ACRECENTA 1 BIT 0 IN VARIABLE _DATA OR IF YOU DO NOT CLEAR THE MAIN AND RE-START
AFTER RECEIVING IT TAKES ALL THE BITS BITS OF ANTE 4 CODE AND TESTS TO KNOW IF THE CODE HAS BEEN RECEIVED
CORRECTLY, IF HE MAKES SURE TO RECEIVE A VARIABLE IN ANTCODE 1.

CREATED BY: DANIEL JACQUES MORESCO
DATE: 28/02/2012 USING ARDUINO 0022.
PHONES: 54 3324 2251 54 9206 7168
E-MAIL: ibisul@ibisul.com.br
Permitted public use, but should keep the name of the author.

  • /

int x, startbit, ctr, dataok, t1, larpulso, larpulso1, larpulso2, larpulso3, larpulso4, bt1, bt2, antcode = 0;
unsigned long _data = 0, / / ??DATA is the Code of recebio HT6p20 all 28 BITS where 22 of the buttons coodigo +2 +4 anti-code;
unsigned long _dur, _dur1 / / Pulse Duration
_pin byte / / Pin that will receive the digital RF signal.

void setup ()

{
_pin = 2;
Serial.begin (9600);
pinMode (2, INPUT);
pinMode (13, OUTPUT);
}

void loop ()

{

digitalWrite (13, digitalRead (2)) / / Blinks the LED as the value of digital input, interference testing.
if (startbit == 0)
{/ / Test Pilot time until the start bit;
_dur pulseIn = (_pin, LOW);
if (_dur> 8000 && _dur <12000 && startbit == 0)
{
larpulso = _dur/23;
= larpulso1 larpulso-50;
larpulso2 larpulso = +50;
= + larpulso3 larpulso larpulso-50;
larpulso4 = larpulso larpulso + +50;
startbit = 1;
_dur = 0;
_data = 0;
dataok = 0;
Ctr = 0;
}
}

/ / If the start bit THEN OK Starts measuring time high of signs, and tests whether the time is in the range.
if (startbit == 1 && dataok == 0 && ctr <28)
{
Ctr + +;
_dur1 pulseIn = (_pin, HIGH);
if (_dur1> && larpulso1 _dur1 <larpulso2) / / If the pulse width is between 1/4000 and 1/3000 seconds
{
_data = (_data << 1) + 1 / / attach a * a * to the rightmost end of the buffer
}
else if (_dur1> && larpulso3 _dur1 <larpulso4) / / If the pulse width is between 2/4000 and 2/3000 seconds
{
_data = (_data << 1) / / attach a * 0 * for the rightmost end of the buffer
}
else
{
/ * Force loop termination * /
startbit = 0;
}

}

if (ctr == 28)
{If (bitRead (_data, 0) == 1)
{
if (bitRead (_data, 1) == 0)
{
if (bitRead (_data, 2) == 1)
{
if (bitRead (_data, 3) == 0)
{
antcode = 1;
}
}
}
}

if (antcode == 1)
{/ / Have been received if all 28 bits, the value goes to _data variable and can be used as an example below.
dataok = 1;
Serial.println (_data, BIN);
Ctr = 0;
startbit = 0;
antcode = 0;
delay (100);
}
}
}

///////em português brasil ////////////////////////////////////////
/*
ARDUINO DECODIFICADOR HT6P20B COM RESISTOR DE 2M2 NO OSC.
ESTE CÓDIGO NÃO USA TIMER, INTERRUPÇÃO EXTERNA E NEM PINO DEFINIDO DE ENTRADA.
ELE MEDE O TEMPO DO PILOT PERIOD E COMPARA SE ESTÁ DENTRO DA FAIXA DEFINIDA,
SE TIVER ELE PASSA PARA CODE PERIOD E FAZ AS MEDIDÇÕES DE TEMPO EM NIVEL ALTO
SE TIVER DENTRO DA FAIXA ACRECENTA BIT 1 OU 0 NA VARIAVEL _DATA CASO NÃO ZERA AS VARIÁVEIS E RE-INICIA
APOS RECEBER TODOS OS BITS ELE PEGA OS 4 BITS DO ANTE CODE E TESTA PARA SABER SE O CÓDIGO FOI RECEBIDO
CORRETAMENTE, CASO RECEBIDO CERTO ELE COLOCA A VARIAVEL ANTCODE EM 1.

CRIADO POR: JACQUES DANIEL MORESCO
DATA: 28/02/2012 USANDO ARDUINO 0022.
FONES:54 3324 2251 54 9206 7168
E-MAIL: ibisul@ibisul.com.br
Permitido o uso público, mas deve-se manter o nome do autor.
*/

int x,startbit,ctr,dataok,t1,larpulso,larpulso1,larpulso2,larpulso3,larpulso4,bt1,bt2,antcode=0;
unsigned long _data=0; // DATA é o Código recebio do HT6p20 todos os 28 BITS onde, 22 do coodigo+2 dos botões+4 do anti-codigo;
unsigned long _dur,_dur1; // Duração do Pulso
byte _pin; // Pino que vai receber o sinal RF digital.

void setup()

{
_pin=2;
Serial.begin(9600);
pinMode(2, INPUT);
pinMode(13, OUTPUT);
}

void loop()

{

digitalWrite(13, digitalRead(2)); //Pisca o LED conforme o valor da entrada digital, testar interferencias.
if (startbit==0)
{// Testa o tempo piloto até o Bit de inicio;
_dur = pulseIn(_pin, LOW);
if(_dur > 8000 && _dur < 12000 && startbit==0)
{
larpulso=_dur/23;
larpulso1=larpulso-50;
larpulso2=larpulso+50;
larpulso3=larpulso+larpulso-50;
larpulso4=larpulso+larpulso+50;
startbit=1;
_dur=0;
_data=0;
dataok=0;
ctr=0;
}
}

// Se o Bit de inicio OK ENTÃO Inicia a medição do tempo em Nivel ALTO dos sinais, e testa se o tempo está na faixa.
if (startbit==1 && dataok==0 && ctr < 28)
{
++ctr;
_dur1 = pulseIn(_pin, HIGH);
if(_dur1 > larpulso1 && _dur1 < larpulso2) // Se a largura de pulso é entre 1/4000 e 1/3000 segundos
{
_data = (_data << 1) + 1; // anexar um * 1 * para a extremidade mais à direita do buffer
}
else if(_dur1 > larpulso3 && _dur1 < larpulso4) // Se a largura de pulso é entre 2/4000 e 2/3000 segundos
{
_data = (_data << 1); // anexar um * 0 * para a extremidade mais à direita do buffer
}
else
{
/* força finalização do laço */
startbit=0;
}

}

if (ctr==28)
{ if (bitRead(_data,0)==1)
{
if (bitRead(_data,1)==0)
{
if (bitRead(_data,2)==1)
{
if (bitRead(_data,3)==0)
{
antcode=1;
}
}
}
}

if (antcode==1)
{// Se foram recebidos todos os 28 Bits, o valor vai para a variavel _data e pode ser usada como exemplo abaixo.
dataok=1;
Serial.println(_data,BIN);
ctr=0;
startbit=0;
antcode=0;
delay(100);
}
}
}

Well done Jaques,

All my new projects use Wirtualwire now, it is so versatile, and fast.

I used the HT12E code to drive my displays on an early board, because each number had already got its HT12D chip inside the display.

Jaques, thanks a lot.

It works for me even without the RESISTOR IN OSC. Is it really needed?
I've used Arduino Mega 1280.

BR,

Manoel

Manuel, Thanks for the reply.
Resistor is required OSC in HT6P20, because it will set the clock.
My code allows a variation in clock that you can adjust according to the CSO.
Another thing that varies the clock and the battery voltage or battery that powers the remote, so you know when the battery is low.

hugs

Jacques Daniel Moresco.

Hi guys,

I have a remote that uses HT12E.
For domotic reasons, I would like to use my Arduino Uno to send RF frame.

Do I need specific library on Arduino to simulate HT12E ?
If yes, is it possible to get a link to download this lattest HT12E library ?

Thanks for your replies

Hi there

Take a look at post #1 in this thread, I provided the source code of the library for HT12E over there.

Your goal is to operate an Arduino with a RC, right? That's the point over here, I mean, to remote-control an Arduino.

Cheers

nu

One question: If I use the HT12D in arduino , I can use the Virtualwire library that will work?

Olá neuron_upheaval, você fala português?

Tem alguma versão desta library para o Arduino 1.0.1 ?

It has some version of this library for Arduino 1.0.1?

Obrigado
Thanks

Hi, I made video, that show this in action

Is it possible for the arduino to mimic the HT12E encoder?
I currently have a HT12D chip that i want to control using my arduino. It is essentially the reverse process.
Thank you

Please refer to the following link to get the latest version of the HT12E library:

http://forum.arduino.cc/index.php?topic=186882.0

As of March 12th, 2014, the current version of the library still does not support sending data to an HT12D chip.

The original purpose of this library was to provide Arduino family of boards with an easy way to BE CONTROLLED REMOTELY by a remote control operated with an HT12E chip.

I have been receiving each day more requests asking for the development of an HT12D library, which would work in the opposite way, that is, letting an Arduino CONTROL remote devices operated with an HT12D chip. If this is what you are looking for, please open a new thread in the appropriate forum, entitled "HT12D library", so that I can more easily track records of it.

Cheers

nu

If you look at the first page of this topic, you will see a code I wrote to send to HT12D chips. It was in my early days and very crude, but it worked.

Hey so I started a topic involving a remote using this encoder (I intend on reading the data and then sending that exact same data back out) but I seem to have hit a bit of a problem ... Instead o copy pasting everything's here's the thread

http://forum.arduino.cc/index.php?topic=320252.0

on other forum (http://arduino.cc/forum/index.php/topic,24424.0.html) has been some pictures or sketches about this issue. But those are not anymore available. Is it possible to get some picture or sketch to this forum? how connections are done and which parts is used to get idea clear..