Jdy40 Arduino Example Best Page

// Control pins pinMode(2, OUTPUT); // SET pin pinMode(3, OUTPUT); // CS pin

Expected Response: +CLSS:A0 (Sets module to transparent transmission mode) Type AT+RFID1234 →right arrow

The JDY‑40 uses 3.3 V logic levels. When connecting it to a 5 V Arduino (such as Uno or Mega), you must use a voltage divider (e.g., 1kΩ and 2kΩ) on the Arduino TX → JDY‑40 RX line to avoid damaging the module. For 3.3 V boards (Arduino Pro Mini 3.3V, ESP32, etc.) a direct connection is safe. jdy40 arduino example best

// If wireless module receives data, send it to the computer (jdy40.available()) Serial.write(jdy40.read());

This example demonstrates real-world, bidirectional sensor transmission with error resistance. It avoids the blocking delay() function, allowing your microcontroller to read sensors locally while waiting for incoming packets. // Control pins pinMode(2, OUTPUT); // SET pin

:

Always double-check your wiring. While the JDY-40 is forgiving, 5V logic can damage it over time. Use a level shifter for production projects. // If wireless module receives data, send it

Because the JDY-40 operates on , connecting its RXD pin directly to a 5V Arduino (like the Uno or Nano) can damage the module or cause unstable behavior. Always use a logic level shifter or a simple resistor voltage divider on the Arduino's TX line. Hardware Connections: JDY-40 VCC →right arrow Arduino 3.3V JDY-40 GND →right arrow Arduino GND JDY-40 TXD →right arrow Arduino Pin 2 (Software RX) JDY-40 RXD →right arrow Through a voltage divider to Arduino Pin 3 (Software TX) Voltage divider tip: Connect Arduino Pin 3 to a 1k Ωcap omega

#include // Connect JDY-40 TX to D2, RX to D3 SoftwareSerial jdy40(2, 3); void setup() Serial.begin(9600); // To computer jdy40.begin(9600); // To JDY-40 (Default is 9600) Serial.println("JDY-40 Wireless Ready..."); void loop() // If data comes from JDY-40, send it to Computer if (jdy40.available()) Serial.write(jdy40.read()); // If data comes from Computer, send it to JDY-40 if (Serial.available()) jdy40.write(Serial.read()); Use code with caution. Copied to clipboard

#include SoftwareSerial jdyWireless(2, 3); // RX, TX const int setPin = 4; const int sensorPin = A0; unsigned long previousMillis = 0; const long interval = 500; // Send data every 500ms void setup() pinMode(setPin, OUTPUT); digitalWrite(setPin, HIGH); // Set to transparent data mode Serial.begin(9600); jdyWireless.begin(9600); Serial.println("Master Transmitter Ready."); void loop() unsigned long currentMillis = millis(); if (currentMillis - previousMillis >= interval) previousMillis = currentMillis; // Read sensor and map to 0-255 byte scale int sensorValue = analogRead(sensorPin); byte mappedValue = map(sensorValue, 0, 1023, 0, 255); // Send packet format: jdyWireless.print('<'); jdyWireless.print(mappedValue); jdyWireless.print('>'); // Debug to local Serial Monitor Serial.print("Sent Value: "); Serial.println(mappedValue); Use code with caution. The Slave Code (Receiver)

If you run into issues, here are the most common problems and solutions: