<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[M5Stack with MIT App Inventor - Easy mobile app creation for your M5Stack]]></title><description><![CDATA[<p dir="auto">This tutorial assumes that you have already pre-installed the necessary com port driver, have installed the Arduino IDE (<a href="http://arduino.cc" target="_blank" rel="noopener noreferrer nofollow ugc">arduino.cc</a>) m5stack board manager files and the m5stack library.<br />
If you haven’t see the Arduino quick start guide on our docs page:<br />
<a href="https://docs.m5stack.com/#/en/quick_start/m5core/m5stack_core_quick_start" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/#/en/quick_start/m5core/m5stack_core_quick_start</a></p>
<p dir="auto">First of all why would we want to use MIT app inventor with M5Stack? MIT app inventor is a fantastic and simple tool that uses block programming and a simple UI to design android apps. You can download the .apk file for the app that you have designed and even publish it on the google play store.</p>
<p dir="auto">Although UI flow already offers a remote mobile app function it is not robust enough yet to accommodate an app with a more sophisticated UI and also it is only accessible by scanning a QR code which connects to a webpage.</p>
<p dir="auto">Currently I have only managed to use Arduino code to program the M5stack to work with MIT app inventor, but I am sure there will be a way to program this functionality soon with UI flow, especially now that the custom blocks function has now been integrated.</p>
<p dir="auto">For the people out there who prefer to use blocks though do not fear. A computer science teacher from Tunisia by the name of Adel Kassah has developed a nice website (<a href="http://easycoding.tn" target="_blank" rel="noopener noreferrer nofollow ugc">easycoding.tn</a> A.K.A Tuniot) which allows the user to generate Arduino code for ESP32 by using blocks, and he has many nice tutorials on his youtube channel on how to use it.</p>
<p dir="auto"><img src="/assets/uploads/files/1551189814107-screen-shot-2019-02-20-at-11.31.17-resized.png" alt="0_1551189779859_Screen Shot 2019-02-20 at 11.31.17.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Let’s get started. First go to the website <a href="http://easycoding.tn" target="_blank" rel="noopener noreferrer nofollow ugc">easycoding.tn</a> scroll down the page until you see the icon<br />
TUNIOT FOR ESP32 on the left side column. (!!Make sure you choose esp32 and not esp8266!!)</p>
<p dir="auto"><img src="/assets/uploads/files/1551226419318-screen-shot-2019-02-20-at-11.35.53.png" alt="0_1551226415918_Screen Shot 2019-02-20 at 11.35.53.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">After you clicked the icon you will be greeted with the block interface that looks like this.<br />
<img src="/assets/uploads/files/1551226453840-screen-shot-2019-02-20-at-11.41.16-resized.png" alt="0_1551226451342_Screen Shot 2019-02-20 at 11.41.16.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I will not go into detail on how this interface works as Adel already does a good enough job of that in his videos. He has created a bunch of templates for setting up a web server on your ESP32 device so we will choose one of those templates from the drop down templates panel which is called “server in an encrypted network”</p>
<p dir="auto"><img src="/assets/uploads/files/1551226498312-screen-shot-2019-02-20-at-11.45.28.png" alt="0_1551226496861_Screen Shot 2019-02-20 at 11.45.28.png" class=" img-fluid img-markdown" /><br />
<img src="/assets/uploads/files/1551226524032-screen-shot-2019-02-20-at-11.45.38.png" alt="0_1551226523769_Screen Shot 2019-02-20 at 11.45.38.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">We need to first enter our wifi network and password into the black block labelled “Connect Network ssid “  ” password “  “  ” so we can connect our device to the network. (note: if you do not feel secure entering your home wifi details into this website it’s ok we can enter it offline in the arduino code later)<br />
<img src="/assets/uploads/files/1551226574269-screen-shot-2019-02-20-at-11.49.42.png" alt="0_1551226573669_Screen Shot 2019-02-20 at 11.49.42.png" class=" img-fluid img-markdown" /><br />
We also need to remove the block that assigns a static IP. Do this by right clicking the block and selecting delete block.<br />
<img src="/assets/uploads/files/1551226610391-screen-shot-2019-02-21-at-13.43.17.png" alt="0_1551226609451_Screen Shot 2019-02-21 at 13.43.17.png" class=" img-fluid img-markdown" /><br />
Next we need to get the clear http request block from the String section. In a moment we will be creating two if blocks which will compare the request against the string “on” or “off”. This clear http request block will remove any unnecessary data from the http request in order to compare the strings better ( if we don’t use this block our http request will look like this “GET /on HTTP/1.1)<br />
<img src="/assets/uploads/files/1551226650768-screen-shot-2019-02-21-at-16.31.04.png" alt="0_1551226650200_Screen Shot 2019-02-21 at 16.31.04.png" class=" img-fluid img-markdown" /><br />
Add this block in below the set STRING client request to server request block.<br />
<img src="/assets/uploads/files/1551226703385-screen-shot-2019-02-21-at-22.54.20.png" alt="0_1551226701134_Screen Shot 2019-02-21 at 22.54.20.png" class=" img-fluid img-markdown" /><br />
Now we can set the two if blocks for off and on http request. We get the if block and comparator block the first two blocks from the logic section and drag them in above the client flush block.<br />
<img src="/assets/uploads/files/1551226788853-screen-shot-2019-02-21-at-22.58.11.png" alt="0_1551226786778_Screen Shot 2019-02-21 at 22.58.11.png" class=" img-fluid img-markdown" /><br />
<img src="/assets/uploads/files/1551226834858-screen-shot-2019-02-21-at-22.59.09.png" alt="0_1551226829378_Screen Shot 2019-02-21 at 22.59.09.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Now we get the client request block from the string section and place it in the first empty slot in the logic block we just placed.</p>
<p dir="auto"><img src="/assets/uploads/files/1551227170925-screen-shot-2019-02-21-at-23.02.02.png" alt="0_1551227169233_Screen Shot 2019-02-21 at 23.02.02.png" class=" img-fluid img-markdown" /><br />
<img src="/assets/uploads/files/1551227186461-screen-shot-2019-02-21-at-23.02.11.png" alt="0_1551227186249_Screen Shot 2019-02-21 at 23.02.11.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Next we need to go into the text section to get a blank block with quotation marks around it, this block creates a string which we can type something into such as “on” and then compare whether the http request has the same message or not.</p>
<p dir="auto"><img src="/assets/uploads/files/1551227232130-screen-shot-2019-02-21-at-23.04.47.png" alt="0_1551227231556_Screen Shot 2019-02-21 at 23.04.47.png" class=" img-fluid img-markdown" /><br />
<img src="/assets/uploads/files/1551227242715-screen-shot-2019-02-21-at-23.05.04.png" alt="0_1551227242459_Screen Shot 2019-02-21 at 23.05.04.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Duplicate the last steps to create an if condition for off as well.<br />
<img src="/assets/uploads/files/1551227300255-screen-shot-2019-02-21-at-23.07.03.png" alt="0_1551227299981_Screen Shot 2019-02-21 at 23.07.03.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Now for this simple example we will light up an LED on pin 26 which is easy to find on the base of the core, but for go and fire users you will have to insert a grove connector into port b (black port) and stick the LED into the end of the grove cable connector. Attach the short leg of the LED which is ground into the left side of the connector which has a black wire connected to it and the other leg into the right side which has a yellow wire connected to it.<br />
<img src="/assets/uploads/files/1551228475341-img_1050-min-resized.jpg" alt="0_1551228469457_IMG_1050-min.JPG" class=" img-fluid img-markdown" /><br />
<img src="/assets/uploads/files/1551228679822-img_1048-resized.jpg" alt="0_1551228677936_IMG_1048.JPG" class=" img-fluid img-markdown" /><br />
To finish off the code on this website we find the digital write pin block in the digital section of IN/OUT and place one in each of the if conditions we just made.<br />
<img src="/assets/uploads/files/1551228732344-screen-shot-2019-02-21-at-23.23.50.png" alt="0_1551228732066_Screen Shot 2019-02-21 at 23.23.50.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Then change their values to these</p>
<p dir="auto"><img src="/assets/uploads/files/1551228758517-screen-shot-2019-02-21-at-23.24.04.png" alt="0_1551228758288_Screen Shot 2019-02-21 at 23.24.04.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="/assets/uploads/files/1551228939105-screen-shot-2019-02-21-at-23.25.43.png" alt="0_1551228937443_Screen Shot 2019-02-21 at 23.25.43.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Now were done with the blocks code on this site, click on the copy arduino code to clipboard code button, load up the arduino IDE, create a new sketch and paste the code in.</p>
<p dir="auto"><img src="/assets/uploads/files/1551228992028-screen-shot-2019-02-21-at-23.35.08.png" alt="0_1551228991709_Screen Shot 2019-02-21 at 23.35.08.png" class=" img-fluid img-markdown" /><br />
<img src="/assets/uploads/files/1551229008337-screen-shot-2019-02-21-at-23.37.11.png" alt="0_1551229007612_Screen Shot 2019-02-21 at 23.37.11.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Now make sure your m5stack is plugged in and port and correct m5 stack board is selected. Although this code will work fine theres some small adjustments we can do to make our lives easier. Unless we do a scan of devices on our network we don’t know what the IP dress of our M5stack device is. So before we upload this code we can make some minor adjustments to display the IP address on the screen of our device.</p>
<p dir="auto">At the very top of the sketch below #include &lt;Wifi.h&gt; we can add the line #include &lt;M5Stack.h&gt; to include the m5stack library.</p>
<p dir="auto"><img src="/assets/uploads/files/1551229084047-screen-shot-2019-02-27-at-00.57.47.png" alt="0_1551229082497_Screen Shot 2019-02-27 at 00.57.47.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Now let’s scroll down to the void setup() section and add this line which initializes the m5stack M5.begin</p>
<p dir="auto">and replace the line Serial.println((WiFi.localIP())); with M5.Lcd.println((WiFi.localIP()));</p>
<p dir="auto"><img src="/assets/uploads/files/1551229196710-screen-shot-2019-02-27-at-00.59.41.png" alt="0_1551229194797_Screen Shot 2019-02-27 at 00.59.41.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Now we can test that this works before we create the app. Upload the code to your device wait for it to display its IP address on the screen which should look something like 192.168.x.x.<br />
Copy that IP address into the browser and then add a forward slash followed by on like so:<br />
<a href="http://192.168.1.8/on" target="_blank" rel="noopener noreferrer nofollow ugc">http://192.168.1.8/on</a> if you did everything correctly your LED should now turn on, to turn it off simply replace on with off in the http request <a href="http://192.168.1.8/off" target="_blank" rel="noopener noreferrer nofollow ugc">http://192.168.1.8/off</a></p>
<p dir="auto">Now to design the app we need to go to <a href="http://ai2.appinventor.mit.edu" target="_blank" rel="noopener noreferrer nofollow ugc">http://ai2.appinventor.mit.edu</a></p>
<p dir="auto">To test the app we will need to install the app inventor companion app on our android device. You can search for it on the google play store and install it from there. Or if you cannot access the play store the app inventor website has provided an .apk link (<a href="http://ai2.appinventor.mit.edu/companions/MITAI2Companion.apk" target="_blank" rel="noopener noreferrer nofollow ugc">http://ai2.appinventor.mit.edu/companions/MITAI2Companion.apk</a>) which you can copy via bluetooth or sd card to your android device and install from the file explorer.</p>
<p dir="auto">If you do not have an android device or need more information on how to get setup you can follow this link <a href="http://appinventor.mit.edu/explore/ai2/setup.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://appinventor.mit.edu/explore/ai2/setup.html</a></p>
<p dir="auto"><strong>Create the App</strong></p>
<p dir="auto">Once your setup with the app or emulator start a new project and drag two buttons from the pallete to the screen.<br />
<img src="/assets/uploads/files/1551229361453-screen-shot-2019-02-27-at-01.02.21.png" alt="0_1551229360911_Screen Shot 2019-02-27 at 01.02.21.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">After dragging the two buttons to the screen we can rename them from button 1, button 2 to something more descriptive like ButtonON, ButtonOFF. Select the the button in the components section and click on the rename button below.</p>
<p dir="auto"><img src="/assets/uploads/files/1551229418626-screen-shot-2019-02-26-at-13.01.43-resized.png" alt="0_1551229416860_Screen Shot 2019-02-26 at 13.01.43.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Aside from the two buttons we also need to drag a web component from the connectivity tab of the palette on to the screen. No icon will appear on the screen for the web component but we can tell that it has been added as it will appear in the components section.<br />
<img src="/assets/uploads/files/1551229478723-screen-shot-2019-02-26-at-13.11.56-resized.png" alt="0_1551229476335_Screen Shot 2019-02-26 at 13.11.56.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Change the text of your buttons by selecting them in the components section and editing them in the text field of the properties section.</p>
<p dir="auto"><img src="/assets/uploads/files/1551229530835-screen-shot-2019-02-26-at-13.17.10-resized.png" alt="0_1551229530342_Screen Shot 2019-02-26 at 13.17.10.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">That’s all for the layout, let’s move to the blocks to complete the app. Press the blocks button in the top right hand corner of the window to move to the blocks page. This is where we will write the code for our app.</p>
<p dir="auto"><img src="/assets/uploads/files/1551229574595-screen-shot-2019-02-26-at-13.22.33-resized.png" alt="0_1551229573652_Screen Shot 2019-02-26 at 13.22.33.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">First we will need to grab two button click blocks from the button section in the blocks menu, click the drop down list to change them to ButtonON and ButtonOFF like so.</p>
<p dir="auto"><img src="/assets/uploads/files/1551229673981-screen-shot-2019-02-26-at-13.25.04-resized.png" alt="0_1551229671486_Screen Shot 2019-02-26 at 13.25.04.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Enter the web section and drag the “set web1 url to” blocks into the button click blocks</p>
<p dir="auto"><img src="/assets/uploads/files/1551229764414-screen-shot-2019-02-26-at-13.27.19-resized.png" alt="0_1551229761631_Screen Shot 2019-02-26 at 13.27.19.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Now this is how we send the http request with the app. Take an empty text block from the Text section of the blocks menu and place it in the slot at the end of the set web1 blocks we just placed. Now we need to enter in the url that we just typed in our browser to turn the light on or off into the text blocks we just placed.</p>
<p dir="auto"><img src="/assets/uploads/files/1551229828284-screen-shot-2019-02-26-at-13.29.07-resized.png" alt="0_1551229827068_Screen Shot 2019-02-26 at 13.29.07.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">The result should look something like the following image. Remember the IP address of your device will be different to mine, so remember to double check that the IP address on the screen of your M5 is the same as what you entered in the block.</p>
<p dir="auto"><img src="/assets/uploads/files/1551229889160-screen-shot-2019-02-26-at-13.33.52-resized.png" alt="0_1551229887876_Screen Shot 2019-02-26 at 13.33.52.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Lastly we need to add the “call web1 .get” blocks from the web blocks and add them below the http request.</p>
<p dir="auto"><img src="/assets/uploads/files/1551229959955-screen-shot-2019-02-26-at-13.35.21-resized.png" alt="0_1551229957528_Screen Shot 2019-02-26 at 13.35.21.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Now our app is finished and we can test it by clicking on connect choosing the ai companion option and scan the qr code.</p>
<p dir="auto"><img src="/assets/uploads/files/1551230029785-screen-shot-2019-02-26-at-13.38.14.png" alt="0_1551230028850_Screen Shot 2019-02-26 at 13.38.14.png" class=" img-fluid img-markdown" /><br />
<img src="/assets/uploads/files/1551230043017-screen-shot-2019-02-26-at-13.38.24.png" alt="0_1551230042425_Screen Shot 2019-02-26 at 13.38.24.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Hope you enjoyed this tutorial. Show us what M5 apps you create.</p>
]]></description><link>https://community.m5stack.com/topic/712/m5stack-with-mit-app-inventor-easy-mobile-app-creation-for-your-m5stack</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 14:13:07 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/712.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 27 Feb 2019 01:14:50 GMT</pubDate><ttl>60</ttl></channel></rss>