The biggest mistake beginners make is connecting the JDY-40 to Serial (Pins 0/1). This clashes with the USB programmer and crashes your uploads.

The best example uses SoftwareSerial:

#include <SoftwareSerial.h>

// Define RX (JDY-40 TX) and TX (JDY-40 RX) pins SoftwareSerial jdy40(2, 3); // RX = pin 2, TX = pin 3

String receivedData = "";

void setup() Serial.begin(9600); // For debugging via USB jdy40.begin(9600); // JDY-40 default baud rate

Serial.println("JDY-40 Master/Slave Ready");

// Optional: Set the module to transparent transmission (default mode) pinMode(4, OUTPUT); // SET pin digitalWrite(4, HIGH); // HIGH = Data mode, LOW = AT mode

void loop() // ----- TRANSMIT BEST PRACTICE ----- static unsigned long lastSend = 0; if (millis() - lastSend > 2000) lastSend = millis();

// Best practice: Send structured, short packets
// Never send Strings larger than the buffer (max 64 bytes per packet)
jdy40.print("TEMP:");
jdy40.print(23.5);
jdy40.print(";BAT:");
jdy40.println(4.12);

// ----- RECEIVE BEST PRACTICE ----- while (jdy40.available()) char c = jdy40.read(); if (c == '\n') Serial.print("Received: "); Serial.println(receivedData);

  // Parse your data here
  if (receivedData.startsWith("TEMP:")) 
    // Extract and act on data
receivedData = "";
 else 
  receivedData += c;

Range Test (Open Field, 0 dBm, default antenna):

Throughput: At 9600 baud, effective data rate ~900 bytes/sec after overhead. Not suitable for streaming, but adequate for sensor readings or short commands.

Power consumption: 23 mA average during continuous transmission.

To achieve the best results, do not just jumper wire this on a breadboard with long flying leads.