Jdy40 Arduino Example Best Instant

This example uses SoftwareSerial so you can keep your hardware Serial port free for the Serial Monitor. The same code can be uploaded to both the transmitter and receiver Arduinos to create a bi-directional "Wireless Serial Monitor".

#include SoftwareSerial jdy40(2, 3); // RX, TX void setup() Serial.begin(9600); jdy40.begin(9600); // Default AT baud rate Serial.println("Enter AT Commands:"); void loop() if (jdy40.available()) Serial.write(jdy40.read()); if (Serial.available()) jdy40.write(Serial.read()); Use code with caution. Useful AT Commands AT (Returns OK ) Check Version: AT+VERSION Set Channel: AT+CL001 (Sets channel to 1, range 001-128) Set Address: AT+ADDR1234 (Sets address to 1234) Reset: AT+RESET 5. Troubleshooting Common JDY-40 Issues No Communication: Ensure the CS pin is grounded.

#include <SoftwareSerial.h>

This example transmits temperature and humidity with error checking. jdy40 arduino example best

SoftwareSerial jdySerial(JDY_RX_PIN, JDY_TX_PIN); // RX, TX

receivedData = ""; else receivedData += c;

This feature allows you to build complex systems like a multi-room sensor network where only the intended node responds to a query. This example uses SoftwareSerial so you can keep

void setup() pinMode(ledPin, OUTPUT); Serial.begin(9600); jdy40.begin(9600); Serial.println("JDY-40 Receiver Ready");

// Start PC Serial Serial.begin(PC_BAUD); while (!Serial) ; // Wait for port to connect

This comprehensive guide covers everything required to master the JDY-40 module with an Arduino, moving from hardware wiring to AT command configuration, and concludes with a robust, real-world communication example. Share public link Useful AT Commands AT (Returns OK ) Check

: First, connect the JDY-40 to your Arduino as described above. To put the module into AT command mode, you must connect the SET pin to GND (LOW) and CS pin to GND.

Here are some concrete projects you can build to put your new knowledge to the test:

#include #define JDY_RX 2 #define JDY_TX 3 SoftwareSerial jdySerial(JDY_RX, JDY_TX); const int sensorPin = A0; unsigned long previousMillis = 0; const long interval = 1000; // Send data every 1 second void setup() Serial.begin(9600); jdySerial.begin(9600); pinMode(sensorPin, INPUT); Serial.println("Transmitter Ready."); void loop() unsigned long currentMillis = millis(); if (currentMillis - previousMillis >= interval) previousMillis = currentMillis; int sensorValue = analogRead(sensorPin); // Construct packet: jdySerial.print(" "); // Local debug monitoring Serial.print("Sent telemetry: "); Serial.println(sensorValue); Use code with caution. Best Example: Robust Receiver Code

#include #define JDY_RX 2 #define JDY_TX 3 #define JDY_SET 4 #define JDY_CS 5 SoftwareSerial jdySerial(JDY_RX, JDY_TX); void sendATCommand(const char* command) jdySerial.println(command); delay(100); while (jdySerial.available()) Serial.write(jdySerial.read()); Serial.println(); void setup() Serial.begin(9600); jdySerial.begin(9600); pinMode(JDY_SET, OUTPUT); pinMode(JDY_CS, OUTPUT); // Activate module and enter AT mode digitalWrite(JDY_CS, LOW); digitalWrite(JDY_SET, LOW); delay(200); Serial.println("--- Configuring JDY-40 ---"); sendATCommand("AT+BAUD4"); // Set baud rate to 9600 sendATCommand("AT+RFID12345678"); // Set unique network ID (Must match receiver) sendATCommand("AT+D_ID1122"); // Set Device ID sendATCommand("AT+POWE9"); // Set max transmit power (+12dBm) sendATCommand("AT+CLSSA0"); // Set as transparent transmission device // Return to transparent communication mode digitalWrite(JDY_SET, HIGH); Serial.println("--- Configuration Complete. Communication Mode Active ---"); void loop() // Pass-through loop for manual debugging via Serial Monitor if (Serial.available()) jdySerial.write(Serial.read()); if (jdySerial.available()) Serial.write(jdySerial.read()); Use code with caution. Best Example: Robust Transmitter Code