Hi, I was wondering if someone can assist me with a Blynk code to switch on the relay when it is at a certain temperature and switch off at a certain temperature?
I am using the following hardware, ESP32, 5v Relay, and DS18B20 Temperature Probe. Using it with the Blynk app over wifi.
I do not have any coding experience. Newbie
You can search the forum for a working sketch first.
I have found something in the forum, but it is to much code for what I want to do. As I do not know coding, I do not know what pieces of code to take out of the code I found.
The forum isn’t a code factory.
I’m sure if you searched you’d find some examples.
Also, watching some YouTube videos on C++ coding basics will give you a much better understanding of what you need to do to achieve your goals.
Pete.
try this sketch first :
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
char auth[] = "";
/* WiFi credentials */
char ssid[] = "";
char pass[] = "";
BlynkTimer timer;
// Data wire is connected to pin 21
#define ONE_WIRE_BUS 21
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float temp;
float Fahrenheit=0;
void getdata()
{
DS18B20.requestTemperatures();
temp = DS18B20.getTempCByIndex(0); // Celcius
Fahrenheit = DS18B20.toFahrenheit(temp); // Fahrenheit
Serial.println(temp);
Serial.println(Fahrenheit);
Blynk.virtualWrite(V3, temp); //virtual pin V3
Blynk.virtualWrite(V4, Fahrenheit); //virtual pin V4
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
DS18B20.begin();
timer.setInterval(1000L, getdata);
}
void loop()
{
timer.run();
Blynk.run();
}
Thank you very much John93. I really appreciate it.
I understand this is not a coding factory and I will try my best to self educate with research.
1 Like