Jdy40 Arduino Example Best
Unlike classic Bluetooth modules such as HC‑05, the JDY‑40 does not require pairing or Bluetooth stacks. It works in two main modes: (UART) and remote I/O control (you can directly toggle pins on a remote module via serial commands).
void setup() Serial.begin(9600); // Serial Monitor for debugging pinMode(3, OUTPUT); // Pin to control the JDY-40 SET pin
#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
To use the JDY-40 with an Arduino, you must ensure you are using or a level shifter, as the module is not 5V tolerant.
If you are encountering specific errors with your setup, tell me you are using, the distance between your modules, or if you need to pass multiple sensor values simultaneously. I can easily modify the data packet code for your exact project needs! Share public link Unlike classic Bluetooth modules such as HC‑05, the
is a 2.4GHz wireless serial port transceiver module that offers an affordable alternative to the NRF24L01 for long-range (up to 120 meters) transparent data transmission MSS Eletrônica
// RX on Pin 2 (connect to JDY-40 TX), TX on Pin 3 (connect to JDY-40 RX) SoftwareSerial jdySerial( setup() Serial.begin( ); jdySerial.begin( ); Waiting for data
I need to structure the article. Let's start writing.
Connect two separate Arduino boards (Transmitter and Receiver) using the following pinout: JDY-40 Pin Arduino Pin (Uno/Nano/Pro Mini) Do NOT connect to 5V GND Common ground TXD Pin 2 (Software RX) Receives data from JDY-40 RXD Pin 3 (Software TX) Use a 1kΩ resistor inline for 5V Arduinos SET Pin 4 (Digital Out) Controls AT Mode / Data Mode CS Kept permanently low for active state Configuring the JDY-40 via AT Commands
This sketch sets up a "Pass-through" bridge. It checks for incoming configuration commands from the PC and relays all other data transparently.
void setup() Serial.begin(9600); jdy.begin(9600); Serial.println("JDY-40 Receiver Waiting...");