void loop() // Read from wireless module if (jdy40.available()) String command = jdy40.readString(); command.trim();
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 #define JDY_RX 2 #define JDY_TX 3 SoftwareSerial jdySerial(JDY_RX, JDY_TX); const byte numChars = 32; char receivedChars[numChars]; boolean newData = false; void setup() Serial.begin(9600); jdySerial.begin(9600); Serial.println("Receiver Ready. Waiting for data..."); void loop() receiveWithMarkers(); processNewData(); void receiveWithMarkers() static boolean recvInProgress = false; static byte ndx = 0; char startMarker = '<'; char endMarker = '>'; char rc; while (jdySerial.available() > 0 && newData == false) rc = jdySerial.read(); if (recvInProgress == true) if (rc != endMarker) receivedChars[ndx] = rc; ndx++; if (ndx >= numChars) ndx = numChars - 1; else receivedChars[ndx] = '\0'; // Terminate the string recvInProgress = false; ndx = 0; newData = true; else if (rc == startMarker) recvInProgress = true; void processNewData() if (newData == true) Serial.print("Raw Packet Received: "); Serial.println(receivedChars); // Parse the CSV data char *strtokIndx; strtokIndx = strtok(receivedChars, ","); // Skip the header label "DATA" if (strcmp(strtokIndx, "DATA") == 0) strtokIndx = strtok(NULL, ","); // Get the actual numeric payload int parsedValue = atoi(strtokIndx); Serial.print("Parsed Sensor Value: "); Serial.println(parsedValue); // Perform actions based on value (e.g., trigger alarm, update display) newData = false; Use code with caution. Advanced Architecture: Multi-Node Addressing
| Arduino Pin | JDY-40 Pin | | :--- | :--- | | 3.3V | VCC | | GND | GND | | TX (Pin 1) | RX | | RX (Pin 0) | TX |
To ensure two JDY-40 modules communicate effectively, they must share the same and Device ID (D_ID) . This sketch programmatically configures the module using SoftwareSerial.
When building networks with more than two devices, change the device type configuration command to or AT+CLSSA2 . This shifts the module out of transparent broadcast mode into an addressed mode, where packets are prefixed with a specific Device ID ( D_ID ). The module will automatically discard any packets that do not explicitly match its own hardcoded D_ID , reducing overhead processing on your host Arduino microcontrollers.
Have you used the JDY-40? What project are you building? Let me know in the comments!
void setup() Serial.begin(9600); // For Serial Monitor output Serial1.begin(9600); // For communication with JDY-40
Have you pushed the JDY-40 to 200 meters? Found a reliable antenna mod? Share your "best" experience in the comments below.
void setup() Serial.begin(9600); jdy.begin(9600); Serial.println("JDY-40 Receiver Waiting...");
Jdy40 Arduino Example Best Now
void loop() // Read from wireless module if (jdy40.available()) String command = jdy40.readString(); command.trim();
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 #define JDY_RX 2 #define JDY_TX 3 SoftwareSerial jdySerial(JDY_RX, JDY_TX); const byte numChars = 32; char receivedChars[numChars]; boolean newData = false; void setup() Serial.begin(9600); jdySerial.begin(9600); Serial.println("Receiver Ready. Waiting for data..."); void loop() receiveWithMarkers(); processNewData(); void receiveWithMarkers() static boolean recvInProgress = false; static byte ndx = 0; char startMarker = '<'; char endMarker = '>'; char rc; while (jdySerial.available() > 0 && newData == false) rc = jdySerial.read(); if (recvInProgress == true) if (rc != endMarker) receivedChars[ndx] = rc; ndx++; if (ndx >= numChars) ndx = numChars - 1; else receivedChars[ndx] = '\0'; // Terminate the string recvInProgress = false; ndx = 0; newData = true; else if (rc == startMarker) recvInProgress = true; void processNewData() if (newData == true) Serial.print("Raw Packet Received: "); Serial.println(receivedChars); // Parse the CSV data char *strtokIndx; strtokIndx = strtok(receivedChars, ","); // Skip the header label "DATA" if (strcmp(strtokIndx, "DATA") == 0) strtokIndx = strtok(NULL, ","); // Get the actual numeric payload int parsedValue = atoi(strtokIndx); Serial.print("Parsed Sensor Value: "); Serial.println(parsedValue); // Perform actions based on value (e.g., trigger alarm, update display) newData = false; Use code with caution. Advanced Architecture: Multi-Node Addressing jdy40 arduino example best
| Arduino Pin | JDY-40 Pin | | :--- | :--- | | 3.3V | VCC | | GND | GND | | TX (Pin 1) | RX | | RX (Pin 0) | TX |
To ensure two JDY-40 modules communicate effectively, they must share the same and Device ID (D_ID) . This sketch programmatically configures the module using SoftwareSerial. void loop() // Read from wireless module if (jdy40
When building networks with more than two devices, change the device type configuration command to or AT+CLSSA2 . This shifts the module out of transparent broadcast mode into an addressed mode, where packets are prefixed with a specific Device ID ( D_ID ). The module will automatically discard any packets that do not explicitly match its own hardcoded D_ID , reducing overhead processing on your host Arduino microcontrollers.
Have you used the JDY-40? What project are you building? Let me know in the comments! Waiting for data
void setup() Serial.begin(9600); // For Serial Monitor output Serial1.begin(9600); // For communication with JDY-40
Have you pushed the JDY-40 to 200 meters? Found a reliable antenna mod? Share your "best" experience in the comments below.
void setup() Serial.begin(9600); jdy.begin(9600); Serial.println("JDY-40 Receiver Waiting...");
A.Vogel Blog – Natural and Healthy
Inspiration for a healthy life!
Alfred Vogel's guide to leading a healthy and happy life
Healthy & nutritious dinner ideas