Skip to main content

Introduction

In this tutorial, you will learn how to create a project with a NodeMCU ESP8266 board and some NeoPixel lights. You will use these devices to display the carbon intensity of electricity generation in New Zealand. Carbon intensity is a metric that shows how much carbon dioxide is emitted per unit of electricity produced. Carbon dioxide is a greenhouse gas that contributes to global warming and climate change.

The NodeMCU board is a microcontroller that can connect to the internet via Wi-Fi. You can program it with PlatformIO and C++, which are software tools that help you write and upload code to your board. The NeoPixel lights are RGB LEDs that can be individually controlled with a single wire.

A microcontroller is a small computer on a single chip that can perform specific tasks. It has a processor, memory, and input/output ports. A NodeMCU's single-core performance is roughly the same as the first Intel Pentium CPU from 1993, but five times faster than a standard Arduino Uno.

The dirtywatts.nz website provides real-time data on the carbon intensity and demand level of electricity in New Zealand through the dashboard, but it's designed for humans and is effectively gobbledygook to our poor microcontroller. Instead, Dirtywatts also provides an API (what's an API?) that's designed forenables computers to get that data, read it and understand. That'sThe the job of the microcontroller,microcontroller is to connect to wifi, download the latest data,data using the API, calculate a colour, and then output the colour for the LEDs.

YouTo complete this project, you need to connect up the electronics and upload your code to the microcontroller. In that code you can change theirthe colours and brightness withas yourwell code.as Thea dirtywatts.nzbunch websiteof hasother ansettings. API, which is an interface that allows your board to communicate with the website and get data from it.

You will need the following components for this project:

There are many fakes "variations" of the official NodeMCU development boards, they will work but they might be less reliable or more finicky to get working. You can see some of them here. 
Look for one with a CP2102 chip - this is the part that connects to your USB.  Also an ESP32 is a bit better than a ESP8266 but for this project it will not make much difference. 

To complete this project, you will need to do the following steps: