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

Friday, July 20, 2012

Is GPU good for large vector addition?


With more than one GPU programming interfaces available, there is a great interest in converting regular program to GPU program with two frequently asked questions.

  1. How much performance improvement can we expect from it?
  2. Which programming interface is better than others?

In this post, the performance of CPU and GPU are compared for vector addition and matrix multiplication, which are widely used building blocks for scientific application.

Additionally, the performance of OpenCL, CUDA, and PGI Accelerator on NVIDIA's M2050GPU are analyzed to compare different GPU programming interfaces.

1. Is GPU faster than CPU?

No - for vector addition

Yes - for matrix multiplication

Figure 1 shows 'elapsed time' for vector addition on CPU and GPU. CPU is about 4 times faster than GPU in this experiment.

Figure 1. CPU is faster than GPU for vector addition

Figure 2. Elapsed time per function on GPU

Large vectors need to be copied from CPU memory to GPU memory through relatively slow PCIe bus and it overshadows the higher computational capability of GPU. Figure 2 tells us that most of time on GPU are used to copy data.

However, for matrix multiplication, GPU is 200 times or more faster than CPU. Computing intensive calculation such as matrix multiplication is best candidate for GPU.

Figure 3. GPU is extremely faster than CPU for matrix multiplication

Most of times are consumed for computations and data transfer time is almost negligible for matrix multiplication on GPU.

Figure 4. Elapsed time per function on GPU

2. Is OpenCL better than CUDA?

Yes for compatibility

??? for performance

CUDA is about 5% faster than OpenCL for matrix multiplication in this experiment on NVIDIA M2050 platform.


To be able to get maximum performance out of NVIDIA GPU, try to take advantage of CUBLAS as much as possible. If there is any chance that your program need to be running on different GPU platform such as AMD or INTEL, etc, then use OpenCL for compatibility.

If you are interested in full article about this experiment, check here.

Thursday, May 17, 2012

Remote Visualization using TurboVNC and VirtualGL on Cluster

1. Purpose

Remote visualization is a technique to overcome two major difficulties of "local visualization." First, visualization process requires a high performance GPU device, but, not every local system has such device. Secondly, even if local system has a high performance GPU device installed, it might take unreasonably long time to transfer huge data from remote system(cluster) to local system for visualization. Those two difficulties can be resolved efficiently by using GPU device on cluster for rendering and displaying it remotely on the display of local system.

You will see these errors if you don't have appropriate GPU device on your local system.

With remote visualization, you will see those instead. Ta-da!

2. Requirements

These are software and hardware requirements for remote visualization on EOS cluster.

Software requirements : CentOS, TurboVNC, VirtualGL
Hardware requirements : NVIDIA GPU

3. Installation

3.1 Install X Window package on GPU node

Even though GPU node has no monitor attached, it still must have X Window package installed and running to provide virtual screen where GPU can draw objects on. These objects eventually will be displayed on physical monitor of local system through SSH tunnel.

$yum groupinstall "X Window System"

3.2 Install TurboVNC on GPU node

TurboVNC is a software that display a screen of remote system on monitor of local system via RFB(remote framebuffer) protocol.

3.3 Install VirtualGL on GPU node

VirtualGL is a key software that actually utilize GPU on remote system and redirect drawing event to use hardware rendering feature.

3.4 Install TurboVNC on local system
During installation, select just vncviewer. vncserver is not necessary for local system.

4. Configuration

Since GPU node on EOS has no physical monitor attached to it, ‘--use-display-device=none’ option need to be used to configure X Window

$nvidia-xconfig -a --virtual=1024x768 --use-display-device=none
$/usr/bin/X :0 -ac -audit 0 -tst -auth /var/gdm/:0.Xauth -nolisten tcp vt7&
$cat ~/.vnc/xstartup

# Uncomment the following two lines for normal desktop:
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

User Guide

For remote visualization, user is required to go through 3 steps. First, start vncserver on GPU node, secondly, establish SSH tunnel between local system and GPU node via login node. Finally, start vncviewer on local machine to open remote display.

Terminal 1
Connect to login node(eos3)
Connect to GPU node(node349,node361,node350,node362)
Start vncserver

Terminal 2
Create SSH Tunnel
$ssh -L 10000:node349:5901

Terminal 3
$vncviewer -medqual localhost:10000
$module load paraview
$vglrun glxspheres64
$vglrun paraview

Multiple GPUs
$vglrun -d :0.x paraview  % x is set to 0 for first GPU, 1 for second GPU, and so on.

Special for ABAQUS CAE

On some system, abacus cae has an issue with color scheme. In that case, set environment variable to fix it.


The reason of this issue is incompatibility between abaqus’s graphic toolkit( and Compiz software package.

Wednesday, February 8, 2012

Setting up email server on CentOS 6.2 within 5 minutes

If you have only 5 minutes,  you can still setup an email server on CentOS 6.2. Don't waste it :)

This email server supports SMTP(TCP port 25) and IMAPS(secure IMAP,TCP port 993). Now, you can specify this as an outgoing and incoming email server on email client such as Thunderbird on your PC.

1. Install packages

Three packages are required for this. Install them if you haven't done yet.
$yum install sendmail
$yum install sendmail-cf
$yum install dovecot

The role of sendmail is to receive emails destined to you and keep them in your mailbox on email server. Then, dovecot actually delivers those emails to your PC when you open Thunderbird or Microsoft Outlook. For outgoing email, Thunderbird first contacts sendmail, then sendmail relays the email to final destination for you.

2. Configure sendmail

You just need to change 2 lines in configuration file /etc/mail/

Comment out this to allow receiving email from anywhere.
dnl DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')dnl

Add this line

Add your PC's full hostname in this file. Create one if this file doesn't exist.

After changing configuration file, run this command to activate it.

$service sendmail start

3. Configure dovecot

You just need to edit two files.

In /etc/dovecot/dovtcot.conf, just edit these two lines
protocols = imap
listen = *, ::

In /etc/dovtcot/dovecot.d/10-mail.conf, edit these 3 lines

mail_location = mbox:~/mail:INBOX=/var/mail/%u
mail_privileged_group = mail
mbox_write_locks = dotlock fcntl

Start dovecot service
$service dovecot start

4. (Optional) Reconfigure iptables only if you are already using iptables
Add these 2 lines into /etc/sysconfig/iptables to allow email to go through firewalls.

-A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 993 -j ACCEPT

then, restart iptables by
$service iptables restart


This is it. Of course, you can do more to enhance the security level of your email server. For example, you can make sendmail more secure by using SMTP over SSL. Feel free to suggest any idea about this article. Thanks.

Monday, January 30, 2012

2012 Spring Short Course, Introduction to Unix/Linux

Date : Jan. 30(Monday) ~ Dec. 2(Thursday).
Time : 3PM ~ 5PM
Location : Teague Rm# 103

It is highly recommended for all attendee to get your EOS login ID ready before the first day of class. EOS login ID is required for hands-on lab.

Introduction to Linux is a short course specifically designed for beginner to Linux/Unix system. It will cover basic concept of Linux and frequently used commands.

  • What is Linux/Unix?
  • File and Directory
  • Edit text file
  • Setup environment
  • Remote access
  • Process,Signal
  • I/O redirection,Pipe
  • Alias
  • Permission
  • Kernel & Shell
For detail,

Please, post a comment or feedback about this class. It would be helpful to improve the class.
Thanks you.

Brian Kim