ESP32 to Arduino MEGA falls to send complete string............
Posted: Fri Nov 15, 2024 7:42 am
Hello I have a lot of trouble sending from ESP32 a string to Arduino MEGA
this is the code
ESP32
MEGA
I send this string lFinalSentString = "Hellog this is a long text to see if ti can receive a loooooooong text FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
Serial2.println(lFinalSentString);
and I receive half of it almost........ from aduino MEGA I really don't know what to do,
The wiring is that the esp 32 is connected to the arduino with wires TX RX and GND, each other idk iif it is 5v or 3.3v or... no idea.....
do I even need resistors? \
If I send a short string it works.... like "hello"
help
this is the code
ESP32
Code: Select all
// this sample code provided by www.programmingboss.com
#include "WiFi.h"
#include <HTTPClient.h>
#define RXp2 16
#define TXp2 17
bool bBodyFound = false;
struct HTMLTag
{
String TagName;
unsigned int TagPos;
String Content;
};
const char* ssid = "Meu"; //choose your wireless ssid.
const char* password = "1234567890"; //put your wireless password here.
void setup()
{
// put your setup code here, to run once: sample baud radtes 9600 115200
Serial.begin(9600);
Serial2.begin(9600, SERIAL_8N1, RXp2, TXp2);
WiFi.begin(ssid, password);
}
void loop()
{
//Serial.println("Message Received: ");
//Serial.println(Serial2.readString());
delay(1000);
HTTPClient http;
http.begin("https://creativeovenstudios.com"); //JSON request http://jsonplaceholder.typicode.com/users/1
//("https://www.basicwebsiteexample.com/");
// http://jsonplaceholder.typicode.com";
String Htmlpayload;
int httpCodeOfStatus = http.GET();
String lFinalSentString;
lFinalSentString = "";
if( WiFi.status() == WL_CONNECTED && httpCodeOfStatus > 0)
{
//Serial2.println("Meow");
Htmlpayload = http.getString();
//Serial.println(Htmlpayload);
Serial.println("FROM ESP32 Loop Main program begiining it ");
delay(2000);
for(int i = 0; i < 10000 && Htmlpayload.length() > i; i++)
{
int XtrI = 0;
if( Htmlpayload[i] == '<' && Htmlpayload[i+1] == 'b' && Htmlpayload[i+2] == 'o' && Htmlpayload[i+3] == 'd' && Htmlpayload[i+4] == 'y' )
{
Serial.println("FROM ESP32v LETTERS PROCESSED Now body found tier 1");
//Serial.println(i);
bBodyFound = true;
}
if( bBodyFound )
{
lFinalSentString += Htmlpayload[i];
//lFinalSentString += "Meow";// test force memory
//Serial.println("FROM ESP32v LETTERS PROCESSED Now body found tier 2");
Serial.println(Htmlpayload[i]);
}
if( Htmlpayload[i] == '<' && Htmlpayload[i+1] == '/' && Htmlpayload[i+2] == 'b' && Htmlpayload[i+3] == 'o' && Htmlpayload[i+4] == 'd' && Htmlpayload[i+5] == 'y' )
{
Serial.println("FROM ESP32v LETTERS PROCESSED Now body found tier 2 nd");
//Serial.println(i);
bBodyFound = false;
}
}
lFinalSentString = "Hellog this is a long text to see if ti can receive a loooooooong text FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
Serial2.println(lFinalSentString);
Serial.println(lFinalSentString);
}
else
{
Serial2.println("Not connected yet wifi or no get");
}
//Serial.println(Htmlpayload);
delay(2000);
http.end();
delay(2000);
}
MEGA
Code: Select all
#include <Elegoo_GFX.h> // Core graphics library
#include <Elegoo_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h> // Hardware-specific library
#include <TranslateHTMLToCHL.h> //Library that translates
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
//Buttons and all
Elegoo_GFX_Button TestHTMLButton;
String iMem;
HTMLTag TagsToRender[HTMLTagsLength];
// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE Select 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// Elegoo_TFTLCD tft;
// this sample code provided by www.programmingboss.com
String ESP32Message = "Message entered IP?";
bool bLoadAlready = false;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
#ifdef USE_Elegoo_SHIELD_PINOUT
Serial.println(F("Using Elegoo 2.4\" TFT Arduino Shield Pinout"));
#else
Serial.println(F("Using Elegoo 2.4\" TFT Breakout Board Pinout"));
#endif
Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
tft.reset();
uint16_t identifier = tft.readID();
if(identifier == 0x9325)
{
Serial.println(F("Found ILI9325 LCD driver"));
}
else if(identifier == 0x9328)
{
Serial.println(F("Found ILI9328 LCD driver"));
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
}
else if(identifier == 0x4535)
{
Serial.println(F("Found LGDP4535 LCD driver"));
}
else if(identifier == 0x7575)
{
Serial.println(F("Found HX8347G LCD driver"));
} else if(identifier == 0x9341)
{
Serial.println(F("Found ILI9341 LCD driver"));
} else if(identifier == 0x8357)
{
Serial.println(F("Found HX8357D LCD driver"));
}
else if(identifier==0x0101)
{
identifier=0x9341;
Serial.println(F("Found 0x9341 LCD driver"));
}
else if(identifier==0x1111)
{
identifier=0x9328;Serial1.readString();
Serial.println(F("Found 0x9328 LCD driver"));
}
else
{
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Elegoo 2.8\" TFT Arduino shield, the line:"));
Serial.println(F(" #define USE_Elegoo_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header (Elegoo_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
Serial.println(F("Also if using the breakout, double-check that all wiring"));
Serial.println(F("matches the tutorial."));
identifier=0x9328;
}
tft.begin(identifier);
TestHTMLButton.initButton(&tft, 25, 25, 25, 25, 5, 5, 5, 'I', 5 );
TestHTMLButton.drawButton();
}
void loop()
{
//Serial.println("FROM Arduino mega sending Info Of Sensor");
//Serial1.println("FROM Arduino mega sending Info Of Sensor Serial1 to esp32 18tx 9rx");
//Serial.println("FROM Arduino mega reading esp32");
if(Serial1.available() > 0 && !bLoadAlready)
{
Serial.println("FROM Arduino mega loop Serial 1 available");
bLoadAlready = true;
ESP32Message = Serial1.readString();
Serial.println(ESP32Message);
}
tft.fillScreen(BLACK);
//tft.fillScreen(BLACK);
unsigned long start = micros();
tft.setCursor(0, 0);
Serial.println("THIS IS FROM PROGRAM ARD MAIN LOOPING TO SEE IF WORKS ");
Serial.println(ESP32Message);
tft.setTextColor(RED);
tft.setTextSize(1);
tft.println(ESP32Message);
delay(500);
}
/*
KInd of modified Returning the used memory
*/
int FreeRam()
{
extern int __heap_start, * __brkval;
int v;
//return __brkval;
return(int) &v - (__brkval == 0 ) ? ( int ) &__heap_start : (int) __brkval;
}
I send this string lFinalSentString = "Hellog this is a long text to see if ti can receive a loooooooong text FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
Serial2.println(lFinalSentString);
and I receive half of it almost........ from aduino MEGA I really don't know what to do,
The wiring is that the esp 32 is connected to the arduino with wires TX RX and GND, each other idk iif it is 5v or 3.3v or... no idea.....
do I even need resistors? \
If I send a short string it works.... like "hello"
help