🚢 Up to 60% OFF Your Dream Liveaboard! Explore the Deals
Blog Find a Dive Shop Replace your Card

Jdy40 Arduino Example Best - //top\\

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.

To go further:

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

Disconnect the SET pin from pin 4 or alter the code below to drive the SET pin to switch from AT mode to Transparent Wireless Mode. Unit A: Sensor Sender & LED Controller jdy40 arduino example best

Because the JDY-40 operates strictly at 3.3V, connecting it directly to a 5V Arduino Uno or Nano requires care. While the TX pin of the JDY-40 can safely trigger a 5V Arduino RX pin, the Arduino's 5V TX pin can damage the JDY-40 RX pin over time. A logic level converter or a simple resistor voltage divider is highly recommended for the RXD line. Wiring Connections JDY-40 Pin Arduino Uno / Nano Pin Ensure your Arduino can supply enough current. GND Common ground is mandatory. TXD Pin 2 (Software RX) Direct connection. RXD Pin 3 (Software TX) Via Voltage Divider (1kΩ and 2kΩ resistors). SET Digital pin used to toggle between AT Mode and Data Mode. CS Tied to ground to keep the module constantly awake. Designing the Voltage Divider for RXD To safely step down the Arduino’s 5V signal to 3.3V: Connect Arduino Pin 3 to a 1kΩ resistor .

Even with perfect code, hardware issues arise. Here is the diagnostic ladder:

// 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); Use the same wiring as in Example 1

Mode Selection Pin (Pull LOW to enter AT command mode, pull HIGH/Floating for transparent transmission) Hardware Wiring Diagram

Chip select/Sleep pin. Pull LOW for active operation; pull HIGH to enter low-power sleep mode. Wiring the JDY-40 to an Arduino

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. To go further: void loop() // ----- TRANSMIT

Many JDY‑40 modules do not store configuration in non‑volatile memory. Work around this by including the AT configuration in your Arduino’s setup() function, so the settings are reapplied every time the device starts.

I can provide tailored modifications to the code to match your specific setup. Share public link

| Command | Description | Example Response | |---------|-------------|------------------| | AT | Test communication | OK | | AT+VER | Get firmware version | +JDY-40-V2.2 | | AT+BAUD | Get current baud rate | +BAUD=9600 | | AT+BAUDx | Set baud rate (x = 1–8) | AT+BAUD4 → 9600 baud | | AT+RFID | Get current RF channel and ID | +RFID=CH001,ID001 | | AT+RFCHxxx | Set channel (xxx = 001–128) | AT+RFCH005 → channel 5 | | AT+RFIDxxx | Set node ID (xxx = 001–999) | AT+RFID123 → ID 123 | | AT+POWE | Get current TX power | +POWE=3 (max) |

Use code with caution. Copied to clipboard 4. Advanced Networking: Multi-Node Broadcast