I have been trying to set up communication between 2 HM10s. I have the HM10 wired straight to the arduino (via breadboard) simply to 5V, GND, TX1 and RX0. The arduino has been flashed with a blank code, but for whatever reason when I go to use command AT, I don’t get an OK back. I have ensured that the wiring is not faulty and I am on the correct baud rate. Any thoughts on how to correct this?
What code? Please post it here.
Tx to Rx and Rx to Tx ?
The code is just the empty template that you get when you load up arduino ide
void setup()
{
}
void loop()
{
}
And yes, I have the RX to TX and TX to RX.
Not sure how you expect that code to reply ?
You need to be checking data received, and then sending it back.
Even AT commands won’t work in the serial monitor?
Because you have no code to handle them. You need to read them and write them.
So how would I go about setting the board to slave/master mode? I've tried pretty much everything I've found online.
Assuming the module runs at 9600 baud.
Connect
- Tx to GPIO 10 (Rx)
- Rx to GPIO 11 (Tx)
- GND to GND
- 5v to 5v
Set baud rate to 9600 in the monitor.
Use this sketch...
#include <SoftwareSerial.h>
#define BAUD 9600
SoftwareSerial softSerial (10, 11); // Rx, Tx as required.
void setup()
{
Serial.begin(BAUD);
softSerial.begin(BAUD);
Serial.print("Ready @ ");
Serial.print(BAUD);
Serial.println(" baud");
}
void loop()
{
while (Serial.available() > 0)
softSerial.write(Serial.read());
while (softSerial.available() > 0)
Serial.write(softSerial.read());
}