Skip to content

Project for BME280 Sensor & ESP8266 (Wemos D1 mini clone)

License

Notifications You must be signed in to change notification settings

birrozza/ESP8266_Sensor_BME280

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP_8266 Temperature, Pressure & Humidity project

GitHub GitHub all releases AUR last modified

The BME280 module, thanks to its sensors, can detect the temperature, pressure and humidity of the surrounding environment, and send this data to the Wemos board which, thanks to its wifi module, can transmit them to a PC or smartphone.

Feautures

Thanks to code inside (sketch), the data is sent to a web platform (www.thingspeak.com) and displayed through graphics. Moreover, these and other data can be viewed on all network devices because the Wemos card works as a web-server (see below). It is possible to activate a bot on a Telegram with which to remotely interrogate the sensor (see below).

This is my chanel were data are sent . The data are in real-time

Dependency:

Library Source
ESP8266WiFi.h ESP8266 Arduino Core (ver 3.0.2)
Ticker.h ESP8266 Arduino Core (ver 3.0.2)
ESP8266mDNS.h ESP8266 Arduino Core (ver 3.0.2)
FS.h ESP8266 Arduino Core (ver 3.0.2)
ESPAsyncTCP.h https://github.com/me-no-dev/ESPAsyncTCP
ESPAsyncWebServer.h https://github.com/me-no-dev/ESPAsyncWebServer
ESPAsyncWiFiManager.h WifiManager 2.0.3 alpha
AsyncTelegram.h Ver. 1.1.3
ArduinoJson.h Ver 6.15.1
ThingSpeak.h Ver 2.0.1
TimeLib.h Ver 1.6.1
ArduinoOTA.h .......

Necessary material:

Software istruction

First you need to register the service (free but with some limitations) here: www.thingspeak.com.
So, download the code for Arduino from this repository.
With the Arduino IDE, you must enter in the secret.h file and update the Channel ID and the Channel Write Key values whith obtained when the service was activated on Thingspeak.

Very important note: to have the Arduino IDE compile the secret.h file you need to modify the sketch following the instructions in the comments.

In this project, in addition to managing the BMP280 sensor, the Wemos card also acts as a web-server. For this purpose, web pages have been created which function as a user interface. These must be loaded into the SPIFFS of the ESP8266. Here the plug-in about it ESP8266 Sketch Data Upload.

When your ESP starts up, it sets it up in Station mode and tries to connect to a previously saved Access Point. If this is unsuccessful (or no previous network saved) it moves the ESP into Access Point mode and spins up a WebServer (default ip 192.168.4.1) Using any wifi enabled device with a browser (computer, phone, tablet) connect to the newly created Access Point (ESP8266 AP Wifi). Because of the Captive Portal and the DNS server you will either get a 'Join to network' type of popup or get any domain you try to access redirected to the configuration portal. Choose one of the access points scanned, enter password, click save. ESP will try to connect. If successful, it relinquishes control back to your app. If not, reconnect to AP and reconfigure. Here this tutorial.

Once the wifi connection is made, the card is now reachable on our network. It is sufficient to type in the address bar of the browser the url http://myesp.local to be able to navigate between the sensor pages. The host name is the default but can be changed in the config.json file (see below).

In the landing page the access data (user & password) are available as tip by passing the pointer over the fields. They are editable via the config.json file.

On the setting page you can find different values, such as the IP address of the card, its ID name, the name of the wi-fi network and its power (RSSI), and other specific card data. Below, in the File Manager section, you have the image of the SPIFFS and further down, you have the possibility to update the Html files as well as upload new ones.

Configuration

Through the config.json file it is possible to configure the program at run-time. In fact, in the file you find the following fields and modifiable sub fields:

  • "board":

    • "board_id": the identification name of the card;
    • "type": it must remain unchanged;
    • "local_host_name": the host name of the card to connect to with your browser;
    • "rateo": no longer in use.
  • "login":

    • "user": user;
    • "password": password.
  • "location":

    • "city": the name of the city where the sensor is installed;
    • "country": the name of the country where the sensor is installed.
  • "field_1" & "field_2":

    • "name": it must remain unchanged;
    • "url": Thingspeak channel fields URL.

The other fields are not currently used.

After modifying the file, you can upload it using the "upload file" function on the setting page. The changes will take effect immediately.

Firmware OTA update (Over The Air)

You can now also update the firmware in the card via the OTA (Over The Air) feature. In fact, it is no longer necessary to connect it to the PC but through the Arduino IDE it can be updated remotely. Just select the network port in the menu: tools -> port -> Network Ports.

Enable a Telegram bot to be able to interrogate the sensor

First of all you need to create a bot on the Telegram with BothFather function. The procedure can be found at this link.

Obtained the token of our new bot, it must be inserted in the secret.h file.

Through the bot, you can interrogate the sensor with commands:

  • "read": returns the latest temperature and humidity reading;
  • "wifi": returns the parameters of the wifi connection;
  • "stato": returns the last status of the data transmission to ThingSpeak;
  • "reset": reboot the card.

Project version for DTH22 sensor

Of this project there is also the version for DHT22 sensors. However, only the temperature and humidity can be read with these sensors. you can find it in the repository: https://github.com/birrozza/esp_8266_T-H

Stay tuned!!! (last update March 2022)

If you want to support me, you can always donate to my paypal account https://www.paypal.me/birrozza.

Thanks