GroveStreams STMicroelectronics Cellular (MB1239A) and Espruino - Quick Start

This tutorial walks through the programming of the STMicroelectronics STM32Brisk (MB1305) and a 2G/3G Add-on cellular board (MB1329A). The program uploads data into GroveStreams.


STMicroelectronics - GroveStreams


The tutorial demonstrates:
  • Uploading data into GroveStreams from STM's STM32Brisk (MB1305) and a 2G/3G Add-on cellular board (MB1329A)
  • Using the Espruino Web IDE as a Chrome browser extension
This tutorial assumes the GroveStreams STMicroelectronics - Quick Start tutorial "Step 1" has been performed and the reader:
  • Has a GroveStreams user account and an Organization
  • Knows where to obtain their GroveStreams organization secret API Key
A video tutorial (different from this one), created by STMicroelectronics, for How to get started with STM32 Cellular to Cloud discovery packs (P-L496G-CELL01, P-L496G-CELL02):

Step 1: Install the Espruino Web IDE

Espruino http://www.espruino.com is an open source solution to run JavaScripts on microcontrollers such as STM32/Brisk board.

The code is made up of two parts:
  • Firmware part : This is the JavaScript interpreter, it needs to be flashed only once. It is assumed that it has already been preloaded on the board. For future updates, we’ll need to use ST-Link, the JTAG adapter to full erase the flash the STM32 memory. The input file is typically a .BIN .HEX or .S19 file type.
  • User code : We will write JavaScript text code that will be interpreted by the Espruino firmware. This part doesn’t need any compilation.

Espruino provides an online IDE to program your embedded user code:
1. The easiest way to install the Web IDE is to do so via the Chrome Web Store and click the Add To Chrome or the Launch App button.
2. Espruino will now appear in your chrome://apps/ folder:
STMicroelectronics GroveStreams Espruino
3. Launch the Espruino IDE

Step 2: Connect the Boards and Test the Espruino Web IDE

1. Connect the boards and connect the Brisk to your PC using a USB cable:
STMicroelectronics GroveStreams Connection Boards

2. Test - Blink the LED: The Espruino The quick start guide explains how to install the driver and helps new users understand the web IDE. Follow the guide found at this link: http://www.espruino.com/Quick+Start.

STMicroelectronics GroveStreams Espruino
1. Connect the IDE to the board
2. Type digitalWrite("E4",0) to turn on the blue LED. Type digitalWrite("E4",1) to turn off the blue LED.


Step 3: Configure the Espruino Web IDE

Espruino uses the concept of Modules. Modules are JS libraries. Modules are stored on-line by default and can be retrieved by using the “require()” function. See http://www.espruino.com/Modules for more in depth details.

This example will configure Espruino Web IDE for on-line mode.

A full set of modules comes with Espruino, but more modules are needed for this example. The QUECTEL.js module needs to be added to do cellular interactions (through serial port and AT command set). To add this module go to settings:
STMicroelectronics GroveStreams Espruino
1. Select PROJECT
2. Click Select Directory for Sandbox. This will create a file tree on your computer at the chosen path. It will contain modules and user projects.

Espruino will first look in the local sandbox directory and then on the Espruino web server to get a module when require() is used (Be careful if a local name matches an official module, see “Load Module – the default mechanism” chapter on Modules page).

Note that modules are searched with in following order:
  • Local minified
  • Online minified
  • Local normal
  • Online normal


Add your custom module in <your_sandbox_path>/modules:
1. Download the GroveStreamsEspruino.zip file. Clicking GroveStreamsEspruino.zip will cause it to be downloaded to your browser's download directory.
2. Unzip the file and rename /modules/QUECTEL._js to QUECTEL.js
3. Copy QUECTEL.js to <your_sandbox_path>/modules directory.

Optional: Enable Off-line Mode

This section is optional and is only recommended if you cannot work in on-line mode.

On-line modules can be installed locally to avoid firewalls. This is considered off-line mode for the IDE. Enabling Offline Mode:
STMicroelectronics GroveStreams Espruino
1. Click the Settings icon
2. Select OFFLINE MODE
3. Select Enable Offline Mode
4. Click Download Offline Data. Click this link --> http://www.espruino.com/files/offline.zip to trigger a new download if the downloaded file, offline.zip, file cannot be found.
5. Click Upload offline data from local file and point to the downloaded file, offline.zip. It will reside in your browser's download directory if you clicked the link in step 4. Do not forget to update this file from time to time.


Use only locally stored modules to avoid proxy issues:
STMicroelectronics GroveStreams Espruino
1. Select Communications
2. Enter none for Module URL


Step 4: Program the Board

Load a GroveStreams example into the IDE:
1. Rename <unzipped file>/Examples/grovestreams-http-put._js to <unzipped file>/Examples/grovestreams-http-put.js
2. Rename <unzipped file>/Examples/http-get._js to <unzipped file>/Examples/http-get.js
3. Close the IDE settings window if it is open.

STMicroelectronics GroveStreams Espruino
1. Connect to the board if it is not already connected. Green indicates the board is connected.
2. Click the Open File button and select <unzipped file>/Examples/grovestreams-http-put.js
3. Set APN, USERNAME, and PASSWORD. Update APN value based on the chosen SIM.
4. Set the API_KEY variable in the code to match your GroveStreams organization Secret API Key.

GroveStreams - API Key

To find your Secret API Key:
1. Select the Admin - API Keys menu option and choose the Feed Put API Key (with auto-registration and request stream rights) key
2. Click View Secret Key
3. Select and copy the API Secret Key to the clipboard (Ctrl-c) and paste it into your sketch (Ctrl-v) replacing the existing API_KEY value.



STMicroelectronics GroveStreams Espruino
1. Click Send to Espruino.


Congratulations! You have successfully pushed data from a STMicroelectronics cellular board into GroveStreams.


How it works

  • A component with streams was created with default settings when the first call from the board arrived.


Tips

  • Utilize Component Templates to avoid hand editing similar components as each registers.
  • Right-click on your component and edit it. Set its location. Add events to streams.
  • Continue Exploring and Learning GroveStreams!

Troubleshooting

Successful API calls to GroveStreams should return a status of: HTTP/1.1 200 OK.

If the call made it to a GroveStreams server, but an error still occurred, a GroveStreams system notification will be created that contains the error. While in the GroveStreams organization's Observation Studio, click on the Notifications button located in the top toolbar (It looks like an envelope) and select the System tab. Click Refresh to list new notifications.

Ensure you are not using the same API Secret Key for different organizations. API Secret Keys are only associated with the organization they have been created within and can only be used for that organization.

Having problems or you wish to modify the solution and are not sure what to do?

Post a question on our forum or send us an email and we'll do our best to help you out: support@grovestreams.com


Helpful Links

GroveStreams Temperature Example
GroveStreams Help Center
GroveStreams Simple Feed PUT API
GroveStreams Forum