How to add an extension for mBlock?


mBlock v2.2.0 provides a new feature of extension management. Users are able to add or remove extensions from now on.

I’ll show you how to add an extension in the following steps(Download (3.3 KB) to see demo extension).
The feature of demo extension:
(1) Output HIGH and LOW level from digital pin on Arduino board
(2) LED blink

  1. Files in demo extension
    Unzip the file, you’ll get following files:

    js file: called JavaScript codes for online communication(Scratch online programming)
    src file: .h and .cpp files for Arduino compiling(Arduino offline programming)
    s2e file: description file of this extension

  2. Defining extension
    Open demo.s2e, you’ll get following codes:

{   "extensionName": "Demo",
    "javascriptURL":"js/demo.js", // define the path of JavaScript file
    "firmware":"1.0",  // firmware version 
    "extensionPort":0, // network port of extension, 0 for serial port
    "blockSpecs": [ // module defining array
        ["h","Demo Program","runArduino"],
            "w", // "h" for event module, "w" for write module, "r" for read module
            "digitalWrite( %n , )", // module display name, %n is number type, is menu value with menu name "digital"
            "digitalWrite", // called javascript function
            "13", // default value of the first parameter
            "HIGH", // default value of the second parameter
            {   // define Arduino programming
                "setup":"pinMode({0},OUTPUT); \n", // codes inserted into void setup{}
                "inc":"", // included header file, such as #include <Arduino.h>
                "def":"", // define variables, such as double _num = 0;
                "work":"digitalWrite({0},{1});\n", // output implementing codes
                "loop":"" // codes inserted into loop{}
                "inc":"#include \"demo.h\"",
                "def":"DemoClass demo; \n",
                "work":"demo.blink(); \n",
    "menus": {
        "digital":["HIGH","LOW"] // menu
    "values":{ // corresponding values for "HIGH" and "LOW"
        "zh_CN":{ // Chinese version
            "Demo Program":"演示程序",
            "digitalWrite( %n , )":"数字口输出( %n , )",
  1. Writing JavaScript codes
    Define corresponding functions.
ext.digitalWrite = function(pin,level) {
  // digitalWrite function 
  runPackage(30,pin,typeof level=="number"?level:levels[level]);

var _level = 0;
ext.blink = function(){
  // blink function 
  _level = 1 - _level;
  1. Writing source codes for Arduino programming
    (1) Create demo.h and demo.cpp files in src folder.
    (2) Define blink function in demo.cpp file.
#include "demo.h"
  level = 0;

void DemoClass::blink(){
  level= 1- level;
  1. Zip the files
    Zip the files and add them to mBlock with extension management. It should look like this:

    Let’s run a test. Create a program with drag-and-drop in mBlock and output its Arduino codes.

How can I develop mBot Extention?


Is it possible to use this method to add a couple of ADAFruit libraries to mBlock? I would like to use mBlock to have students work with the 2.8" Resistive TFT arduino screen.



Could you please explain how to add mBlock to Extension list. Is it so that mBlock is not working with mac os? My arduino prog has no opportunity to select any device.


I mean mBlock-software


Using a mac with OS X El Capitan, extensions->mbot is not an option, therefore scripts for mbot are not available. Please clarify missing links between mbot and mblock.


Hi. Does anyone know if the WeDo extension for Scratch 2.0 can be applied to mblock? The location of the info on that extension is here. I downloaded the extension and it is a .msi file. If not, does anyone know of any WeDo extensions for mblock?


Did you get any response on this or make any progress? I’d like to know how to add libraries as well. Thanks.


I would like to know as well.

Please can someone help


Dear JS01: I am trying to use your example to make a new extension for MakeBlock for my mbot. But in my current version of Makeblock (3.2.2 or 3.2.3) there are no files using the Java Script codes that I can see. Was your example written for an earlier version of MakeBlock? Is this the file that is now included as firmware for the mbot? Also can one name the commands in the new extension? Can you please update this example so it will work with the current version of MakeBlock? Thanks so much! Eric


Hi i have tried open one a file but it no open. You may be guide to initialization one a extension for mblock ?


Hi everybody,
I am a bit new in this Mblock environment, but I really want to know how to make my own extensions, Do anyone knows if it is really possible to add custom extensions to mblock?


Hi JMOG_94,

Here is a post to you for reference:


wifi ve firebase mblok yapmak mümkün mü?


Absolutely great post here. it has a lot of key elements that truly makes it work.:relaxed:
stay connected with us: online android course


Thanks for that post, I was also stuck on that problem.


Open the MBLOCK5 client
First, open your mBlock PC and click the “add” button:

  1. Add device
    Among the devices, find the Arduino device we want to add:

  2. Drag the mext file into the mblock application
    After adding the device, we know the mext files (. Mext files you get from the web or export from the extension designer) we want to import is called “2dimArray”.

Drag and drop it into our mBlock app. When you drag and drop, the window will say “drag the file and drop here” :

  1. Extend, add feedback
    We drop the extension to the mBlock, then we will get notification saying the extension is loaded.

  2. Opens an extended add window for the corresponding device
    Next we open the extension center for the currently selected Arduino device and try to add our extension:

  3. Add extensions
    The extension has been added to mBlock. We can click

“add” to add this extension to our block panel:

  1. Use extension blocks
    Now the extension blocks have been successfully loaded in the panel, and we can use them for our amazing projects!

I hope these steps will be helpful!
Mark Wilson


You can use this: