Introduction: IoT Weather Station With Adafruit HUZZAH ESP8266 (ESP-12E) and Adafruit IO (UPDATED)

Hello, everyone ! Time ago I saw this Weather Station by Aleator777 and I was inspired to make my own weather station. I saw that the Intel Edison is too expensive in my country, so I decided to look for something much cheaper, and I found the Adafruit HUZZAH which is lot cheaper and I ordered one.

When the breakout arrived I start to build my IoT Weather Station, and now I will show you how to make your own and how to stream the data from it to Adafruit IO.

The weather station is using a DHT11, for measuring air humidity, a TMP102, for measuring air temperature a BMP180, for measuring the pressure and a prototyping PCB to build it. I know I am using too much sensors but that is because I had them, and if you ask I should use DHT22 and BMP180 or just one BME280 which reads - temperature, humidity, pressure and altitude.

The waether station measures the temperature in Celsius(it could be changed to Fahrenheit), the pressure in PSI - Pounds per square Inch and humidity in percentage. It also has deep sleep mode that can be controlled, by default is set on 5 minutes.

You can see the readings from my weather station here, they are for my home town - Polski Trambesh. - ONLINE

Step 1: Info About Adafruit HUZZAH ESP8266 (ESP-12E)

The ESP8266 processor from Espressif is an 80 MHz microcontroller with a full WiFi front-end (both as client and access point) and TCP/IP stack with DNS support as well.

Technical details:

  • Reset button,
  • User button that can also put the chip into bootloading mode,
  • Red LED you can blink,Level shifting on the UART and reset pin,
  • 3.3V out,
  • 500mA regulator (you'll want to assume the ESP8266 can draw up to 250mA so budget accordingly)
  • Two diode-protected power inputs (one for a USB cable, another for a battery)
  • Two parallel, breadboard-friendly breakouts on either side give you access to:
  • 1 x Analog input (1.8V max)
  • 9 x GPIO (3.3V logic), which can also be used for I2C or SPI2 x UART pins
  • 2 x 3-12V power inputs,
  • reset,
  • enable,
  • LDO-disable,
  • 3.3V output


Features:

  • 802.11 b/g/n
  • Integrated low power 32-bit MCU
  • Integrated 10-bit ADC
  • Integrated TCP/IP protocol stack
  • Integrated TR switch, balun, LNA, power amplifier and matching network
  • Integrated PLL, regulators, and power management units
  • Supports antenna diversity
  • WiFi 2.4 GHz, support WPA/WPA2
  • Support STA/AP/STA+AP operation modes
  • Support Smart Link Function for both Android and iOS devices
  • SDIO 2.0, (H) SPI, UART, I2C, I2S, IR Remote Control, PWM, GPIO
  • Deep sleep power <10uA, Power down leakage current < 5uA
  • Wake up and transmit packets in < 2ms
  • Standby power consumption of < 1.0mW (DTIM3)
  • +20 dBm output power in 802.11b mode
  • Operating temperature range -40C ~ 125C
  • FCC, CE, TELEC, WiFi Alliance, and SRRC certified

Step 2: Info About DHT11

The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). Its fairly simple to use, but requires careful timing to grab data. The only real downside of this sensor is you can only get new data from it once every 2 seconds, sensor readings can be up to 2 seconds old.

Features:

  • Small size, low cost
  • Easy to use 3 to 5V power and I/O
  • 2.5mA max current use during conversion (while requesting data)
  • Good for 20-80% humidity readings with 5% accuracy
  • Good for 0-50°C temperature readings ±2°C accuracy
  • No more than 1 Hz sampling rate (once every second)

Step 3: Info About TMP102

TMP102 is a super small digital temperature sensor. The TMP102 is a digital sensor (I2C a.k.a. TWI), has a resolution of 0.0625°C, and is accurate up to 0.5°C. This is a very handy sensor that requires a very low-current.

Communication with the TMP102 is achieved through a I2C serial interface. There is no on-board voltage regulator, so supplied voltage should be between 1.4 to 3.6VDC. Filtering capacitors and pull-up resistors are included as shown.

Features:

  • 12-bit, 0.0625°C resolution
  • Accuracy: 0.5°C (-25°C to +85°C)
  • Low quiescent current
  • 10µA Active (max)
  • 1µA Shutdown (max)
  • 1.4V to 3.6VDC supply range
  • Two-wire serial interface
  • 2x Mounting Holes

