Before startin more complex activities I am checking serial data transfer from ESP-01 and UNO and back. The code obviously doesn't work.
ESP-01 transmitter:
const byte ledpin = 1;
int i;
void setup()
{
Serial.begin(9600);
delay(10);
pinMode(ledpin, OUTPUT);
i = 0;
digitalWrite(ledpin, LOW);
}
void loop()
{
if(Serial.available()) // Check for availablity of data at Serial Port
{
Serial.print('A'); // Printing the Serial data
digitalWrite(ledpin, HIGH);
delay (500);
digitalWrite(ledpin, LOW);
delay (500);
i = i + 1;
}
}
UNO receiver:
#include <SoftwareSerial.h>
SoftwareSerial UnoSerial = SoftwareSerial(2,3);
// variables definition
int i; // variable to be used e.g. for indexing the loops
char data;
void setup()
{
Serial.begin(9600);
UnoSerial.begin(9600);
Serial.println("**** Its a Hardware Serial ****");
Serial.println(" Designed by Draggon");
Serial.println();
i = 0;
}
void loop()
{
if (UnoSerial.isListening())
{
while (i < 5)
{
if (UnoSerial.available() > 0)
{
Serial.println("UnoSerial is listening!");
char data = UnoSerial.read();
if (data != -1)
{
Serial.println(data);
}
i = i + 1;
}
}
}
else
{
Serial.println("UnoSerial is not listening!");
}
}
I am receiving this:
17:59:58.891 -> **** Its a Hardware Serial ****
17:59:58.936 -> Designed by Draggon
17:59:58.936 ->
17:59:59.410 -> UnoSerial is listening!
17:59:59.410 ->
18:00:00.416 -> UnoSerial is listening!
18:00:00.416 ->
18:00:01.419 -> UnoSerial is listening!
18:00:01.419 ->
18:00:02.421 -> UnoSerial is listening!
18:00:02.421 ->
18:00:03.421 -> UnoSerial is listening!
18:00:03.421 ->