I want to make a web base ohm meter with uno and esp8266

hello.
i made a ohm meter in my ardino uno. this is the code( i don't need LCD any more):

#include <LiquidCrystal_I2C.h>   
#include<SoftwareSerial.h>
SoftwareSerial SUART(5, 6);//SRX = 5, STX = 6

LiquidCrystal_I2C lcd(0x27,  16, 2);

#define CH0  12
#define CH1  11
#define CH2  10
#define CH3  9
#define CH4  8

// variables
byte ch_number;
uint32_t res;
const uint32_t res_table[5] = {100, 1000, 10000, 100000, 2000000};
char _buffer[11];


void setup(void) {
  
  SUART.begin(9600);

  
  lcd.init();
  // turn on the backlight
  lcd.backlight();
  pinMode(CH0, OUTPUT);
  pinMode(CH1, OUTPUT);
  pinMode(CH2, OUTPUT);
  pinMode(CH3, OUTPUT);
  pinMode(CH4, OUTPUT);

  ch_number = 4;
  ch_select(ch_number);
Serial.begin(9600);
}

// main loop
void loop() {

  uint16_t volt_image = analogRead(A1) + 1;

  if(volt_image >= 550 && ch_number < 4) {
    ch_number++;
    ch_select(ch_number);
    delay(50);
    return;
  }

  if(volt_image <= 90 && ch_number > 0) {
    ch_number--;
    ch_select(ch_number);
    delay(50);
    return;
  }

  if(volt_image < 900) {
    float value = (float)volt_image*res/(1023 - volt_image);
    if(value < 1000.0)
      sprintf(_buffer, "%03u.%1u", (uint16_t)value, (uint16_t)(value*10)%10);
    else if(value < 10000.0)
           sprintf(_buffer, "%1u%03u", (uint16_t)(value/1000), (uint16_t)value%1000);
    else if(value < 100000.0)
           sprintf(_buffer, "%02u%02u0", (uint16_t)(value/1000), (uint16_t)(value/10)%100);
    else if(value < 1000000.0)
           sprintf(_buffer, "%03u%1u00", (uint16_t)(value/1000), (uint16_t)(value/100)%10);
    else
      sprintf(_buffer, "%1u%03u000", (uint16_t)(value/1000000), (uint16_t)(value/1000)%1000);
  }

  else
    sprintf(_buffer, "Over Load ");

  lcd.setCursor(0, 1);  // move cursor to position (0, 1)
  lcd.print(_buffer);
  Serial.println(_buffer);
  SUART.println(_buffer);
  

  delay(500);   // wait some time

}

void ch_select(byte n) {
  switch(n) {
    case 0:
      digitalWrite(CH0, LOW);
      digitalWrite(CH1, HIGH);
      digitalWrite(CH2, HIGH);
      digitalWrite(CH3, HIGH);
      digitalWrite(CH4, HIGH);
      break;
    case 1:
      digitalWrite(CH0, HIGH);
      digitalWrite(CH1, LOW);
      digitalWrite(CH2, HIGH);
      digitalWrite(CH3, HIGH);
      digitalWrite(CH4, HIGH);
      break;
    case 2:
      digitalWrite(CH0, HIGH);
      digitalWrite(CH1, HIGH);
      digitalWrite(CH2, LOW);
      digitalWrite(CH3, HIGH);
      digitalWrite(CH4, HIGH);
      break;
    case 3:
      digitalWrite(CH0, HIGH);
      digitalWrite(CH1, HIGH);
      digitalWrite(CH2, HIGH);
      digitalWrite(CH3, LOW);
      digitalWrite(CH4, HIGH);
      break;
    case 4:
      digitalWrite(CH0, HIGH);
      digitalWrite(CH1, HIGH);
      digitalWrite(CH2, HIGH);
      digitalWrite(CH3, HIGH);
      digitalWrite(CH4, LOW);
  }
  res = res_table[n];
}

i want to make a plot for the changes of resistance in a web page.
i use softwareserial to transfer the result, to esp8266.
my problem is here: i can't use the input as value for the html plot because it is not string.
when i convert it to string, it writes for example (5167) in ( 5 after some second 1 and 6 and 7 ) so my plot shows 5 then 1 then 6 and 7 ) .in my serial monitor it is same. but when i use void loop for myserial.read

