Friday, June 12, 2015

ESP8266 based Wifi weather monitoring system


Low-cost Wireless Weather Monitoring System


This system transmits temperature and humidity data to cloud on internet via Wifi and provides web interface to monitor those measured information.

In this system, ESP8266 reads data from DHT22 sensor, then, send it to cloud system using simple HTTP protocol. For web interface, all charts are implemented with Google Chart APIs. 


- Arduino IDE
- ESP8266 package for Arduino IDE (*Refer to for more information)

Compiling and uploading is done in Arduino IDE with ESP8266 package installed. Therefore, basic knowledge about Arduino IDE is required to proceed following steps.   



-ESP8266 ( Around $3 on ebay )
-DHT22 ( Around $7 on eBay )
-Resistor 10k(Pull up)

To keep the cost low, ESP8266 is used as not only controller, but also Wifi transmitter. DHT22 sensor can be replaced by any other temperature sensor. Pull up resistor is used for the input pin of ESP8266.

-Google Chart 

We used cloud system to store measured data with two reasons. First, it provides free service and even does not require any account. We just need to create a 'free stream', which is basically a storage area. Secondly, it's easy to use. A single HTTP GET request can send measured data to cloud.

For web interface, Google Chart is used to draw gauge and graph to show historical change of temperature, humidity, and heat index.


Setup hardware

For uploading

Here is a wiring information to upload sketch to ESP8266 using USB to TTL converter. Since my converter is 5v version, I used another power supply to provide 3.3v to ESP8266. GPIO 0 should be pulled down to the ground for uploading.

BE CAREFUL! ESP8266 works with only 3.3v, not 5v!

For running

Connect ESP8266 to DHT22 temperature sensor. GPIO 2 pin of ESP8266 is used to read measured data of DHT22.

Step 1. Create 'free data stream' at

Visit and click 'CREATE' menu to create a 'free data stream'. It's like an identifier for your data to read and write. One interesting feature of is that it doesn't require you to create or activate any account. Just create 'free data stream'. Just remember that no more than 100 requests within 15 minutes window are allowed. On average, one request is allowed every 9 seconds. Check here for detail.

Among several fields in the creation form, 'Fields' and 'Stream Alias' are important. Fields are actual variable name for data when you send it with HTTP GET request. 'Stream Alias' is a name which can be used in URL to retrieve data from cloud.

Once you finish creating 'stream', it provides several information such as private key, public key and simple instructions on how to send and retrieve data. Don't loose them, you need them to proceed to the next step.

Step 2. Upload Sketch

For this step, you need those information at hand,

-SSID & Password of you Access Point
-List of field names you typed in 'Fields' in the creation form in Step 1
-Public Key from Step 1
-Private Key from Step 1

In this example, we used 3 fields to send data to cloud,

-temp: for temperature value measured in DHT22
-hum: for humidity value measured in DHT22
-hidx: for heat index calculated in the sketch

HTTP GET request for sending data looks like this,

Modify those values in the sketch according to your configuration. Then, compile and upload to ESP8266 using USB to TTL converter. If you face errors on Mac machine, refer to for solution.

Once finish uploading, open 'Serial Monitor' in Arduino IDE, then you will see something like this,

To verify whether the data has been transmitted and stored in cloud without error, type this URL in web browser.

You will see this kind of output if everything has gone well.

Step 3. Create HTML file

For this step, you need this information at hand,

-Public key from Step 1

Modify the value of public_key to your own key in example HTML file for web interface. Basically, it retrieves data in JSON format from cloud, then pass it to Google Chart API for drawing chart. In this example, gauge chart and line chart are used for demonstration.


Open HTML file with web browser, then you will see this chart right away. If you would like to access web interface from anywhere in the world, then, just upload this HTML file to your web site. It does not require any additional files or libraries or anything, just one single HTML file.  That's it!


Tuesday, June 9, 2015

ESP8266 Arduino IDE on Mac OS X Yosemite 10.10.3


How to program ESP8266 with Arduino IDE on Mac OS X Yosemite 10.10.3


This article provides a walkaround for using Arduino IDE to program ESP8266 on Mac OS X Yosemite 10.10.3.


To be able to follow this article, make sure your environment is same as below.

1. OS X Yosemite 10.10.3
2. Arduino IDE 1.6.4
3. ESP8266 Package for Arduino IDE 1.6.4-673-g8cd3697 
    *Refer to for more information about this package 

FYI, I used USB to TTL Serial Cable Adapter Chipset PL2303HX' from ebay. Different chipset may produce different output.

What is problem?

If you click 'upload' on Arduino IDE, then you most likely end up with these errors and your ESP8266 won't be programmed properly.

