Sending data from Arduino to ESP01

Hello,

I'm working in a small project where I'm using ESP01 and Arduino to get data and send it to a Rapsberry.

This are as this:

ESP01
Tx and Rx used for programming the chip.
I2C to get data from 2 sensors.

Arduino 33 BLE Sense
Tx and Rx to program it
D2 and D3 to get data from one sensor
I2C to send information to a 16x2 LCD screen.

Problem: data gathered by Arduino needs to be sent over WiFi to the Raspberry
Question: What suggestins you guys have to send the data from Arduino to ESP01 so that the latter can send it to the Raspberry over WiFi in the described scenario?

You can install Mosquitto broker on Raspberry then send data via MQTT.

I forgot to mention that. Mosquitto is running and getting the data from the ESP01. However, this Arduino I'm using doesn't have a WiFi interface to do the same. I have to send the data from the Arduino to the ESP01 so that it sends it via MQTT to the Raspberry!

You can replace this ESP-01 by ESP32 then send data from Arduino 33 to ESP32 via BLE then send it to Raspberry via MQTT.

Or you can replace the Arduino 33 by ESP32 and send the data directly via MQTT.

I can't replace anything. These are the items I have available. At this point, the system is kinda ready and I need a way of sending this data from Arduino to ESP01. I can't change things when I already have the perfurated circuit board ready with all the components that will be part of these project.

If I could replace the ESP01 by ESP32 I wouldn't even need the Arduino! :expressionless:

Your RPI has BLE capability?

You mean if it has a Bluetooth adapter?

No.

could you use Nano 33 BLE pins "RX0" and "TX1" the Serial1 interface to communicate with the ESP-01 U0RXD and U0TXD?

Hum, you mean Serial1 of Arduino with Serial of ESP01? ESP01 has only one Serial port, yes?

have a look at Pinout-diagram-for-ESP-01-module
I have used U0RXD and U0TXD to communicated with an Arduino Due
will see if I can find the program

Ok, will try to work this out!

What's the distance between this devices?

Between Arduino and ESP01, Arduino and Rasapberry or ESP01 and Raspberry?

I have remembered when disconnected from programmer

  1. serial.read() reads from U0RXD (GPIO3)
  2. serial.write() writes to U0TXD (GPIO1)

e.g. this blinks the ESP-01 LED and echos characters received on U0RXD to U0TXD

//  ESP-01 blink LED and read characters from serial U0RXD  and echo back to U0TXD

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println();
  Serial.println("\n\nESP-01 blinking LED and read characters from serial U0RXD  and echo back to U0TXD ");
  Serial.println(LED_BUILTIN);
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(100);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(100);                      // wait for a second
  // read serial U0RXD and echo it back to U0TXD
  while (Serial.available() > 0) 
    Serial.write(Serial.read());
}

I tested it with an Arduino Due (3.3V logic)

// Arduio Due  test Serial1 connected to a ESP-01

// connect Due RX1 pin 19 to ESP-01 U0TXD (GPIO1)
// connect Due TX1 pin 18 to ESP-01 U0RXD (GPIO3)

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  Serial1.begin(115200);
  Serial.println();
  Serial.println("serial 1 TO esp-01 test ");
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial1.write(inByte);
  }
}

the serial monitor of the Due displays


serial 1 TO esp-01 test 

ESP-01 blinking LED and read characters from serial U0RXD  and echo back to U0TXD 
test 1 from due
test 2 from due
1234567890 test 3

Between ESP-01 and Arduino 33.

Serial communication has limited distance.

Oh, those are close to each other. Few centimeters away.

Your project doesn't make so much sense to me.

I can't see reason to use two MCUs next to each other.

You could use a single board with WiFi and enough pins.

I know about that but ESP01 doesn't have enough exposed pins and the Arduino I was given to work doesn't have WiFi interface. It's simple!

Going to start experimenting with both serials of Arduino and ESP01.

if you only have I2C devices attached you could use ESP-01 pins GPIO0 SDA and GPIO2 SCL
however, you did mention sensors attached to Arduino D2 and D3?