void loop(){
 byte n = SUART.available();
 if (n != 0)
 {
   char y = SUART.read();
   Serial.print(y);
 }
 
}

all things is right in my serial Monitor , but i can't use it in server.on request:

server.on("/resistance ", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", string().c_str() );
  });

.
also i can't run my ohm meter in esp8266 nude. because i need aref pin.
please help me what can i do.

Does anyone have any comments?

You're here sending the value as a string followed by the line terminating chars '\r' and '\n':

  Serial.println(_buffer);
  SUART.println(_buffer);

This means when you read the data (remember it's a "serial" line, so you get one char at the time) you should store received chars in a buffer string, then use its value as soon as you'll receive the terminating '\n' (while ignoring the unnecessary '\r').
Thus, apart from a couple of new global variables, the loop should look like:

// Serial input buffer
char buf[16]; // Set here the longest string size + 1
// Pointer to current buffer rightmost empty position
byte bufp = 0; 
// Tells the code the data is complete and can be read from the buffer
bool DataReceived = false;

void loop(){
  while (!DataReceived && SUART.available())
  {
    char c = SUART.read();
    if (c == '\n') {
      // The string is complete
      DataReceived = true;
    }
    // Ignore \r
    if (c != '\r') {
      buf[bufp++] = c;
      buf[bufp] = 0x0; // Terminating char
      DataReceived = false;
  }

  if (DataReceived) {
      // The string is complete, do what you need to do, for example:
      Serial.print("Received: \""); Serial.print(buf); Serial.println("\"");
      // Now reset the buffer
      bufp = 0;
      buf[0] = 0x0;
      // Wait for the next data
      DataReceived = false;
  }
}

thank you for answering .
i use it:

if (DataReceived) {
      // The string is complete, do what you need to do, for example:
      Serial.print("Received: \""); Serial.print(buf); Serial.println("\"");
      // Now reset the buffer
      bufp = 0;
      buf[0] = 0x0;
      // Wait for the next data
      DataReceived = false;

but it doesn't show any thing .
so i use it :

char c = SUART.read();
    if (c == '\n') {
      // The string is complete
      DataReceived = true;
      Serial.print(c);

in serialmonitor it writes nothing in several lines... :upside_down_face:
like this :
"

"

My fault, I missed a closed curly bracket. This should work (I wrote that on the fly and currently have no way to test it, but you should do):

void loop(){
  while (!DataReceived && SUART.available())
  {
    char c = SUART.read();
    if (c == '\n') {
      // The string is complete
      DataReceived = true;
    }
    // Ignore \r
    if (c != '\r') {
      buf[bufp++] = c;
      buf[bufp] = 0x0; // Terminating char
      DataReceived = false;
    } // <-- missing
  }

  if (DataReceived) {
      // The string is complete, do what you need to do, for example:
      Serial.print("Received: \""); Serial.print(buf); Serial.println("\"");
      // Now reset the buffer
      bufp = 0;
      buf[0] = 0x0;
      // Wait for the next data
      DataReceived = false;
  }
}

sure, because you're printing the content of variable "c" but, as you can see on the preceding "if()" statement, it is just a '\n', so that "Serial.print(c);" is (almost) perfectly equivalent to "Serial.println();", thus printing nothing than just a line feed. The data received is on "buf" variable.

it's ok. i know it.
my problem is it shows nothing on buf or anything i tested in your way.

Yes, I also missed a "break" statement as soon as the string is completed. I told you I wrote the code "on the fly", right?... :wink:

Now this below works (tested on Wokwi using regular serial):

void loop(){
  while (!DataReceived && SUART.available())
  {
    char c = SUART.read();
    if (c == '\n') {
      // The string is complete
      DataReceived = true;
      break; // <-- ADDED
    }
    // Ignore \r
    if (c != '\r') {
      buf[bufp++] = c;
      buf[bufp] = 0x0; // Terminating char
      DataReceived = false;
    }
  }

  if (DataReceived) {
      // The string is complete, do what you need to do, for example:
      Serial.print("Received: \""); Serial.print(buf); Serial.println("\"");
      // Now reset the buffer
      bufp = 0;
      buf[0] = 0x0;
      // Wait for the next data
      DataReceived = false;
  }
}

If you need to input numbers only, replace the "if (c != '\r') {" with "if (c >= '0' && c <= '9') {"-

PS: if possible (e.g. if the emulator lets you use the needed components) I always suggest testing code on Wokwi or Tinkercad Circuits.

still nothing is in my serialmonitor.

You need to better track it down that thing. Post here current wirings between the two parties, and your FULL and latest code you're using to receive data (I think/hope exactly the one I sent you here, plus SoftwareSerial initialization) and we'll see.

ok
my arduino code :

/***********************************************************************
 * 
 * Arduino autoranging ohmmeter with 16x2 LCD.
 * This is a free software with NO WARRANTY.
 * https://simple-circuit.com/
 *
 ***********************************************************************/

#include <LiquidCrystal_I2C.h>   
#include<SoftwareSerial.h>
SoftwareSerial SUART(5, 6);//SRX = 5, STX = 6

LiquidCrystal_I2C lcd(0x27,  16, 2);

#define CH0  12
#define CH1  11
#define CH2  10
#define CH3  9
#define CH4  8

// variables
byte ch_number;
uint32_t res;
const uint32_t res_table[5] = {100, 1000, 10000, 100000, 2000000};
char _buffer[11];


void setup(void) {
  
  serial1.begin(9600);

  
  lcd.init();
  // turn on the backlight
  lcd.backlight();
  pinMode(CH0, OUTPUT);
  pinMode(CH1, OUTPUT);
  pinMode(CH2, OUTPUT);
  pinMode(CH3, OUTPUT);
  pinMode(CH4, OUTPUT);

  ch_number = 4;
  ch_select(ch_number);
Serial.begin(9600);
}

// main loop
void loop() {

  uint16_t volt_image = analogRead(A1) + 1;

  if(volt_image >= 550 && ch_number < 4) {
    ch_number++;
    ch_select(ch_number);
    delay(50);
    return;
  }

  if(volt_image <= 90 && ch_number > 0) {
    ch_number--;
    ch_select(ch_number);
    delay(50);
    return;
  }

  if(volt_image < 900) {
    float value = (float)volt_image*res/(1023 - volt_image);
    if(value < 1000.0)
      sprintf(_buffer, "%03u.%1u", (uint16_t)value, (uint16_t)(value*10)%10);
    else if(value < 10000.0)
           sprintf(_buffer, "%1u%03u", (uint16_t)(value/1000), (uint16_t)value%1000);
    else if(value < 100000.0)
           sprintf(_buffer, "%02u%02u0", (uint16_t)(value/1000), (uint16_t)(value/10)%100);
    else if(value < 1000000.0)
           sprintf(_buffer, "%03u%1u00", (uint16_t)(value/1000), (uint16_t)(value/100)%10);
    else
      sprintf(_buffer, "%1u%03u000", (uint16_t)(value/1000000), (uint16_t)(value/1000)%1000);
  }

  else
    sprintf(_buffer, "Over Load ");

  lcd.setCursor(0, 1);  // move cursor to position (0, 1)
  lcd.print(_buffer);
  Serial.println(_buffer);
  serial1.print(_buffer);
  

  delay(500);   // wait some time

}

void ch_select(byte n) {
  switch(n) {
    case 0:
      digitalWrite(CH0, LOW);
      digitalWrite(CH1, HIGH);
      digitalWrite(CH2, HIGH);
      digitalWrite(CH3, HIGH);
      digitalWrite(CH4, HIGH);
      break;
    case 1:
      digitalWrite(CH0, HIGH);
      digitalWrite(CH1, LOW);
      digitalWrite(CH2, HIGH);
      digitalWrite(CH3, HIGH);
      digitalWrite(CH4, HIGH);
      break;
    case 2:
      digitalWrite(CH0, HIGH);
      digitalWrite(CH1, HIGH);
      digitalWrite(CH2, LOW);
      digitalWrite(CH3, HIGH);
      digitalWrite(CH4, HIGH);
      break;
    case 3:
      digitalWrite(CH0, HIGH);
      digitalWrite(CH1, HIGH);
      digitalWrite(CH2, HIGH);
      digitalWrite(CH3, LOW);
      digitalWrite(CH4, HIGH);
      break;
    case 4:
      digitalWrite(CH0, HIGH);
      digitalWrite(CH1, HIGH);
      digitalWrite(CH2, HIGH);
      digitalWrite(CH3, HIGH);
      digitalWrite(CH4, LOW);
  }
  res = res_table[n];
}

// end of code.

my node :


  #include <Arduino.h>
  #include <ESP8266WiFi.h>
  #include <Hash.h>
  #include <ESPAsyncTCP.h>
  #include <ESPAsyncWebServer.h>
  #include <FS.h>
  #include <SoftwareSerial.h>


char buf[16]; // Set here the longest string size + 1
// Pointer to current buffer rightmost empty position
byte bufp = 0; 
// Tells the code the data is complete and can be read from the buffer
bool DataReceived = false;


//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
SoftwareSerial serial1(D2, D1);

// Replace with your network credentials
const char* ssid = "home";
const char* password = "mypass:))";

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);






void setup(){
  // Serial port for debugging purposes
  Serial.begin(9600);
  serial1.begin(9600);
  


  // Initialize SPIFFS
  if(!SPIFFS.begin()){
    Serial.println("An Error has occurred while mounting SPIFFS");
    return;
  }

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }

  // Print ESP32 Local IP Address
  Serial.println(WiFi.localIP());

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(SPIFFS, "/index.html");
  });
  server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", "a string" /*readBME280Temperature().c_str()*/);
  });


  // Start server
  server.begin();
}
 
