I want to send a simple AT-Command like: AT\r\n from the ESP32 to the Fanstel BC805M (nRF52805M) breakout board. My goal is to get an answer.
Problem: The Esp32 does not get an answer from the BC805M.
Setup
Hardware
The ESP32 is connected by usb cable to my Mac.
The ESP32 connects to the BC805M by five cables -> 3V3->VDD, GND->GND, Rx->Tx, Tx->Rx, GPIO32(high)->GPIO04(P004). Rx and Tx from ESP32 are Serial2 (not the Serial0 of the programmer). The P004 pin from BC805M is set to high to enable "command-mode".
Software
The BC805M came already preloaded with The AT commands code.
The ESP32 is flashed by a simple Serial2 write/read arduino code:
#include <HardwareSerial.h>
#define RXD2 16
#define TXD2 17
#define CMD_MODE 32
void setup() {
Serial.begin(115200);
Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);
pinMode(CMD_MODE, OUTPUT);
digitalWrite(CMD_MODE, HIGH);
delay(1000);
Serial.println("start");
}
void loop() {
Serial2.write("AT\r\n");
delay(500);
if(Serial2.available()){
Serial.write(Serial2.read());
}
}
On Monitor, I received nothing: Terminal Output
What I tested
I connected the two ESP32 Rx and Tx Serial2 Pins with each other and the monitor prints AT AT AT ... (so this works)
I connected the ESP32 with the BC805M not by crossing Tx and Rx but like: Rx->Rx, Tx->Tx; I received the message
BlueNor 200622 started
on my monitor. This means I read the values of the Rx pin of the BC805M and wrote them to my monitor. Shouldn't this message be sent on on the Tx pin of the BC805M?
I connected to the BC805M per Android App, which connects to it via Bluetooth Low Energy. I sent commands from the app to the BC805M. But I got no response. I could read the commands I sent on the Rx Pin of the BC805M.
I connected solely the BC805M per usb to my mac and ran Arduino-IDE's monitor, the monitor prints absolutely nothing and writing AT-Commands also results into nothing.
The Fanstel support just wrote me that the BC805M Evaluation Board is NOT preloaded with the AT-Command firmware.
Only the BC805M module has it preloaded.
That explains why the AT-Commands did not work.
I've been trying to connect two HC-05 bluetooth modules together as master and slave devices. I know that to do this i need to establish one as a slave device and one as a master using the AT command mode. I am using an arduino nano with each of the modules and the circuit i have used is shown:
Vcc -----> 5V
GND ----> GND
Rx ------> Rx
Tx ------> Tx
I followed various online tutorials and have used this code:
include SoftwareSerial.h
SoftwareSerial BTSerial(0, 1); // RX | TX
void setup()
{
Serial.begin(9600);
BTSerial.begin(9600); // HC-05 default speed in AT command more
Serial.println("Enter AT commands:");
}
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());
}
}
Using the button on the module or by setting the EN pin high, i am able to put the module into AT mode as displayed by the LED blinking every 2 seconds. However, i receive no response after sending commands to the module using the serial monitor when i should receive a confirmation of my command.
Any ideas where i'm going wrong?
Here's the solution that eventually worked for me: I used this circuit with a voltage divider:
Vcc -----> 5V
GND ----> GND
D2 ------> Tx
D3 ------> Rx
I ended up having to buy an Uno for this to work, I'm assuming then that my Nano's were faulty in some way. I then used the following code:
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX | TX
void setup()
{
Serial.begin(9600);
BTSerial.begin(38400); // HC-05 default speed in AT command more
Serial.println("Enter AT commands:");
}
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());
}
}
This allowed me to enter the AT mode and also receive responses.
One of the issues was that I was using the Tx and Rx pins which are also used to communicate with the computer so cannot be used with the HC-05 at the same time.
Another issue was the baudrate: I alternated between 9600 and 38400 for each communication until I found a combination that worked, and adjusted the speed in the Serial monitor so that it made sense.
Then I was able to use the command mode normally.
I am trying to get my SIM800C to talk with my Arduino. There is no communication happening, though.
#include <SoftwareSerial.h>
SoftwareSerial at(2, 3);
void setup() {
Serial.begin(9600);
at.begin(9600);
}
void loop() {
// try every 2 seconds
delay(2000);
Serial.println("sending AT ... ");
at.println("AT");
while (at.available() > 0) {
Serial.write(at.read());
}
}
I am not able to get an OK back. SIM800C is supposed to detect the baud rate by itself.
I am sure there has to be a simple stupid mistake. I just don't know what to do at this point. I obviously already checked for cable break. Out of desperation I already tried to switch RX and TX. I also tried different baud rates (whatever is within the usual limitations of SoftwareSerial) but it should automatically detect it once a couple of AT commands got in anyway.
Weird enough, the pin PWX on the SIM800C needs to be hooked up to a GND to work. It started blinking every second now and is responding to AT commands.
Also it turned out that this specific module does not ship with autobauding enabled, as stated by the SIM800C documentation. The correct baud rate is 115200.
There are some problems you need to consider:
Use below sample code which transfers data between PC and SIM. Sometimes SIM module would go into power down state and won't respond on any AT command but would print some results in the serial monitor.
As already mentioned in comments it seems that your wiring is wrong and as you declared Software Serial as SoftwareSerial at(2, 3); which means pin 2 is Rx on Arduino and should connect to Tx pin of SIM and pin 3 is Tx on Arduino and should connect to Rx pin of SIM. Please don't mess with the pins and connect the pins like below correctly.
Arduino SIM
Rx 2 ----> Tx
Tx 3 ----> Rx
I'm not sure if you can power on SIM800 with a 500mA USB connector, make sure that use an external 1/2 A power supply for VCC of SIM module.
Look at the blink speed of SIM module if it connected and powered on it would blinky with 3 seconds delay and if it blinks fast, it means that it is being restarted. Also if SIM powered on correctly it would print some info like SIM READY, CALL READY, etc.
Try other baud rates like 115200 and see if you get anything on power on.
I put some macro definition to make pin mappings more clear.
#include <SoftwareSerial.h>
//SIM800 TX is connected to Arduino D2
#define SIM800_TX_PIN 2
//SIM800 RX is connected to Arduino D3
#define SIM800_RX_PIN 3
//Create software serial object to communicate with SIM800
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);
void setup() {
//Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
while(!Serial);
//Being serial communication witj Arduino and SIM800
serialSIM800.begin(9600);
delay(1000);
Serial.println("Setup Complete!");
}
void loop() {
//Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
if(serialSIM800.available()){
Serial.write(serialSIM800.read());
}
//Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
if(Serial.available()){
serialSIM800.write(Serial.read());
}
}
Yes this module will not work in this configuration. There is a pin of V_TTL With 5V pin.. This pin enables the TTL logic converter of your GSM.. You have to connect this pin to 5V in case of arduino and to 3V in case of ESP8266.See the pin configuration here
I am a newbie with Arduino Mega 2560 .I have been trying to connect the Arduino and SIM900A module(GSM/GPRS module).I have connected the USB to my PC(Serial instance) and pins 18(Tx) and 19(Rx) to Rx and Tx in the GSM/GPRS module respectively and the GND pin(GSM/GPRS) module's is connected to GND,one near pin 13 in the Arduino.
Power connection:-
I am powering using 12V supplies for each of the boards.
The below is my code.
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
delay(1000);
Serial.print("Initial Setup !!");
delay(5000);
}
void loop()
{
if(Serial.available())
{
char a=Serial.read();
Serial1.print(a);
//Serial.print(a);
}
if(Serial1.available())
{
char B=Serial1.read();
Serial.print(B);
//Serial.print(a);
}
}
I am able to get the initial response in the "Serial Monitor" like (+CFUN:1,+CPIN:READY)(Once I open the Serial monitor I used to press the reset in the GSM/GPRSmodule).
But when I type some AT commands in the Serial Monitor,I am not able to get the response like "OK" from the GPRS/GSM Module.
Please let me know what I should be doing for getting the responses back from GSM/GPRS module.
Have you tried cutting out the Arduino, for just a moment? Get yourself a UART and wire up TX/RX to the GMS respectively. Then plug it into your PC and launch terminal (Tera Term, etc.).
Try issuing some AT commands and make sure you're getting correct responses/echos. You may also want to try a tool called QNavigator (free download).
I'm using an Arduino Micro. When I use "Serial.write", etc. with the Arduino's IDE serial monitor, everything is working fine.
However, when I try to read or send data via "Serial1", I get nothing. "Serial1" is supposed to use 0 and 1, RX and TX, respectively.
Do I need to connect these pins through a USB converter or are they connected on the boards USB converter?
Here is the code:
Void setup(){ Serial1.begin(4800); }
Void loop(){ Serial1.prrint('X'); }
The only serial port connected to the USB that the serial monitor can read from is Serial.
Serial1, Serial2, and Serial3 are all logic level serial and will not show up on the Arduino serial monitor.
If you want to see the output from these on your computer, it will require extra hardware.
Serial is the only serial port connected to USB. So serial monitor can access only that port. If you need Serial1 or Serial2 to be accessed by serial monitor, then you should use 'USB to TTL Serial Cable' and connect this to RX and TX pins of the arduino's Serial1 port.
Please visit link for USB to TTL Serial Cable, enter link description here
"Serial1" in Arduino Micro is physically connected to the TX and RX pins (TTL), and "Serial" is just a "virtual port" which you can read using Arduino IDE's Serial Monitor. That’s why Arduino Micro is a little different from another, such as Arduino Nano or Arduino Pro Mini.
If you use Serial and Serial1, you can approach this advantage, upload code using USB and make a connection through Bluetooth (using HC06 connected to physical pins) without disconnecting the USB cable and powered both devices (Arduino Micro and Bluetooth).
If you can't upload code to your Arduino Micro sometimes, press the Arduino Micro's reset button, release it, and press the upload button in Arduino IDE's.
"virtual port" sometimes needs to restart and connect using USB.
This is from Arduino's documentation website:
...Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Micro, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class.
You said it right. Serial1 is the RX and TX pin, while Serial is a virtual interface between the computer and Arduino. I have used the TX and RX pins for a wireless module, and if you need to use Serial1, it would have to occupy pins 0 and 1, and switch from DLINE to UART on your board.
Make sure you go to tool/board: and select Arduino Mega (or other board with multiply serial ports) or it won't work, because the Uno only has one Serial communication port (aka The TX and RX pins on pins on 1 and 0)! Write 1,2 or 3 depending on what TX and RX pins you are using on the Board. The mega has a whole set of extra pins for Serial 1,2 and 3, for example:
Arduino Uno (etc):
Serial.begin(9600)
Serial.write("testing")
Arduino Mega:
Serial1.begin(9600) // <{or what even baud rate you should use}
Serial1.write("testing")
or
Serial2.begin(9600)
Serial2.write("testing")
or
Serial3.begin(9600)
Serial3.write("testing")
Serial1 is the wrong class for pin 0 and pin 1. You should use Serial class.
Do I need to connect these pins through a USB converter or are they connected on the boards USB converter?
It makes no difference for Serial class.
Use:
Void setup()
{
Serial.begin(4800); // 9600....
}
void loop()
{
if(Serial.available())
{
int a = Serial.read();
Serial.Writeln(a);
}
else
{
Serial.Writeln("Error");
}
}
Open the serial monitor with the icon placed in right corner of Arduino IDE. It will be available if you connect the Arduino with PC.
When you open the Arduino IDE, write this code block:
Void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available())
{
char get = Serial.read();
Serial.Write(get);
}
}
Select the Arduino 9600 port and write something. If you get your written text, your Arduino is ready for serial communication.
You have to define Serial1 by using SoftwareSerial class from SoftwareSerial library, google and download the library:
The code should be something like this:
// Example
SoftwareSerial Serial1(9, 10); // RX and TX, respectively
Void setup() {
Serial1.begin(4800); // Here is your New serial
Serial.begin(9600); // This is where Arduino is connected to your PC
}
Void loop() {
// Code goes Here
}