OnQ Blog

Care for some JavaScript with your IoT? New QCA4020 developer projects from Moddable.

Aug 22, 2019

Qualcomm products mentioned within this post are offered by Qualcomm Technologies, Inc. and/or its subsidiaries.

If you’ve started building embedded IoT devices on the Qualcomm® QCA4020 and Qualcomm® QCA4024, you’ve probably seen how tight your code needs to be. Sure, you get Wi-Fi, Bluetooth 5 and Zigbee/Thread connectivity all wrapped up in one compact system on chip (SoC), but embedded development is about making the most of scarce resources. Several developers featured on our Projects page have built tight, embedded apps with the QCA4020 Development Kit, and we have three new projects for you.

Moddable has announced that its Moddable SDK now supports the QCA4020 platform for efficient, security-rich application development in JavaScript. The Moddable SDK is a combination of development tools and runtime software to create applications for resource-constrained SoC and microcontroller platforms. With this port of the SDK, you can create robust applications combining JavaScript and native C/C++ that run efficiently on devices you build around the QCA4020.

And, because showing is better than telling, Moddable has also published three QCA4020 projects based on its SDK.

1. Get started with a Hello World project

The Hello World project is a beginner-level project that introduces you to Moddable SDK development in JavaScript on the QCA4020 Development Kit. It covers setup of the Linux host environment and walks you through building, flashing and running the helloworld JavaScript example app in the Moddable SDK.

The app connects to Moddable’s JavaScript source-level debugger, xsbug, and traces the string 'Hello, world – sample’ to the debugger console.

Inside the Moddable SDK you’ll find several example apps that demonstrate available modules such as display and sensor drivers, networking and Bluetooth low energy (BLE).

2. User interface development using JavaScript

In this project, a JavaScript weather app from the Moddable SDK issues HTTP requests to the OpenWeatherMap REST API. It then displays the forecast for various U.S. cities on a color 240 x 320 LCD.

The app is built with the Piu UI framework, designed for smooth animations and crisp font rendering. You’ll see that, even on microcontrollers with tight resource constraints like the QCA4020, you can use Piu to build a UI in JavaScript with text, buttons and animations, as shown in the image.

The Piu UI framework allows you to develop beautiful, advanced user interfaces that integrate fonts and images, have responsive layouts, and display smooth, flicker-free animations. The project also shows you how to attach a SPI LCD and use Moddable’s integrated ILI9341 MIPI-compatible display driver.

3. Using JavaScript for networking, HTTP and REST APIs (JSON) on embedded devices

This project showcases the httpgetjson example app, a JavaScript app from the Moddable SDK. The app issues an HTTP request to the OpenWeatherMap REST API to retrieve the current weather in Menlo Park, California. The response is delivered in JSON format, parsed into a JavaScript object and output to the xsbug debugger, as shown in the screenshot.

The app uses a dictionary of properties along with JavaScript template literals. Compared to native C code, this is a much simpler way to build and issue an HTTP request.

Why? First, JavaScript automatically allocates the memory required to contain the URI components. Next, it frees the memory once the request is complete, reducing the risk of memory buffer overrun and related security vulnerabilities. Then, you specify HTTP request properties, like headers and body, by simply adding associated properties to the dictionary. Finally, the HTTP 'Request’ class is the only module required for the request; no additional networking, HTTP or Wi-Fi libraries are needed.

Next Steps

Who knew how quick and efficient embedded development could be in JavaScript using the Moddable SDK runtime software and development tools?

But I don’t want to steal Moddable’s thunder. The company has put together a trio of developer projects with ample documentation and step-by-step instructions, so head over to our Projects page and take them for a spin.


Qualcomm QCA4020 and Qualcomm QCA4024 are products of Qualcomm Technologies, Inc. and/or its subsidiaries.


Engage with us on


Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries ("Qualcomm"). Qualcomm products mentioned within this post are offered by Qualcomm Technologies, Inc. and/or its subsidiaries. The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.

Rajan Mistry

Sr. Staff Engineer, Qualcomm Technologies

©2021 Qualcomm Technologies, Inc. and/or its affiliated companies.

References to "Qualcomm" may mean Qualcomm Incorporated, or subsidiaries or business units within the Qualcomm corporate structure, as applicable.

Qualcomm Incorporated includes Qualcomm's licensing business, QTL, and the vast majority of its patent portfolio. Qualcomm Technologies, Inc., a wholly-owned subsidiary of Qualcomm Incorporated, operates, along with its subsidiaries, substantially all of Qualcomm's engineering, research and development functions, and substantially all of its products and services businesses. Qualcomm products referenced on this page are products of Qualcomm Technologies, Inc. and/or its subsidiaries.

Materials that are as of a specific date, including but not limited to press releases, presentations, blog posts and webcasts, may have been superseded by subsequent events or disclosures.

Nothing in these materials is an offer to sell any of the components or devices referenced herein.