WL101-341 OOK/ASK decoder

 2.1.2022
WL101-341 OOK/ASK decoder


 



Arduino used for providing 3.3V and GND.


 



Wireless OOK doorbell signal.
WL101-341 data pins (2) output same signal. WL101-341 data output is random noise when there is no signal.


Arduino Due code

#define SERIAL_SPEED    57600
#define DATA_PIN        5
#define DATA_SIZE       3072
#define TIMEOUT         16000
#define PLOT_SCALE      16

int32_t data[DATA_SIZE];
uint32_t timeoutStart;
volatile uint16_t idx = 0;
volatile uint8_t state = 0;

void setup() {
  Serial.begin(SERIAL_SPEED);
  pinMode(DATA_PIN, INPUT);
  memset(data, 0, sizeof(data));
  timeoutStart = millis();
  attachInterrupt(digitalPinToInterrupt(DATA_PIN), isr, CHANGE);
}

void loop() {
  if (state == 1) {
    detachInterrupt(digitalPinToInterrupt(DATA_PIN));
    state = 2;
    if (idx > 0) {
      for (uint16_t i = 0; i < idx; i++) {
        Serial.println(data[i] / PLOT_SCALE);
      }
    }
  }
  if (state == 0) {
    if ((millis() - timeoutStart) >= TIMEOUT) {
      state = 1;
    }
  }
}

void isr() {
  static uint32_t timestart = micros();
  static uint32_t timenow = 0;

  if (state == 0) {
    timenow = micros();
    data[idx] = timenow - timestart;
    timestart = timenow;
    if (!bitRead(PIOC->PIO_PDSR, 25)) {
      data[idx] = -data[idx];
    }
    if (idx == DATA_SIZE) {
      state = 1;
    }
    else {
      idx++;
    }
  }
}

Comments

Popular posts from this blog

Modifying old SDR# TETRA demod plug-in

Mods for SDR# TETRA demod plugin 1.0.14.0 - 2