Home » IT » The weather station, the Raspberry Pi and the ESP8266

The weather station, the Raspberry Pi and the ESP8266

In a previous post going back to 2012 I talked about how I used an Android netbook running Linux and wview to post data from my WS 2355 weather station to Weather Underground. Such a long time ago, things have changed a lot since then.

First up I replaced the Linux netbook with a Raspberry Pi running Raspbian and using pywws to upload the weather info for IWELLING61.  The netbook was ok but getting Linux on it had been a kludge so as soon as I found out about Raspberry Pis I got one in. Cost – around $60 NZD.

ws1Then a second weather station to go at the bach. This time I was pretty confident that I could get away with a cheaper variant so picked up a WH1082 from Trademe for about $185 and another Raspberry Pi from nicegear.

trademeA year or two rolled by and the original WS 2355 base station stopped communicating with the sensors – I tried cables and wireless without luck so I went hunting on Trademe for another weather station – this time it was a WH108x for $135 NZD from debra101 in Taranaki.


Another year and the $185 WH1082 at the bach stopped working so back to debra1010 for a $135 replacement.

That leaves me with a set of spare gauges from the WS 2355 and WH1082 lying around.

In between times I started playing with the cheap (< $10 NZD on ebay)  ESP8266 Internet of Things devices.  esp8266So much fun to be had here! The ESP8266 has a large fan base now so lots of resources around – it is  bit like a dumbed down Ardunio that you can use as a single purpose thing to do stuff. I had a choice between programming it in C using the Ardunio IDE or LUA using nodemcu firmware. I decided on nodemcu as although I hadn’t used Lua before it looked easy, especially if using the cloud firmware build service that has a lot of APIs to common sensors and devices built in.

So what do do with it? Well first up I  connected the ESP8266 to my Macbook Air and flashed it with a custom cloud build using esptool.py. I could then use a terminal program (I used zterm for the Mac) to talk to it at 115200 baud 8N parity. It seemed to work better with no flow control. Next up I created a small init.lua script to start the wifi and connect to my network. To transfer the script to the ESP 8266 I used luatool.py. The ESP restarted and was on the network. All good but I wanted a smarter way of transferring files and running adhoc commands. Some googling and I built Lua scripts for tftp and telnet servers for the ESP (thanks to whoever I stole bits of scripts from), loaded them up and then unplugged and I could access the ESP over wifi for most things I wanted to do.

You can download copies of the scripts here. There are also a few shell scripts in there to automate copying files, restarting the ESP etc;

espThe last thing I did was to hook up a very cheap and inaccurate it turns out DHT11 temperature sensor and post the results to thingspeak.

I’ve now ordered the better DHT22 (and another ESP, and a 4 line LCD display, and a relay … all up less than $20 NZD delivered) for my next project – that is get the ESP talking directly with my leftover rain, anemometer and wind direction gauges.


A couple of things to watch out for:

  1. You can only  run one TCP and one UDP service at a time on the ESP so if my telnet server is running then the ESP won’t be able to use https posts to update thingspeak.
  2. There are a lot of variants of the ESP around – you can buy them cheaply on ebay and probably a few cents cheaper still on Alibaba. Go for a 12E or better variant, apparently the newer ones have more flash and better wifi reception.