Dht11+arduino mega+gauge


hi, I need to display the temperature given by a DHT11, through an Arduino Mega, in a widgest gauge with a decimal number and symbol degrees celsius. example: 20.6 °. can someone help me??? and if you can have a reference code. thanks


Try searching this forum for the keyword DHT11 :wink:

Basically, get it working in Arduino first, - DHT11 - DHT11

then simply send the data to a display Widget.

And for good measure :smiley:


I have already used this library DHT11, and I did not understand how to pass the data to gauge. I think we should convertitre string?


What have you got written for code so far and how have you set up your display widget?

Personally I used the Adafruit DHTXX Library as it was a bit simpler.

And as for the display… remember that the DHT11 has only a ±2deg accuracy… so no decimals needed :slight_smile:


#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>
#include <DHT.h>
char auth[] = “fefabd5745bc4960819ac43f29d3c7a6”;
#define DHTPIN 2
#define DHTTYPE DHT11
SimpleTimer timer;
void setup()
timer.setInterval(1000L, sendSensor);
void sendSensor()
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println(“Failed to read from DHT sensor!”);
void loop()


Please edit your last post and format your code between the ~~~ as instructed… I can’t see all the libraries, etc.




Use the Tilde key three times, then your code, followed by three more Tilde keys (or just click on the welcome link I sent, twice, and watch the little video :wink: )

Tilde. Alternatively referred to as the squiggly or twiddle, the tilde is a character ( ~ ) on keyboards below the escape or ESC key and on the same key as the back quote that resembles a squiggly line.


#include BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>
#include <DHT.h>


Oh well… :confused:

Meanwhile, I will leave you with this… (untested in it’s current format, so check for syntax).

You will need to integrate your own Blynk info and settings.
Also, make sure you have the proper Adafruit library’s.

This sensor is slow… I suggest giving it at least 2 seconds between readings… I am using Blynk’s SimpleTimer.h for this…

#include <SimpleTimer.h>
#include <Adafruit_Sensor.h>
#include <DHT_U.h>
#define DHTPIN 2  // Defines pin number to which the sensor is connected
#define DHTTYPE DHT11 // DHT 11 object
SimpleTimer timerTempHum;  // Setup Temp and Humidity timer.

void setup() {
  // Setup Blynk stuff here
  timerTempHum.setInterval(2000L, sendTempHum);  // Run every 2 seconds.  Set display Widgets to PUSH.

void sendTempHum()
  sensors_event_t event;
  dht.temperature().getEvent(&event);  // Get temperature...
  Blynk.virtualWrite(V5, event.temperature);  // and send it's value.
  dht.humidity().getEvent(&event);  // Get humidity...
  Blynk.virtualWrite(V6, event.relative_humidity);  // and send it's value.

void loop() {;


I’m sorry but I’m doing everything by phone and I can not find the tilde key


That’s OK… technically it is the ` key that is needed… but everyone (aka me) just sees the larger ~ symbol on the key and calls it as such :smiley: But bonus points for doing all this on a little phone keyboard :+1:


Its the ‘backtick’ button.

@rok.kom, like this. You can do it on your phone… also EDIT YOUR POSTS … dont spam with more posts.



Code snippets should be formatted. Please edit your initial post:

How to do that:

 ``` cpp <--put 3 backticks BEFORE your code starts  //("cpp" means C++ language) 

   //Put your code here

 ``` <--insert 3 backticks AFTER your code

**This makes your code readable and with highlighted syntax, like this


//comment goes here 
void helloWorld() { 
   String message =  "hello" + "world"; 


Hi Rok, I’ve done it using a mega and an Ethernet shield with an SD card. Basically the htm file is stored on the SD card and is populated with the DHT11 data to display on the two gauges. If you are using a W5100 wifi shield with an SD card I can post you both the sketch and the htm code.


thank you so much


I accept willingly
thank you so much


I also wanted to know if it was possible to put a logo in the app with my image. if you can do please postarki an example


At the moment you can’t put your logo. If you would like to convert your project into standalone app (with your branding, etc.) please consider