Electrical – How to interface SIM800L to UART on STM32F103

cmicrocontrollerserialstm32uart

I have problem to interface SIM800L with STM32F103. I just read SIM800L datasheet that UART logic level is on 2.8 V. But the STM32F103,can be operated in 3.3 V. I connected my TX RX pin directly to my MCU. I send AT command but nothing happen. Am I doing something wrong?

Best Answer

You have to check the I/O and serial port characteristics in the datasheet of the devices to be sure that logic levels are matched. You need the VIL, VIH, VOL, VOH respectively for the SIM800L and the STM32F103. For the SIM800:

enter image description here

For the STM32F103 the input values that are tested in production:

  • VILmax = 0.35 * VDD = 0.35 * 3.3 V = 1.155 V
  • VIHmin = 0.65 * VDD = 0.65 * 3.3 V = 2.145 V

Theoretically VIL a bit higher and VIH a bit lower.

enter image description here

As you can see there is no problem here as the SIM800's VOLmax (0.1 V) is below the STM32's VILmax (1.155 V). And the SIM800's VOHmin (2.7 V) is above the STM32's VIHmin (2.145 V).

The other direction, STM32F103 output values:

enter image description here

There are several cases, you should calculate with the worst case values, so when the IO current is +20 mA. VOLmax = 1.3 V and VOHmin = 3.3 V - 1.3 V = 2 V.

Now, here come the problems as the SIM800's VILmax is 0.3 V but the STM32's VOLmax is at least 0.4 V. There is a 0.1 V gap in which the input to the SIM800 is undefined.

Also the STM32's VOHmin can be 2 V, 2.4 V or 2.9 V. The 2 V is far below the SIM800's VIHmin 2.5 V. The 2.9 V would probably be fine.


All in all logic level conversion is suggested, it is mentioned in the SIM800's datasheet as well along with a reference circuit.

enter image description here


If your problem persist after doing the level shifting, here are a couple of items that you should check:

  • You should check that you connected the SIM800's TX pin to the STM32's RX pin and the SIM800's RX pin to the STM32's TX pin.
  • SIM800 has autobauding enabled by default, and autobauding supports only the following baudrates: 1200, 2400, 4800, 9600, 19200, 38400 and 57600. So if your baudrate is 115200 then that should be changed.
  • Make sure that every AT command you send ends with \r\n sequence.