Jdy40 Arduino Example Best Access
jdy40.println(packet); // println adds newline as delimiter delay(5000); // Send every 5 seconds
: Sets the Wireless ID (0000 to FFFF). Both modules must have the same RFID to talk. jdy40 arduino example best
#include // Define Arduino pins const int J_RX = 2; // Connects to JDY-40 TX const int J_TX = 3; // Connects to JDY-40 RX (via voltage divider) const int J_SET = 4; // Connects to JDY-40 SET pin const int SENSOR_PIN = A0; SoftwareSerial jdy40(J_RX, J_TX); void setup() Serial.begin(9600); jdy40.begin(9600); pinMode(J_SET, OUTPUT); digitalWrite(J_SET, HIGH); // Set to HIGH for Transparent Data Mode Serial.println("--- JDY-40 Transmitter Ready ---"); void loop() // Read dummy data from analog pin int sensorValue = analogRead(SENSOR_PIN); // Format packet: [START_MARKER][DATA][END_MARKER] // Example payload sent: jdy40.print("<"); jdy40.print(sensorValue); jdy40.print(">"); // Local debug log Serial.print("Transmitted: <"); Serial.print(sensorValue); Serial.println(">"); delay(1000); // Send data packet every second Use code with caution. 2. Receiver Code (Rx) // RX = pin 2
// Define RX (JDY-40 TX) and TX (JDY-40 RX) pins SoftwareSerial jdy40(2, 3); // RX = pin 2, TX = pin 3 void setup() Serial.begin(9600)
Place the module away from metal objects or high-frequency devices. Power: Although they work with 3.3V3.3 cap V is safer for the IO pins.