0

i have a Genuino101 board and HM-11 module. Im trying to set the parameters of the module like name, etc. So i started with a simple code but it doesnt work. As we can see, my serial monitor is supposed to show "SETUP 1" and "SETUP 2". But this is what my serial monitor shows.

SETUP 1

It did not show or print "SETUP 2". So im guessing the problem is in between. I tried to comment out mySerial.begin(4800); and saw that this.

SETUP 1SETUP 2LOOP
LOOP
LOOP
LOOP
LOOP
LOOP

it works as it should except that i removed the mySerial.begin(4800).

Is this a softwareSerial problem? I also tried changing baud to 9600 but still problem arises. Looks like mySerial.begin(4800) pauses the arduino. Please help.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2,3);

void setup(){
  Serial.begin(9600);
  delay(2000);
  Serial.print("SETUP 1");
  mySerial.begin(4800);
  delay(2000);
  Serial.print("SETUP 2");
  mySerial.print("AT+NAMEMASTER0000");

}

void loop(){
  delay(1000);
  Serial.println("LOOP");  
}

EDIT:

The problem was the code paused halfway because of an error in initialization of software serial caused by RX/TX pins being interchanged. The problem was fixed automatically after swapping RX/TX pins.

xchan
  • 37
  • 5
  • Your code looks OK to me. You might need to either use `println()` or add `\r\n` in your print statements. Also, some basic troubleshooting - disconnect your module from your arduino and see if the software serial part passes now. Also, ensure you have the TX of the module connected to your RX on the arduino (ie. pin 2 on your arduino goes to TX on your module, and pin 3 on your arduino go to RX on your module). Lastly, try changing your software serial to use different pins on the arduino, ie `SoftwareSerial mySerial(4,5);` or something. – SnakeDoc Dec 28 '16 at 17:02
  • I cannot believe myself. So the problem was my RX and TX pin got interchanged. I cannot express how thankful I am to you sir. – xchan Dec 28 '16 at 17:07
  • We've all been there! I still swap them on accident sometimes, takes a bit to get used to. Happy hacking! :) – SnakeDoc Dec 28 '16 at 17:12

0 Answers0