Rf transmitter 433 Mhz on xiao esp32c3?

The supply voltage of the module seems to be 5V, where is it supplied from?
XIAO’s IO is 3.3V specification, but is the module’s IO 3.3V or 5V?

Here’s the code that manages to compile, the only thing is that I don’t know how to define the pin of my module.

#include <RH_ASK.h> // Include RadioHead Amplitude Shift Keying Library
#include <SPI.h> // Include dependant SPI Library
RH_ASK rf_driver(2000, 21, 22); // ESP32 Create Amplitude Shift Keying Object
void setup() {
Serial.begin(115200);
delay(4000);
Serial.println(“ESP32 433MHz receiver”);
if (RH_PLATFORM == RH_PLATFORM_ESP32)
Serial.println(“RH_PLATFORM_ESP32”);
delay(5000);
Serial.println(“Receiver: rf_driver initialising”);
if (!rf_driver.init()) {
Serial.println(“init failed”);
while (1) delay(1000);
}
Serial.println(“Receiver: rf_driver initialised”);
}
void loop() {
uint8_t buf[20]={0}; // Set buffer to size of expected message
uint8_t buflen = sizeof(buf);
// Check if received packet is correct size
if (rf_driver.recv(buf, &buflen)) {
// Message received with valid checksum
Serial.print("Message Received: ");
Serial.println((char*)buf);
}
}

It’s 5V but there is a 5V OUTPUT in the XIAO

XIAO’s IO is 3.3V specification, so if the module’s IO is 5V specification, it cannot be directly connected. Is the module’s IO 3.3V or 5V?

the module have a Working voltage of DC5V

The definition of a pin is as follows.

static const uint8_t TX = 21;
static const uint8_t RX = 20;

static const uint8_t SDA = 6;
static const uint8_t SCL = 7;

static const uint8_t SS = 20;
static const uint8_t MOSI = 10;
static const uint8_t MISO = 9;
static const uint8_t SCK = 8;

static const uint8_t A0 = 2;
static const uint8_t A1 = 3;
static const uint8_t A2 = 4;
static const uint8_t A3 = 5;

static const uint8_t D0 = 2;
static const uint8_t D1 = 3;
static const uint8_t D2 = 4;
static const uint8_t D3 = 5;
static const uint8_t D4 = 6;
static const uint8_t D5 = 7;
static const uint8_t D6 = 21;
static const uint8_t D7 = 20;
static const uint8_t D8 = 8;
static const uint8_t D9 = 9;
static const uint8_t D10 = 10;

Do you have the specifications or schematic of the module?

If the module includes a level shifter, it can be connected to XIAO, if not, it cannot be connected. 5VIO spec Arduino can be connected.

The module is indeed specified for Arduino. but If I want to define pin D4 as the input for the sensor, should I use RH_ASK driver(2000, 4, 5)? I admit I don’t quite understand how this function works.
I have the impression that the problem comes from there.

The following description is found in RH_ASK.h.

/// Initialise RH_ASK for ATTiny85 like this:
/// \code
/// // #include <SPI.h> // comment this out, not needed
/// RH_ASK driver(2000, 4, 3); // 200bps, TX on D3 (pin 2), RX on D4 (pin 3)
/// \endcode
/// then:
/// Connect D3 (pin 2) as the output to the transmitter
/// Connect D4 (pin 3) as the input from the receiver.

RH_ASK rf_driver(2000, D4, D3);  // D4:connected receiver, D3:connected transmitter

A big thank you for your help and for taking the time to assist me. I’ll go test everything out, and I’ll keep you posted.

I have this grove module but have not taken it out the bag yet

Alright, I’ve tested everything, and now I’m not sure what to do anymore. It still doesn’t work. The code compiles half the time, and when it does compile, nothing happens. Here’s an excerpt from my code.

transmitter (XIAO esp32c3) :
#include <RH_ASK.h>

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

RH_ASK driver(2000, 4, 3);

void setup()

{

Serial.begin(9600);    // Debugging only

if (!driver.init())

     Serial.println("init failed");

}

void loop()

{

Serial.println(“boule”);

const char *msg = "Hello World!";

driver.send((uint8_t *)msg, strlen(msg));

driver.waitPacketSent();

delay(1000);

}

Receiver (Arduino Uno):

#include <RH_ASK.h>

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

RH_ASK driver(2000, 4, 3);

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);

Serial.println("boule");

if (driver.recv(buf, &buflen)) // Non-blocking

{

  int i;

  // Message with a good checksum received, dump it.

  Serial.print("Message: ");

  Serial.println((char*)buf);        

}

}

transmitter (XIAO esp32c3) :
#include <RH_ASK.h>

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

RH_ASK driver(2000, 4, 3);

Is the receiver connected to the D2 pin of the XIAO?
In XIAO, “4” means pin D2.

no this is the transmitter who is connect to xiao, is connect to D3, is it bad ?

In any case, I’ve tried nearly all the wire combinations, whether it’s on the XIAO or the Arduino

    /// 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);

It appears that RH_ASK requires 5 arguments.

static const uint8_t D0 = 2;
static const uint8_t D1 = 3;
static const uint8_t D2 = 4;
static const uint8_t D3 = 5;
static const uint8_t D4 = 6;
static const uint8_t D5 = 7;
static const uint8_t D6 = 21;
static const uint8_t D7 = 20;
static const uint8_t D8 = 8;
static const uint8_t D9 = 9;
static const uint8_t D10 = 10;

When connecting to XIAO, “the pin number” and “pin name” must be carefully checked.

ho, what is the utility of pttPin, I really need to put it?

/// \param[in] pttPin The pin that is connected to the transmitter controller. It will be set HIGH to enable the transmitter

Do you need to set the pin mode? For example.

pinMode(D3, OUTPUT);

Since I don’t have the hardware, I can’t check your connection and sketch.

Well, I don’t know by what miracle, but I changed the pin numbers in the code, I relocated the transmitter, and MIRACLE it works! So, a big thank you because you’ve helped me so much. Without you, it would have taken 20 times longer. As we say where I’m from, tu gère.

1 Like

Glad I could be of help.