#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
#include <SoftwareSerial.h>
The JDY-40 defaults to 9600 baud. Make sure both modules are on the same channel (default is channel 1). jdy40 arduino example best
#include <SoftwareSerial.h>
For 80% of hobbyist wireless projects, the JDY-40's simplicity is a true superpower, allowing you to skip the driver headaches and get straight to the fun part of your project. Happy building! #include const int RX_PIN = 2; const int
The example above is production-ready. Just change pin definitions, power with clean 3.3V, and you will have a wireless link in under 60 seconds.
const int buttonPin = 7; int buttonState = 0; int lastButtonState = HIGH; Make sure both modules are on the same
#include SoftwareSerial jdyWireless(2, 3); // RX, TX void setup() Serial.begin(9600); jdyWireless.begin(9600); Serial.println("System initialized. Ready to send/receive data..."); void loop() // Check if data is received from the remote JDY-40 module if (jdyWireless.available()) Serial.print("Received: "); while (jdyWireless.available()) char inChar = (char)jdyWireless.read(); Serial.write(inChar); Serial.println(); // Check if there is data from local serial monitor to transmit if (Serial.available()) String outData = Serial.readStringUntil('\n'); jdyWireless.println(outData); Serial.print("Sent: "); Serial.println(outData); Use code with caution. Advanced Best Practices for Production Projects