Sawssen Bejaoui
Sawssen Bejaoui

Reputation: 77

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.

Upvotes: 5

Views: 13188

Answers (2)

Ramon
Ramon

Reputation: 49

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.

Upvotes: 3

cagdas
cagdas

Reputation: 1644

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);

Upvotes: 2

Related Questions