IoT Weather Station with ESP8266-12E

IoT weather station that shows room and local temperatures.

mainpic.jpg

What is does

Temperature sensor gets temperature data and LCD screen displays it. Local temperature is taken from a server which gets the data from openweathermap.org. ESP8266-12E has built-in Wi-Fi which it uses to access the server.

Part list

  • ESP8266-12E
  • 1602 LCD Display store link
  • DS18B20 temperature sensor store link
  • 2,2k resistor
  • Breadboard and jumber cables

Prototyping with arduino

Building things with ESP takes a lot longer than Arduino, because of the long upload time. I tested each of the components separately and then made them to work together. I used materials from iot.botbook.com to set up my computer as a server using a python script.

Switching to ESP8266-12E

Making everything work with ESP was not easy. First the temperature sensor wasn’t giving the same readings as with Arduino. I found this thread where someone told to use 2,2k resistor instead of 4,7k, which worked fine with Arduino.

Up next was getting the data from openweathermap to the ESP. I tried to handle the JSON formatted data with the ESP, but my C++ skills didn’t quite cut it. Instead I set up a server that uses Python Flask to get the data and serve it to the ESP.

Below is the code for Flask.

from flask import Flask
from requests import get
import json
app = Flask(__name__)
@app.route("/helsinkiTemp")
def helsinkiTemp():
 r = get("http://api.openweathermap.org/data/2.5/weather?q=Helsinki&appid=API_KEY_HERE")
 d = r.json()
 t = d["main"]["temp"]-273.15
 return str(t)
if __name__ == "__main__":
 app.run()

Code for ESP can be found on GitHub.

circuit.png

Circuit diagram for the weather station.

The temperature sensor is working in leech mode, where it takes power from the data pin while sending out data from it.

Plans for the future

  • Adding more information, it would be great to know if its raining or not.
  • Right now the device doesn’t actively check if it has a Wi-Fi connection.
  • 3D-printed case.
  • Custom circuit board instead breadboard.

Sources used

http://www.instructables.com/id/I2C-LCD-Controller-the-easy-way/
http://www.instructables.com/id/How-to-connect-a-serial-LCD-to-an-Arduino-UNO/
http://www.esp8266.com/viewtopic.php?f=13&t=10374
https://www.losant.com/blog/how-to-connect-lcd-esp8266-nodemcu
http://www.instructables.com/id/ESP8266-and-Multiple-Temperature-Sensors-DS18b20-W/
https://openenergymonitor.org/forum-archive/node/2516.html
http://iot.botbook.com/
http://terokarvinen.com/2017/using-apis-with-python-example-with-open-weather-map-api-and-botbook-com-iot-api

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: