Hey all
I'm having issues connecting my 433Mhz module to an esp32.
from what I can see, there are not any resources that assist me.
if you have any guidance that you could provide, it is greatly appreciated
thanks!
Hey all
I'm having issues connecting my 433Mhz module to an esp32.
from what I can see, there are not any resources that assist me.
if you have any guidance that you could provide, it is greatly appreciated
thanks!
Google
esp32+433+mhz+transmitter
First hit doesn't help?
have a look at rf-433mhz-transmitter-receiver-module-with-arduino
the example code uses the SparkFun_RadioHead_Arduino_Library
if connecting to an ESP32 you will need to explicitly set the pins used, e.g.
/// 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);
using verson Radiohead library version 1..21 (Edited!)
connected a 433MHz transmitter to ESP8266 pin GPIO4 with constructor
//RH_ASK(uint16_t speed = 2000, uint8_t rxPin = 11, uint8_t txPin = 12, uint8_t pttPin = 10, bool pttInverted = false);
RH_ASK rf_driver(2000, 2, 4); // ESP8266 Create Amplitude Shift Keying Object
works OK transmitting data to receiver
connected 433MHz transmitter to ESP32 and it resets and goes into a loop when
if (!rf_driver.init()) {
is called
looking at RF_ASK.H it lists supported microcontrollers - ESP8266 is listed but not the ESP32
Edit: looking at RF_ASK.CPP it does support ESP32
ESP32 433MHz receiver code using pin GPIO21 (Tools>Board set to NodeMCU-32S)
// ESP32 433MHz receiver test 1
#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);
}
}
not tested transmitter on GPIO22
ESP8266 transmitter
// ESP8266 433MHz transmitter test 1
#include <RH_ASK.h> // Include RadioHead Amplitude Shift Keying Library
#include <SPI.h> // Include dependant SPI Library
//RH_ASK(uint16_t speed = 2000, uint8_t rxPin = 11, uint8_t txPin = 12, uint8_t pttPin = 10, bool pttInverted = false);
RH_ASK rf_driver(2000, 2, 4); // ESP8266 Create Amplitude Shift Keying Object
void setup() {
Serial.begin(115200);
delay(4000);
Serial.println("ESP8266 433MHz transmitter");
if (!rf_driver.init()) {
Serial.println("init failed");
while (1) delay(10000);
}
Serial.println("Transmitter: rf_driver initialised");
}
// transmit packet every 5 seconds
void loop() {
Serial.println("Transmitting packet");
const char *msg = "Hello World";
rf_driver.send((uint8_t *)msg, strlen(msg)+1);
rf_driver.waitPacketSent();
delay(5000);
}
ESP8266 serial monitor
ESP8266 433MHz transmitter
Transmitter: rf_driver initialised
Transmitting packet
Transmitting packet
Transmitting packet
Transmitting packet
ESP32 receiver serial monitor
ESP32 433MHz receiver
RH_PLATFORM_ESP32
Receiver: rf_driver initialising
Receiver: rf_driver initialised
Message Received: Hello World
Message Received: Hello World
Message Received: Hello World
Message Received: Hello World
Thank you so much for this, I was wondering if I would have needed to change my board.
Thanks again!
Where can I download RadioHead version 1.22
follow the Radiohead library link in post 4 and download RadioHead-1.121.zip
if you unzip it you will find the version of RH_ASK.h is commented as
RH_ASK.h,v 1.22 2020/05/06 22:26:45
which is the one I used in post 4
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.