Design News is part of the Informa Markets Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

IoT Sensor Nodes using Micro Python and the ESP8266

IoT Sensor Nodes using Micro Python and the ESP8266

One challenge that is particularly interesting about the IoT is how to develop an Internet-connected sensor node.

One challenge that is particularly interesting about the IoT is how to develop an Internet-connected sensor node. Sensor nodes must be able to interface to a wide range of industrial sensors and actuators while being deployed in areas within the field where there may not be an easily accessible Internet drop or even power source. In some circumstances, using commercially off-the-shelf boards such as the Raspberry Pi with a customized daughter board can bridge the gap. When the nodes need to be deployed in high volume, at low costs and where battery life is an important requirement, the Raspberry Pi may not be the correct solution. An interesting contender to providing low-cost, low-power sensor nodes that are highly adaptable is the ESP8266.

The ESP8266, from Espressif Systems, was introduced in August 2014 and quickly became popular among maker groups. There were plenty of reasons for engineers and makers to be excited about the ESP8266. The ESP8266 is a WiFi chip with an integrated 32-bit Tensilca microcontroller, a fully integrated TCP/IP stack, and up to 1 MB Flash for code space. It is even designed to operate in environments ranging from -40C to 125C, which makes it well suited for an industrial environment.

There are two different ways a designer can use the ESP8266 for an industrial sensor node. First, the ESP8266 can be used to facilitate wireless communication with the cloud. From the factory, the part contains a TCP/IP stack that can be accessed via UART commands. A designer can connect the ESP8266 to the UART on any microcontroller and then use the microcontroller to perform sensor node data acquisition while using the ESP8266 as its own low-cost, wireless Internet gateway. A quick Digi-Key search reveals several ESP8266 modules that can be dropped into a design for less than $5 and that’s in prototype volumes. Using the ESP8266 as just a drop-in WiFi chip is an interesting solution since it requires no more than seven external components to make it work.

Using the ESP8266 all on its own as the sensor nodes WiFi module and also as the brains behind the sensor acquisition is far more interesting. The ESP8266 is designed to consume less than 12 uA in standby. Since it already has a microcontroller onboard, there is Flash available to customize the application code and peripherals such as SPI, GPIO, I2C, PWM, and an ADC available to communicate with and control external sensors. In fact, most sensors can be interfaced using I2C, which provides a convenient two-pin addressable interface. Higher speed sensors if required can be connected using SPI although the interface on the ESP8266 is limited to three devices. For many industrial applications, sampling at frequencies greater than 10 Hz will be rare. If these capabilities match the sensor node needs, why not get rid of the external microcontroller and extra software, and save cost and complexity?

Developers do need to be slightly careful when using the ESP8266 as the whole solution. For starters, they will need to create their own custom firmware to load on the ESP8266. Creating custom firmware means they will need to review the firmware libraries that currently exist since they will be overwriting the TCP/IP stack and communication protocol that comes factory Flashed. The ESP8266 has gathered quite an active community around the part and there exists an open SDK that is readily available for developers along with a forum to ask questions and get design ideas.

For developers who have little to no interest in learning the ESP8266 SDK, there is also an alternative solution -- using Micro Python. Adafruit has been working on a Micro Python port for the ESP8266. An example on how to load Micro Python onto the ESP8266 can be found on the Adafruit website. Micro Python is a Python 3.x port that is designed to run on microcontrollers. Rather than cross compiling a Python application into byte code and loading it onto the microcontroller, Micro Python ports the interpreter which allows developers to write a script and simply copy it onto the device.

ESC logoMastering Modern Debug Techniques. Attendees of this session will walk away with an understanding of the modern debug techniques available to engineers in todays development cycle. Attendees will learn how to quickly setup SWV and how it can benefit their development effort. Finally, a look at ETM and code coverage analysis will be examined. Don't miss "Mastering Modern Debug Techniques" at ESC Silicon Valley, Dec. 6-8, 2016 in San Jose, Calif. Register here for the event, hosted by Design News ’ parent company, UBM.

Coupling Micro Python with the ESP8266 provides sensor node developers with a huge opportunity. First, designers are able to minimize the BOM count and exclude extra components such as another microcontroller along with crystals, decoupling capacitors, and the like. Decreasing the component count allows the sensor node to shrink not just in size but also in BOM costs. Next, developers can still take advantage of the ESP8266 wireless capabilities through Micro Python. The benefit becomes a simple scripting language that nearly any engineer can use to develop sensor node application code. Python is being taught not just in universities but also to elementary school students! Python is also an object oriented language so developers can create highly architected and reusable software.

Not every sensor node solution will necessarily benefit from using the ESP8266 and Micro Python. Low volume solutions may look to Raspberry Pi or other development hardware that is inexpensive and readily available. Exploring the possibilities and needs for different industrial applications also shows that there isn’t a one-device-fits-all scenario. Every application has slightly differing requirements and needs which makes at least some hardware customization for the different scenarios highly likely. Even with that being the case, exploring the ESP8266 and Micro Python provides an interesting and unique possibility for developers to jumpstart their designs while reducing complexity and BOM costs.   

Jacob Beningo is an embedded software consultant who currently works with clients in more than a dozen countries to dramatically transform their businesses by improving product quality, cost, and time to market. He has published more than 200 articles on embedded software development techniques, is a sought-after speaker and technical trainer and holds three degrees which include a Masters of Engineering from the University of Michigan. Feel free to contact him at, on his website, and sign-up for his monthly Embedded Bytes Newsletter.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.