Sketch uses 240,292 bytes (45%) of program storage space. Maximum is 524,288 bytes.
Uploading 33216 bytes from /var/folders/94/rt16wrlj14ng3z47m6q85qgr0000gn/T/build5456473246941663239.tmp/wifi-weather-sensor.cpp_00000.bin to flash at 0x00000000
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed

It means that compilation has been completed successfully, but, there is an error while it is uploading compiled binaries to ESP8266. To fix the problem, we need to identify who is taking care of the 'uploading'? It's a little program, called 'esptool' and full path to it is



Since 'esptool' does not work correctly, we need to use alternative tool to upload binaries to ESP8266. One of the solution is '', which is a little python program for uploading and it works fine on Mac.

Follow these steps to install '', then, inform Arduino IDE to use '' instead of 'esptool' to upload binary to EPS8266.

Step 1: Close Arduino IDE completely

Step 2: Install

Follow installation instruction at

In my case, I just downloaded a single python file '', then, installed pySerial, which requires to run. Make a note where you installed We need full path to it in Step 3.

All installation is done. Now, we just need to ask Arduino IDE to use '' we've just installed instead of 'esptool'

Step 3: Modify platform.txt file

By modifying 'platform.txt' file, we can specify '' as an uploading tool. 

In my case, I installed '' at /Users/$USER/tmp/esp8266/esptool/"

Just open platform.txt located at 


and move to the end of file. Then you will se this line.

tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}_00000.bin" -ca 0x10000 -cf "{build.path}/{build.project_name}_10000.bin"

Change it like this way

#tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}_00000.bin" -ca 0x10000 -cf "{build.path}/{build.project_name}_10000.bin"
tools.esptool.upload.pattern="/Users/$USER/tmp/esp8266/esptool/" --port "{serial.port}" write_flash 0x00000 "{build.path}/{build.project_name}_00000.bin"  0x10000  "{build.path}/{build.project_name}_10000.bin"

You can change the full path to to wherever you installed on your system.

Step 4: Open Arduino IDE and Load esp8266 example sketch

Set 'Board' to 'Generic ESP8266' and 'Port' to wherever ESP8266 connected to currently. It is '/dev/cu.usbserial/' in my case.

Click 'upload' on Arduino IDE, then you will see following message if everything goes well.

Sketch uses 240,292 bytes (45%) of program storage space. Maximum is 524,288 bytes.
/Users/$USER/tmp/esp8266/esptool/ --port /dev/cu.usbserial write_flash 0x00000 /var/folders/94/rt16wrlj14ng3z47m6q85qgr0000gn/T/build8386918307655313675.tmp/wifi-weather-sensor.cpp_00000.bin 0x10000 /var/folders/94/rt16wrlj14ng3z47m6q85qgr0000gn/T/build8386918307655313675.tmp/wifi-weather-sensor.cpp_10000.bin 
Erasing flash...

Writing at 0x00000000... (3 %) 
Writing at 0x00000400... (6 %) 
Writing at 0x00000800... (9 %) 
Writing at 0x00007400... (90 %) 
Writing at 0x00007800... (93 %) 
Writing at 0x00007c00... (96 %) 
Writing at 0x00008000... (100 %)
Erasing flash...

Writing at 0x00010000... (0 %) 
Writing at 0x00010400... (0 %) 
Writing at 0x00010800... (1 %) 
Writing at 0x00041c00... (98 %) 
Writing at 0x00042000... (99 %) 
Writing at 0x00042400... (99 %) 
Writing at 0x00042800... (100 %)


Now, ESP8266 starts to run with newly installed sketch.

In the following post, I will describe how I made a wifi weather monitoring system using ESP8266, DHT22 sensor,, and Google Chart APIs.



Monday, June 1, 2015

Arduino implementation of La Crosse TX6U


Arduino implementation of La Crosse TX6U Remote Temperature Sensor with Arduino Uno, DHT22 temperature humidity sensor, 433Mhz Transmitter.


Low cost remote temperature sensor comaptible with La Crosse Weather Station
Source at github

La Crosse Weather Station WS-9016U

WS-9016U consists of Indoor Weather Station(WS-9016U) and Remote Temperature Sensor(TX6U)
Acording to WS-9016U & TX6U manual,
  • Power up remote sensor first, then, power up base station
  • Range of 80 feet

WS-9016U Indoor Weather Station,

  • can have up to 3 remote sensors

TX6U Remote Temperature Sensor,

  • transmits temperature every 1 minute



  • Arduino Uno
  • DHT22 Temperature Humidity Sensor
  • 433Mhz Transmitter
  • 10k resistor(pull up)
  • Breadboard




License and Credits

tx6u-arduino is based on Adafruit's DHT library and jremington's TX6U_send.ino source code.
tx6u-arduino is distributed under GPL License.


Source at github