BME280 vrs DHT11

A sample ESP8266 Program that displays the output from a DHT11 sensor and a Bosch BME sensor on a port forwardable webpage.

Webpage display. Well, needs some work, at least they both display the same temperature. I am at sea level actually, which it read correctly yesterday.


The BME280 is using I2C communication. SDA (Serial Data) – The line for the master and slave to send and receive data. and SCL (Serial Clock) – The line that carries the clock signal. On the ESP8266, these are GPIO4 (D2) for SDA and GPIO5 (D1) for SCL.


The DHT11 is to be connected to 3-5V, and a data line with a 10kOhm pull up resistor. IN the mounted version, the pullup is included. In this example the data line is connected to GPIO12 (D6)


The Code

Start with library inclusions (they must also be installed in the /tools). Then list the sensors, pin assignments, and variables.

Then a string processor, and anything else you want to do before the setup and loop.

The next part creates your webpage. This example starts with some CSS in a <style> tag. It then creates paragraphs held with %% placeholders. It then sets up "GET" command server requests.

Then the Setup. The setup includes the server which processes the GET requests.

And finally the Loop, which executes and reads the sensors each time the timer interval value is met.