Is there anyway to send a string from an Arduino UNO to a ESP8266-01 (one with only 8 pins RX, TX, CH-PD, vcc, ground, reset, GPIO0, GPIO2) without using without using AT commands. I've looked everywhere and from what I can see UART doesn't work and SoftwareSerial uses only AT commands. I am at my wits end. Can anyone help here? please.
I have tried Serial.write but only writes String and Esp8266 only receives ints.
I found some code I thought might work but so far I can see that the arduino is sending <100.00:200:00>, but on the esp8266 all I get is four backwards question marks
this is the code on the Arduino UNO
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // TX | RX
float water = 100.00;
float battery = 200.00;
void setup()
{
Serial.begin(9600); // communication with the host computer
//while (!Serial) { ; }
// Start the software serial for communication with the ESP8266
ESPserial.begin(57600);
}
void loop()
{
ESPserial.print("<");
ESPserial.print(water,2);
ESPserial.print(":");
ESPserial.print(battery,2);
ESPserial.print(">");
Serial.print("<");
Serial.print(water,2);
Serial.print(":");
Serial.print(battery,2);
Serial.print(">");
delay(10000);
}
and here is the code on the ESP8266
#include <SoftwareSerial.h>
#include <string.h>
SoftwareSerial ESPSerial(2,0);
const byte numChars = 32;
char receivedChars[numChars];
boolean newData = false;
String water;
String battery;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
ESPSerial.begin(57600);
delay(10);
}
void loop() {
// put your main code here, to run repeatedly:
recvWithStartEndMarkers();
showNewData();
water= getValue(receivedChars, ':', 0);
battery = getValue(receivedChars, ':', 1);
Serial.println(water);
}
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '<';
char endMarker = '>';
char rc;
while (ESPSerial.available() > 0 && newData == false) {
rc = ESPSerial.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
The Arduino sends writes every 10 seconds and the esp prints the ???? every 10 seconds but with a lag.
I am not sure what the pin out to pin in should be. Right now I have the Arduino 2(TX) attached to the GPIO0 and the Arduino 3(RX) attached to the GPIO2.
Can someone look at my code and see what I am doing wrong. I thought I would send over two values because eventually I want to show water level and battery level.
Arduino 2(TX) attached to the GPIO0 and the Arduino 3(RX) attached to the GPIO2
nope, you have to connect Arduino-TX to Esp-RX and Arduino-RX to Esp-TX. At least the esp8266 has very limited possibilities on gpio0 and gpio2 – Sim Son Apr 18 '19 at 4:21