Hello,
below the updated code.
he’s still very confused, but he’s getting better.
I solved the local / remote connection problems and also configured the gmail account.
The account now works, connects and allows Blynk to send download links for reports.
Probably the Blynk / gmail connection was already working on Friday, but I hadn’t thought about restarting the java server.
I opened a second thread dedicated to configuring reports, as now I would like to fix those too.
good day everyone
[Unformatted code removed by moderator]
…sorry edit now:
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <BlynkSimpleFishino.h>
#include <DHT.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <DHT.h>
#define DHTPIN 8 //DHT on pin 8
#define DHTTYPE DHT22 //DHT 22, AM2302, AM2321
const int Temp1SensorPin = 2; //18b20 probe 1 on pin 2
const int Temp2SensorPin = 3; //18b20 probe 1 on pin 2
float temp1;
float temp2;
float h;
float t;
float tset = 20.0;
float dif = 0.3;
double pinValue;
double pinVal;
int RELAY = 5; //relay on pin 5
boolean hot = true; //assign hot true fr cooling, false for heating
char auth[] = "xxxxxxxxxxxxxx"; //Blynk Auth
char ssid[] = "xxxxxxxxxxxxxx"; //wifi SSID
char pass[] = "xxxxxxxxxxxxxx"; //wifi password
OneWire Temp1OneWire(Temp1SensorPin); //onewire for 18b20 probe 1
OneWire Temp2OneWire(Temp2SensorPin); //onewire for 18b20 probe 2
DallasTemperature Temp1Sensor(&Temp1OneWire); //dallas for 18b20 probe 1
DallasTemperature Temp2Sensor(&Temp2OneWire); //dallas for 18b20 probe 2
BlynkTimer timer;
DHT dht(DHTPIN, DHTTYPE);
WidgetTerminal terminal(V15);
float Temp1() {
Temp1Sensor.requestTemperatures();
return Temp1Sensor.getTempCByIndex(0);
}
float Temp2() {
Temp2Sensor.requestTemperatures();
return Temp2Sensor.getTempCByIndex(0);
}
void th()
{
h = dht.readHumidity();
t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (hot)
{
if (Temp1() > (tset + dif / 2))
{
digitalWrite(RELAY, HIGH);
}
if (Temp1() < (tset - dif / 2))
{
digitalWrite(RELAY, LOW);
}
}
else
{
if (Temp1() > (tset + dif / 2))
{
//In inverno se supero x gradi è meglio spegnere la stufa
digitalWrite(RELAY, LOW);
}
if (Temp1() < (tset - dif / 2))
{
//In inverno se scendo sotto y gradi è meglio accendere la stufa
digitalWrite(RELAY, HIGH);
}
}
}
BLYNK_WRITE(V0)
{
double pinValue = param.asDouble(); // assigning incoming value from pin V1 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
tset = pinValue;
Serial.print("V00Slider value is: ");
Serial.println(tset);
}
BLYNK_WRITE(V1)
{
double pinVal = param.asDouble(); // assigning incoming value from pin V1 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
dif = pinVal;
Serial.print("V01Slider value is: ");
Serial.println(dif);
}
void sendSensor()
{
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
Blynk.virtualWrite(V7, Temp1());
Blynk.virtualWrite(V2, digitalRead(5));
Blynk.virtualWrite(V3, tset);
Blynk.virtualWrite(V4, dif);
Blynk.virtualWrite(V8, Temp2());
terminal.clear();
terminal.print("Temperatura ril.1: ");
terminal.print(Temp1());
terminal.println("°C");
terminal.print("Temperatura ril.2: ");
terminal.print(Temp2());
terminal.println("°C");
terminal.print("Setting tset/▲: ");
terminal.print(tset);
terminal.print("°C / ");
terminal.print(dif);
terminal.println("°C");
terminal.print("Temp Amb. / Umidità Amb.: ");
terminal.print(t);
terminal.print("°C / ");
terminal.println(h);
terminal.print("Stato relè: ");
terminal.print(digitalRead (5));
terminal.flush();
Serial.print("Temperatura ril.1: ");
Serial.print(Temp1());
Serial.println("°C");
Serial.print("Temperatura ril.2: ");
Serial.print(Temp2());
Serial.println("°C");
Serial.print("Setting tset/dif: ");
Serial.print(tset);
Serial.print("°C / ");
Serial.print(dif);
Serial.println("°C");
Serial.print("Temp ambiente / Umidità Ambiente: ");
Serial.print(t);
Serial.print("°C / ");
Serial.println(h);
Serial.print("Stato relè: ");
Serial.println(digitalRead (5));
}
void setup()
{
pinMode(RELAY, OUTPUT);
// Debug console
Serial.begin(115200);
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2);
timer.setInterval(1000L, sendSensor);
timer.setInterval(1000L, th);
// process received value
Temp1Sensor.begin();
Temp2Sensor.begin();
DeviceAddress Probe01 = { 0x28, 0x1B, 0x27, 0x79, 0x97, 0x01, 0x03, 0x5B };
DeviceAddress Probe02 = { 0x28, 0x00, 0x55, 0x79, 0x97, 0x01, 0x03, 0x16 };
Temp1Sensor.setResolution(Probe01, 12);
Temp2Sensor.setResolution(Probe02, 12);
dht.begin();
Blynk.begin(auth, ssid, pass, IPAddress(xxx.xxx.xxx.xxx),8080);
}
void loop()
{
Blynk.run();
timer.run();
}