Jump to content
43oh

AT Commands with Software Serial on MSP430


Recommended Posts

Hi, i'm trying to run AT commands on HC-05 connected to MSP430G2553. The code below works on Arduino but i need to do it with MSP430. I changed the pins to match the MSP, tried to run the code but i see nothing on serial monitor. Total noob here and needs help. :)

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(3, 4); 

void setup() 
{
  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(9, HIGH); 
  Serial.begin(9600);
  Serial.write("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more
}

void loop()
{

  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())
    BTSerial.write(Serial.read());

}

Link to post
Share on other sites

Which MSP430 are you using? I recently tested it on an MSP430F5529 and that worked.

One thing to note though is that pins 3 and 4 are already used by Hardware Serial which you use in your Sketch (Serial.xyz()).

Try changing to different pins. I would suggest you try pins 11 and 12 if you are not using those for anything else.

Robert

Link to post
Share on other sites
On 12/3/2020 at 9:25 PM, energia said:

Which MSP430 are you using? I recently tested it on an MSP430F5529 and that worked.

One thing to note though is that pins 3 and 4 are already used by Hardware Serial which you use in your Sketch (Serial.xyz()).

Try changing to different pins. I would suggest you try pins 11 and 12 if you are not using those for anything else.

Robert

 

On 12/4/2020 at 7:52 PM, StefanSch said:

G2553 has a Hardware Serial Interface,  so do not use the Software implementation. 

Serial BTSerial.....

Should work

 

Thanks for the  replies,  i changed the pins, flipped some wires and it almost works! :) The code looks like this now;

 

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(11, 12); 

void setup() 
{
  pinMode(10, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(10, HIGH); 
  Serial.begin(9600);
  Serial.write("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more
}

void loop()
{

  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available()){
    Serial.write(BTSerial.read());
  }
  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available()){
    BTSerial.write(Serial.read());
  }
}

When i send "AT", it returns some weird answer. You can see it in the image. What should i do to fix it?

Ekran Alıntısı.PNG

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...