Skip to main content

Software

Now that your NodeMCU is connected to your lights, you must set up a development environment. DirtyWatts MicroIndicator uses a tool called PlatformIO to handle uploading the C++ code to the NodeMCU.

To setup your windows/macos/linux device for development:

  1. Download and install Git if you don't have it already.
  2. Download and install Visual Studio Code (VS Code) if you don't have it already.
  3. Open VS Code and install the PlatformIO extension.
  4. Download and extract the DirtyWatts codebase from Questionable-Research-Labs/DirtyWatts.

    image.png


  5. Open the DirtyWatts/MicroIndicator folder: 

    image.png

     

You are now ready to start making changes!

Make changes to fit your device

In src/config.h file, there are some configuration options you might need to change:

#pragma once


#ifdef OUTPUT_NEOPIXEL
    #define NeoPixelPin D1 // D1 on esp8266
    #define NeoPixelCount 30
#endif

#define APIRequestInterval 2000	 // 20 seconds

#define ApiErrorColour 150, 150, 255  // Light Blue

In particular, if you plug your lights into a different pin than D1, you must change it here. You also need to set the number of LEDs you have connected. To set this, count every single one, and change the #define NeoPixelCount 30 to #define NeoPixelCount <numberOfLEDs>.

Here, you can change the colour shown when it can't connect to the Dirtywatts Servers and change how often it polls new data.

Upload the code

First, you want to check that PlatformIO can see the device. Plug your NodeMCU via a micro USB cable into your computer; if everything goes right, it will automatically pick it up.

image.png

image.png

If it doesn't show here, then your NodeMCU is detected/recognised by your computer. The first thing to check is to try a new USB cable and port. It needs to be able to carry data which quite a few of the cheap cables can't. You might need to install a driver, so check the bottom of your NodeMCU to see if it wants you to install a driver for a 'CH304g', 'CP2021', etc. As a last step, you can also reflash the firmware.

If your NodeMCU shows up, great! Let's upload and monitor the result using the PROJECT TASKS panel and expand the correct compile target according to the following table:

Development Board Name
Compile Target
ESP8266 ESP-12 NodeMCU (v0.9) nodemcu-neo
ESP8266 ESP-12E NodeMCU (v2) nodemcuv2-neo
ESP8266 ESP-12E NodeMCU (v3) nodemcuv2-neo
ESP32 Development Board esp32-neo

 If you're unsure, you can always try them all! It won't permanently brick your board, but it will fail to upload with possibly weird errors.

When you are ready, run the "Upload and Monitor" task; hopefully, it will start uploading!

image.pngimage.png

Now, you're onto configuring your device!