Nodemcu dev kit

I thouhgt I wanted to try IoT with ESP8266 easily, so I got Nodemcu dev kit to the test lua on ESP8266. The kit I got was NodeMcu Lua WIFI Development Board For ESP8266 Module from Banggood. The kit contains somewhat more (around 8 Euros) than bare ESP8266 module (around $3), but promises to provide easier to work dev kit and more features. Here is the kit I got

image

I already had CH340G USB-serial adapter driver installed on my PC (I have used USB-RS232 adapters with this CH340 chip set earlier), so getting it to work with the Windows computer (Windows 7 and 8 tested) was just plugging the module to computer USB port with standard microUSB-to-USB cable (I used cable borrowed from my smart phone charger).

The dev kit should show as serial port. According to the instructions I expected that when I set the baud rate to 9600 bps, I could talk Lua to the module. That experiment failed :-(

I ended up in the situation that I could talk to module at 115200 bps data rate and it only seemed to answer to AT commands. So it seems that this kit came with standard default ESP8266 firmware instead of nodemcu.

The next step is to get the proper firmware module. I followed the instructions provided by Electrodragon to get the nodemcu Lua into the ESP8266 module in this dev kit. I downloaded nodemcu-flasher and run it. The module got programmed. After power-down and power-up I could talk Lua to it at 9600 bsp data rate. I used Teraterm to communicate with the module (I had to set the Setup->Terminal..->New Line / Transmit: CR+LF).

The first successful test to control IO pin:

pin =1
gpio.mode(pin,gpio.OUTPUT)
gpio.write(pin,gpio.HIGH)
gpio.mode(pin,gpio.INPUT)
print(gpio.read(pin))

The next was to connect to WLAN base station (Android smart phone) and load web page. I used example from nodemcu web page to do that. Now I have all the basic parts tested, and now it is time to think for IoT applications. In the short test this nodemcu feels like a very good platform for IoT.

 

 

 

18 Comments

  1. Tomi Engdahl says:

    This looks like an interesting add-on to NodeMCU dev board that provides motor driver H bridge and Arduino sensor shield like sensor connection pins:

    ESP8266 WiFi Motor Drive Expansion Board For NodeMCU ESP-12E
    http://www.banggood.com/ESP8266-WiFi-Motor-Drive-Expansion-Board-For-NodeMCU-ESP-12E-p-991603.html?p=27131452996820140438

    Motor power supply (VM): 4.5V ~ 36V, can be powered separately
    Control power (VIN): 4.5V ~ 9V (10VMAX), can be powered separately

    Drive Type: Dual high-power H-bridge driver
    ESP12E Dev Kit Control Port: D1, D3 (A motor); D2, D4 (B motor)
    Expand two-way motor-driven, two-way direct drive motor

    Reply
  2. Tomi Engdahl says:

    Some comments on NodeMCU and SSL support:

    nodemcu/nodemcu-firmware » mqtt.client:connect() secure options
    https://www.bountysource.com/issues/23926513-mqtt-client-connect-secure-options
    https://www.reddit.com/r/esp8266/comments/2zt58x/does_ssl_work/
    There are many examples for HTTPS around the web for the ESP though, and people claiming that it worked for them , there is even a gmail example, but I don’t know what nodemcu firmware version they were using.
    So I can personally confirm that after Too Much Goddamn Effort I was able to get esp_mqtt to build and connect via SSL; I had to use a self-signed 1024 bit cert, so it’s…technically SSL.
    https://github.com/ParsePlatform/parse-embedded-sdks/issues/5
    There is a new phenomenon currently getting good hype and worked on, ESP8266 which is full-fledged 32bit SoC with WiFi built-in. It’s more powerful (speed + flash storage) than regular Arduino Mini Pro or even Mega 2560, and the size of it makes it really ideal for standalone IoT devices.
    There are many modified firmwares for it with added functionality, and some like NodeMCU (LUA runtime with a file system). I’ve been playing around with it, and pretty impressed.
    I believe a Parse SDK for ESP8266 would be really useful for many IoT developers like myself.
    Latest ESP SDK is actually v1.0.0 (possibly 0.9.9? I’m seeing conflicting version numbers) – I was able to build, after quite a bit of hacking, a few things with it – including SSL support. Limited, but there – particularly, asking it to validate a full certificate chain makes it fall over. Self-signed 1024-bit certs appears to be the maximum. (For reference, api.parse.com is sending me a 2048-bit key – https://www.ssllabs.com/ssltest/analyze.html?d=api.parse.com&s=54.152.176.8&hideResults=on)

    Reply
  3. Tomi Engdahl says:

    Nodemcu LUA Script for Posting things to Amazon Web Services (AWS)
    https://github.com/dsbaha/nodemcu-awsv4

    Reply
  4. Tomi Engdahl says:

    Article on some challenges with NodeMCU:

    4 reasons I abandoned NodeMCU/Lua for ESP8266
    http://internetofhomethings.com/homethings/?p=424

    Like many, I became very excited when first introduced to the ESP8266. Imagine, a complete IoT system on a chip for a couple of USDs! It was very easy to bring a factory-new ESP8266 module up and running from the wealth of information available on-line. The “OK” response to the “AT” command was the “Hello World” for this device, and on you go from there.

    With more education, it became obvious that a lot of folks were using NodeMCU to develop Lua scripts for the device. It looked simple enough. And the demo applications to control an LED from a web browser were easy to duplicate. Wow, this really works!

    But then I started to develop a larger server, which responded to multiple requests.

    And that’s when the problems started…

    I have concluded that the NodeMCU/Lua development environment (at least at this time) is not suitable for ESP8266 application development.

    Here is why…

    #1. Insufficient memory provided for your application

    This environment does not compile your application, but rather interprets it while running. And every byte counts, including code comments. They all reduce the available free heap. Anyone that has worked with the NodeMCU/Lua development has encountered the “not enough memory” wall. It does not take much code and you start scrounging for bytes just to get the script to run.

    #2. Web Server stops replying to client

    During repeat-ability testing, I noticed that at some point, usually within a few web browser requests, the ESP8266 simply stopped replying to “http GET” requests.

    #3. Crashes

    Many times, I would start the application with a restart.

    #4. Better options

    After circling the wagons with NodeMCU/Lua for over a week, insanity set in. I really was expecting different results. But nooo – the problems persisted.

    So I investigated other options.

    The Espressif SDK offers native ESP8266 support. Your code is developed in C language and compiled.

    I am currently using the Arduino IDE for ESP8266 application development. While not as robust as the SDK, this is the only development environment that I have found (at this time) to work.

    Reply
  5. Tomi Engdahl says:

    Another ESP8266 Lua project

    Luanode for ESP32 and ESP8266
    A Lua SDK, multi-task support, for ESP32 and ESP8266
    https://hackaday.io/project/11477-luanode-for-esp32-and-esp8266

    View Gallery
    69 0 4 0
    Team

    Wei Wang

    Join this project

    Luanode
    Luanode on Kickstarter
    DOIT

    ongoing project
    ESP32 ESP8266 luanode car
    This project is submitted for

    Hackaday.com Tip Line

    This project was created on 04/28/2016 and last updated 2 hours ago.
    Description
    We want to make Lua run on the ESP32 Wi-Fi chip, as well as ESP8266, which is the most integrated solution for Wi-Fi applications in the industry. Lua, a well-known programming language, is simple and powerful code, and rapid development for the resource constraints microcontroller. Thus, Luanode is here. In Luanode, we provide some Lua modules for developers to operate periphs more conveniently. Unlike programing with C, the developers can just invoke the methods in the modules to operate periphs, it is no need for them to understand modules in detail. Developers can read/write GPIO in just one line. We believe that the Luanode will make it easier to create great IoT application than ever before!

    Reply
  6. Tomi Engdahl says:

    Thinking of You: IoT Style
    http://hackaday.com/2016/05/07/thinking-of-you-iot-style/

    Do you have loved ones who live far away? Or do you just want an interesting starter ESP8266 project to get your feet wet? If the answer to either of these questions is “yes”, we’ve got just the project for you. [Craig Lindley] built a “thinking of you” button-and-LED display device that helps people keep in touch, in a very simple way.

    We like the minimalism of the design. One party presses their button, electrons flow, WiFis WiFi, data travels through a set of tubes, and an LED far away glows a pre-arranged color.

    The code is available in a zip file
    http://www.craigandheather.net/misc/Lindley_ThinkingOfYou.zip

    Thinking Of You Page
    http://www.craigandheather.net/celethinkingofyou.html

    The ToY devices are built using an inexpensive module called a NodeMCU Amica that incorporate a ESP8266-12 WiFi module with embedded application processor.

    Reply
  7. Tomi Engdahl says:

    A Small Collection of NodeMCU Lua Scripts
    http://www.limpkin.fr/index.php?post/2016/04/17/A-Small-Collection-of-NodeMCU-Lua-Scripts-for-Data-Collection

    Anyway, the ‘standard’ way of compiling programs for this neat little chip involves installing a cross-compiling toolchain on a Linux computer (or VM), and then using a dedicated tool to flash your program to the ESP8266.
    As you can guess, this can quickly get tiring if all you want to do is blink an LED… but then I stumbled upon NodeMCU and Domoticz.

    NodeMCU is an open-source firmware and development kit that helps electronics enthusiasts to prototype IoT products within a few Lua script lines. Concretely, it is a firmware you can flash to any ESP8266 board, which will then interpret a text file which contains your commands.

    Getting data isn’t particularly useful if it can’t correctly be stored and displayed to the user.
    Domoticz is a Home Automation System that lets anyone monitor and configure various devices like lights, switches, various sensors/meters like temperature, rain, wind, UV and much more. It is open source, can be installed on Linux, Windows and embedded devices.
    In my case I had it installed on my usbarmory and could access it in my browser in less than 10 minutes. You’ll find Domoticz main user manual here.

    In the Domoticz interface, simply add a virtual device of “light/switch” type and use this domoticz.lua script

    Second Small Project: DHT22 Temp & Humidity Sensor

    Third Small Project: Sleep Cycle Monitor

    Fourth Small Project: Switching on Lights by Tapping on Furniture

    Doing More with NodeMCU and Domoticz

    As you can guess I’ve shown here basic examples of the capabilities of the NodeMCU + Domoticz combo. Domoticz allows much more complex actions using scripts which can be triggered by the output of your installed sensors.
    In my case I’m only using the monitoring capabilities of Domoticz, even though its main purpose it to automatize your complete home!

    Reply
  8. Tomi Engdahl says:

    Minimal MQTT: Networked Nodes
    http://hackaday.com/2016/05/17/minimal-mqtt-networked-nodes/

    Last time on Minimal MQTT, we used a Raspberry Pi to set up an MQTT broker — the central hub of a home data network. Now it’s time to add some sensor and display nodes and get this thing running. So pull out your ESP-8266 module of choice, and let’s get going.

    DSCF8443For hardware, we’re using a WeMos D1 Mini because they’re really cute, and absolutely dirt cheap, but basically any ESP module will do. For instance, you can do the same on the simplest ESP-01 module if you’ve got your own USB-serial adapter and are willing to jumper some pins to get it into bootloader mode.

    We’re using the NodeMCU firmware because it’s quick and easy to get running. But you’re not stuck with NodeMCU if you want to go it alone: MQTT has broad support. [TuanPM] ported over an MQTT library to the native ESP8266 SDK and of course there’s espduino, a port for an Arduino-plus-ESP combo. He also ported the MQTT module to NodeMCU that we’ll be using today. Thanks, [TuanPM]!

    Head over to NodeMCU custom builds and build yourself a custom firmware with only the modules compiled in that you need. Here, I’ve included dht, file, gpio, mqtt, node, tmr, uart, wifi, and ws2812.

    To upload the NodeMCU firmware to the ESP8266, I use esptool.py, which should work on any platform that Python runs on.

    MQTT in NodeMCU

    So let’s get a little experience with MQTT on the NodeMCU platform. The online documentation is pretty good, so open that up to follow along. The MQTT library centers around the mqtt.Client() object and its methods, connect(), publish(), subscribe(), and close(). When you create the client, you can also register some callback functions that you’d like to be triggered by certain events, namely connect, offline, and message for when the client connects, goes offline, or receives a message.

    If you’ve got your broker set up from last time, let’s send it some messages and monitor them on the broker. Open up a window on the Pi and type mosquitto_sub -h localhost -v -t home/#.

    The node’s MQTT client needs an ID, keepalive time in seconds, username and password, and a clean-session flag. Connecting to the server can be as simple as specifying its IP address, and publishing takes the usual topic, message, QoS, and retain flags.

    The client code continually listens for messages or state changes, and sends the appropriate strings to the client:on() function that then runs your code when the named event occurs. It’s a lot like the way Javascript uses callbacks, if you’ve done any of that.

    The WeMos module I used has DHT-11 and DHT-22 shields available. The sensor is hooked up to NodeMCU pin D4, which is GPIO2 in the ESP8266 datasheet. The NodeMCU DHT library docs for using the DHT units are short and sweet, with one function that you’ll care about, dht.read().

    As mentioned above, NodeMCU runs many commands asynchronously. That means that we can’t just write code that says “do this, wait for a return value, and then do that” like you often do in C or C++, because the first function doesn’t block. Everything happens almost at once. The upside of this is that we call m:subscribe() and it just runs in the background. The downside is that when we don’t want everything happening at once, we need a timer.

    Say we want to publish the temperature of our sensor every ten seconds. We set a repeating timer, for ten seconds, that calls our publishing function, and we’re done. The timer command runs as soon as it is called, but the function that the timer contains is only called periodically

    Typing code directly into the nodes clearly won’t do. We need to store our code on the device. NodeMCU has an emulated filesystem that we can use to upload our code to.

    Reply
  9. Tomi Engdahl says:

    nodeLED
    WiFi controller for RGB/RGBW Analog LED strips
    https://hackaday.io/project/11521-nodeled

    I decided to design my own lamp using an analog RGBW LED strip. This board I designed will give you the tools to design your own WIFI controlled light source.

    The board’s controller is run by the NodeMCU which is connected to a N-Channel MOSFET for each color of the RGBW LED strip. Trimpot for brightness and 2 user buttons (that can be setup to change modes, possibly) were also added. A 5v regulator was then added so the power can be shared with 9-12v input for the LED strip. The nodeMCU will be wirelessly updatable as well.

    My idea is to have the nodeMCU be a web server for direct control via a web page. The site will have various configurations including color options, number of channels, animations (like fade effects) and a timer. I’d like to have it connect to MQTT server to integrate with larger servers such as openHAB.

    Reply
  10. Tomi Engdahl says:

    Another interesting looking Lua IoT platform:

    WiFiMCU
    Design for IoT
    Simplicity、Reliability:STM32F4+WiFi(Broadcom)+Lua
    http://www.wifimcu.com/

    WiFiMCU is developed based on EMW3165. Run the Lua script directly; operate hardware resource; achieve product prototypes. EMW3165 is a low-power embedded WIFI module, which is developed by the Shanghai MXCHIP Technology Co., Ltd. It incorporates a WiFi RF-Chip and a microcontroller based on STM Cortex-M4. The WiFi module includes a “self-hosted” WiFi network library and application components. In addition, It also provides 2M bytes of out-chip flash, 512K bytes of on-chip flash, 128K bytes of RAM and a rich peripheral resources.

    Reply
  11. Tomi Engdahl says:

    Cute USART Trick Brings PWM to IR LEDs
    http://hackaday.com/2016/07/08/cute-usart-trick-brings-pwm-to-ir-leds/

    We love little tricks like this. Suppose that you want to generate an IR remote’s signal. It’s easy, because most of the codes are known. But it can be slightly harder because most IR remotes and receivers modulate the on pulses with a square wave at roughly 38 kHz for background lighting immunity.

    With a competent PWM generator on a microcontroller, you can create this carrier modulation easily enough yourself. Set the PWM frequency to 38 kHz and the duty cycle somewhere in the 33%-50% range, and you’re set. But what if you don’t have a competent PWM generator? Such was the case that prompted [AnalysIR Blog] to fake it, with USART.

    Here’s the trick. You set up the serial port to communicate at ten times the desired carrier frequency, and then transmit “special” data.

    ESP8266 NodeMCU Backdoor uPWM Hack for IR signals
    https://www.analysir.com/blog/2016/07/06/esp8266-nodemcu-backdoor-upwm-hack-ir-signals-using-uart/

    Most posts we have read suggest that there is no PWM readily available on any of the supported platforms. As we have already shown with Arduinos and the Particle Photon we figured it would be possible to use a spare UART pin on the ESP8266 NodeMCU to achieve our goal.

    This time we were successful and the ESP8266 NodeMCU Backdoor uPWM Hack for IR signals using works!

    The Hack
    Quite simple really – just set the baud rate to 10 times the desired Infrared carrier frequency and send a ‘magic’ 8 bit character to achieve the desired duty cycle. Of course we need to take the 1-start bit and 1-stop bit into account plus the 8 bits in each character.

    In summary, sending the following characters will generate the associated duty cycle, as follows:

    0xF0 – 50%
    0xF8 – 40%
    0xFC – 30%
    0xFE – 20%
    0xFF – 10%

    This is more than sufficient for most, if not all IR systems, which would typically use 50% or more commonly 33%.

    Reply
  12. Rose says:

    Aw, this was an exceptionally good post. Finding the time and actual effort to
    create a superb article… but what can I say… I procrastinate a
    whole lot and don’t manage to get nearly anything done.

    Reply
  13. Tomi Engdahl says:

    IoT Sit Counter
    Personal Lethargy Tracker
    https://hackaday.io/project/25152-iot-sit-counter

    Once a luxury, sitting has now become an ailment. Have you yet wondered to just how many times in a day you sit or to what percentage of your day is consumed on bended knee? Making use of a resistance sensor and a NodeMCU ESP-12E, we are able to track our daily lethargy and display it in all of it’s aggregated misery. Amend as needed.

    Reply
  14. Tomi Engdahl says:

    Hackaday Prize Entry: Don’t Build This
    http://hackaday.com/2017/07/24/hackaday-prize-entry-dont-build-this/

    The ESP8266 is a remarkable piece of hardware. What we originally thought — and what was originally marketed as — a simple UART to WiFi bridge with Hayes modem commands has turned into one of the best embedded platforms around. It’s a powerful little microcontroller, it has WiFi, and it can send raw frames. That last bit is awesome, because it allows for some mischief or mirth making, depending on your point of view.

    For his Hackaday Prize entry, [Tejas] is building a WiFi Jammer with an ESP8266. It’s a small device that is able to disconnect anyone from a WiFi AP. Should you build it? No. Can you? Sure, why not.

    Wifi Hacking using ESP8266

    Based on
    NodeMCU ESP8266 Lua multi-mode WiFi hacking kit
    https://hackaday.io/project/20072-wifi-hacking-using-esp8266

    Reply
  15. sondakika haberler says:

    Good blog you have got here.. It’s difficult to find excellent writing
    like yours these days. I truly appreciate people like you!
    Take care!!

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

*

*