The Idea

To use a battery powered microcontroller to capture and log temperature and other measurements onto the Internet.

The data will be logged to ThinkSpeak and can be analysed with MatLab. Simple enough huh?

Step 1 – Choosing a temperature module the ESP8266

The following article goes into depth on specifications and reliability of which temperature module you should use to hook up to an ESP8266 microcontroller –

I had decided on the BME280 module. Once I found a library and a demo sketch it was up and running within a few minutes after soldering. The module can use SPI or I2C:

I chose ‘wisely’ the BME280 and the library:

Connecting up SCL and SDA to D1 and D2 respectively

Connecting up SCL and SDA to D1 and D2 respectively

After wiring D1 to SCL and D2 SDA to the ESP8266 kit board, I loaded the ‘Enviroment_Calculations’ demo code which was installed from the BME280 library.

The temperature is definitely working well from the serial monitor output.

Step 2 – Get Internet Connectivity

I added some code to switch on the Wifi module as follows:

#include <ESP8266WiFi.h>;
const char* ssid = "ssid";
const char* password = "yourpassword";

void setup()

// We start by connecting to a WiFi network
Serial.print("Connecting to ");

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {

Serial.println("WiFi connected");
Serial.println("IP address: ");

Run and ensure an IP address is set.

Wifi connectivity enabled

So far so good. Wireless connectivity is working too…

Step 3 – Visualisation and Logging with ThinkSpeak

After setting up an account and creating a channel, I was able to get an API key for the sketch code.

Using the code and taking the bits from
I was able to send data to ThinkSpeak –

Step 4 – Enabled Deep Sleep to Save Power

To get “Deep Sleep” mode working with D1 WeMOS ESP8266 device I had to connect D0 and RST together. This is required to wake up the controller from deep sleep. This setup really saves a lot of battery power. This difference makes the board run weeks instead of days.

// convert to microseconds
ESP.deepSleep(sleepSeconds * 1000000);

Step 5 – Voltage Monitoring

Additionally, I could also add some voltage monitor too.

Monitoring LiPo battery voltage with Wemos D1 minibattery shield and Thingspeak

However, on a battery circuit, this would reduce the running life, so more research is required for battery monitoring.


Sketch Code

The entire sketch for this post can be downloaded from: