[Solved] How to turn row bits in something useful?

Helo
I’m trying to decode windows blinds remote and after couple of months i did get row data of it:

0010111010111011100000111000000001110111 CH1 Up
0010111010111011100010101000000001111010 CH1 Stop
0010111010111011100010001000000001111001 CH1 Down

Can somwone tell me exemple how to turn this 00101… to somting and turm my serwo ( myservo0.write(180); )
I try just “unsigned long long sender = 0b0010111010111011100000111000000001110111;”
But this dont work.

Here is script please help:

int rxPin = 2; // Input of 433 MHz receiver
int t1 = 0; // Latch 1 time only needed for debugging purposes
int t2 = 0; //latch 2 time only needed for debugging purposes.
int led = 3;
unsigned long long   sender = 0b0010111010111011100000111000000001110111;
void setup()

{ 
pinMode(rxPin, INPUT); // Input of 433 MHz receiver
pinMode(led, OUTPUT);
Serial.begin(19200);
Serial.println ("Receiver Hard Coded");
}


void loop()
{
int i = 0;
unsigned long t = 0;
byte prevBit = 0;
byte bit = 0;

Serial.println ();
// latch 1
while (t < 5000 || t > 6000)
{ t = pulseIn(rxPin, HIGH, 1000000);
}
// latch 2
while (t < 2300 || t > 2700)
{ t = pulseIn(rxPin, LOW, 1000000);
}
// latch 3
while ((t < 1300 || t > 1700))
{ t = pulseIn(rxPin, HIGH, 1000000);
}


// data collection from reciever
while (i < 40)
{
t = pulseIn(rxPin, LOW, 1000000);

if (t > 500 && t < 700)
{ bit = 0;
}

else if (t > 300 && t < 400)
{ bit = 1;
}
else
{ i = 0;
break;
}
Serial.print(bit);
}

if (i == 200714453111)
{
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
}
}

Edit:
Wave from remote:

QrokPL:
Helo
I'm trying to decode windows blinds remote and after couple of months i did get row data of it:

0010111010111011100000111000000001110111 CH1 Up

0010111010111011100010101000000001111010 CH1 Stop
0010111010111011100010001000000001111001 CH1 Down




Can somwone tell me exemple how to turn this 00101... to somting ....

how did you read this? oscilloscope? serial monitor? ...?

Arduino + 433MHz modul. (serial monitor)

I don't think pulseIn() is going to work for you. It can't read consecutive HIGH and LOW pulses. When the HIGH pulse ends and you call pulseIn(pin, LOW) to get the LOW time it will wait for the next falling edge to start timing a LOW pulse. Since the HIGH pulse ended on a falling edge you already missed that edge. It has to wait until the current LOW ends and the next HIGH starts before it can look for a falling edge. That means if you have pulseIn(pin, HIGH) followed by pulseIn(pin, LOW) you will miss a LOW pulse and a HIGH pulse between the two measurements.

There are libraries for receiving and decoding IR signals. IRremote and IRlib2 are popular. They should work on RF signals as well.

I will try it, I’m desperate. I try to decode this for months (I’m very low skilled).

“It can’t read consecutive HIGH and LOW pulses.”

If you compere readout from wave and my bits its line up perfect:


0010111010111011100000111000000001110111

For this low skill purpose it is ok i think.

QrokPL:
I try just "unsigned long long sender = 0b0010111010111011100000111000000001110111;"

If I'm not mistaken the '0b' prefix works only for 8bits

if you want to put the whole bit stream into a long long type, try using the hexadecimal representation on the bit stream ie:

0010111010111011100000111000000001110111 CH1 Up -> 0x002EBB838077
0010111010111011100010101000000001111010 CH1 Stop -> 0x002EBB8A807A
0010111010111011100010001000000001111001 CH1 Down -> 0x002EBB888079

Ok, but right now i don’t know how to store this 00101… information so Arduino knows when to digitalWrite(led, HIGH);

This original script was for Nexa remote and all info was stored in “i” and transferred to “Sender” “Receiver”… and i don’t know how to do that here because:

