Here’s a really easy demonstration of how you can control outputs on the NodeMCU with a simple web interface. The NodeMCU runs as a simple web server, writing a control panel interface directly as HTML.
The circuit is very simple, just four LEDs with resistors wired to outputs of the NodeMCU.
Here’s the wiring I used, which matches the code.
yellow – D1 = GPIO5
green – D2 = GPIO4
blue – D3 = GPIO0
red – D7 = GPIO13
In Arduino code, GPIO numbers map to Arduino digital outputs, so to turn on yellow LED use digitalWrite(5, HIGH)
Board type in Arduino IDE is ‘Node MCU 1.0 (ESP-12E Module)’
You will need to set up your Arduino IDE to work with the NodeMCU. A good guide can be found at https://www.circuito.io/blog/nodemcu-esp8266/ (go to the last section Programming NodeMCU with Arduino IDE. Note there is a slight typo in the instructions, the board URL should end with ‘.json’ not ‘.jso’).
Upload the code to the NodeMCU.
When it has finished loading, quickly open the Serial Monitor, set the baud rate to 115200.
Wait until the device joins the WiFi network, and note the IP address it obtains.
Enter this address in a web browser, and the interface will load.
Now you can turn on and off the various coloured LEDs by clicking on the respective buttons.
My son entered Science Talent Search with this Arduino-powered buggy. We used IR with a TV remote to issue codes for motor control and combinations of colours for the RGB LEDs.
Programming was fairly simple, but we found issues with power. It seems that motors are very noisy and when they run it can reset the Arduino. We solved this by running the motor off 4 x AA batteries, whilst the Arduino is powered by a phone battery booster. The Arduino in question is actually a Freetronics Leostick, which is a nice small board, and has a USB plug which we just plugged straight into the phone battery.
So it’s been busy, and school is just about to go back. I did find time to try out my Christmas present so I opened up the kit, plugged in the SD card and WiPi adaptor, hooked up peripherals that normally are hooked up to the Mac Mini, plugged in the power and we’re up and running. A few clicks and we’ve joined the network and posting a new item on this blog!
So this project had been sitting on my desk for ages now with the sensors and RF module spread across two breadboards with a mess of wire connecting it all up. Today I finally found some time to add the RF module to a prototyping shield. The other sensors are still on a breadboard and that’s the extra wires hanging off it, but it’s one step closer to a finished project. Some of the soldering was a bit fiddly but worked straight off.
I’m thinking I might have to back this one, which has already reached its target after less than 24 hours. It’s Aussie-designed although being made in the USA. Read more on Kickstarter. Now what could I use it for …
Home early from work and a beautiful afternoon, so I thought, it’s time to install the weather station sensor array on the roof. There is a pipe from a flue or something up there that is doing nothing and ideal. Didn’t take too long, used the compass on the phone and checked the satellite image on Google Maps to get a good idea of where North is. Even whilst I was up there I could see that it was picking up much more wind rather than when it had been down low and sheltered.
There’s a whole heap of updates still to write, but this is now sending data to my Arduino which is getting pushed to the internet along with some data from sensors inside the house.