void loop(){
  while (!DataReceived && serial1.available())
  {
    char c = serial1.read();
    if (c == '\n') {
      // The string is complete
      DataReceived = true;
      break; // <-- ADDED
    }
    // Ignore \r
   
    if (c >= '0' && c <= '9') {
      buf[bufp++] = c;
      buf[bufp] = 0x0; // Terminating char
      DataReceived = false;
    }
  }

  if (DataReceived) {
      // The string is complete, do what you need to do, for example:
      Serial.print("Received: \""); Serial.print(buf); Serial.println("\"");
      // Now reset the buffer
      bufp = 0;
      buf[0] = 0x0;
      // Wait for the next data
      DataReceived = false;
  }
}

it said (((
Connecting to WiFi..
Connecting to WiFi..
Connecting to WiFi..
192.168.1.52

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (9):
epc1=0x40205b36 epc2=0x00000000 epc3=0x00000000 excvaddr=0x32323139 depc=0x00000000

stack>>>

ctx: sys
sp: 3fffeb90 end: 3fffffb0 offset: 0150
3fffece0: 00002120 00000424 402138c8 40204e58
3fffecf0: 3fff11ec 00000001 3fffed30 3fffed9c
3fffed00: 3ffefca8 3fffed90 3fff214c 40205c34
3fffed10: 3ffe88f2 3fff1cbc 3fffed30 3ffeebe8
3fffed20: 00000000 00000003 3fff18c4 00000002
3fffed30: 000001f4 40203371 00000020 40101168
3fffed40: 00000000 3fffed60 00000050 00000002
3fffed50: 3ffefca8 3fff1cbc 3fff214c 4020337c
3fffed60: 000001f4 3fffed9c 3fffed90 40206f0a
3fffed70: 3ffe8a25 3fff1cf0 3fff1cbc 40203398
3fffed80: 00000000 000d000f 3ffefc94 40206aa6
3fffed90: 00000000 3fff1f80 00000000 00000000
3fffeda0: 00000000 00000000 3fff1cf0 40208cc4
3fffedb0: 3ffe8a25 3fff1f80 00000000 40100660
3fffedc0: 3fff1f80 3ffef2e0 3fff1aa0 00000002
3fffedd0: 00000002 3fff1f80 3fff1cbc 40204ad2
3fffede0: 00000014 3fff1a9c 000000ff 00000000
3fffedf0: 00000001 00000020 3fff1244 40101134
3fffee00: 3fff1cf0 00000000 ab020c49 003ceb1d
3fffee10: 3ffef2e0 3fff1cbc 3fff1bd4 3fff1e04
3fffee20: 3fffee70 3fff1bd4 3fff17c4 4020212c
3fffee30: 00000138 3fff1e4a 3fff1bd4 3fff1cbc
3fffee40: 00000000 00000452 3ffe85e4 40100de6
3fffee50: 3fff0000 3ffeebe8 3fff17c4 00000000
3fffee60: 3fff1e04 3fff17c4 3fff1bd4 4020218c
3fffee70: 3fff1780 3fff1774 00000000 3ffef2e0
3fffee80: 3ffef748 3ffef2e0 3fff1e04 3ffef580
3fffee90: 3fff17c4 3ffef584 3ffef585 4021f47d
3fffeea0: ffffffff 3fffc6fc 00000001 3fffdab0
3fffeeb0: 00000018 00000000 3ffeeeb0 00000030
3fffeec0: 00000000 00000451 3ffe85e4 3ffef2e0
3fffeed0: 3ffef748 3fff1e22 3fff1e04 402243d9
3fffeee0: 00000014 3ffef2e0 00000000 4021c0d5
3fffeef0: 00000000 00000354 3ffe85e4 40100de6
3fffef00: 4024092c 3fff1244 3ffefb84 3fff172c
3fffef10: 3ffef2e0 00000008 3fff1e04 4021b795
3fffef20: 3fffdc80 3ffefb84 3fff1244 4021b5a8
3fffef30: 40243af5 3ffefb84 3fff1244 40243b07
3fffef40: 3fff1e14 3fff1e04 00000000 3fffdab0
3fffef50: 4024055b 00000000 3fff1244 40244def
3fffef60: 40000f49 3fffdab0 ffffff01 40000f49
3fffef70: 40000e19 00053a2f bff00000 0000bfff
3fffef80: 00000005 aa55aa55 000000ed 40105ac5
3fffef90: 40105acb bff00000 0000bfff 69616c70
3fffefa0: 4010000d bff00000 00053a2f 401000ab
3fffefb0: 00000000 3fffef4c 00000000 3fffff18
3fffefc0: 3fffffd0 00000000 00000000 feefeffe
3fffefd0: feefeffe feefeffe feefeffe feefeffe
3fffefe0: feefeffe feefeffe feefeffe feefeffe
3fffeff0: feefeffe feefeffe feefeffe feefeffe
3ffff000: feefeffe feefeffe feefeffe feefeffe
3ffff010: feefeffe feefeffe feefeffe feefeffe
3ffff020: feefeffe feefeffe feefeffe feefeffe
3ffff030: feefeffe feefeffe feefeffe feefeffe
3ffff040: feefeffe feefeffe feefeffe feefeffe
3ffff050: feefeffe feefeffe feefeffe feefeffe
3ffff060: feefeffe feefeffe feefeffe feefeffe
3ffff070: feefeffe feefeffe feefeffe feefeffe
3ffff080: feefeffe feefeffe feefeffe feefeffe
3ffff090: feefeffe feefeffe feefeffe feefeffe
3ffff0a0: feefeffe feefeffe feefeffe feefeffe
3ffff0b0: feefeffe feefeffe feefeffe feefeffe
3ffff0c0: feefeffe feefeffe feefeffe feefeffe
3ffff0d0: feefeffe feefeffe feefeffe feefeffe
3ffff0e0: feefeffe feefeffe feefeffe feefeffe
3ffff0f0: feefeffe feefeffe feefeffe feefeffe
3ffff100: feefeffe feefeffe feefeffe feefeffe
3ffff110: feefeffe feefeffe feefeffe feefeffe
3ffff120: feefeffe feefeffe feefeffe feefeffe
3ffff130: feefeffe feefeffe feefeffe feefeffe
3ffff140: feefeffe feefeffe feefeffe feefeffe
3ffff150: feefeffe feefeffe feefeffe feefeffe
3ffff160: feefeffe feefeffe feefeffe feefeffe
3ffff170: feefeffe feefeffe feefeffe feefeffe
3ffff180: feefeffe feefeffe feefeffe feefeffe
3ffff190: feefeffe feefeffe feefeffe feefeffe
3ffff1a0: feefeffe feefeffe feefeffe feefeffe
3ffff1b0: feefeffe feefeffe feefeffe feefeffe
3ffff1c0: feefeffe feefeffe feefeffe feefeffe
3ffff1d0: feefeffe feefeffe feefeffe feefeffe
3ffff1e0: feefeffe feefeffe feefeffe feefeffe
3ffff1f0: feefeffe feefeffe feefeffe feefeffe
3ffff200: feefeffe feefeffe feefeffe feefeffe
3ffff210: feefeffe feefeffe feefeffe feefeffe
3ffff220: feefeffe feefeffe feefeffe feefeffe
3ffff230: feefeffe feefeffe feefeffe feefeffe
3ffff240: feefeffe feefeffe feefeffe feefeffe
3ffff250: feefeffe feefeffe feefeffe feefeffe
3ffff260: feefeffe feefeffe feefeffe feefeffe
3ffff270: feefeffe feefeffe feefeffe feefeffe
3ffff280: feefeffe feefeffe feefeffe feefeffe
3ffff290: feefeffe feefeffe feefeffe feefeffe
3ffff2a0: feefeffe feefeffe feefeffe feefeffe
3ffff2b0: feefeffe feefeffe feefeffe feefeffe
3ffff2c0: feefeffe feefeffe feefeffe feefeffe
3ffff2d0: feefeffe feefeffe feefeffe feefeffe
3ffff2e0: feefeffe feefeffe feefeffe feefeffe
3ffff2f0: feefeffe feefeffe feefeffe feefeffe
3ffff300: feefeffe feefeffe feefeffe feefeffe
3ffff310: feefeffe feefeffe feefeffe feefeffe
3ffff320: feefeffe feefeffe feefeffe feefeffe
3ffff330: feefeffe feefeffe feefeffe feefeffe
3ffff340: feefeffe feefeffe feefeffe feefeffe
3ffff350: feefeffe feefeffe feefeffe feefeffe
3ffff360: feefeffe feefeffe feefeffe feefeffe
3ffff370: feefeffe feefeffe feefeffe feefeffe
3ffff380: feefeffe feefeffe feefeffe feefeffe
3ffff390: feefeffe feefeffe feefeffe feefeffe
3ffff3a0: feefeffe feefeffe feefeffe feefeffe
3ffff3b0: feefeffe feefeffe feefeffe feefeffe
3ffff3c0: feefeffe feefeffe feefeffe feefeffe
3ffff3d0: feefeffe feefeffe feefeffe feefeffe
3ffff3e0: feefeffe feefeffe feefeffe feefeffe
3ffff3f0: feefeffe feefeffe feefeffe feefeffe
3ffff400: feefeffe feefeffe feefeffe feefeffe
3ffff410: feefeffe feefeffe feefeffe feefeffe
3ffff420: feefeffe feefeffe feefeffe feefeffe
3ffff430: feefeffe feefeffe feefeffe feefeffe
3ffff440: feefeffe feefeffe feefeffe feefeffe
3ffff450: feefeffe feefeffe feefeffe feefeffe
3ffff460: feefeffe feefeffe feefeffe feefeffe
3ffff470: feefeffe feefeffe feefeffe feefeffe
3ffff480: feefeffe feefeffe feefeffe feefeffe
3ffff490: feefeffe feefeffe feefeffe feefeffe
3ffff4a0: feefeffe feefeffe feefeffe feefeffe
3ffff4b0: feefeffe feefeffe feefeffe feefeffe
3ffff4c0: feefeffe feefeffe feefeffe feefeffe
3ffff4d0: feefeffe feefeffe feefeffe feefeffe
3ffff4e0: feefeffe feefeffe feefeffe feefeffe
3ffff4f0: feefeffe feefeffe feefeffe feefeffe
3ffff500: feefeffe feefeffe feefeffe feefeffe
3ffff510: feefeffe feefeffe feefeffe feefeffe
3ffff520: feefeffe feefeffe feefeffe feefeffe
3ffff530: feefeffe feefeffe feefeffe feefeffe
3ffff540: feefeffe feefeffe feefeffe feefeffe
3ffff550: feefeffe feefeffe feefeffe feefeffe
3ffff560: feefeffe feefeffe feefeffe feefeffe
3ffff570: feefeffe feefeffe feefeffe feefeffe
3ffff580: feefeffe feefeffe feefeffe feefeffe
3ffff590: feefeffe feefeffe feefeffe feefeffe
3ffff5a0: feefeffe feefeffe feefeffe feefeffe
3ffff5b0: feefeffe feefeffe feefeffe feefeffe
3ffff5c0: feefeffe feefeffe feefeffe feefeffe
3ffff5d0: feefeffe feefeffe feefeffe feefeffe
3ffff5e0: feefeffe feefeffe feefeffe feefeH
))))
and restart ...