if (i < 16)
{ 
sender <<= 1;
sender |= prevBit;

don’t work.

QrokPL:
Ok, but right now i don’t know how to store this 00101… information so Arduino knows when to digitalWrite(led, HIGH);

This original script was for Nexa remote and all info was stored in “i” and transferred to “Sender” “Receiver”… and i don’t know how to do that here because:

if (i < 16)

{
sender <<= 1;
sender |= prevBit;




don't work.

Maybe because english is not your native language but I’m having trouble understanding the issue you are having.

Please post your code or at least an example of what you are trying to achieve

If I understood correctly you are:

  1. trying to read the transmitted signal from a remote (to be stored into a variable)
  2. use that signal to then operate some other device.

Please post the code where you tried to do just that.

Hopefully it will be clearer for us and we may then be able to help you! :wink:

All correct and script is in first post. Thank you for being patient with me!
It’s hard to understand me probably because I don’t know proper phrases used in coding.

I try to decode remote for my remote windows blinds which i already have hardware build.
This Remote witch i trying to decode have 3 buttons Up, Down and Stop. I modify script so i can at least get bit data of it what I did but now i don’t know what to do with that data to turn pins in Arduino HIGH, example:

00101110 10111011 10000011 10000000 01110111 - digitalWrite(led1, HIGH);

00101110 10111011 10001010 10000000 01111010 - digitalWrite(led2, HIGH);

00101110 10111011 10001000 10000000 01111001 - digitalWrite(led3, HIGH);

This bit data I got when I connected 433 MHz module to Arduino, upload my script, opened serial monitor and push button “Up” on remote (Wich is 433 MHz - BF305) that when i get 001011…
Now I’m stuck because i don’t know how to turn this 001011… to make digitalWrite(led2, HIGH)

Script:

int rxPin = 2; // Input of 433 MHz receiver
int t1 = 0; // Latch 1 time only needed for debugging purposes
int t2 = 0; //latch 2 time only needed for debugging purposes.
int led = 3;
unsigned long long   sender = 0b0010111010111011100000111000000001110111;
void setup()

{
pinMode(rxPin, INPUT); // Input of 433 MHz receiver
pinMode(led, OUTPUT);
Serial.begin(19200);
Serial.println ("Receiver Hard Coded");
}


void loop()
{
int i = 0;
unsigned long t = 0;
byte prevBit = 0;
byte bit = 0;

Serial.println ();
// latch 1
while (t < 5000 || t > 6000)
{ t = pulseIn(rxPin, HIGH, 1000000);
}
// latch 2
while (t < 2300 || t > 2700)
{ t = pulseIn(rxPin, LOW, 1000000);
}
// latch 3
while ((t < 1300 || t > 1700))
{ t = pulseIn(rxPin, HIGH, 1000000);
}


// data collection from reciever
while (i < 40)
{
t = pulseIn(rxPin, LOW, 1000000);

if (t > 500 && t < 700)
{ bit = 0;
}

else if (t > 300 && t < 400)
{ bit = 1;
}
else
{ i = 0;
break;
}
Serial.print(bit);
}

if (i == 200714453111)
{
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
}
}

sherzaad:
If I'm not mistaken the '0b' prefix works only for 8bits

You are mistaken.

However long strings of 0's and 1's are not human readable, so hex is a better representation for
anyone having to read the program.

sherzaad:
If I'm not mistaken the '0b' prefix works only for 8bits

MarkT:
You are mistaken.

you're right.... it's the '0B' prefix according to this link:

https://www.arduino.cc/reference/en/language/variables/constants/integerconstants/

Let’s assume that we don’t need to keep the first 8 bits of the 40-bit numbers. Your patterns are:

2E BB 83 80 77
2E BB 8A 80 7A
2E BB 88 80 79

If you merge those together and throw away the first 8 bits:

const uint32_t UpCode = 0xBB838077UL;
const uint32_t StopCode = 0xBB8A807AUL;
const uint32_t DownCode = 0xBB888079UL;

To put your bits in a uint32_t:

uint32_t code = 0;
  // As each bit arrives:
  code = (code << 1) | newBit;

When all of the bits have arrived:

  switch (code)
  {
  case UpCode:
    // Things to do when UpCode arrives
    digitalWrite(UpPin, HIGH);  // for example
    break;  // End of this case
 
  case StopCode:
    // Things to do when StopCode arrives
    digitalWrite(StopPin, HIGH);  // for example
    break;  // End of this case
 
  case DownCode:
    // Things to do when DownCode arrives
    digitalWrite(DownPin, HIGH);  // for example
    break;  // End of this case
   }

Thank you for taking time to help!
I put script together and i will test it when i get home and if it works i need to understand why it works.

Correct me if I’m wrong, I’m googling everything an try to learn:

So 2E BB 83 80 77 is Hex of that bit code (00101110 = 2E)

uint32_t is special int where i can put up to 32 bits.

0xBB8A807AUL - 0x I can put 0-9, A-F, a-f characters and UL to force the constant into an unsigned long constant.

code = (code << 1) | newBit; this is where bits are collected in to code then put in uint32_t
then uint32_t is compered to const uint32_t UpCode = 0xBB838077UL; and if uint32_t from signal match UpCode wich is 0xBB838077UL (10111011 10000011 10000000 01110111) then i get HIGH on pin 3.

I don’t know what | newBit do but i will try to find it.

Probably all of this is basics but I can only understand something if i see it in action, I can’t learn definitions and do something with it.

Skript:

int rxPin = 2; // Input of 433 MHz receiver
int UpPin = 3;
int StopPin = 4;
int DownPin = 5;

const uint32_t UpCode = 0xBB838077UL;
const uint32_t StopCode = 0xBB8A807AUL;
const uint32_t DownCode = 0xBB888079UL;



void setup()

{
  pinMode(rxPin, INPUT); // Input of 433 MHz receiver
  
  pinMode(UpPin, OUTPUT);
  pinMode(StopPin, OUTPUT);
  pinMode(DownPin, OUTPUT);
  
  Serial.begin(19200);
  Serial.println ("Receiver Hard Coded");
}


void loop()
{
  int i = 0;
  unsigned long t = 0;
  byte newBit = 0;
  byte bit = 0;
  unsigned long code = 0;

  Serial.println ();
  // latch 1
  while (t < 5000 || t > 6000)
  { t = pulseIn(rxPin, HIGH, 1000000);
  }
  // latch 2
  while (t < 2300 || t > 2700)
  { t = pulseIn(rxPin, LOW, 1000000);
  }
  // latch 3
  while ((t < 1300 || t > 1700))
  { t = pulseIn(rxPin, HIGH, 1000000);
  }


  // data collection from receiver
  while (i < 40)
  {
    t = pulseIn(rxPin, LOW, 1000000);

    if (t > 500 && t < 700)
    { bit = 0;
    }

    else if (t > 300 && t < 400)
    { bit = 1;
    }
    //Serial.print(bit);////////////////////////////BIT

    uint32_t code = 0;
    // As each bit arrives:
    code = (code << 1) | newBit;


  }
  ////////////////////////////////////////////////////////////////
  switch (code)
  {
    case UpCode:
      // Things to do when UpCode arrives
      digitalWrite(UpPin, HIGH);  // for example
      break;  // End of this case

    case StopCode:
      // Things to do when StopCode arrives
      digitalWrite(StopPin, HIGH);  // for example
      break;  // End of this case

    case DownCode:
      // Things to do when DownCode arrives
      digitalWrite(DownPin, HIGH);  // for example
      break;  // End of this case
  }


}

I don’t know where to put code = (code << 1) | newBit; so it will collect data.
I try meany different places and i get 0 on serial monitor when Serial.print(code);

On Serial.print(bit); i get 001011…

There is while (i = 40) where bits are read and i think code = (code << 1) should be after this but i get one 0

Skript:

int rxPin = 2; // Input of 433 MHz receiver
int UpPin = 3;
int StopPin = 4;
int DownPin = 5;

const uint32_t UpCode = 0xBB838077UL;
const uint32_t StopCode = 0xBB8A807AUL;
const uint32_t DownCode = 0xBB888079UL;



void setup()

{
  pinMode(rxPin, INPUT); // Input of 433 MHz receiver

  pinMode(UpPin, OUTPUT);
  pinMode(StopPin, OUTPUT);
  pinMode(DownPin, OUTPUT);

  Serial.begin(19200);
  Serial.println ("Receiver Hard Coded");
}


void loop()
{
  int i = 0;
  unsigned long t = 0;
  byte newBit = 0;
  byte bit = 0;
  uint32_t code = 0;

  Serial.println ();
  // latch 1
  while (t < 5000 || t > 6000)
  { t = pulseIn(rxPin, HIGH, 1000000);
  }
  // latch 2
  while (t < 2300 || t > 2700)
  { t = pulseIn(rxPin, LOW, 1000000);
  }
  // latch 3
  while ((t < 1300 || t > 1700))
  { t = pulseIn(rxPin, HIGH, 1000000);
  }


  // data collection from reciever
  while (i = 40)
  {
    t = pulseIn(rxPin, LOW, 1000000);

    if (t > 500 && t < 700)
    { bit = 0;
    }
    else if (t > 300 && t < 400)
    { bit = 1;
    }
    else
    {
      i = 0;
      break;
    }
    //Serial.print(bit);////////////////////////////BIT
  }
code = (code << 1) | newBit;
Serial.print(code);

  ////////////////////////////////////////////////////////////////
  switch (code)
  {
    case UpCode:
      // Things to do when UpCode arrives
      digitalWrite(UpPin, HIGH);  // for example
      break;  // End of this case

    case StopCode:
      // Things to do when StopCode arrives
      digitalWrite(StopPin, HIGH);  // for example
      break;  // End of this case

    case DownCode:
      // Things to do when DownCode arrives
      digitalWrite(DownPin, HIGH);  // for example
      break;  // End of this case
  }


}
  if (i <=40)
  {
   code << 1;
   code | newBit;
  }

Does not work either :slightly_frowning_face:

I’d like to see what you get on Serial Monitor with this version of the sketch:

int rxPin = 2; // Input of 433 MHz receiver
int UpPin = 3;
int StopPin = 4;
int DownPin = 5;


const uint32_t UpCode = 0xBB838077UL;
const uint32_t StopCode = 0xBB8A807AUL;
const uint32_t DownCode = 0xBB888079UL;


void setup()
{
  pinMode(rxPin, INPUT); // Input of 433 MHz receiver


  pinMode(UpPin, OUTPUT);
  pinMode(StopPin, OUTPUT);
  pinMode(DownPin, OUTPUT);


  Serial.begin(19200);
  Serial.println ("Receiver Hard Coded");
}




void loop()
{
  unsigned long t = 0;
  byte bit = 0;
  uint32_t code = 0;


  Serial.println ();
  // latch 1
  Serial.println("latch 1: Looking for pulse 5000-6000");
  while (t < 5000 || t > 6000)
  {
    t = pulseIn(rxPin, HIGH, 1000000);
    Serial.print("HIGH pulse ");
    Serial.println(t);
  }


  // latch 2
  Serial.println("latch 2: Looking for pulse 2300-2700");
  while (t < 2300 || t > 2700)
  {
    t = pulseIn(rxPin, LOW, 1000000);
    Serial.print("LOW pulse ");
    Serial.println(t);
  }


  // latch 3
  Serial.println("latch 3: Looking for pulse 1300-1700");
  while (t < 1300 || t > 1700)
  {
    t = pulseIn(rxPin, HIGH, 1000000);
    Serial.print("HIGH pulse ");
    Serial.println(t);
  }


  Serial.println("Found header");


  // data collection from reciever
  while (true)
  {
    t = pulseIn(rxPin, LOW, 1500);


    if (t > 500 && t < 700)  // LONG LOW = 0
    {
      bit = 0;
    }
    else if (t > 300 && t < 400) // SHORT LOW = 1
    {
      bit = 1;
    }
    else // Pulse is not in the 300-400 or 500-700 range so we're done
    {
      break;
    }
    code = (code << 1) | bit;
    // Serial.print(bit); ////////////////////////////BIT
  }


  Serial.println(code, HEX);


  ////////////////////////////////////////////////////////////////
  switch (code)
  {
    case UpCode:
      // Things to do when UpCode arrives
      digitalWrite(UpPin, HIGH);  // for example
      break;  // End of this case


    case StopCode:
      // Things to do when StopCode arrives
      digitalWrite(StopPin, HIGH);  // for example
      break;  // End of this case


    case DownCode:
      // Things to do when DownCode arrives
      digitalWrite(DownPin, HIGH);  // for example
      break;  // End of this case
  }
}

Never endings timings witch automatically starts after upload, I think there need to be break; somewhere.

Receiver Hard Coded


latch 1: Looking for pulse 5000-6000
HIGH pulse 40
HIGH pulse 133
HIGH pulse 222
HIGH pulse 81
HIGH pulse 153
HIGH pulse 43
HIGH pulse 55
HIGH pulse 53
HIGH pulse 86
HIGH pulse 324
HIGH pulse 63
HIGH pulse 55
HIGH pulse 149
HIGH pulse 62
HIGH pulse 68
HIGH pulse 68
HIGH pulse 48
HIGH pulse 133
HIGH pulse 86
HIGH pulse 162
HIGH pulse 80
HIGH pulse 176
HIGH pulse 45
HIGH pulse 137
HIGH pulse 129
HIGH pulse 280
HIGH pulse 187
HIGH pulse 67
HIGH pulse 106
HIGH pulse 52
HIGH pulse 65
HIGH pulse 237
HIGH pulse 335
HIGH pulse 156
HIGH pulse 97
HIGH pulse 70
HIGH pulse 76
HIGH pulse 37
HIGH pulse 182
HIGH pulse 252
HIGH pulse 56
HIGH pulse 62
HIGH pulse 269
HIGH pulse 49
HIGH pulse 302
HIGH pulse 128
HIGH pulse 142
HIGH pulse 64
HIGH pulse 112
HIGH pulse 141
HIGH pulse 671
HIGH pulse 91
HIGH pulse 105
HIGH pulse 92
HIGH pulse 295
HIGH pulse 82
HIGH pulse 149
HIGH pulse 53
HIGH pulse 268
HIGH pulse 64
HIGH pulse 137
HIGH pulse 78
HIGH pulse 69
HIGH pulse 131
HIGH pulse 221
HIGH pulse 49
HIGH pulse 124
HIGH pulse 60
HIGH pulse 149
HIGH pulse 258
HIGH pulse 113
HIGH pulse 122
HIGH pulse 226
HIGH pulse 153
HIGH pulse 401
HIGH pulse 37
HIGH pulse 64
HIGH pulse 50
HIGH pulse 152
HIGH pulse 75
HIGH pulse 87
HIGH pulse 117

QrokPL:
Never endings timings witch automatically starts after upload, I think there need to be break; somewhere.

Looks like it’s getting a lot of noise on Pin 2. Did you push a button on the remote? It was working before and adding Serial.print() shouldn’t have caused it to fail. Could a wire have come loose?

This is on breadboard and I did not push button, now i did and disconnect Arduino, and go back to copy results:

(sorry)

HIGH pulse 1588
HIGH pulse 634
HIGH pulse 642
HIGH pulse 647
HIGH pulse 337
HIGH pulse 5470
latch 2: Looking for pulse 2300-2700
LOW pulse 640
LOW pulse 633
LOW pulse 314
LOW pulse 2433
latch 3: Looking for pulse 1300-1700
HIGH pulse 332
HIGH pulse 333
HIGH pulse 649
HIGH pulse 110
HIGH pulse 7163
HIGH pulse 59635
HIGH pulse 4849
HIGH pulse 232
HIGH pulse 266
HIGH pulse 414
HIGH pulse 495
HIGH pulse 239
HIGH pulse 1426
Found header
0

latch 1: Looking for pulse 5000-6000
HIGH pulse 372
HIGH pulse 166
HIGH pulse 150
HIGH pulse 92
HIGH pulse 717
HIGH pulse 160
HIGH pulse 399
HIGH pulse 203
HIGH pulse 383
HIGH pulse 82
HIGH pulse 173
HIGH pulse 107
HIGH pulse 170
HIGH pulse 461
HIGH pulse 67
HIGH pulse 72
HIGH pulse 181
HIGH pulse 429
HIGH pulse 166
HIGH pulse 341
HIGH pulse 160
HIGH pulse 75
HIGH pulse 71
HIGH pulse 48
HIGH pulse 49
HIGH pulse 186
HIGH pulse 82
HIGH pulse 361
HIGH pulse 96
HIGH pulse 134
HIGH pulse 56
HIGH pulse 296
HIGH pulse 71
HIGH pulse 525
HIGH pulse 47
HIGH pulse 177
HIGH pulse 77
HIGH pulse 58
HIGH pulse 637
HIGH pulse 142

In my house everything is wireless, i don't have real light switch, but all sensors are using Z-Wave so that should not interfere with 433MHz.

That why I'm trying to build my own wireless things which there is non on the market.