This Arduino project utilizes an ESP8266 module to connect to Wi-Fi and an MQTT broker, allowing you to transmit data wirelessly using an RCSwitch transmitter.
For example this can be used whenever a button is pressed from another device, we can automate lights or doorbells over 433mhz.
To run this project, you will need the following:
- Arduino board and 433mhz transmitter
- Wi-Fi network with credentials (SSID and password)
- MQTT broker server with configuration details (server address, port, user, and password)
NodeMCU | 433MHz Transmitter |
---|---|
D2 | Data Pin |
3.3v | VCC |
GND | GND |
-
Clone or download this repository.
-
Open the Arduino IDE and install the following libraries:
ESP8266WiFi
PubSubClient
RCSwitch
-
Connect your Arduino board with the ESP8266 module to your computer.
-
Open the Arduino sketch file (
arduino_mqtt_rf_transmitter.ino
) in the Arduino IDE. -
Modify the following variables in the sketch to match your Wi-Fi and MQTT settings:
ssid
: Your Wi-Fi network SSIDpassword
: Your Wi-Fi network passwordmqttServer
: Your MQTT broker server addressmqttPort
: MQTT broker port (usually 1883)mqttUser
: MQTT username (if applicable)mqttPassword
: MQTT password (if applicable)mqttTopic
: MQTT topic to subscribe and transmit ontransmitterPin
: The pin connected to the RF transmitter (D2 by default)transmitterProtocol
: Protocol used by the RF transmittertransmitterPulseLength
: Pulse length for the RF transmittertransmissionData
: Data to be transmitted wirelesslytransmissionLength
: Length of the transmission data
-
Upload the sketch to your Arduino board.
-
Open the Serial Monitor to view the debug output and verify the Wi-Fi and MQTT connections.
-
Once connected, sending an MQTT message to the subscribed topic (
mqttTopic
) will trigger the transmission of data using the RCSwitch transmitter.
This project is licensed under the MIT License.