Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interface NodeMCU (ESP8266) with GSM module

I'm a new user of NodeMCU and I would like to make it communicate with a GSM module like SIM900. Can I use the second UART terminal of ESP8266 to interface with the GSM module?

Thanks.

like image 300
Sawssen Bejaoui Avatar asked Jan 26 '17 11:01

Sawssen Bejaoui


People also ask

How does GSM module connect to NodeMCU?

The GSM Sim900A module 3.3V TXD pin is connected with the Nodemcu RX pin, the 3.3V RXD pin is connected with the Nodemcu TX pin, while the ground pin of the GSM Sim900A module is connected with the ground pin of the Nodemcu ESP8266 Wifi Module.

Does ESP8266 have GSM?

ESP8266 is a world phenomenon microcontroller for bringing WiFi connectivity for things (IoT). It's a fully integrated chip with, among other cool things, wireless and UART interfaces. We can use this microcontroller for sending AT commands to a GSM module.


2 Answers

I wrote a tutorial how to do it: http://atcommander.io/Tutorials/Name/ESPInterface

As cagdas said, essentially you use UART0 from ESP8266, remembering to switch its pins assignment to GPIO13/GPIO15 with uart.alt(1); in NodeMCU.

To receive debug messages in your computer, you won't be able to use UART0 anymore, but instead you can use UART1 from ESP8266 which is transmit only.

like image 105
Ramon Avatar answered Dec 15 '22 06:12

Ramon


Yes you can. The second serial interface has bounded on gpio 13 (rxd2) and 15(txd2). You can switch to control them via these commands on lua:

uart.alt(1);
uart.setup(..);

So your code gonna be look like :

 uart.alt(1) --use alternative gpios
 uart.setup(0, 9600,8, uart.PARITY_NONE, uart.STOPBITS_1,0)
 uart.on(...)
 uart.alt(0) --switch back to standard Rx/Tx pins

Here is the doc for nodemcu uart usage.

If you gonna use arduino, you can use SoftwareSerial library to config any gpio as serial interface like below:

SoftwareSerial mySerial(16, 5); // RX, TX
mySerial.begin(9600);
like image 38
cagdas Avatar answered Dec 15 '22 06:12

cagdas