Radio Frequency modules. Arduino. Bluetooth HC-06. FM

5.- Radio Frequency 433 MHZ. ASK. OOK.

  • Modulation Digital ASK (Amplitude-Shift Keying).

  • To transmit a "1" use an Amplitude. To transmit a "0" use another Amplitude. The frequency of Carrier is the same in the two states.

  • Modulation Digital OOK ( On-Off Keying).

  • These are two old, classic and cheap modules: FS1000A and JY-JS03.

  • Frequency: 433 MHz. Modulation: ASK. Price: about $ 1.

  • Range: about 10 m indoor, 90 m outdoor.

  • In my example the antenna is a 34 cm wire.

- App.

p9AAi_bluetooth_radiofrecuencia.aia (4.3 KB)
[this application is common for the following modules.]

  • App sends by Bluetooth a message to Arduino with HC-06 BT module.

  • Arduino gets the message and passes it through terminal 12 to the RF emitter.

  • The RF receiver receives the message and passes it to another Arduino through terminal 11.
    The message is displayed on the Serial Monitor.

  • The first Arduino use a battery as a Power Supply, the second Arduino is connected to a PC.

  • In this code, if TimerEnabled is false you can write and send a message.
  • If TimerEnabled is true, the timer automatically sends a sequence of numbers (1, 2, 3, 4,...)

- Arduino. Emitter code:

#include <RH_ASK.h>
#include <SPI.h> 

char caracterfinal = '\n';
String texto;
RH_ASK rf_driver;
// Conectar DATA al terminal 12 del Arduino. 

void setup(){ 
  Serial.begin(9600);
  rf_driver.init();
}

void loop() { 
  if(Serial.available()) {
    texto = Serial.readStringUntil(caracterfinal); // from App by Bluetooth
    Serial.println(texto);
    char *msg = texto.c_str();
    rf_driver.send((uint8_t *)msg, strlen(msg)); // FS1000A sends msg
    rf_driver.waitPacketSent();
  }
} 

- Arduino. Receiver code:

#include <RH_ASK.h>
#include <SPI.h> 
 
RH_ASK rf_driver;
// Conectar DATA al terminal 11 del Arduino.
 
void setup(){
    Serial.begin(9600);
    rf_driver.init();
}
 
void loop(){
    uint8_t buf[16] = {""}; // Size buffer 16.
    uint8_t buflen = sizeof(buf);
    if (rf_driver.recv(buf, &buflen)){
      Serial.print("Mensaje recibido: ");
      Serial.println((char*)buf);         
    }
}
  • Library: RadioHead. [it also works with the VirtualWire library.]
1 Like