Code for passing interger data from arduino to esp8266

Can someone please help me with code for sending integer vakue data from arduino to esp2866 via serial ?? Pleass help me with the code

Thank you.

We can't see any code.

This is for arduino

#include <SoftwareSerial.h>
#include <Servo.h>
#include <LiquidCrystal.h>
SoftwareSerial ESP8266(6,8);
Servo servo_test;
int angle=0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int trigPin = 9;
int echoPin = 10;
//int led = 7;

void setup() {
Serial.begin(115200);
ESP8266.begin(115200);
Serial.print(“begin”);
servo_test.attach(8);
lcd.begin(16, 2);
lcd.print(“hello”);

// pinMode(led, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
// put your setup code here, to run once:

}

void loop() {

long duration, distance;
digitalWrite(trigPin,HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration=pulseIn(echoPin, HIGH);
distance =(duration/2)/29.1;

delay(100);

if((distance<=10 && distance>5 ))
{

//lcd.print(“Distance:”,distance);
//digitalWrite(led, HIGH);
lcd.begin(16, 2);
lcd.print(“less than 10cm”);
lcd.print(distance);
//Serial.println(1);
Serial.println(“1”);
if(ESP8266.available())
{
Serial.println(“esp -available”);
Serial.write(ESP8266.read());
}
if(Serial.available())
{
Serial.print(“serial +available”);
ESP8266.write(Serial.read());
Serial.print(“written”);
}
servo_test.write(0);
delay(3000);
}
else if(distance>5)
{

//digitalWrite(led, LOW);
lcd.begin(16, 2);
lcd.print(“more than 10cm”);
servo_test.write(90);
//Serial.print(distance);

}
}

this is for esp2866

#include <SoftwareSerial.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

const char* ssid=“An”;
const char* password=“xxx.1234”;

const byte numChar=32;
char receivedChar[numChar];
boolean newData=false;

void setup()
{
Serial.begin(115200);
WiFi.begin(ssid,password);
while(WiFi.status()==WL_CONNECTED)
{
Serial.print(“connected”);

}
while(WiFi.status()!=WL_CONNECTED)
{
delay(1000);

Serial.print(“nt connected”);
}
}
void loop()
{
//void recvWithEndMarker();
//showNewNumber();
//void recvWithEndMarker()
//{
static byte ndx=0;
char endMarker=’\n’;
char rc;
if (Serial.available()>0)
{
rc=Serial.read();
if(rc!=endMarker)
{
receivedChar[ndx]=rc;
ndx++;
if(ndx>=numChar)
{
ndx=numChar-1;
}
else
{
receivedChar[ndx]==’\0’;
ndx=0;
newData=true;
}
}
}
//}
if(Serial.available()>0 && newData==true)
{
//String getData[1]=Serial.readString();
if(WiFi.status()==WL_CONNECTED)
{
//Serial.println("from esp "+receivedChar[ndx]);
HTTPClient http;
http.begin(“http://automatedcarparking.000webhostapp.com/index.php?number=”+receivedChar[ndx]);
int httpCode=http.GET();
// Serial.print(“posting”);
http.end();
}
}
}

You can't run SoftwareSerial at 115200. It really only works at 9600 baud or maybe 38400. If you can't change the baud rate on your ESP8266 then I suggest you use Serial for communication with the ESP8266 and use SoftwareSerial at 9600 baud for debugging with a USB-TTL cable between your PC and the SoftwareSerial pins. Note that you will need to disconnect from the pins 0 and 1 to upload an Arduino program.

And you need to change this

ESP8266.write(Serial.read());

to

ESP8266.println(Serial.read());

in order to ensure that a '\n' character is sent.

If that was my code I would separate the reading and the sending like this

byte inByte = Serial.read();
ESP8266.println(inByte);

because it gives me the opportunity to print inByte so I can see what is happening

I don't understand why you have commented out the line //void recvWithEndMarker();. It would make debugging much easier if you just use the function in the way it is presented in Serial Input Basics.

And why are you not also using recvWithEndMarker() in your Arduino program?

Also, the communication would be more reliable if you use the 3rd example with start- and end-markers.

...R

Thank you so much… I will try tht and get back to you…