Software serial issues

897 Views Asked by At

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.

0

There are 0 best solutions below