I want to send data from my ESP8266 device to an Arduino Uno board via UART.
The ESP8266 has been flashed with NodeMCU firmware (the build has the following timestamp: nodemcu-master-8-modules-2017-05-30-19-21-49-integer
). The firmware has been built using only the following modules: file, gpio, net, node, tmr, uart, websocket, wifi
. The ESP8266 board itself is an Adafruit Huzzah board.
The ESP board is powered via a Serial Cable from my laptop USB. The cable I am using is this one, which provides me 5V for powering my board and I know the USB on my Mac can supply the 500mA needed.
The Arduino is also powered via the other USB port on my computer.
The ESP board and the Arduino are connected as follows:
ESP8266
TX RX GND
| | |
| | |
10 11 |
RX TX GND
Arduino
The Adafruit Huzzah board claims that:
The TX pin is the output from the module and is 3.3V logic. The RX pin is the input into the module and is 5V compliant (there is a level shifter on this pin)
So there shouldn't be a need for a level converted between these two.
The code I am running on the ESP8266 board, as init.lua
is:
uart.setup(0,115200,8,0,1)
tmr.alarm(0, 5000, 0, function()
uart.write(0, "A", 19)
end)
The code I am running on the Arduino is:
#include <SoftwareSerial.h>
#define rxPin 10
#define txPin 11
MeetAndroid meetAndroid;
SoftwareSerial sSerial(rxPin, txPin);
uint8_t lastByte;
uint8_t serialBuffer[64];
int count = 0;
int onboardLed = 13;
void setup() {
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
Serial.begin(115200);
sSerial.begin(115200);
pinMode(onboardLed, OUTPUT);
digitalWrite(onboardLed, HIGH);
}
void loop() {
while (sSerial.available() > 0) {
serialBuffer[count] = sSerial.read();
count++;
}
for (int i = 0; i < count; i++) {
Serial.println(serialBuffer[i]);
}
}
What I see on the Serial Monitor in Arduino once I reset my ESP board is garbage:
⸮⸮⸮⸮⸮⸮Z,⸮}⸮߿⸮ߏ⸮\⸮⸮LYLYLYLYL⸮L⸮L⸮L⸮L⸮L (((((⸮$⸮$⸮$⸮$⸮$⸮$⸮4⸮0⸮@⸮@⸮@⸮@⸮@⸮@⸮@⸮@⸮@⸮@⸮@⸮@ ((((⸮$:⸮&i(⸮⸮
After a short delay it starts printing out line upon line of garbage after this initial line. It's clear to me that, somewhere, there is a mismatch.
I've looked for previous questions on this matter, but the only one I could find that was the closest to my use stated simply that one ought to read the docs, which was not very helpful.
Does anyone know what is amiss here?