2

I've found tons of libraries. But as I understand it, they are all made to link the receiver with the transmitter of the same type (WL101 - WL102). And they work according to their specific protocol.

I want to use arduino and a receiver module to analyze various data from the air at a frequency of 433 MHz. At the output of this receiver, there is already an audio frequency signal, so I would like to first observe it on the graph, see certain amplitude changes when the transmitter is nearby from my remote control, and then write my own protocol for receiving data to extract bits.

I tried to connect the receiver to the analog output of the arduino and build a graph, but nothing comes out, there are always some pulses. Something I am doing wrong.

enter image description here enter image description here

uint32_t t; // Time that always increases
uint32_t myTimer1;

unsigned long startTime; //Turn on two timers, this one
unsigned long elapsedTime; // and this one


#include <util/atomic.h>

// Used analog input A0
const uint8_t analog_in = 0;

// The frequency we want to determine is in Hz.
const float SIGNAL_FREQ = 1000.0;

// Bits of time.
const float SAMPLING_FREQ = F_CPU / (128 * 13.0);  // 9.615 kHz
const long PHASE_INC = round(SIGNAL_FREQ / SAMPLING_FREQ * (1L << 16));
const int LOG_TAU = 6;  // tau = 64 / SAMPLING_FREQ = 6.656 ms

// Set the ADC to "free running mode"
static void configure_adc()
{
  ADMUX  = _BV(REFS0)  // ref = AVCC
           | _BV(ADLAR)  // left adjust result
           | analog_in;  // input channel
  ADCSRB = 0;          // free running mode
  ADCSRA = _BV(ADEN)   // enable
           | _BV(ADSC)   // start conversion
           | _BV(ADATE)  // auto trigger enable
           | _BV(ADIF)   // clear interrupt flag
           | _BV(ADIE)   // interrupt enable
           | 7;          // prescaler = 128
}

//Demodulated (I, Q) amplitudes.
volatile int16_t signal_I, signal_Q;

// The interrupt handler is called each time the ADC is ready to read.
ISR(ADC_vect)
{
  // Read the ADC and convert it to a sign number.
  int8_t sample = ADCH - 128;

  // Update the phase of the local oscillator.
  static uint16_t phase;
  phase += PHASE_INC;

  // Multiplication of samples by rectangular waves in quadrature.
  int8_t x = sample;
  if (((phase >> 8) + 0x00) & 0x80) x = -1 - x;
  int8_t y = sample;
  if (((phase >> 8) + 0x40) & 0x80) y = -1 - y;

  // First order low pass filter.
  signal_I += x - (signal_I >> LOG_TAU);
  signal_Q += y - (signal_Q >> LOG_TAU);
}


/ * Return power readings. * /
    static uint16_t get_power_reading()
    {
      int16_t I, Q;
      ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
        I = signal_I;
        Q = signal_Q;
      }
      return sq((int8_t)(I >> LOG_TAU)) + sq((int8_t)(Q >> LOG_TAU));
    }
    void setup()
    {
      configure_adc();
      Serial.begin(9600); // Enable serial port
    }
    
void loop()
{
  // We display power readings every 8 ms.
  static const uint16_t print_period = 8;
  static uint16_t last_print;
  uint16_t now = millis();

  if (now - last_print >= print_period)
  {
      Serial.println(get_power_reading());  // Build a graph (signal power versus time) by which you can determine the optimal threshold
    last_print += print_period;
  }
}
2
  • 1
    it is not possible to guess what is wrong ... we do not know what you connected, how you connected it, and what code you ran
    – jsotola
    Jul 15 '21 at 17:26
  • I am trying to plot a graph and see the low and high levels there, which I transmit with my transmitter. To do this, I use the program to read data from the analog port of the arduino, to which the 433 MHz receiver module is connected. However, nothing is accepted.
    – Антон
    Jul 16 '21 at 9:25
1

It is not working because of:

SPEED

Consider the frequency of the 433Mhz device vs. the speed of the serial monitor. The device sends signals with pulse width in the range of tens of microseconds while the serial monitor can't display that fast.

Your code should analyze the signals, clean the noise (the output of the device is very noisy) and figure out the protocol. All that is done by dedicated libraries such as rc-switch which is very extensive and robust compared to just reading a pin and plotting the output.

DIGITAL

The recover device is outputting a digital pulse which based on it's pulse width changes one can figure out the sequence of numbers sent by the remote control. Each such ASK protocol has it's timing characteristics which you should follow in order to decode the code.

If you want to experiment with that vs. using a ready made library you should start with a code similar to the example below.

void setup() {
  Serial.begin(6000000);
  attachInterrupt(digitalPinToInterrupt(1), handleInterrupt, CHANGE);
}

void loop() {
}

void handleInterrupt() {
  bool s = digitalRead(1);
  Serial.println(s);
}

Just pay attention to the timing issue, this code will show a lot of data but not necessarily (almost for sure) not all the data, but you can avoid the serial print and use the data for analysis.

4
  • Thank you. But unfortunately I can't get absolutely anything with your code. I tried to figure out the library, but I didn't get any data. As I understand it, the library works strictly according to a certain protocol, and the pulses that I send, it takes for noise, maybe.
    – Антон
    Jul 17 '21 at 4:25
  • Also the module you are using is limited to ASK so if you are sending anything else it will not be detected. As for code sample, not that it's listening on interrupt pin 1 (PA23_TC4-W1 on MKR 1010 WIFI), check with your Arduino what pin number it should be showing in order to work and transmit from a compatible device or remote control.
    – Nino
    Jul 17 '21 at 8:02
  • Как то мне здесь помог человек при решении подобной задачи, он поделился кодом, который из частот уровня лишь частоту 1 кГц и уже на ней сигнал анализировался. Это было Гомодинное обнаружение. Сейчас я не знаю заранее точной частоты, которую нужно построить, пробовал использовать код, на обнаружение 1 кГц, но он не обнаруживает мой сигнал. Мне нравится этот код тем, что он позволяет установить АЦП ардуино в режиме прямого преобразования, то есть обрабатывать сигнал очень быстро. Подскажите, как можно оставить этот режим работы АЦП, но убрать выделение сигнала 1 кГц?
    – Антон
    Jul 17 '21 at 12:40
  • @Edgar Bonet, I used your code to detect a 1 kHz harmonic signal. Tell me how I can use it to detect a rectangular pulse with a duration of 640 μs?
    – Антон
    Jul 18 '21 at 3:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.