@DrJFM I had to format your code for this forum as well
@David_Vinch Glad you are seeing some positive results.
Here is a simple example I put together using a single DHT22 and a single DS18B20 both running on a ESP-01 with OTA suport.
Hopefully you can see that there is really nothing fancy about it⦠no need to hack into libraries or otherwise strange manipulations⦠You do need to know the specific ID of the DS18B20 sensor, but that can be determined with another simple code (here) ⦠or otherwise red using the index method.
And yes, this can also be coded to read multiples of either sensors (additional sensor designations for the DS18B20, and additional GPIO pins for the DHT22).
#include <ESP8266WiFi.h> // For Blynk
#include <BlynkSimpleEsp8266.h> // For Blynk
#include <ESP8266mDNS.h> // For OTA
#include <WiFiUdp.h> // For OTA
#include <ArduinoOTA.h> // For OTA
char auth[] = "xxxxxxxxxx";
char ssid[] = "xxxxxxxxxx";
char pass[] = "xxxxxxxxxx";
char IP[] = "xxx.xxx.xxx.xxx";
BlynkTimer timer;
// DHT22 Sensor setup
#include <DHT.h>
#define DHTPIN 0
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
float h;
float t;
// DS18B20 Sensor setup
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float DS18B20Temp1;
DeviceAddress DS18B20Thermometer1 = { 0x28, 0xFF, 0xCD, 0x13, 0x23, 0x17, 0x04, 0xA5 };
void setup()
{
DS18B20.begin();
DS18B20.setResolution(DS18B20Thermometer1, 10);
DS18B20.setWaitForConversion(false); // Or (true) for Fahrenheit... I think?
Blynk.begin(auth, ssid, pass, IP, 8442);
timer.setInterval(1000L, UpTime);
timer.setInterval(3000L, DS18B20TempSensor);
timer.setInterval(6000L, DHT22TempHumSensor);
ArduinoOTA.setHostname("ESP-01 Test"); // For OTA
ArduinoOTA.begin(); // For OTA
}
void DS18B20TempSensor() // DS18B20 sensor reading
{
DS18B20.requestTemperatures();
delay(250);
DS18B20Temp1 = DS18B20.getTempC(DS18B20Thermometer1);
Blynk.virtualWrite(V3, DS18B20Temp1);
}
void DHT22TempHumSensor() // DHT22 sensor reading
{
h = dht.readHumidity();
t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
Blynk.virtualWrite(V4, h);
Blynk.virtualWrite(V5, t);
}
void UpTime()
{
Blynk.virtualWrite(V0, millis() / 1000);
}
void loop()
{
Blynk.run();
timer.run();
ArduinoOTA.handle(); // For OTA
}