Strange encoded response to AT commands - gsm

I get strange encoded messages from my sim900 module when I enter AT commands. I have set the baud rate to 9600. I've tried using several terminals but to no avail.
Any help is appreciated.
Thanks

I am quite sure the issue is with baud rates. Your terminal baud rate should be set to the baud rate of the module. There can be one of the followings issues with your setup
Your sim900 module is set to another baud rate (try 115200)
You are not sending \r at the end of your commands
Your sim900 is in auto-baud state and is waiting for AT\r command to lock in to the baud rate you are communicating in. In this state you need to send AT in uppercase a few times after the modem switches ON.

Related

Serial monitor font arduino can't show

Hello my serial monitor font is get trouble, i can't fix it, anybody knows ?
enter image description here
Either the sending device is sending non-sense or non-ASCII data or (more likely) you have a baud rate mismatch.
The serial interface you're using here is asynchronous. That means there is no common clock to synchronize communication. Hence the receiving side must know the baud rate of the sender or vice versa. If you're sampling the Rx line with the wrong frequency you don't recieve what has been sent but more or less random characters.
Alter the baud rate setting until you read the correct data.
Give this a read
https://learn.sparkfun.com/tutorials/serial-communication/all it explains serial communication for beginners.

How can I change the stdout baud rate in ESP-IDF?

I wrote a small program on PlatformIO for an ESP32 with ESP-IDF framework.
Currently this is connected to my PC with USB cable.
I receive lots of data from a CAN-BUS and I print this data with printf()
It seems the output with the standard baud rate 115200 is too slow. This is why I want to set this to a higher value.
I changed this in the platformio.ini without success.
monitor_speed = 115200
I searched and did not find where I can change this baud rate.
If possible my idea is to add some code, maybe just a line or two, to set the value i.e. to 230400
I mention the ESP32, PlatformIO and ESP-IDF because I am not sure where this setting is supposed to be.
It is a setting of esp-idf framework. You can set the console baud rate in sdkconfig.defaults (at project root directory):
CONFIG_CONSOLE_UART_BAUDRATE=230400
You can also configure it via menuconfig (idf.py menuconfig or pio run -t menuconfig):
Component config
Common ESP-related
UART console baud rate

Can't connect to ESP-201 over PL2303

UPDATE:
I figured the problem was with the connection over the PL2303. I reduced the BAUD rate of ESP to 9600 bps with help of an Arduino. Contacted the manufacturer of PL2303 and will update the post with the instructions when I receive them.
I'm trying to get an ESP-201 (variant of ESP8255) to work on Windows host. My aim is to configure the setup correctly and valitade by geting an OK response for AT command.
I've read that PL2303 PC-side default baud rate is 9600 and ESP-201's baud rate is 115200. I've suspected that data I'm sending isn't received correctly by ESP so I tried to configure the BAUD rates. I tried do it with Python because PuTTY connects to the device but doesn't let me give any input to the terminal. So I've tried to run this Python code, without the ESP connected to the PL2303.
import serial
esp = serial.Serial(port="COM5", baudrate=9600, timeout=1)
esp.write(b"PLBAUD 115200")
time.sleep(500)
print(esp.readline())
esp.write(b"BAUD 115200")
time.sleep(500)
print(esp.readline())
This should first set the ESP side BAUD rate of PL2303 to 115200 then set the PC side BAUD rate to 115200. But sending the AT command with the following code doesn't yield the expected OK response after changing BAUD rate setting in Windows device manager BAUD settings and plugging in the ESP module.
import serial
esp = serial.Serial(port="COM5", baudrate=115200, timeout=1)
esp.write(b"AT\r\n")
print(esp.readline())
Incase the strings sent are in UTF-8, I encoded them to hex manually and sent them again and result didn't change.
I've contacted Waveshare, maker of this module, and learned that the host PC and the device on the TTL side of this adapter must have the same BAUD rate in order to work. Set them both back to 115200 and it is solved.
This is due to the adapter not having a buffer that adapts the BAUD rate, rather than it being a pass-through device.

Why do I need to change the Baudrate after I send a Reset to the ESP8266?

So I have succesfully attached a Esp8266 to an Arduino Due. I can communicate with it via Serial Monitor if I choose the Baudrate to be 74880. Then all the commands come to it correctly and can be read back correctly. However, when I send the command AT+RST which restarts the Esp8266 I can no longer communicate with it and need to reopen the serial connection with a Baudrate of 115200. I have to repeat this every time I load the code new to the Arduino or when I power off the Esp8266.
Any ideas where this behaviour comes from?
Here you are an explanation about where are the origins of such a behavior:
Baudrate of 74880 Bd is ESP's 'native' baud rate for sending debug messages generated automatically by the system itself during the boot in case there is 26 MHz instead of 40 MHz crystal used on board - and as we can see, mostly that is the case.
With 40 MHz crystal the baudrate would be as expected (115200) but with 26 MHz crystal instead, baudrate is 115200 * 26/40 = 74880.
Later after bootloader ends baudrate is controlled in other way so that's why you have two different baudrates - the first is the default one (74880) and the second is the one that is active later (the one you can set).
I usually set baudrate to 74880 so I can see both the messages generated automatically and the messages I send from the code.
In order to set UART baudrate persistent after a reset you should use AT+UART_DEF.
From the AT instruction :
AT+UART_DEF – default UART configuration This command sets the UART configuration and save it to flash. It is stored as the default
parameter and will also be used as the default baudrate henceforth.

Serial communication using USB

I am trying to connect ATmega128 uart to PC using USB-to-RS232 converter so that PC can receive and transmit data from microcontroller using hyper terminal. I set the correct stop bits and baud rate in hyper terminal. It doesn't seem to work.
Can any one tell me if this is possible by USB-to-RS232 converter and if not what other options are there for serial communication between PC and microcontroller ?
You should be able to do this without any issues. I'd suggest putting your USB-to-RS232 cable in loopback mode first (if possible) to ensure you can communicate, then connect it back up to your MCU.
If you aren't seeing what you expect the first thing to look at are the settings, specifically the baud rate. Since your USB-to-RS232 cable is from a third party vendor I'd assume that your settings on the host side are OK. So you should look in to your MCU code to ensure that all your clocks are running at the proper speed and you have indeed performed the correct calculations to achieve your desired baud rate. Debugging here to ensure you are transmitting data out of the device is important.
Additionally, there are tools that can help you debug. Portmon is a tool from Microsoft that lets you look at the serial data path on the host side. I'd also recommend a USB analyzer, such as an Ellisys, that will allow you to view data going across the line from your MCU to the host.

Resources