Problem : Communication betwenn ARDUINO UNO, ESP32 and BLYNK

Hi all,

I will need your help on a program that I am in the process of making.

I want to control an RGB LED strip (12V DC) and a fan (PWM) via the BLYNK application.

For this I have an Arduino UNO board and an ESP32 (we do not only use the ESP32 card because we need the ARDUINO UNO card to power our fan and our LEDs in 12V).

I have the code for the Arduino UNO as well as for the ESP32 but I don't know which code to use to link the ESP32 to the Arduino.

Thank you in advance for your help

Attached are the codes for the 2 cards.

Code of Arduino Uno

int RedPin = 10; //Arduino driving pin for Red
int GreenPin = 11; //Arduino driving pin for Green
int BluePin = 9; //Arduino driving pin for Blue

int analogPin = 0;
int pinFan = 3;
int val = 0;
int pinPulse = 5;

void setColor(int red, int green, int blue)
{
analogWrite(RedPin, red);
analogWrite(GreenPin, green);
analogWrite(BluePin, blue);

}

void setup() {

pinMode(RedPin, OUTPUT); //Init Arduino driving pins
pinMode(GreenPin, OUTPUT);
pinMode(BluePin, OUTPUT);
Serial.begin(9600);

pinMode(pinFan, OUTPUT); //en D3
pinMode(pinPulse, INPUT); //en D5
Serial.begin(9600); //Set serial baud rate to 9600 bps
Serial.begin(9600);

// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
;
}
}

void loop()
{
analogWrite(RedPin,0);
analogWrite(GreenPin,0);
analogWrite(BluePin,255);
delay(1000);

int val;
val = Serial.read();

analogWrite(pinFan, val / 4);

// run over and over
if (Serial.available()) {
Serial.write(Serial.read());
}
}

Code of ESP32

#define BLYNK_PRINT Serial

#define BLYNK_USE_DIRECT_CONNECT

#include <BlynkSimpleEsp32_BLE.h>
#include <BLEDevice.h>
#include <BLEServer.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "yawVHYjwOfD_OYqepg7fFQxAgXFaeIF-";

BLYNK_WRITE(V0)
{
int Value = param.asInt(); // assigning incoming value from pin V1 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();

Blynk.virtualWrite(V0,Value);
Serial.print("V0 Slider value is: ");
Serial.println(Value);

}

void setup()

{

// Debug console
Serial.begin(9600);

Serial1.begin(9600);

Serial.println("Waiting for connections...");
Blynk.setDeviceName("Siluxe");
Blynk.begin(auth);

}

void loop()
{
Blynk.run();

}

First: edit your post and insert code tags!

The UNO runs on 5V so you need an amplification anyway so that's no cause to need the UNO.

As you failed to provide a wiring diagram of your setup we're not able to help you further.

Check out this page for an ESP to Arduino Serial connection
Arduino to Arduino via Serial
Here is a circuit for Arduino Uno to ESP32

Hi,
Why can't you do all the processing on the ESP32 and not use the UNO?

No you don't, the ESP32 will be able to do it for you with some external components.

What are your LEDS and Fan?

Can you please tell us your electronics, programming, arduino, hardware experience?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

I am using this to drive a 12V pump from an ESP32
pumpDriver
Has built-in flywheel diode to suppress the turn off spike.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.