ESP32 and 433Mhz RF Transmitter And Receiver Modules

Hi, I’ve bought these 433MHz Transmitter and Receiver modules. from AliExpress but can’t seem to get them to work with ESP32s. There are plenty of tutorials out there but to be honest they confuse the hell out of me. Some seem pretty straight forward when using an Arduino Uno but I want two way communication between 2x ESP32s. Even if I could work out one way comms between 2x ESP32s I’d be able to work out the rest.

This is what I’ve tried for the receiver but it gets an error in the Serial Monitor



#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile

#define RadTX 22
#define RadRX 21

RH_ASK driver(2000, RadTX, RadRX); 

void setup()
{
    Serial.begin(9600);	// Debugging only
    if (!driver.init())
         Serial.println("init failed");
}

void loop()
{
    uint8_t buf[12];
    uint8_t buflen = sizeof(buf);
    if (driver.recv(buf, &buflen)) // Non-blocking
    {
      int i;
      // Message with a good checksum received, dump it.
      Serial.print("Message: ");
      Serial.println((char*)buf);         
    }
}

It just keeps looping through this in the serial monitor-

                mode:DIO, clock div:1
load:0x3fff0030,len:4980
load:0x40078000,len:16612
load:0x40080400,len:3480
entry 0x400805b4
[     1][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400d509c
[    12][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400d506c
[    26][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400d503c
[    39][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400d500c
[    53][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400d509c
[    66][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400d506c
[    80][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400d503c
[    93][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400d500c
[   107][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400d509c
[   120][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400d506c
[   133][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400d503c
[   147][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400d500c
[   163][D][esp32-hal-cpu.c:276] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[   177][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type UART_RX (2) with bus 0x3ffbdba4
[   188][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 1 successfully set to type UART_TX (3) with bus 0x3ffbdba4
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
  Model             : ESP32
  Package           : D0WD-Q5
  Revision          : 3.01
  Cores             : 2
  CPU Frequency     : 240 MHz
XTAL Frequency    : 40 MHz
  Features Bitfield : 0x00000032
  Embedded Flash    : No
  Embedded PSRAM    : No
  2.4GHz WiFi       : Yes
  Classic BT        : Yes
  BT Low Energy     : Yes
  IEEE 802.15.4     : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   377064 B ( 368.2 KB)
  Free Bytes        :   336192 B ( 328.3 KB)
  Allocated Bytes   :    33676 B (  32.9 KB)
  Minimum Free Bytes:   330404 B ( 322.7 KB)
  Largest Free Block:   110580 B ( 108.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
  Chip Size         :  4194304 B (4 MB)
  Block Size        :    65536 B (  64.0 KB)
  Sector Size       :     4096 B (   4.0 KB)
  Page Size         :      256 B (   0.2 KB)
  Bus Speed         : 80 MHz
  Bus Mode          : QIO
------------------------------------------
Partitions Info:
------------------------------------------
                nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
            otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
               app0 : addr: 0x00010000, size:  3072.0 KB, type:  APP, subtype: OTA_0
             spiffs : addr: 0x00310000, size:   896.0 KB, type: DATA, subtype: SPIFFS
           coredump : addr: 0x003F0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
  Compile Date/Time : Oct  3 2025 02:04:04
  Compile Host OS   : macosx
  ESP-IDF Version   : v5.5.1-1-g129cd0d247
  Arduino Version   : 3.3.0
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : ESP32_DEV
  Arduino Variant   : esp32
  Arduino FQBN      : esp32:esp32:esp32:UploadSpeed=115200,CPUFreq=240,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=huge_app,DebugLevel=verbose,PSRAM=disabled,LoopCore=1,EventsCore=1,EraseFlash=all,JTAGAdapter=default,ZigbeeMode=default
============ Before Setup End ============
[   680][V][esp32-hal-uart.c:707] uartBegin(): UART0 baud(9600) Mode(800001c) rxPin(3) txPin(1)
[   689][V][esp32-hal-uart.c:805] uartBegin(): UART0 not installed. Starting installation
[   699][V][esp32-hal-uart.c:815] uartBegin(): UART0 RX FIFO full threshold set to 120 (value requested: 120 || FIFO Max = 128)
[   712][V][esp32-hal-uart.c:845] uartBegin(): Setting UART0 to use REF_TICK clock


Can anyone help me?

The worst type of 433MHz receivers you can buy.
Do yourself s favour and throw them in the recycling.

Why not use ESPNOW.

RadRX is not same as RadRx.
Also the syntax is speed, rx, tx

I can do 2 way communication using WiFi and Bluetooth, that is not an issue…. I now want to try Radio to communicate longer distances where WiFi is not available.

RadRX and RadRx was just a typo on my part. It wouldn’t have compiled properly. I’ve been undoing typing to get back to what it was and forgot that part.

ESPNOW is not WiFi although it uses the same frequency band.
What do you mean with "longer distances"
The 433MHz modules you linked to top at 30m with external aerials and days of tweeking.
What is the environment (indoors/outside, trees, walls).
ESPNOW has been tested to >1Km outside.

Then buy decent rf modules. Those that you have have range less than 2.4G of Esp, if the receiver luckily even works. You find reasonable ones on AE for $2.
https://aliexpress.com/item/1005003436580019.html

I don’t think I made myself clear sorry. I have done 2 way communication with WiFi and Bluetooth and happy with that. I want to try different ways to communicate using ESP32s and now I want to try radio. I couldn’t care less how far the range is, but to be honest I states 200m on their site, I just want to try it. I have the boards and looking to see if I can get them to work.

+1
Superhytrodyne is much better than superreg (the ones with the laquered coil).

I’ve just ordered some Superhytrodyne ones. Have you sample code to help me on my way?

That depends which decoder chip is fitted on the module.
Ali didn't give you anything to go by.
The decoder is the 16- pin chip.

The set from post#7 is AFAIK meant to only receive and generate remote control codes,
to operate (switch on/off) 433MHz power points, garage doors, toys, etc.
I think the RCSwitch library is commonly used for this.
The decoder chip could be a xx2272 or HT12D.
I don't think the modules are useful to send custom data, just switch states.
Leo..

I tend to agree with previous posts that there are alternative long distance wireless solutions
e.g. LoRa, HC-12, etc

however, looking back I did test the 433MHz modules some time ago
transmitter

// ESP32/ESP8266 433mHz transmit a structure - from File>Examples>RadioHead>ask

#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h>  // Not actually used but needed to compile
#endif

//RH_ASK driver;
RH_ASK driver(2000, 4, 5, 0);  // ESP8266 or ESP32: do not use pin 11 or 2
// RH_ASK driver(2000, 3, 4, 0); // ATTiny, RX on D3 (pin 2 on attiny85) TX on D4 (pin 3 on attiny85),
// RH_ASK driver(2000, PD14, PD13, 0); STM32F4 Discovery: see tx and rx on Orange and Red LEDS

#define nodeID 2  //  <<< set up required node ID

// test structure
struct __attribute__((packed)) Struct1 {
  byte StructureID;  // identifies the structure type
  byte NodeID;       // ID of transmitting node
  int16_t seq;       // sequence number
  int16_t x;
  float y;
  char z[10];
  byte crc;           // CRC check
};

Struct1 struct1 = { 1, nodeID, 0, 1, 4.5, "hello", 0 };

void setup() {
  Serial.begin(115200);  // Debugging only
  delay(2000);
  Serial.println("\n433mHz transmit Structure");
  if (!driver.init()) {
    Serial.println("init failed");
    while(1) delay(1000);
  }
  Serial.println("init OK");
}

void loop() {
  Serial.print("Transmitting ");
  struct1.seq++;  // increment packet sequence number
  struct1.x += 1; // and test data
  struct1.y += 1;
  struct1.z[4] += 1;
  struct1.crc=CRC((byte *) &struct1);   // calculate CRC
  // transmit the structure
  driver.send((uint8_t *)&struct1, sizeof(struct1));
  driver.waitPacketSent();
   Serial.print(" StructureID ");
  Serial.print(struct1.StructureID);
  Serial.print(" Node ");
  Serial.print(nodeID);
  Serial.print(" seq number ");
  Serial.print(struct1.seq);
  Serial.print(" x = ");
  Serial.print(struct1.x);
  Serial.print(" y = ");
  Serial.print(struct1.y);
  Serial.print(" z = ");
  Serial.print(struct1.z);
  Serial.print(" crc = 0x");
  Serial.println(struct1.crc, HEX);
  delay(2000);
}

// simple checksum - replace with CRC8
byte CRC(byte * s) {
  byte crc=0;
  for(int i=0;i<sizeof(Struct1)-1;i++) crc+=s[i];
  return crc;  
}

receiver

// ESP32 433mHz receive structure - from File>Examples>RadioHead>ask

#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h>  // Not actually used but needed to compile
#endif

//RH_ASK driver;
RH_ASK driver(2000, 4, 5, 0);  // ESP8266 or ESP32: do not use pin 11 or 2
// RH_ASK driver(2000, 3, 4, 0); // ATTiny, RX on D3 (pin 2 on attiny85) TX on D4 (pin 3 on attiny85),
// RH_ASK driver(2000, PD14, PD13, 0); STM32F4 Discovery: see tx and rx on Orange and Red LEDS

struct __attribute__((packed)) Struct1 {
  byte StructureID;  // identifies the structure type
  byte NodeID;       // ID of transmitting node
  int16_t seq;       // sequence number
  int16_t x;
  float y;
  char z[10];
  byte crc;
} struct1;

void setup() {
  Serial.begin(115200);  // Debugging only
  delay(2000);
  Serial.println("433mHz receive Structure");
  if (!driver.init()) {
    Serial.println("init failed");
    while (1) delay(1000);
  }
  Serial.println("init OK");
}

void loop() {
  static int16_t node1seq = 0, node2seq = 0, seqErrors = 0, crcErrors;
  uint8_t buf[100];  // Set buffer to size of expected message
  // receive  packet - check is correct size
  uint8_t len = 100;
  if (driver.recv((uint8_t *)&struct1, &len)) {
    if (len != sizeof(Struct1)) {
      Serial.print("Error - incorrect packet size received!! length ");
      Serial.println(len);
      return;
    }
    // Message received with valid checksum  ??
    Serial.print("Received ");
    Serial.print(len);
    Serial.print("bytes StructID ");
    Serial.print(struct1.StructureID);
    Serial.print(" Node ");
    Serial.print(struct1.NodeID);
    Serial.print(" seq ");
    Serial.print(struct1.seq);
    Serial.print(" x = ");
    Serial.print(struct1.x);
    Serial.print(" y = ");
    Serial.print(struct1.y);
    Serial.print(" z = ");
    Serial.print(struct1.z);
    Serial.print(" crc = 0x");
    Serial.print(struct1.crc, HEX);
    if (struct1.NodeID == 1) {
      if (struct1.seq != node1seq) {
        Serial.print("\n  seq number error expected ");
        Serial.print(node1seq);
        node1seq = struct1.seq;
        ++seqErrors;
      }
      node1seq++;
    }
    if (struct1.NodeID == 2) {
      if (struct1.seq != node2seq) {
        Serial.print("\n  seq number error expected ");
        Serial.print(node2seq);
        ++seqErrors;
        node2seq = struct1.seq;
      }
      node2seq++;
    }
    Serial.print(" seq errors ");
    Serial.print(seqErrors);
    byte crc = CRC((byte *)&struct1);
    //crc++;                        // uncommend to display crc error message
    if (crc != struct1.crc) {
      Serial.print("\n  crc error calculated 0x");
      Serial.print(crc, HEX);
      crcErrors++;
    }
    Serial.print(" crc errors ");
    Serial.println(crcErrors);
  }
}

// simple checksum - replace with CRC8
byte CRC(byte *s) {
  byte crc = 0;
  for (int i = 0; i < sizeof(Struct1) - 1; i++) crc += s[i];
  return crc;
}

transmitter serial monitor output

nit OK
Transmitting  StructureID 1 Node 2 seq number 1 x = 2 y = 5.50 z = iello crc = 0xB
Transmitting  StructureID 1 Node 2 seq number 2 x = 3 y = 6.50 z = jello crc = 0x2E
Transmitting  StructureID 1 Node 2 seq number 3 x = 4 y = 7.50 z = kello crc = 0x51
Transmitting  StructureID 1 Node 2 seq number 4 x = 5 y = 8.50 z = lello crc = 0x6D
Transmitting  StructureID 1 Node 2 seq number 5 x = 6 y = 9.50 z = mello crc = 0x80
Transmitting  StructureID 1 Node 2 seq number 6 x = 7 y = 10.50 z = nello crc = 0x93
Transmitting  StructureID 1 Node 2 seq number 7 x = 8 y = 11.50 z = oello crc = 0xA6
Transmitting  StructureID 1 Node 2 seq number 8 x = 9 y = 12.50 z = pello crc = 0xB9
Transmitting  StructureID 1 Node 2 seq number 9 x = 10 y = 13.50 z = qello crc = 0xCC
Transmitting  StructureID 1 Node 2 seq number 10 x = 11 y = 14.50 z = rello crc = 0xDF
Transmitting  StructureID 1 Node 2 seq number 11 x = 12 y = 15.50 z = sello crc = 0xF2
Transmitting  StructureID 1 Node 2 seq number 12 x = 13 y = 16.50 z = tello crc = 0x1
Transmitting  StructureID 1 Node 2 seq number 13 x = 14 y = 17.50 z = uello crc = 0xC
Transmitting  StructureID 1 Node 2 seq number 14 x = 15 y = 18.50 z = vello crc = 0x17
Transmitting  StructureID 1 Node 2 seq number 15 x = 16 y = 19.50 z = wello crc = 0x22
Transmitting  StructureID 1 Node 2 seq number 16 x = 17 y = 20.50 z = xello crc = 0x2D
Transmitting  StructureID 1 Node 2 seq number 17 x = 18 y = 21.50 z = yello crc = 0x38
Transmitting  StructureID 1 Node 2 seq number 18 x = 19 y = 22.50 z = zello crc = 0x43

receiver serial monitor output

init OK
Received 21bytes StructID 1 Node 2 seq 4 x = 5 y = 8.50 z = lello crc = 0x6D
  seq number error expected 0 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 5 x = 6 y = 9.50 z = mello crc = 0x80 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 6 x = 7 y = 10.50 z = nello crc = 0x93 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 7 x = 8 y = 11.50 z = oello crc = 0xA6 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 8 x = 9 y = 12.50 z = pello crc = 0xB9 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 9 x = 10 y = 13.50 z = qello crc = 0xCC seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 10 x = 11 y = 14.50 z = rello crc = 0xDF seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 11 x = 12 y = 15.50 z = sello crc = 0xF2 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 12 x = 13 y = 16.50 z = tello crc = 0x1 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 13 x = 14 y = 17.50 z = uello crc = 0xC seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 14 x = 15 y = 18.50 z = vello crc = 0x17 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 15 x = 16 y = 19.50 z = wello crc = 0x22 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 16 x = 17 y = 20.50 z = xello crc = 0x2D seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 17 x = 18 y = 21.50 z = yello crc = 0x38 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 18 x = 19 y = 22.50 z = zello crc = 0x43 seq errors 1 crc errors 0
Received 21bytes StructID 1 Node 2 seq 19 x = 20 y = 23.50 z = {ello crc = 0x4E seq errors 1 crc errors 0

If you want 433MHz send/recieve you can also go to lora modules like the sx1276 (few euros on aliexpress, with the option also to have an external antenna). Libraries are mature on both esp-idf and arduino, and you get few kilometers range on 100mW. Beware radio frequencies regulations on your country expecially if you live on a crowded area!

Hi Horace, What ate the values 2000, 4, 5 and 0 for? I take it that 4 and 5 are GPIO numbers? If so what are the 2000 and 0 values for?

the constructor

   /// Constructor.
    /// At present only one instance of RH_ASK per sketch is supported.
    /// \param[in] speed The desired bit rate in bits per second
    /// \param[in] rxPin The pin that is used to get data from the receiver
    /// \param[in] txPin The pin that is used to send data to the transmitter
    /// \param[in] pttPin The pin that is connected to the transmitter controller. It will be set HIGH to enable the transmitter (unless pttInverted is true).
    /// \param[in] pttInverted true if you desire the pttin to be inverted so that LOW wil enable the transmitter.
    RH_ASK(uint16_t speed = 2000, uint8_t rxPin = 11, uint8_t txPin = 12, uint8_t pttPin = 10, bool pttInverted = false);

As always Horace, you’re the man :grinning_face:

Hi Horace and everyone else…….. I’m a complete idiot :flushed_face: When I ordered the them from AliExpress I accidentally ordered two 433MHz receivers instead of a receiver and a transmitter. When they turned up, I realised what I did so I ordered two transmitters which I assumed would be 433MHz. I’ve just looked at my order details and I’ve accidentally ordered 2x 315MHz transmitters. I feel a complete idiot and so sorry to waste peoples time. I’m going to order 2 of each so I have 2 sets of 433MHz and 2 sets of 315MHz.

The transmitters you already had can be used with the new receivers.
Assuming the transmitter is just that (not an encoder).
Make sure the frequency of transmitter and receiver matches.
Leo..

I have ordered the matching transmitters and receivers so I’ll have 4 sets. 2x 315MHz and 2x 433MHz :roll_eyes: I’ll find a use for them :grinning_face: I’m curious to find out if they do indeed transmit up to 200m without obstacles and how far with obstacles.