Step 4: Info About BMP180

This is a breakout board for the Bosch BMP180 high-precision, low-power digital barometer. The BMP180 offers a pressure measuring range of 300 to 1100 hPa with an accuracy down to 0.02 hPa in advanced resolution mode. It’s based on piezo-resistive technology for high accuracy, ruggedness and long term stability. These come factory-calibrated, with the calibration coefficients already stored in ROM. What makes this sensor great is that it is nearly identical to its former rev, the BMP085!


Features:

  • Digital two wire (I²C, TWI, “Wire”) interface
  • Wide barometric pressure range
  • Flexible supply voltage range (1.8V to 3.6V)
  • Ultra-low power consumption
  • Low noise measurements
  • Factory-calibrated
  • Includes temperature sensor
  • Low-profile with a small footprint

Step 5: Tools & Materials for the Project

You will the following stuff:

Parts:

Tools:

  • Soldering iron
  • Hot glue gun
  • Clips

Step 6: Making the Circuit Board

Make it with the help of the prototyping board. Connect the SDA and SCK pins of the TMP102 and BMP180 sensors to pins 5 and 4 (like on Arduino UNO) of the HUZZAH module and the DHT sensor to pin 2. GND to GND on the board and the power input of the sensors to +3 V pin of the HUZZAH board. If you want put a hardware reset button so you can reset the board. Also add a battery connector so you can power it with a battery like me. Also you have to put jumper between pin 16 and RST of the HUZZAH board so the board wake up.

By default the time for sleep is set on 300s - 5 minutes, if you want you can change it.

I have putted additional headers for more sensors such as anemometer for measuring wind speed, pyranometer for measuring solar radiation, rain gauge for measuring liquid precipitation over a set period of time. So check this instructable regular for updates.

Step 7: Enclosure

My enclosure is a simple plastic box from nearest store, but you can use another box,a 3D printed, laser cutted or a normal plastic box. The box should have enough space for the main board, the battery and the sensors.

I putted the BMP180 and the TMP102 on the right side of the box and the DHT at the top.

I have pointed the digital sensors to North because of the Sun (its warming up the TMP102 sensor).

Step 8: Setting Up Adafruit IO

WATCH THE VIDEO !!!


Adafruit IO is giving you the opportunity to connect your device to internet and to read data from sensors or to control it remotely from every point on Earth (if you have internet of course), and in this step I will snow you how to set it up.

Go to Adafruit IO and sign up or sign in. Then the dashboard page will load, on this page are your dashboards. On left you will see a menu, click on feeds then on right you will see the create feed button(its blue) click on it. Name the feed temperature, add description and then click on the createfeed button(its grey) and your feed is done. Repeat the process for other feeds such as: humidity,pressure, altitude, etc.

Now go to Dashboards menu and create new dashboard, then add gauge and name it temperature, make the rest.

After that go to settings and click on View AIO Keys and copy your key, then paste it in the Arduino sketch. If you refresh your key you have to replace it. You can get your key from any of your feeds or dashboards by clicking on the key button which is on the right (it is yellow in color with small white key in it) then move to the next step.

If you forget to make the feeds don't worry, the module will create them for you !

NOTE: If you have issues with Adafruit IO, go to settings and destroy all IO data and IO account, then sign in with your Adafruit account.

Step 9: Download and Install the Software

This step is easy, just download .INO fileESP8266_Weather_Station_v1.0 - then open and it with the Arduino IDE put your WLAN name and password, add your Adafruit IO username and IO key. After that upload the code to the ESP8266 module with the help of FTDI cable.

Libraries:

BMP180 lib from SparkFun

DHT lib from Adafruit

Adafruit MQTT library

Download and unzip the libraries at - /Program Files(x86)/Arduino/Libraries (default).

Arduino IDE and ESP8266 set up:

Copy this link : http://arduino.esp8266.com/stable/package_esp8266c... open Arduino IDE and press H + comm to open preferences then paste it into Additional Board Manager URLs field. Restart Ardiuno IDE and go to boards manager, search for ESP8266 and download it.

Step 10: Congrats !!!

If you receive the data on you Adafruit IO account that means everthing is OK. Now you have your own weather station.

Bitcoin tips: 1Bfgrq4dQSuRHuTdk5jzZPtnMZLymDQ5dv

Comments

author
MegaDAS (author)2016-12-23

good one

author
TomV85 (author)2016-11-24

