Connecting ESP8266 [Mongoose IoT Platform Starter Guide]

Sergey Lyubka, Jul 28, 2015 04:13 PM

If you have come across Mongoose IoT Platform in forums or have heard about it in the IoT community and you are ready to take it out for a test drive, then this guide will help you get started!

By way of an introduction, Mongoose IoT Platform is a firmware that lets you program ESP8266 in JavaScript and connect to the Internet easily. Real-time data feeds are also available from the integrated cloud infrastructure with dashboard.

It’s open source and licensing is based on dual license, GPLv2 for everyone with commercial use and / or need support. It’s in Alpha release and ready for you to test now.

Let’s take a deeper look

The heart of Mongoose IoT Platform is a V7 JavaScript engine we developed specifically for embedded platforms. It has a very small memory footprint (static and runtime), excellent portability and configurability.

Mongoose IoT Platform embeds V7 and provides the following API for interacting with hardware and network:

  • SPI. ESP has two SPI interfaces. The documentation for the device mentions them as SPI and HSPI. HSPI stands for Hardware SPI. An SPI is used by the chip to work with flash, meaning it is always busy. It is possible to use bit-banging, but so far we didn’t do it and implemented HSPI only (by the way, there is an excellent blog about ESP which tells a lot about SPI).

There is also an API for GPIO and a simple HTTP client together with a set of built-in functions.

A lot more information is available for you in the readme as well.

Get IoT connected in 2 minutes Download Mongoose IoT Platform

Getting Started

Now that we have the bases covered, let’s get started.

1. Download the archive with Mongoose Flashing Tool.
This utility is used for flashing the firmware onto the device. You can use another utility if you wish. The benefit of Mongoose Flashing Tool is that it immediately generates a device id and password required to connect to the cloud.

There is a version for OS X and Windows. Linux users can build the binary themselves.

The flasher is available on GitHub, together with the firmware.

When you connect ESP8266 to your USB and run Mongoose Flashing Tool, you’ll see this on your screen:

Flashing Smart.js ESP8266

2. Hit «Load firmware».
The firmware will flash to the device. Depending which specifications of ESP you are working with, you may require additional gestures. If you use simple ESP01, you need to connect GPIO0 to GND.

3. Connect the terminal.
In Mongoose Flashing Tool there is a built-in console, you can also use picocom or whatever you like. Speed - 115200.

4. We now see the console.
We tried to make it as convenient as possible, it looks like Bash.

In this console, you can immediately type JS code. («Smartjs NNN / MM $» - is the prompt, NNN - the amount of free memory, MM - the amount of memory currently consumed directly by the interpreter).

It looks like an ordinary console:

Smart.js Console ESP8266

When you press Enter the command is executed and the result of the evaluation is printed. So you can do without a lot of explicit “print()” commands.

Another way to write and run the JS code is to type it in your favorite editor, save the file and upload it to the device by selecting «Upload file» on the Mongoose Flashing Tool UI. That file can be executed via the command File.load (”file_name”). Type this command in the console or add it to a file init.js (if you need the file to automatically be executed as the device loads).

As an example, if you wanted to monitor the temperature in your apartment, you could set up in minutes. Just connect the temperature sensor to the ESP, write the “driver” (or use the ready made one) in JS, register ESP in the cloud, write a small script that reads the temperature and send it to the cloud. Once that’s set up, you can go to the dashboard and look at the chart.

And that’s it - you are up and running! We’ve done it in 2 minutes and recorded our engineers taking it live, check out the video here.

Cloud Component and adding features

Mongoose IoT Platform on ESP8266 is not limited to above. There is a cloud component where you can pull data from the device, store it, export it, remove it or simply just to look at the graphs. Here the link for the client-side API to send data to the cloud. This is the link to the server-side cloud API.

Of course, the firmware will work without the cloud, too. But the cloud is more convenient and shaves the work needed right down. We have a link to the cloud on GitHub. If you have a GitHub or G+ login you can register within a few clicks.

You do have the option to add any missing features that you need using C. You can write new functionality in C and not associate it with JS. This would be an opportunity to use almost all of the API (in most cases JS API - a thin wrapper around the C functions) and in addition, you can use the functions of the ESP SDK. Building the firmware from the source is not difficult thanks to the docker image.

You can even expand the available JavaScript API. To do this, write the required functionality in C, and then export it to JavaScript, here is the documentation.

A bit about the future

Mongoose IoT Platform is in ALPHA 1 release and we are working hard towards the next edition. Your feedback is important to get us there!

Test Mongoose IoT Platform, connect your device and let us know what worked well for you, what you think we could improve. On our list already is increased amount of RAM available to the user, ability to update scripts from the cloud, and port to other platforms.

Get IoT connected in 2 minutes Download Mongoose IoT Platform


Mongoose IoT Platform has grown since the release of this blog post. Check out theMongoose IOT product page for details or download the newest release