Hi community !
I run sketch for read DS18B20 on esp8266. It’s ok all good, chart, value on app.
Now i want add another DS18B20. What’s the way for this ?
I’ve to plug both to D4 with onewire ? In this case i need to finds DS18B20 adress ?
Or there’s other method ?
Maybe i can add :
int outdoorTemperature
Blynk.virtualWrite(2, outdoorTemperature);
But how to know wich is wich ?
my sketch :
#define BLYNK_PRINT Serial
#include <SimpleTimer.h> // Allows us to call functions without putting them in loop()
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // Your ESP8266 pin (ESP8266 GPIO 2 = WeMos D1 Mini pin D4)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xx";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xx";
char pass[] = "xx";
SimpleTimer timer;
int roomTemperature; // Room temperature in F
void setup()
{
// Debug console
Serial.begin(9600);
//Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,xx), 8080);
while (Blynk.connect() == false) {
// Wait until connected
}
sensors.begin(); // Starts the DS18B20 sensor(s).
sensors.setResolution(10); // More on resolution: http://www.homautomation.org/2015/11/17/ds18b20-how-to-change-resolution-9101112-bits/
timer.setInterval(1000L, sendTemps); // Temperature sensor read interval. 1000 (ms) = 1 seconds.
}
void loop()
{
Blynk.run();
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
timer.run();
}
// Notice how there are no delays in the function below? Blynk works best that way.
void sendTemps()
{
sensors.requestTemperatures(); // Polls the sensors.
roomTemperature = sensors.getTempCByIndex(0); // Stores temperature. Change to getTempCByIndex(0) for celcius.
Blynk.virtualWrite(1, roomTemperature); // Send temperature to Blynk app virtual pin 1.
}
void loop()
Thakns