DHT11 + LED on same ESP8266 (ESP-01?)

Hello everyone, i have a esp8266 and controlling a light with a relay using pin I02 But i would like to control/see a temperature sensor with the same esp8266 lets say on pin I01? is this possible or do i need a separate board for this? If is possible can someone share/link me the code for this plz.

Thanks!.

Yes and No (as long as you have available pins and memory)

Lots of Documentation, Hep Files and Examples in the links at the top right of this page.

i know theres a lot of Documentation, Hep Files and Examples but i cant find what i am looking for otherwise i wouldn’t be asking for help.

Then perhaps you are not looking hard enough? Your stats show you have only read 4 topics and spent only 9 minutes read time.

Oh no stats dont mean nothing those 9 mins were after i subscribed a few hours ago cuz i hept reading and reading with no solution so i decided to subscribe so i can i ask and hopefully get some help, and yeah i’ve been on that link you posted but doesnt give me what i need those sample i can find them on arduino libraries probably am not explaining good enough English not my native language, so my question is can i control two devices with one board/esp8266? my board has a I01 pin and a I02 pin? one pin to control a light and the other pin to control a sensor ??

Welcome to the forum :slight_smile: my point still stands… if you found that example, then why are you still asking for DHT11 code?

Are you using an ESP-01? Looks like this…

image

If so, then you are very limited; Just not by Blynk’s capabilities… but rather by the hardware, in both memory and GPIO… Another thing you will have discovered with some searching about your model type in this forum :wink:

Lots of solutions are available in general… but NO, you will not easily find the exact code for the exact situation… everyone is different and that is why we stress read, read, read… interspersed with try, fail, try again, succeed.

We (other members in this forum) are here to help with specific questions about how a specific commands work, where to find a specific help document, what widget will work best for a specific need, etc… but generic questions get generic answers.

Blynk - RE-SEAR-CH

And the answer again, yes… barely… take the DHT example already provided, modify it to work with one of your available GPIO pins and add in whatever other code you need to control the LED with the other GPIO pin.

Note that GPIO pins use different numbering when used in the Arduino IDE. And with that board, you may have to juggle between one of the TX/RX pins to use them for other GPIO purposes.

Ye i am using a ESP-01 And i did it took me days and nights to figure that out and also setting up my local serer with the PI zero W tho, now am controlling my lamp and the temperature sensor now time to make a good board for it and order me some more ESP-01’s .

1 Like

Good job!!

Yes, the ESP-01 can be a pain in the :monkey: to program and utilize, but eventually doable.

I just got this one working with bunch of DS18B20 Temperature Sensors and OTA programming… even though everything else worked, I could not get the sensors to work at all, until I tried a third 3.3v power source.


Here is some more code for you to work with.

//#define BLYNK_NO_BUILTIN  // Disable built-in analog & digital pin operations
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#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";

/* DS18B20 Sensor */
#include <OneWire.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
#include<DallasTemperature.h>
DallasTemperature DS18B20(&oneWire);
float temp_0;
float temp_1;
float temp_2;
float temp_3;
float temp_4;
DeviceAddress ThermometerOne = { 0x28, 0xFF, 0xDE, 0x10, 0x23, 0x17, 0x04, 0x1F };
DeviceAddress ThermometerTwo = { 0x28, 0xFF, 0x1F, 0x12, 0x23, 0x17, 0x04, 0xF7 };
DeviceAddress ThermometerThree = { 0x28, 0xFF, 0xCD, 0x13, 0x23, 0x17, 0x04, 0xA5 };
DeviceAddress ThermometerFour = { 0x28, 0xFF, 0xD9, 0x12, 0x23, 0x17, 0x04, 0x49 };
DeviceAddress ThermometerFive = { 0x28, 0xFF, 0x4C, 0xD9, 0x22, 0x17, 0x04, 0x2A };

BlynkTimer timer;

void setup()
{
  //pinMode(2, INPUT);
  // Start up the library
  DS18B20.begin();
  // set the resolution to 10 bit (good enough?)
  DS18B20.setResolution(ThermometerOne, 10);
  DS18B20.setResolution(ThermometerTwo, 10);
  DS18B20.setResolution(ThermometerThree, 10);
  DS18B20.setResolution(ThermometerFour, 10);
  DS18B20.setResolution(ThermometerFive, 10);
  DS18B20.setWaitForConversion(false);

  //Serial.begin(115200);
  Blynk.begin(auth, ssid, pass, IP, 8442);
  Blynk.virtualWrite(V1, 0);
  Blynk.virtualWrite(V2, 0);
  Blynk.virtualWrite(V3, 0);
  Blynk.virtualWrite(V4, 0);
  Blynk.virtualWrite(V5, 0);
  timer.setInterval(1000L, UpTime);
  timer.setInterval(30000L, getTempData);

  ArduinoOTA.setHostname("ESP-01 Test");  // For OTA
  ArduinoOTA.begin();  // For OTA
}



void getTempData()
{
  DS18B20.requestTemperatures();
  delay(250);
  temp_0 = DS18B20.getTempC(ThermometerOne);
  temp_1 = DS18B20.getTempC(ThermometerTwo);
  temp_2 = DS18B20.getTempC(ThermometerThree);
  temp_3 = DS18B20.getTempC(ThermometerFour);
  temp_4 = DS18B20.getTempC(ThermometerFive);

  Blynk.virtualWrite(V1, temp_0);
  Blynk.virtualWrite(V2, temp_1);
  Blynk.virtualWrite(V3, temp_2);
  Blynk.virtualWrite(V4, temp_3);
  Blynk.virtualWrite(V5, temp_4);
}



void UpTime()
{
  Blynk.virtualWrite(V0, millis() / 1000);
  //digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}



void loop()
{
  Blynk.run();
  timer.run();
  ArduinoOTA.handle();  // For OTA
}
1 Like