The HC‑05 is a module that uses the Serial Port Profile (SPP). It is great for communicating with smartphones and PCs, but you must go through a pairing procedure, and its range is limited to about 10 metres. The JDY‑40, on the other hand, works like a wireless serial cable – two modules set to the same channel and ID immediately exchange data. This makes it far simpler for Arduino‑to‑Arduino links, especially when you need longer range or lower power consumption.
Because AT commands take only a few milliseconds, this method works well for low‑duty‑cycle applications.
If you have multiple sets of JDY-40s nearby, change the channel and address:
Now for the most important part: how to use the JDY-40 in your own projects. Here are three practical examples, from simple to more advanced. jdy40 arduino example best
SoftwareSerial jdySerial(JDY_RX, JDY_TX);
Which are you planning to use for the project? What is the target distance between your wireless nodes? Share public link
// Send configuration commands Serial1.println("AT+RFID1133"); // Change Network ID delay(100); Serial1.println("AT+BAUD6"); // Change baud rate to 19200 delay(100); The HC‑05 is a module that uses the
This code reads data from the Serial Monitor and sends it wirelessly to any other JDY-40 on the same channel (must be in Transparent Mode).
The JDY-40 operates on the 2.4 GHz frequency band and uses a standard serial interface (UART), making it highly compatible with almost any Arduino board. Key Technical Specifications 2.4 GHz Transmit Power: Maximum 12 dBm Working Voltage: 2.2V to 3.6V (Requires a 3.3V supply)
Here is a quick reference of the most common AT commands to get you started: This makes it far simpler for Arduino‑to‑Arduino links,
: Chip select pin. Pull low to enable the module; pull high to enter sleep mode. Technical Specifications Frequency Range : 2.4 GHz Communication Distance : Up to 120 meters in open space Interface : Serial UART
#include const int RX_PIN = 2; const int TX_PIN = 3; const int SET_PIN = 4; SoftwareSerial jdy40(RX_PIN, TX_PIN); void setup() pinMode(SET_PIN, OUTPUT); digitalWrite(SET_PIN, LOW); // Enter AT Command Mode Serial.begin(9600); jdy40.begin(9600); // Default baud rate for JDY-40 Serial.println("JDY-40 AT Mode Initialized. Ensure Serial Monitor is 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
void setup() // Initialize hardware serial to talk to the JDY-40 Serial.begin(9600);
#define DHTPIN 2 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE);
#include const int rxPin = 2; const int txPin = 3; const int setPin = 4; SoftwareSerial jdy40(rxPin, txPin); void setup() pinMode(setPin, OUTPUT); // Enter AT command mode by pulling SET pin LOW digitalWrite(setPin, LOW); delay(100); Serial.begin(9600); jdy40.begin(9600); Serial.println("JDY-40 AT Command Mode Ready."); Serial.println("Type AT commands in the Serial Monitor."); void loop() // Pass data from Arduino Serial Monitor to JDY-40 if (Serial.available()) jdy40.write(Serial.read()); // Pass data from JDY-40 back to Arduino Serial Monitor if (jdy40.available()) Serial.write(jdy40.read()); Use code with caution. Essential AT Commands