Is publish the command to send something to the API ?

author
ShubhamG32 (author)2016-05-03

fatal error: ESP8266WiFi.h: No such file or directory

author
ShubhamG32 (author)2016-05-03

fatal error: ESP8266WiFi.h: No such file or directory

author
SimonN12 (author)2016-03-20

For deep sleep to work properly:

"Everything behaves as expected, however, when i put my HUZZAH board into deep sleep (yes GPIO16 has to be connected to RST for this to work)."

I couldn't find this in the instruction, can you give me some feedback for this?

author
mrsharkit (author)2016-01-24

how often do you read sensors and how does the battery you choose last, with your setup, before recharging?

author

I read the sensors on every 5 minutes and I dont know how long it will take for the battery to discharge. I will tell you when this happens.

author

thanks

author

The battery lasted for 3 days and 11 hours.

3.7V 2900mah

author

not so great, in the end... maybe updating online data a less often, or disabling wifi if not needed, or some low power optimization, will enhance the time...

author

Actually the ESP8266 module enters Deep sleep mode which turns of the wi-fi and consumes 10 uA, but the TMP102 keeps working. The power consumption would drop if I use only one sensor, BME280 for example.

I read that the module can work for over 2 months with 2 regular AA batteries by sending data once on every 15 minutes, in the ESP8266 forum.

Also I am not sure how much of the battery was charged, cause I removed the protection board (It was damaged) and I am afraid of overcharging it.

author
Gert_O (author)2016-01-26

I am not able to open the Ino-file in my Arduino IDE ? i only get an unformattet textfile. Can anybody help me ?

author

That is strange, can you give me more details ?

author

