Jdy40 Arduino Example Best 〈TRENDING • Roundup〉
Before sending data, you must configure both modules (e.g., to the same channel). : Pull the SET pin LOW . Common Commands : AT+BAUD : Set baud rate (Default is 9600).
Ensure SET pin is connected to GND before powering it on for AT mode.
void loop() // Relay any data from the Serial Monitor to the JDY-40 if (Serial.available() > 0) String comdata = ""; while (Serial.available() > 0) comdata += char(Serial.read()); delay(2);
Transparent transmission (data sent to TX is received on RX of the other module) Support: AT Command setup 2. Wiring Diagram: JDY-40 to Arduino jdy40 arduino example best
| AT Command | Description | Default Value | Example | | :--- | :--- | :--- | :--- | | AT+BAUD | Set the serial baud rate. | 4 (9600) | AT+BAUD4 | | AT+RFC | Set the radio frequency channel (001-128). | 001 | AT+RFC010 | | AT+RFID | Set the wireless network ID (0000-FFFF). | 8899 | AT+RFID1234 | | AT+DVID | Set the device ID (0000-FFFF). | 1122 | AT+DVID0011 | | AT+POWE | Set the transmit power (0-9, higher = more power). | 9 | AT+POWE5 | | AT+CLSS | Set the operating mode ( A0 =Transparent, C1 =IO Send, C4 =IO Receive). | A0 | AT+CLSSC1 | | AT+VER | Query the firmware version. | N/A | AT+VER |
110 m: connection lost
Note: For reliable operation, it is recommended to use to communicate with the JDY-40 to leave the hardware serial (pins 0 & 1) open for USB debugging. 3. The Best JDY-40 Arduino Example: Wireless Serial Bridge Before sending data, you must configure both modules (e
#include // Define Arduino pins const int J_RX = 2; // Connects to JDY-40 TX const int J_TX = 3; // Connects to JDY-40 RX (via voltage divider) const int J_SET = 4; // Connects to JDY-40 SET pin const int SENSOR_PIN = A0; SoftwareSerial jdy40(J_RX, J_TX); void setup() Serial.begin(9600); jdy40.begin(9600); pinMode(J_SET, OUTPUT); digitalWrite(J_SET, HIGH); // Set to HIGH for Transparent Data Mode Serial.println("--- JDY-40 Transmitter Ready ---"); void loop() // Read dummy data from analog pin int sensorValue = analogRead(SENSOR_PIN); // Format packet: [START_MARKER][DATA][END_MARKER] // Example payload sent: jdy40.print("<"); jdy40.print(sensorValue); jdy40.print(">"); // Local debug log Serial.print("Transmitted: <"); Serial.print(sensorValue); Serial.println(">"); delay(1000); // Send data packet every second Use code with caution. 2. Receiver Code (Rx)
Pull LOW to enable module; pull HIGH to enter deep sleep mode Wiring the JDY-40 to Arduino
: For stable communication between multiple links, it is best to separate their channels by at least 6 to avoid interference. Ensure SET pin is connected to GND before
// Define software serial pins for the JDY-40 #define JDY_RX 10 // Connect to JDY-40 TX #define JDY_TX 11 // Connect to JDY-40 RX
AT+DVID (Default is 2453 ). Both modules must match.
SoftwareSerial jdy40(2, 3); DHT dht(7, DHT11);
to avoid interfering with the Arduino's hardware serial (USB) port. It allows you to send data from one Serial Monitor to another wirelessly Longan Labs // Connect JDY-40 TX to D2, RX to D3 SoftwareSerial jdy40( setup() Serial.begin( // For debugging via USB jdy40.begin( // Default JDY-40 baud rate Serial.println( "JDY-40 Wireless Serial Ready" // If data is received from JDY-40, send to Serial Monitor (jdy40.available()) Serial.write(jdy40.read()); // If data is typed in Serial Monitor, send to JDY-40