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?
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!
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!
I have remembered when disconnected from programmer
serial.read() reads from U0RXD (GPIO3)
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
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?