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 that's designed for computers to read and understand. That's the job of the microcontroller, to connect to wifi, download the latest data, calculate a colour, and then output the colour for the LEDs.
You can change their colours and brightness with your code. The dirtywatts.nz website has an 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.