SoftwareSerial jdySerial(JDY_RX_PIN, JDY_TX_PIN); // RX, TX
Use the same wiring as in Example 1. However, for the transmitter Arduino (the one with the sensor), you might want to use a different pair of pins for the JDY-40 so you can still use the built-in serial port for debugging. This is where SoftwareSerial becomes very useful.
This code reads data from the Serial Monitor and sends it wirelessly to any other JDY-40 on the same channel (must be in Transparent Mode). jdy40 arduino example best
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.
void setup() // Initialize hardware serial to talk to the JDY-40 Serial.begin(9600); This code reads data from the Serial Monitor
The JDY-40 is a small, low-power wireless serial port transceiver module operating in the 2.4GHz ISM band. Its key features include:
Upload the same simple code to both Arduinos. It simply echoes any data it receives from the other module. void setup() // Initialize hardware serial to talk
The remote module must be set to (usually via the AT+IO command). After that, the transmitter can send +IO1=1 to turn on pin 1, +IO1=0 to turn it off, etc. The receiver decodes these commands automatically and drives its pins accordingly. This feature eliminates the need for a second Arduino, reducing cost and complexity in simple control applications.
/* * JDY-40 Hub * Communicates with remote nodes 1, 2, and 3. */