Well, this code doesn't send data over SoftwareSerial "SUART" object anymore, while the first one (post #1) did it ("SUART.println(_buffer);"). This means you actually don't send anything.
In fact the code won't even compile because "serial1" variable hasn't been defined.
Anyway, I'll assume SUART variable definition will be replaced by "serial1" (but please, always post the real code you're using when testing!):

SoftwareSerial serial1(5, 6);//SRX = 5, STX = 6

Ok, let's move on to the second code.

I can't test it "as is" because I don't have your devices, but if i strip out everything except serial communication variables and statements (and switching from "serial1" to "Serial" for testing), it works correctly. So it's not this the cause if you don't receive anything.

This is a completely different issue (BTW, please ALWAYS post outputs as "code" to avoid forum translations).

In my experience I can say exceptions like this often indicate some kinda overflow or pointers out of control. In this case I found Exception 9 should be "LoadStoreAlignmentCause: Load or store to an unaligned address" so the culprit could be a string and/or a pointer (e.g. a serial message longer than the allocated 15 chars receiving buffer string).
I see Arduino has some sprintf() calls, none of them seem to exceed that size, but you'd better have a look at the Arduino serial output first, to see what Arduino is sending (trying to send) via SoftwareSerial to the ESP, and what length.
Meanwhile, you could even make some more debug serial printing like this new loop version and post here this output together with the Arduino sender one:

void loop(){
  if (!DataReceived && serial1.available()) {
    char c = serial1.read();
    // DEBUG ONLY
    Serial.print("0x");Serial.print(c, HEX);Serial.print(" ");
    if (c == '\n') {
      // The string is complete
      DataReceived = true;
    } else if (c >= '0' && c <= '9') {
      buf[bufp++] = c;
      buf[bufp] = 0x0; // Terminating char
      DataReceived = false;
    }
  }
  if (DataReceived) {
      // The string is complete, do what you need to do, for example:
      Serial.print("Received: \""); Serial.print(buf); Serial.println("\"");
      // Now reset the buffer
      bufp = 0;
      buf[0] = 0x0;
      // Wait for the next data
      DataReceived = false;
  }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.