433MHz RX spewing junk

Hi,

Doing this without VirtualWire.

I have some el-cheapo sensors e.g. hall-effect door-open sensor, that send out a short coded message using 433.92MHz ASK module. So I rigged up my Arduino with a RXD1 (433MHz receiver unit) connecting it to the Arduino, just as explained in the VirtualWire documentation. However I am not using the VirtualWire library, because my transmitting device doesn't follow the VirtualWire protocol. So I wrote a very small program to read what the module is throwing at the Arduino input pin. What amazes me is that there is a continuous / steady stream of 0's, 1's, in no particular pattern, which seems more like noise. On removing the connection between data-out from the RXD1 and Arduino, the random flipping stops, and restarts as soon as I plug the wire in. Looking for advise on how to improve the code, and how to actually start detecting the code sent out by my sensor to my Arduino.

int lastVal = 0;
int lastBitCount = 0;
  
void setup() {
  Serial.begin(9600);
  pinMode(11, INPUT);
}

void loop() {
  int sensorValue = digitalRead(11);
  if (lastVal != sensorValue) {
    Serial.print("Lc: ");
    Serial.print(lastBitCount, DEC);
    Serial.print("   Bit: ");
    Serial.println(lastVal, DEC);
    lastBitCount = 0;
    lastVal = sensorValue;
  }
  else {
    lastBitCount ++;
  }
  delay(10);
}

And here's a small excerpt of what it spews out in Serial-port monitor...

Lc: 1   Bit: 0
Lc: 0   Bit: 1
Lc: 2   Bit: 0
Lc: 4   Bit: 1
Lc: 0   Bit: 0
Lc: 1   Bit: 1
Lc: 10   Bit: 0
Lc: 6   Bit: 1
Lc: 1   Bit: 0
Lc: 0   Bit: 1
Lc: 0   Bit: 0
Lc: 2   Bit: 1
Lc: 4   Bit: 0
Lc: 0   Bit: 1
Lc: 10   Bit: 0
Lc: 2   Bit: 1

Thanks for pointers, guidance.

regards,
F

the random noise is generated because these RF-receivers have an automatic gain function.

Sensors transmit normally a specific start sequence to give the receiver time to adjust to their signal.

Your code should look for this start sequence in the signal stream. Usually, these start bits last longer than the noise.

Your first task will be to find out what kind of signal your sensors are transmitting. Use your soundcard on the PC for this - you should be actually able to hear your sensor sending. Once you identified your signal, you might go on and record this with a soundcard utility, a soundcard oscilloscope or a real oscilloscope. Find out the exact timing of the start bit or bit sequence and have your Arduino watch out for this sequence.

Examples how such a program might work can be found in the various IR-libs floating around on the web. The timing of IR-signals is comparable to the timing of RF-sensor signals.