I can show you how i look vhen i try to open the file:
/********************************************************** Adafruit Huzzah IoT weather station with: DHT11 - For humidity BMP180 - For pressure TMP102 - For temperature I2C - pins - 5(SDA) and 4(SCL) DHT pin - 2 by KonstatinDimitrov ***********************************************************/ /*******************LIBRARIES**************************/ // Libraries #include #include #include #include #include #include /********************SENSORS***************************/ //TMP102 sensor address int tmp102Address = 0x48; //Pressure sensor SFE_BMP180 pressure1; char status; double T,P,p0,a; #define ALTITUDE 44.80 //DHT11 sensor #define DHTPIN 2 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE, 15); /********************SLEEP MODE**********************/ const int sleepTimeS = 300; // Sleep mode time in seconds /* 60s - 1min, 120s- 2min, 180s - 3min 300s - 5min */ /****************************************************/ // WI-FI PARAMETERS #define WLAN_SSID "NAME" //WLAN NAME #define WLAN_PASS "PASSWORD" //WLAN PASSWORD // Adafruit IO #define AIO_SERVER "io.adafruit.com" #define AIO_SERVERPORT 1883 #define AIO_USERNAME "USERNAME" //Your Adafruit IO user name #define AIO_KEY "YOU KEY HERE" //Your IO key // Functions void connect(); // Create an ESP8266 WiFiClient class to connect to the MQTT server. WiFiClient client; // Store the MQTT server, client ID, username, and password in flash memory. const char MQTT_SERVER[] PROGMEM = AIO_SERVER; // Set a unique MQTT client ID using the AIO key + the date and time the sketch // was compiled (so this should be unique across multiple devices for a user, // alternatively you can manually set this to a GUID or other random value). const char MQTT_CLIENTID[] PROGMEM = AIO_KEY __DATE__ __TIME__; const char MQTT_USERNAME[] PROGMEM = AIO_USERNAME; const char MQTT_PASSWORD[] PROGMEM = AIO_KEY; // Setup the MQTT client class by passing in the WiFi client and MQTT server and login details. Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD);/****************************** Feeds ***************************************/ /******************** Setup feeds ***********************/ const char TEMPERATURE_FEED[] PROGMEM = AIO_USERNAME "/feeds/temperature"; Adafruit_MQTT_Publish temperature = Adafruit_MQTT_Publish(&mqtt, TEMPERATURE_FEED); const char PRESSURE_FEED[] PROGMEM = AIO_USERNAME "/feeds/pressure"; Adafruit_MQTT_Publish pressure = Adafruit_MQTT_Publish(&mqtt, PRESSURE_FEED); const char HUMIDITY_FEED[] PROGMEM = AIO_USERNAME "/feeds/humidity"; Adafruit_MQTT_Publish humidity = Adafruit_MQTT_Publish(&mqtt, HUMIDITY_FEED); /***************************Sketch Code******************/ void setup() { // Wire.begin (5, 4); // setting up the SDA(5) and SCL(4) pins dht.begin(); //reads data from DHT sensor pressure1.begin(); //reads data from BMP180 Serial.begin(115200); Serial.println(F("IoT weather station")); // Connect to WiFi access point. Serial.println(); Serial.println(); delay(10); Serial.print(F("Connecting to ")); Serial.println(WLAN_SSID); WiFi.begin(WLAN_SSID, WLAN_PASS); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print(F(".")); } Serial.println(); Serial.println(F("WiFi connected")); Serial.println(F("IP address: ")); Serial.println(WiFi.localIP()); // connect to adafruit io connect(); } /***********************TMP102 BLOCK********************/ float getTemperature() { Wire.requestFrom(tmp102Address,2); byte MSB = Wire.read(); byte LSB = Wire.read(); //it's a 12bit int, using two's compliment for negative int TemperatureSum = ((MSB << 8) | LSB) >> 4; float TempC = TemperatureSum*0.0625; if (TempC > 128) { TempC = TempC - 256; // for negative temperatures } else TempC; return TempC; } /*******************************************************/ void loop() { if(! mqtt.ping(3)) { // reconnect to adafruit io if(! mqtt.connected()) connect(); } /***********************TMP102*******************/ float TempC = getTemperature(); if (! temperature.publish(TempC)) Serial.println(F("Failed to publish temperature")); else Serial.println(F("Temperature published!")); delay(500); /**********************Pressure******************/ status = pressure1.startPressure(3); status = pressure1.getPressure(P,T); if (! pressure.publish(P*0.01450377)) Serial.println(F("Failed to publish pressure")); else Serial.println(F("Pressure published!")); delay(500); /******************DHT Humidity*******************/ int humidity_data = (int)dht.readHumidity(); if (! humidity.publish(humidity_data)) Serial.println(F("Failed to publish humidity")); else Serial.println(F("Humidity published!")); delay(500); /*******************SLEP MODE***********************/ Serial.println(F("ENTERING SLEEP MODE!")); ESP.deepSleep(sleepTimeS * 1000000); //Sleep mode, for power save } /**************************************************/ void connect() { Serial.print(F("Connecting to Adafruit IO... ")); int8_t ret; while ((ret = mqtt.connect()) != 0) { switch (ret) { case 1: Serial.println(F("Wrong protocol")); break; case 2: Serial.println(F("ID rejected")); break; case 3: Serial.println(F("Server unavail")); break; case 4: Serial.println(F("Bad user/pass")); break; case 5: Serial.println(F("Not authed")); break; case 6: Serial.println(F("Failed to subscribe")); break; default: Serial.println(F("Connection failed")); break; } if(ret >= 0) mqtt.disconnect(); Serial.println(F("Retrying connection...")); delay(5000); } Serial.println(F("Adafruit IO Connected!")); } /*************** END OF FILE ******************/

author
joepmaas (author)Gert_O2016-01-27

Could it be that you have the file-association for the .ino extension to a text-editor?

Plse try the following:

Find the .ino file in your microsoft explorer.

Right-mouseclick on the file and choose "open with"

Now select the Arduino IDE to be the standard exe to open when a .ino file is selected.

This should do the trick assuming my impression is correct.

Happy Arduining!

author

That the code, I see no problem in it.

author
gdsmit1 (author)2016-01-25

Nice 'ible. I've added it to my favorites.

Any plans on getting the data over to wunderground?

author

Thanks !

I dont know how to thank you about Wunderground, definitely I will get the data there.

Thank again !

author

I haven't gotten my weather station built yet. But it will be on wunderground when it is. That's where I go for all my weather needs.

If you click on the name of the weather station, a lot of the people will put descriptions of their setup. Helps when designing your own station.

author

Thats nice !

About This Instructable

30,034views

216favorites

License:

Bio: I am a dreamer, maker and an engineer making and sharing interesting projects here at Instructables. Follow me @ instagram: @the_gadget.boy
More by Konstantin Dimitrov:Arduino/Genuino 101 BLE Thermometer With TMP102 and BlynkPixie: An Arduino Based NeoPixel WristwatchTurn Your Old 2.5'' Or 3.5'' Hard Drive Into Portable/External
Add instructable to: