Introduction: How to Build a WiFi Thermometer

Picture of How to Build a WiFi Thermometer

In this instructable, you will learn how to build a WiFi Thermometer.

Source code is also included.

Step 1: Overview

Picture of Overview

I built a WiFi IoT board called WiThumb and would like to show you one of the many applications enabled by WiThumb. It is currently listed on KickStarter to make it available to more people. Check it out.

In short, WiThumb is an Arduino compatible WiFi IoT board with integrated high precision temperature sensor and 6-axis IMU (gyroscope + accelerometer). An optional plastic case could be ordered through KickStarter as well.

Specifications

  • 32-bit MCU with 802.11b/g/n WiFi (ESP8266)
  • Integrated TCP/IP protocol stack
  • 4MB Flash memory
  • Precision temperature sensor (+/- 0.25C typical accuracy)
  • 6-axis Gyroscope + Accelerometer
  • IO pins: One 10-bit ADC, I2C and GPIOs
  • Breadboard friendly (0.1" pitch header holes)
  • Optional plastic case

Benefits

  • Compact (1.9 inch x 0.85 inch PCB)
  • USB Powered. Plug in anywhere.
  • Large community (Arduino, ESP8266 WiFi)
  • Easy to program
  • Easy to carry
  • Low cost
  • Low power (deep sleep mode)
  • Plastic case protects the electronics
  • Expandable

Step 2: Flash the WiThumb

Picture of Flash the WiThumb

(If you are familiar with ESP8266, you may skip step 2 and 3)

WiThumb is compatible with Arduino. However, it needs to be flashed before the first use. Here is how:

  • Download and install the NodeMCU flasher program here : https://github.com/nodemcu/nodemcu-flasher
  • Plug in WiThumb to your PC
  • Run NodeMCU flasher
  • Select the COM port that corresponds to WiThumb
  • Press the "Flash(F)" button in the program
  • Press the "flash" button on WiThumb for about 1 seconds and release it
  • It will take about 1 minute to complete the flash process.

Step 3: Install Arduino Core Libraries for ESP8266

In order to compile and load the executable to WiThumb through Arduino IDE, you need to add the core libraries for ESP8266 to Arduino environment. To do so, simply follow the instructions on this GitHub page.

Once it is done, invoke Arduino and select "NodeMCU 1.0" as your board. Now, you should be able to compile and load the executable to WiThumb.

Step 4: Download Temperature Sensor Library

The temperature sensor used in WiThumb is MCP9808 from Microchip.

There is a library written by Adafruit for MCP9808. Download it from here and add it to your Arduino IDE:

https://github.com/adafruit/Adafruit_MCP9808_Libra...

Step 5: Download My Code

The code could be downloaded from here:

https://github.com/ThomasCLee/funnyvale/tree/maste...

It should be pretty self-explanatory. It measures the temperature every 2 minutes (roughly).

Here are the steps:

  1. initializes the temperature sensor and reads the temperature
  2. logs into the WiFi network (you need to fill in the SSID and password in lines 28,29)
  3. post the readings to the cloud (hosted on https://data.sparkfun.com). But before you can do that, you need to create a data stream and obtain a public key and a private key. Don't worry, I'll show you how in the next step.

Step 6: Upload Readings to the Cloud

To create a data stream, follow these steps

  1. Go to https://data.sparkfun.com
  2. Create a new data stream (by clicking 'create' button on the right)
  3. Fill in all the mandatory entries. In the 'Fields' entry, enter 'temp'
  4. Once you save it, a public key and a private key will be assigned. Private key is like the password. Don't share it with anyone else.
  5. Now, enter both keys in lines 35 and 36 in the Arduino program
  6. Once you saved, compiled and uploaded the program to WiThumb, it will start logging the temperature to Sparkfun every 2 minutes.
  7. You may also open the Serial Monitor in Arduino to review the debug messages.
  8. Once everything looks good, you could unplug WiThumb from your PC and plug it in to any USB type A connector to measure the temperature at any location interested.

Step 7: Plot the Graph

Picture of Plot the Graph

To see the temperature readings, you can simply go to

https://data.sparkfun.com/streams/public key

(where is your public key you obtained in the previous step)

One of the benefits is that you could export the data to analog.io to plot the temperature online.

Here is how:

  • Click on "Export to Analog.io" button on the upper right corner
  • Select "temp" and click "load all" button on Analog.io website

In my case, I put WiThumb in the freezer to see how cold it can get . It went all the way to 0 degree F. Impressive!

Step 8: Where to Buy

If you want to build a WiFi thermometer but don't want to deal with messy wiring, you may want to buy a WiThumb.

We are currently accepting pre-orders on KickStarter.com

Please help us spread the word. Thanks!

Comments

tinkerology (author)2017-02-06

So, I have this all running well. I'm planning to modify the code some, but I want to understand the flow of control. My understanding is that typically repeated code goes in loop() and not setup(), but all the main logic appears in setup() in this example. Is that because the board is put into deep sleep and executes setup() when it comes out of sleep?

HackARobot (author)tinkerology2017-02-07

Yes are exactly right. The code is executed from setup() upon waking up from deep sleep. To get accurate ambient temperature, it minimizes the execution time to avoid heat generated from the ESP8266. It tries not to do things repeatedly (i.e. looping). Although, technically there is still loops in this program , like the function that connects to WiFi. I could have moved it into loop(), but I didn't because it is the same function that I used in other program. I don't want to rewrite it for the sake of moving it to loop().

jantjep (author)2016-07-03

looks great, I'm in