Jdy40 Arduino Example Best Jun 2026
// Prepare JDY-40 (connected to hardware serial pins 0/1) pinMode(2, OUTPUT); // SET pin digitalWrite(2, LOW); // Enter AT mode (for configuring) // We'll set the channel and ID inside the loop, before each transmission.
void setup() Serial.begin(9600); // For debugging via USB jdy40.begin(9600); // JDY-40 default baud rate
The JDY‑40 is usually sold as a small PCB with the following pins (order may vary depending on the vendor):
This comprehensive guide covers everything you need to know to build a robust wireless link using the JDY-40 and Arduino, complete with wiring diagrams, AT command configuration, and a production-ready code example. Technical Specifications & Pinout
| Command | Function | | :--- | :--- | | AT | Test communication | | AT+VERSION | Get firmware version | | AT+DEFAULT | Reset to factory | | AT+BAUD4 | Set baud to 9600 (4=9600, 5=19200, etc.) | | AT+RFCH0 | Set channel (0-19) – use same on both | | AT+ADDR0001 | Set address (0001-FFFF) – use same on both | jdy40 arduino example best
In the crowded world of 2.4GHz wireless modules, the nRF24L01 often steals the spotlight. However, it comes with a notorious catch: complex configuration, pin sensitivity, and frequent “fried” modules due to 5V logic. Enter the — a hidden gem for Arduino enthusiasts who need simple, reliable, ultra-low-power point-to-point or broadcast communication.
You can configure these features using AT commands when the SET pin is grounded: : Change serial speed (Default is 9600 ).
However, if your project requires high-speed data links (streaming audio, etc.), the nRF24L01+ is a better fit.
The following example uses the SoftwareSerial library. This is the "best" general example because it leaves the Arduino's Hardware Serial (USB) free for debugging and monitoring data on the Serial Monitor. // Prepare JDY-40 (connected to hardware serial pins
To ensure a highly stable and interference-free connection in real-world scenarios, implement the following engineering practices: Implement Data Packet Framing
#include SoftwareSerial jdySerial(2, 3); // RX, TX unsigned long lastSendTime = 0; const unsigned long interval = 1000; // Send every 1 second void setup() Serial.begin(9600); jdySerial.begin(9600); Serial.println("Transmitter Initialised."); void loop() if (millis() - lastSendTime >= interval) lastSendTime = millis(); // Simulate sensor readings int temperature = random(20, 35); int humidity = random(40, 80); // Construct packet with start '<' and end '>' markers jdySerial.print("<"); jdySerial.print(temperature); jdySerial.print(","); jdySerial.print(humidity); jdySerial.println(">"); // Debug output to local PC Serial.print("Sent: T="); Serial.print(temperature); Serial.print("C, H="); Serial.print(humidity); Serial.println("%"); Use code with caution. Receiver Code (Base Station Node)
Each remote listens for incoming commands and executes them when its ID is matched.
The JDY‑40 is a hidden gem in the Arduino wireless world. It offers a dead‑simple way to turn any serial connection into a wireless link, with excellent range and low power consumption. Once you have mastered the basic example (a transparent wireless UART), you can build remote sensor networks, wireless data loggers, robot controllers, and home automation systems – all without wrestling with Bluetooth pairing or WiFi IP addresses. However, it comes with a notorious catch: complex
After setting AT+RFNETID , the modules automatically pair. No need for AT+LINK or address targeting. This is transparent broadcasting — anything one sends, all receive.
Open Tools → Serial Plotter on the receiver. You’ll see a live graph of temperature and humidity – wirelessly!
Despite its simplicity, things can go wrong. Here is a practical guide based on common community challenges.
#include <DHT.h>