ismarlowe
ismarlowe

Reputation: 157

Use the Arduino Nano's serial interface to communicate with ESP8266 -- currently hangs

I have designed a ledstrip driver capable of receiving commands over UDP-IP. I initially worked with an Arduino MEGA, and currently I'm in the process of deploying the code in an Arduino NANO.

The Arduino NANO only has one hardware serial interface, unlike the MEGA, which has several. This forces me to disable the usual debugging through one of the Serial ports (by sending strings to the computer) and to reserve the one and only serial interface for the ESP8266. In short, I am connecting the ESP8266 to the TX and RX pins in the NANO.

I am aware that I could use the softwareserial.h library, but I'd like to avoid it if possible.

The following function sets up the Wifi object:

void wifi_setup(){

    // Initialize serial for ESP module
    Serial.begin(9600);

    // Initialize ESP module
    WiFi.init(&Serial); /* GETS STUCK HERE */

    ...

}

The problem is: the microcontroller gets stuck in the Wifi.init() function and never abandons it.

I am aware that the serial interface is connected to the USB port, and am suspicious this might be a problem. However, I have tried giving power to the NANO through the VIN pin instead of through the USB port, and it hasn't worked.

What am I doing wrong?

Upvotes: 0

Views: 402

Answers (1)

TheLastGimbus
TheLastGimbus

Reputation: 631

The best solution will be to write separate code for ESP8266 and Arduino Nano - or even only for ESP8266 (NodeMCU to make it easy). It will be much easier. But if you really want to do it in your way, i think ESP uses 115200 baud, and you've set it to 9600.

Upvotes: 0

Related Questions