Project tutorial
Weather Station Based On Arduino And NodeMCU

Weather Station Based On Arduino And NodeMCU © Apache-2.0

Weather Station based on Arduino and NodeMCU.

  • 26 respects

Components and supplies

About this project

Step 1

We are about to build a weather station with forecast for three days, it will also include clock with local time and date.

The whole project is based on Arduino, NodeMCU provides access to the Internet over WiFi. The display is built from single LEDs. Since they can be really bright it adopts illumination based on light conditions.

Let's start from the beginning. I've found those 8x8 LED modules:

So I've decided to combine few to build a display. In my case there are 3 lines, each consists of 8 modules, 24 it total, this give us 1532 single LEDs!

To drive single module I've chosen MAX72xx, I also wanted to improve my soldering skills, so I've decided to go for 24 PIN DIP chips and solder them to prototype boards:

Well that worked out pretty well when it comes to those skills, but I would recommend to use LED modules combined with MAX Chip, this will save you at least few hours, not mentioning time spent afterwards when single cable gets loose ;) Such combo-module has only 3 wires instead of 16.

So we have hardware part for our display: 24 led modules with drivers. Now it's time to light them up! I've decided to go for Arduino Mega, because it has two serial ports, so it's easier to debug things (one port will be used for communication with EPS8266). You could also use Uno, in this case you would have to daisy chain MAX chips and change addressing in software. I've used separate line for each Max chip, but Uno just does not have enough digital output pins.

I was looking for API that will join all led modules into one canvas, so that you can print spites on it without bothering with transitions between LED modules. I did not find anything that would make me happy so I've decided to implement one by myself. It provides not only simple canvas, but fonts and few animations. Basically everything that will be needed to display time and weather.

So ... we have display and API to control it. Now we need to get date and weather. Arduino does not support Internet connectivity and it definitely does not have enough resources to process incoming data. So I've decided to use NodeMCU. With few Lua scripts I was able to implement simple API that is accessible over serial port. Arduino connects over it with NodeMCU, obtains time, date, weather and displays it.

In order to provide date NodeMCU connects with NTP server and receives UTC time, afterwards it calculates local date from it. I could use one of Internet services to grab the local date, but I was looking for solution that will remain stable for long time. Those services can change their API or just go offline, but NTP protocol will remain unchanged. In worst case you will have to change server name. Current implementation supports also failover trough many different servers, so probably you will not have to bother with it soon.

Getting the weather was a bit tricky, because I had to find API that will return response small enough so it could be parsed by NodeMCU. I've decided to use yahoo weather. They provide nice REST API with small and simple response. Hopefully they will keep interfaces stable for long time.....


First you have to build the display, I've already described it in this post: Arduino LED Display .You can use the same pin numbers on Mega, so that you will not have to alter software.

After the display is ready, you should connect ESP8266 and photoresistor. Schematic below contains all hardware elements together:

The area on right top corner is the display itself - 8x3 LED modules. Each single module exposes 3 PINs, those are MAX 72xxx PINs responsible for communication over SPI. Here you will find exact schematic of single module including SPI PINs:

Next one is just another representation:

Those last two schematics can be found here:

Now it's time to build a software.

Software for Arduino Mega

You need to compile this project and upload into Arduino. In order to compile it, you will need to include SPI module and two other libraries: and

Here is a compiled software for those with the same hardware setup. You can use Sloeber for compilation, just follow those steps:

  • Create new Arduino sketch and name it: LEDClock
  • Confirm next screens until it will ask you about code, select cpp:
  • Finish it, and you should get something like that:
  • Clone LEDClock project from and move its content into Sloeber project folder. This operation should replace two files: LEDClock.h and LEDClock.cpp. Now we have Sloeber cpp project with right main files. Those wired steps were necessary, because I did not want to check in into github IDE specific files. This is our structure now:
  • There are still compilation errors, we will now add missing libraries

  • Imported project LEDDisplay has subfolder: examples. We have to exclude it from compilation, because it contains files with main-loop and this will disturb Sloeber. Select Properties on folder examples and check: Exclude resource from build:
  • Now you should have following structure:
  • You can upload it now !

Software for NodeMCU/ESP8266

I am using EPS8266 with Lua interpreter, this combination is called NodeMCU.

In order to provide weather and time to Arduino you will have to clone NodeMCUUtil, modify few scripts and finally upload those into NodeMCU. Below you will find exact instruction:

  • Compile firmware for NodeMCU so that it has all required modules. Here you will find instructions on it, and those are required modules: file, gpio, net, node, tmr, uart, wifi and cjson.
  • Edit serialAPIClock.lua and set UTC offset for your location. This will be required to calculate local date from UTC time. For most European countries it's already set to correct value. For US you will have to replace require "dateformatEurope" with require "dateformatAmerica" and rename all method calls from setEuropeTime to setAmericaTime
  • Edit yahooWeather.lua and provide city and country that you would like to have weather for.
  • Create new file called: credentials.lua and specify login data for WiFi connection, it's just one line, for example: cred = {ssid = 'openwifi', password = '123456789'}
  • Upload all Lua scirpts from main project's folder into NodeMCU: credentials.lua, dateformat.lua, dateformatAmerica.lua, dateformatEurope.lua, ntp.lua, ntpClock.lua, serialAPI.lua, serialAPIClock.lua, serialAPIYahooWeather.lua, wlan.lua, yahooWeather.lua
  • Now for the final touch we need the init-file that will be executed right after NodeMCU boots up. In our case we are using the only Serial Port in order to expose weather and clock API. This also means, that once our API is registered, it's impossible to execute standard NodeMCU commands, like file upload. For this reason init-script has two seconds delay, during this time you can still upload files, or just remove current init.lua file. Init-files are there: NodeMCUUtils/init/serialInit: init.lua, serialInit.lua

Github repos used in this project




Similar projects you might like

eDOT - Arduino Based Precision Clock and Weather Station

Project tutorial by antiElectron

  • 35 respects

Arduino Based Weather Station with Remote Sensor Unit

Project showcase by antiElectron

  • 51 respects

Arduino Weather Station

Project tutorial by woutvdr

  • 52 respects

Personal Weather Station (Arduino+ ESP8266 + Thingspeak)

Project tutorial by Jayraj Desai

  • 141 respects

Arduino Easy Weather Station With BME280 Sensor

Project tutorial by Nick Koumaris

  • 1 comment
  • 37 respects

AWS - Arduino Weather Station

Project tutorial by GilettaStefano

  • 69 respects
Add projectSign up / Login