so that i can safely connect my arduino and esp32 for serial communication. It was working fine just connecting the wires together but I was told that it has potential to short circuit
Might help if you told us if the device works or not! Does the documentation show any inversion of signal. + on input becomes 0 on output, or something like that.
It looks like you've got them reversed (or maybe I'm looking at it wrong). HV side connects to the arduino and LV side connects to the ESP. So on the LV side TXI is received from the ESP and snd sent to the arduino at 5v through TXO, and RXO on the LV side is 3v received from the RXI from the arduinos 5v output. TXO is OUTPUT / TXI is INPUT
Sorry for the delay. Supper and an hour long ham radio emergency net.
Did you download the data sheet for the device you linked to? It shows exactly what to connect to on the 5 volt, Arduino side of the board and what to connect to on the ESP32 side.
Look at from the boards point of view. I mean in and O means out. Arduino's tx goes to the board's RXI. Arduino RX goes to boards TXO. Same for the 3.3 volt side. ESP TX goes to boards TXI and ESP RX goes to board's RXO.
Just had another going doing this connection and still didnt have any luck
for reference here is my code for my arduino uno:
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 rtc;
int SensorPin = 3;
#define PIXEL_PIN 6
#define PIXEL_COUNT 24
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
char auth[] = "--"; // Replace with your Blynk auth token
unsigned long startTime = 0;
unsigned long endTime = 0;
void setup() {
pinMode(SensorPin, INPUT);
pixels.begin();
Serial.begin(9600);
Wire.begin();
rtc.begin();
if (!rtc.isrunning()) {
Serial.println("RTC is NOT running!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop() {
DateTime now = rtc.now();
int SensorValue = digitalRead(SensorPin);
if (SensorValue == LOW && startTime == 0) { // Object Detected and timer not started
startTime = millis(); // Start the timer
for(int i = 0; i < pixels.numPixels(); i++){
pixels.setPixelColor(i, pixels.Color(255, 200, 100));
pixels.show();
delay(166.67);
}
delay(7000);
for(int i = pixels.numPixels()-1; i >= 0; i--){
pixels.setPixelColor(i, 0, 0, 0, 0);
pixels.show();
delay(80);
}
}
else if (SensorValue == LOW && startTime != 0) { // Object Detected and timer started
endTime = millis(); // Update the end time
for(int i = 0; i < pixels.numPixels(); i++){
pixels.setPixelColor(i, pixels.Color(255, 200, 100));
pixels.show();
delay(166.67);
}
delay(7000);
for(int i = pixels.numPixels()-1; i >= 0; i--){
pixels.setPixelColor(i, 0, 0, 0, 0);
pixels.show();
delay(80);
}
}
else if (SensorValue == HIGH && startTime != 0) { // Object not detected and timer started
endTime = millis(); // Update the end time
unsigned long duration = endTime - startTime; // Calculate the duration
startTime = 0; // Reset the timer
Serial.print("object used for: ");
Serial.print(duration/1000);
Serial.println(" seconds.");
}
else { // Object not detected and timer not started
for(int i = 0; i < pixels.numPixels(); i++) {
pixels.setPixelColor(i, pixels.Color(0, 0, 0));
}
pixels.show();
}
}
and here is my code for my esp32:
#include <BlynkSimpleEsp32.h> // Blynk library
// #include <WiFi.h>
// #include <WiFiClient.h>
#define RXpO 34
#define TXpO 35
#define BLYNK_TEMPLATE_ID "--"
#define BLYNK_TEMPLATE_NAME "--"
#define BLYNK_AUTH_TOKEN "--"
char auth[] = "--"; // Blynk auth token
//char ssid[] = "--";
//char pass[] = "--";
void setup() {
Serial.begin(9600);
Blynk.begin//(auth, "--", "--");
void loop() {
Blynk.run(); // Run the Blynk background tasks
if (Serial.available()) {
String message = Serial.readString();
Serial.print("Received: ");
Serial.println(message);
// Send the message to Blynk for display
Blynk.virtualWrite(V1, message); // Use Virtual Pin V1
int lastMessageSpace = message.lastIndexOf(" ");
int value = message.substring(21,lastMessageSpace).toInt(); // take numerical data
Blynk.virtualWrite (V2, value); // V2 pin for superchart
}
}
I also don't think my code is the issue since it works if i connect tx and rx directly from the boards, but I don't really want to continue doing that since esp32 works on 3.3v logic