Jdy40 Arduino Example Best !!install!! < UHD · 360p >
| Feature | JDY‑40 | HC‑05 | |---------|--------|-------| | Protocol | Simple 2.4 GHz proprietary / BLE‑like | Bluetooth 2.0 + EDR (Classic) | | Pairing | No pairing needed – works out of the box | Requires pairing and binding | | Max Range | ~120 m (line of sight) | ~10 m (class 2) | | Power Consumption | Very low (suitable for battery) | ~40 mA transmitting | | Configuration | SET pin + AT commands | AT commands via button / EN pin | | Complexity | Plug‑and‑play for simple links | More complex for master/slave setup |
Let’s build the simplest possible wireless link. Two Arduinos, each with a JDY‑40, will exchange data: whatever one Arduino sends via the Serial Monitor appears on the other’s Serial Monitor.
: Verify that AT+DVID and AT+RFID are identical across both units. Make sure the SET pin is disconnected from GND during communication mode. jdy40 arduino example best
Because the JDY-40 operates strictly at 3.3V, connecting it directly to a 5V Arduino Uno or Nano requires care. While the TX pin of the JDY-40 can safely trigger a 5V Arduino RX pin, the Arduino's 5V TX pin can damage the JDY-40 RX pin over time. A logic level converter or a simple resistor voltage divider is highly recommended for the RXD line. Wiring Connections JDY-40 Pin Arduino Uno / Nano Pin Ensure your Arduino can supply enough current. GND Common ground is mandatory. TXD Pin 2 (Software RX) Direct connection. RXD Pin 3 (Software TX) Via Voltage Divider (1kΩ and 2kΩ resistors). SET Digital pin used to toggle between AT Mode and Data Mode. CS Tied to ground to keep the module constantly awake. Designing the Voltage Divider for RXD To safely step down the Arduino’s 5V signal to 3.3V: Connect Arduino Pin 3 to a 1kΩ resistor .
In this guide, I’ll show you the to connect, code, and use the JDY-40 with Arduino. Make sure the SET pin is disconnected from
This seemingly trivial code is all you need. Type a message into the Serial Monitor of the first Arduino; it will appear instantly on the second Arduino’s Serial Monitor. The two modules act as a virtual cable, seamlessly forwarding any serial data in both directions.
#include // RX on Pin 2 (connects to TXD), TX on Pin 3 (connects to RXD) SoftwareSerial jdy40(2, 3); const int setPin = 4; void setup() pinMode(setPin, OUTPUT); // Enter AT Command Mode by pulling SET Low digitalWrite(setPin, LOW); delay(100); Serial.begin(9600); jdy40.begin(9600); // Default JDY-40 baud rate is 9600 Serial.println("JDY-40 AT Mode Initialized."); Serial.println("Type your AT commands in the Serial Monitor (Set to Both NL & CR)."); void loop() if (jdy40.available()) Serial.write(jdy40.read()); if (Serial.available()) jdy40.write(Serial.read()); Use code with caution. Essential AT Commands to Run: A logic level converter or a simple resistor
#include // RX, TX pins on Arduino (connect to TXD, RXD on JDY-40) SoftwareSerial jdy40(2, 3); void setup() Serial.begin(9600); // For Serial Monitor jdy40.begin(9600); // JDY-40 Default baud Serial.println("JDY-40 Ready"); void loop() // Send data from Serial Monitor to JDY-40 if (Serial.available()) jdy40.write(Serial.read()); // Receive data from JDY-40 and show in Serial Monitor if (jdy40.available()) Serial.write(jdy40.read()); Use code with caution. Copied to clipboard 4. Advanced Networking
// 2. Read data from Serial Monitor (USB) and send to JDY-40 (Wireless) if (Serial.available()) char c = Serial.read(); jdySerial.write(c);
The JDY‑40 uses 3.3 V logic levels. When connecting it to a 5 V Arduino (such as Uno or Mega), you must use a voltage divider (e.g., 1kΩ and 2kΩ) on the Arduino TX → JDY‑40 RX line to avoid damaging the module. For 3.3 V boards (Arduino Pro Mini 3.3V, ESP32, etc.) a direct connection is safe.
*Using SoftwareSerial is recommended to keep the hardware Serial port free for debugging. 2. Configuration (AT Mode)
