Chuyển tới nội dung
Home » Mit App Inventor Arduino Wifi | Arduino Uno Wifi Firmware Updater

Mit App Inventor Arduino Wifi | Arduino Uno Wifi Firmware Updater

How to Build an Android App to Control Your WiFi Enabled Arduino



The Arduino UNO WiFi can be powered via the USB connection or with an external power supply. The power source is selected automatically.External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board’s power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector.

The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

The power pins are as follows:

  • VIN. The input voltage to the Arduino board when it’s using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.
  • 5V. This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 – 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don’t advise it.
  • 3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 1 A (according to the power input source).
  • GND. Ground pins.
  • IOREF. This pin on the Arduino board provides the voltage reference with which the microcontroller operates. A properly configured shield can read the IOREF pin voltage and select the appropriate power source or enable voltage translators on the outputs for working with the 5V or 3.3V supplies.


The ATmega328 has 32 KB Flash (with 0.5 KB used for the bootloader). It also has 2 KB of SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).

Input and Output

Each of the 14 digital pins on the UNO can be used as an input or output, using pinMode(), digitalWrite() and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have specialised functions:

  • Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.
  • External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.
  • PWM: 3, 5, 6, 9, 10 and 11. Provide 8-bit PWM output with the analogWrite() function.
  • SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library.
  • LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it’s off. The UNO has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function. Additionally, some pins have specialized functionality:
  • TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library. NOTE: the A4 or SDA pin and A5 or SCL pin are in use by the IO Expander SC16IS750IBS. There are a couple of other pins on the board:
  • AREF. Reference voltage for the analog inputs. Used with analogReference().
  • RESET. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.


The Arduino UNO WiFi has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels this serial communication over USB and appears as a virtual com port to software on the computer. The 16U2 firmware uses the standard USB COM drivers, and no external driver is needed. However, on Windows, a .inf file is required. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the USB-to-serial chip and USB connection to the computer (but not for serial communication on pins 0 and 1).

A SoftwareSerial library allows for serial communication on any of the UNO’s digital pins.

The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of the I2C bus; For SPI communication, use the SPI library.

On the Arduino UNO WiFi there’s a SC16IS750IBS IO Expander Single UART with I2C-bus/SPI interface that allows the communication between AtMega 16u2, AtMega 328p and the ESP8266EX.

The Arduino UNO WiFi allow you to communicate via Wi-Fi with your sensors or actuators mounted on your board to create easily and quickly your IoT System. You can use your Arduino UNO WiFi as a client of your Wi-Fi network, as a server to connect other client devices or you can create an ad’hoc Wi-Fi connection.

The perfect way to communicate to internet via your Arduino UNO WiFi is the Ciao Library and using, for example, the REST connector.

On the Arduino UNO WiFi is pre-uploaded the RestServer sketch that allows you to command immediately your board via browser:

Connect to the Arduino UNO WiFi SSID and go to the link to turn ON the LED L

Here other possible commands:

  • “/arduino/digital/13” -> digitalRead(13)
  • “/arduino/digital/13/1” -> digitalWrite(13, HIGH)
  • “/arduino/analog/2/123” -> analogWrite(2, 123)
  • “/arduino/analog/2” -> analogRead(2)
  • “/arduino/mode/13/input” -> pinMode(13, INPUT)
  • “/arduino/mode/13/output” -> pinMode(13, OUTPUT)


The Arduino UNO WiFi can be programmed as a classic Arduino UNO with the Arduino software (download). Select “Arduino UNO WiFi from the Tools > Board menu (according to the microcontroller on your board.

The new features of the Arduino UNO WiFi allow you to upload your sketch via Wi-Fi (in the same way of Arduino Yun), without any wired connection to your PC and your board.

The ATmega328 on the Arduino UNO WiFi comes pre-burned with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. It communicates using the original STK500 protocol.

You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit Serial Programming) header using Arduino ISP or similar.

Automatic (Software) Reset

Rather than requiring a physical press of the reset button before an upload, the Arduino UNO WiFi is designed in a way that allows it to be reset by software running on a connected computer. One of the hardware flow control lines (DTR) of the ATmega8U2/16U2 is connected to the reset line of the ATmega328 via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the Arduino environment. This means that the bootloader can have a shorter timeout, as the lowering of DTR can be well-coordinated with the start of the upload.

This setup has other implications. When the UNO WiFi is connected to either a computer running Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the following half-second or so, the bootloader is running on the UNO. While it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the board after a connection is opened. If a sketch running on the board receives one-time configuration or other data when it first starts, make sure that the software with which it communicates waits a second after opening the connection and before sending this data.

The UNO WiFi contains a trace that can be cut to disable the auto-reset. The pads on either side of the trace can be soldered together to re-enable it. It’s labeled “RESET-EN”. You may also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line.

USB Overcurrent Protection

The Arduino UNO WiFi has a resettable polyfuse that protects your computer’s USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.

Physical Characteristics

The maximum length and width of the UNO WiFi PCB are 2.7 and 2.1 inches respectively, with the USB connector and power jack extending beyond the former dimension. Four screw holes allow the board to be attached to a surface or case. Note that the distance between digital pins 7 and 8 is 160 mil (0.16″), not an even multiple of the 100 mil spacing of the other pins.



const char* ssid = “Phamson”; const char* password = “phamtheson”; WiFiServer server(80); void setup() { Serial.begin(115200); //Default Baud Rate for NodeMCU delay(10); pinMode(2, OUTPUT); // Connect Relay to NodeMCU’s D4 Pin digitalWrite(2, 0); // Connect to WiFi network Serial.println(); Serial.println(); Serial.print(“Connecting to “); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print(“.”); } Serial.println(“”); Serial.println(“WiFi connected”); // Start the server server.begin(); Serial.println(“Server started”); // Print the IP address Serial.println(WiFi.localIP()); } void loop() { // Check if a client has connected WiFiClient client = server.available(); if (!client) { return; } // Wait until the client sends some data Serial.println(“new client”); while(!client.available()){ delay(1); } String req = client.readStringUntil(‘\r’); Serial.println(req); client.flush(); int val; if (req.indexOf(“/gpio/0”) != -1) val = 0; else if (req.indexOf(“/gpio/1”) != -1) val = 1; else { Serial.println(“invalid request”); client.stop(); return; } // Set GPIO2 according to the request digitalWrite(2, val); client.flush(); String s = “HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n


\r\nGPIO is now “; s += (val)?”high”:”low”; s += ”

“; }

Hey guys, I need to create an app by app inventor. It should be able to receive strings from Arduino via ESP8266.
I need an app inventor extension of the WiFi module.
I have seen so many module of Bluetooth or wifi module that can only send messages to Arduino.

So I need an extension that can receive data from Arduino via WiFi module.
Any idea? Thank you very much!

My extension works with TCP/IP. I can’t tell if it works with your WIFI card.
If you are going to connect to the Arduino from time to time, and use your phone for other tasks as well, then I think it’s better to let the Arduino be the server and your phone be a client. Then use polling as suggested before. This will be easier to implement.

Dear @Junrong_Huang,
I’m struggling since a couple of days with a problem similar to yours.
Behind the scene: => I wanted to make something like a home automation/antitheft system on my own.
I have then bought 3 NODEMCU8266 and some PIR sensors (Arduino compatibles).
The aim is to have a PAD (or phone) with an AI2 application to behave as the “controller” of the various NODEMCU’s in a totally local WiFi network, without any router (therefore no remote control via WEB).
.I’ve then decided to have a structure like:
1 NODEMCU (#1) acting as a soft Access Point in Server configuration. It acquires the PIR and drives two relays (when it receives the command by each of the other two NODEMCU’s).
2 NODEMCU’s (#2 and #3) acting as Stations (STA) in Client configuration, Every 5 seconds they send a relay ON/OFF request to the AP, just to see whether they are alive and connected.
1 PAD (Lenovo M8 Android 9) in Client configuration, acting as User Interface or Controller. It can send a relay ON/OFF command by hitting on two buttons (of the PAD screen). On the screen are also shown the HTML strings as they come from the AP. No extensions used, just blocks.
With my configuration, in which the PAD (phone) is a client, I found that the “easy” way to receive messages from the server, is to set a periodical clock (i.e. 250 ms) on the PAD, so the PAD can ask the server if there are any news (like it was sent unsolicited by the server: see [(@rkl099) Rolf’s answer].
In other words, by means of a 250 ms clock, the PAD (phone) asks the server to respond with some updates. If the server has some news to transmit to the client, it sends this new information, else, it sends the string “nothing to say”. As soon as the string is received by the PAD, the app parses it, and decides consequently (i.e. “nothing to say” = no actions ).
The .aia and the .ino files that you find attached are really far from being “ready to use” but, anyway, they are working in my configuration, as described above and I guess they can be a good base that you can elaborate to get your needs Auto_Home_04 _1.aia (103.0 KB) ESP_8266_base.ino (8.1 KB)

EDIT: removed yesterday’s Client .ino. Replaced with a commented one:

I know you are at the experimental stage but it is best to not have any unused cables near the Arduino and no cables should be near the module other than the ones connected to it. ESP-01S ESP8266 Module should work just fine, make sure it’s in good condition -check for hairline cracks with a magnifying glass and test the cabling for continuity. Need to be sure you start with a good base

Open the Google Play store or Apple App store on your phone or tablet, or use the buttons below to open the corresponding page:

After downloading, step through the instructions to install the Companion app on your device. You need to install the MIT App Inventor Companion app only once, and then you can leave it on your phone or tablet for whenever you use App Inventor. Note: There are some differences between the Android and iOS versions. Please review this page for more details.

Alternatively, you can scan the following QR codes to get either the iOS or Android app:

For iOS, scan this code to go to the Companion app on the Apple App Store.

For Android, scan this code to download the Android .APK file for the Companion app directly to your device. (Using an .APK file requires sideloading the app on your device and updating the app manually in the future.)

App Inventor will automatically show you the app you are building, but only if your computer (running App Inventor) and your device (running the Companion) are connected to the same Wi-Fi network. See a more detailed explanation of this here.

Go to App Inventor and open a project (or create a new one — use Project > Start New Project and give your project a name).

Then Choose “Connect” and “AI Companion” from the top menu in your browser:

A dialog with a QR code will appear on your PC screen. On your device, launch the MIT App Companion app just as you would do any app. Then click the “Scan QR code” button on the Companion, and scan the code in the App Inventor window:

Within a few seconds, you should see the app you are building on your device. It will update as you make changes to your design and blocks, a feature called “live testing.”

If you have trouble scanning the QR code or your device does not have a scanner, type the code shown on the computer into the Companion’s text area on your device exactly as shown. The code is directly below where the screen on your PC shows “Your code is” and consists of six characters. Type the six characters and choose the orange “Connect with code.” Do not type an Enter or carriage return: type just the six characters followed by pressing the orange button.

If your app does not appear on your device, the most likely problems are:

Arduino Uno WiFi

The UNO WiFi board is the Arduino UNO with integrated Wi-Fi

Note: This page refers to a product that is retired. Check out the Arduino UNO WiFi Rev2

The Arduino UNO WiFi is the same as a Arduino UNO Rev3 but with an integrated Wi-Fi module! The board is based on the ATmega328P with an ESP8266 Wi-Fi Module integrated (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with an AC-to-DC adapter or battery to get started.

The ESP8266 Wi-Fi Module is a self contained SoC with integrated TCP/IP protocol stack that can give access to your Wi-Fi network. (Or the device can act as an access point.) One useful feature of UNO WiFi is support for OTA (over-the-air) programming, either for transfer of Arduino sketches or Wi-Fi firmware.

How to Build an Android App to Control Your WiFi Enabled Arduino
How to Build an Android App to Control Your WiFi Enabled Arduino

Sơ đồ đấu nối

Các linh kiện cần thiết cho dự án

Tên linh kiện Số lượng Shopee
NodeMCU ESP8266 Mua ngay
Dây cắm (Cái – Cái) Mua ngay
Module Relay 5V Mua ngay

Tạo App Android bằng MIT APP INVENTOR

Để có thể tạo một App Android bằng MIT app inventor chúng truy cập vào link để tạo dự án nhé:

Bước đầu tiên các bạn Click vào Projects chọn “Start new project” để tạo một dự án mới.

Tiếp theo chúng ta cần đặt tên cho dự án.

Ở bên tay trái màn mình các bạn, chúng ta Click vào Button dùng để bật tắt thiết bị. Ở đây mình sẽ chọn 2 nút và đặt là “ON” và “OFF”.

Để có thể chỉnh sửa các thông số của Button các bạn Click vào và nó sẽ xổ ra các trường thông tin. Ở đây các bạn có thể đặt lại tên cho Button ở phần Text …

Tiếp theo, các bạn chọn mục Connectivity và cho Web và kéo thả vào Viewer nhé.

Sau khi đã cấu hình cho các Button và Web ta chọn vào Block để chuyển qua lập trình kéo thả Block.

Click vào “Button 1” chọn phần mà mình đã khoanh đỏ và kéo chúng vào vùng lập trình.

Tiếp tục, ta chọn “Web1” và kéo Block đã được đánh dấu. Ở phần này chúng ta sẽ cấu hình địa chỉ IP Web.

Chọn mục “Text” kéo block được khoanh đỏ vào vùng lập trình.

Tiếp theo ở mục Web1 chọn Block “Call Web.Get”.

Để biết được địa chỉ IP của NodeMCU ESP8266 ta cần nạp Code và bật Monitor lên xem nhé. Code mình để cuối bài viết các bạn tải về và

thực hiện nhé. Ở đây địa chỉ IP của mình là:


Các bạn kéo thả các Block lại với nhau giống như trên màn hình nhé.

Để có thể tải dự án về điện thoại, các bạn vào mục Build chọn App (project QR code for apk).

Quét mã QR code xuất hiện trên màn hình. Và các bạn tiến hành cài đặt App vào điện thoại nhé.

Như vậy là đã xong các bạn có thể điều khiển bật tắt thiết bị trên App điện thoại rồi.

How to Make a Simple App--[NodeMCU-ESP8266] -PART1
How to Make a Simple App–[NodeMCU-ESP8266] -PART1

Arduino UNO WiFi firmware updater

This tutorial will guide you in the process of updating the firmware of your Arduino UNO WiFi board.


Connect the board at the USB port of your computer ready with Arduino Software (IDE) 1.8.0 or later.

UNO WiFi Firmware updater procedure

To simplify the process, we have prepared a tool – UNO WiFi FirmwareUpdater – available in Arduino IDE 1.8.0 or later.

Follow these steps to enable this tools into Arduino software:

  • Download the tool here.
  • Create a folder called tools into the sketchbook directory (normally in Documents>Arduino).
  • Extract it.


  • Launch the Arduino IDE (1.8.0 or later).
  • Connect the board to PC.
  • Select the Arduino UNO WiFi as board in the Tools>Board menu.
  • Select the corresponding serial port in the Tools>Port menu.
  • Upload the ESP Recovery sketch. It is into the UNOWiFiDev.Edition Library. Download it from Library Manager.

1/\*ESP Recovery sketch\*/2#include


45#define BAUD 96006WifiData ESPSerial;78void setup()9{10Serial.begin(BAUD);11pinMode(13, OUTPUT);12digitalWrite(13, LOW);1314ESPSerial.begin(BAUD);15}1617void loop()18{19while (Serial.available()) {20char inChar = (char);21ESPSerial.write(inChar);22}2324while (ESPSerial.available()) {25char inChar = (char);26Serial.write(inChar);27}2829}

  • Put the board in DFU mode, keeping pressed the ESP B/L button and connect the board to PC
  • Select the UnoWiFi Firmware Updater from the Tools menu.
  • Click on Refresh list if the port is not listed.
  • Select the corresponding port.
  • Click on Test connection.
  • Select from windows menu the ESP firmware requested.
  • Click on Update Firmware.
  • Wait the end of process.

Warning: The process could last several minutes.

Suggested changes

The content on is facilitated through a public GitHub repository. You can read more on how to contribute in the contribution policy.


The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.

I am trying to use the app inventor with an iPhone and and Arduino. I used code I learned in a workshop for Android phones and it doesn’t work with the iPhone.

A recent post gave this as an answer to the same question, but I don’t understand how to use the answer: “Use ElementsFromString property in the designer rather than the ListData property.”

Are there any tutorials you can suggest to help me use it with the iPhone and Arduino?

Welcome Elene.

The Android users use Bluetooth to communicate with an Arduino . I don’t think an ios version of App Inventor can do that yet. Android users use extensions to accomplish that goal. The ios version of App Inventor currently cannot use extensions.

Some users use the Web component to talk to their arduinos. See Search results for ‘arduino Web ‘ – MIT App Inventor Community.

Is this using App Inventor Blocks?

Ultimately it will depend on the Arduino you are using. At the moment, App Inventor for iOS does not have the BluetoothClient, BluetoothLE (currently an extension), or Serial components implemented, which are common ways to connect to Arduinos. If you have an Arduino Yun (or another Wifi shield), you should be able to use the Web component to communicate with it.

Of the three unavailable connection methods, BluetoothLE is the mostly likely to be implemented in the short term as we are producing new curricula around BluetoothLE and the micro:bit, and we want to ensure that this will be a good experience for both Android and iOS users.

1 Like

Yes. They used the app inventor with the HM-10 Bluetooth module, the Arduino Uno, and an android phone.

Does this mean that the App inventor will work with the HM-10 Bluetooth module, Arduino uno and iPhones in the future?

I would need to see an example project to better assess that.

MIT App Inventor is an intuitive, visual programming environment that allows everyone even children to build fully functional apps for smartphones and tablets. Those new to MIT App Inventor can have a simple first app up and running in less than 30 minutes. And what’s more, our blocks-based tool facilitates the creation of complex, high-impact apps in significantly less time than traditional programming environments. The MIT App Inventor project seeks to democratize software development by empowering all people, especially young people, to move from technology consumption to technology creation.

A small team of CSAIL staff and students, led by Professor Hal Abelson, forms the nucleus of an international movement of inventors. In addition to leading educational outreach around MIT App Inventor and conducting research on its impacts, this core team maintains the free online app development environment that serves more than 6 million registered users.

Blocks-based coding programs inspire intellectual and creative empowerment. MIT App Inventor goes beyond this to provide real empowerment for kids to make a difference — a way to achieve social impact of immeasurable value to their communities. In fact, App Inventors in school and outside of traditional educational settings have come together and done just that:

With over 400,000 unique monthly active users who come from 195 countries who have created almost 22 million apps, MIT App Inventor is changing the way the world creates apps and the way that kids learn about computing.

Hi all and thanks in advance to everyone who can interest about my aim.

My tools: I have created an app with appinventor that, connecting to the wifi created by the access point of the Arduino controller, is able to work as a remote controller. Indeed with the app I can set the work condition of a servo. The Arduino controller uses the WiFi.h Library and save the output of some variables in the SD in this format: #,#,#,#,#….. with n=20 and with a baud rate of 57600.

My aim: I would like to avoid the Sd card and to send, directly and with no latency, the same output in somelike a cloud or a file.txt or a page or a google sheets…everything (not arduino iot cloud where I need to pay in order to have some upgrade).

My desire: I would like to store as so much possible using only the App and the controller

My question: Do you have some direct examples about this request? Some specific documentation?

Thank You again.

For my program my Arduino needs to connect to the Wi-Fi and we do this by inputting the username and password in the code. Is there any way to have the user enter the password and choose the wifi in the app itself?

Use variables, text boxes and TinyDb for data entry.

1 Like

you might want to try the wifi manager extension


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

5 posts were split to a new topic: Connect method of WiFi extension not working anymore on Android 10

Juan A. Villalpando
Version del módulo 9.2.4
Velocidad 9600
Carga el programa. Ve al Serial Monitor.
Escribe en un navegador
Pulsa los botones para encender o apagar el LED13 del Arduino.

#define DEBUG true
SoftwareSerial esp8266(3,2);
// El TX del módulo al terminal 3 del Arduino.
// El RX del módulo al terminal 2 del Arduino.
void setup()
esp8266.begin(9600); // Importante la velocidad del módulo.
sendData(“AT+RST\r\n”,2000,DEBUG); // Borra la configuración que tenía el módulo
sendData(“AT+CWJAP=\”Nombre_de_tu_WiFi\”,\”Clave_de_tu_WiFi\”\r\n”, 2000, DEBUG);
delay(5000); // Espera un poco que conecte con el Router.
sendData(“AT+CWMODE=3\r\n”,1000,DEBUG); // Modo de cliente y servidor.
sendData(“AT+CIFSR\r\n”,1000,DEBUG); // En el Serial Monitor aparece la IP de cliente y servidor.
sendData(“AT+CIPMUX=1\r\n”,1000,DEBUG); // Multiples conexiones.
sendData(“AT+CIPSERVER=1,80\r\n”,1000,DEBUG); // El Puerto web es el 80
void loop(){
if(esp8266.available()) // Consulta si el módulo está enviando algún mensaje
int connectionId =;
// Aquí las construcción de la PAGINA WEB.
String webpage = “HTTP/1.1 200 OK\r\n Content-Type: text/html\r\n\r\n\r\n”;
webpage += ”


webpage += ”

webpage += ”

webpage += ”

webpage += ”

String cipSend = “AT+CIPSEND=”;
cipSend += connectionId;
cipSend += “,”;
cipSend +=webpage.length();
cipSend +=”\r\n”;
// Lee el pin 13
int pin13 = digitalRead(13);
// Retorno de la lectura.
String retorno = “HTTP/1.1 200 OK\r\n Content-Type: text/html\r\n\r\n\r\n”;
if (pin13 == 1) {retorno += ” ON – Encendido”;}
if (pin13 == 0) {retorno += ” OFF – Apagado”;}
// ResponseCode App Inventor
cipSend = “AT+CIPSEND=”;
cipSend += connectionId;
cipSend += “,”;
cipSend += retorno.length();
cipSend +=”\r\n”;
// Cierra la conexión
String closeCommand = “AT+CIPCLOSE=”;
// Función para Enviar datos al Servidor.
String sendData(String command, const int timeout, boolean debug){
String response = “”;
esp8266.print(command); // Envía la información de command al servidor
long int time = millis();
while( (time+timeout) > millis())
// A response van los datos que regresan al servidor.
char c =; // Va leyendo caracter a caracter.
// Consulta si en la información que regresa al servidor
// viene “GET /enci” o “GET /apag”
// Encenderá o apagará el LED13 del Arduino
if(response.indexOf(“GET /enci”) >0){
// Serial.print(“enciende”);
if(response.indexOf(“GET /apag”) >0){
return response;

// Juan A. Villalpando

SoftwareSerial esp8266(3,2);
// El TX del módulo al terminal 3 del Arduino.
// El RX del módulo al terminal 2 del Arduino.
int random_1 = 10;
int random_2 = 50;
String random_out = “0,0”;
String input_data = “”;
String fin = “”;
void setup(){
sendData(“AT+RST\r\n”,2000); // Borra la configuración que tenía el módulo
sendData(“AT+CWJAP=\”Nombre_de_tu_WiFi\”,\”Clave_de_tu_WiFi\”\r\n”, 2000);
delay(10000); // Espera un poco que conecte con el Router.
sendData(“AT+CWMODE=1\r\n”,1000); // Modo de cliente del Router.
sendData(“AT+CIFSR\r\n”,1000); // En el Serial Monitor aparece la IP del Servidor Web.
sendData(“AT+CIPMUX=1\r\n”,1000); // Multiples conexiones.
sendData(“AT+CIPSERVER=1,80\r\n”,1000); // Crea Servidor Web, puerto 80
void loop(){
char c =;
input_data += c;
if(input_data.indexOf(“genera”) > 0){
random_1 = random(10,50);
random_2 = random(50,99);
random_out = (String) random_1 + “,” + (String) random_2;
input_data = “”;
fin = “finalizado”;
// Return responseContent
if(fin == “finalizado”){
String header = “HTTP/1.1 200 OK\r\n Content-Type: text/html; \r\n”;
header += “Content-Length: “;
header += random_out.length();
header += “\r\nConnection: close\r\n\r\n”;
header += random_out;
sendData(“AT+CIPSEND=” + String(0) + “,” + header.length() + “\r\n”, 500);
// sendData (“AT+CIPCLOSE=” + String(0) + “\r\n”, 1000);
fin = “”;
// Envia datos al servidor y recibe la respuesta de los AT.
String sendData(String command, const int timeout){
String response = “”;
esp8266.print(command); // Envía la información de command al servidor
long int time = millis();
while( (time+timeout) > millis()){
// A response van los datos que regresan al servidor.
char c =; // Va leyendo caracter a caracter.
return response; // Devuelve la respuesta del AT

It took me a while to figure out how the web server “knew” to work off IP address, but then I saw it in the COM24 log as the result of the AT+CIFSR command, and I imagine you read that output to get the IP address hard coded into the AI2 app.

Now we are going to carry out the previous example but we will create an Access Point (SoftAP – Soft Access Point), that is, the module will create a network independent from the Router, it will not be connected to the Router.

The code will create a network called ESP_81411C and the Web Server will have as IP:

For this we will change these lines…

void setup(){
sendData(“AT+RST\r\n”,2000); // Borra la configuración que tenía el módulo
// sendData(“AT+CWJAP=\”Nombre_de_tu_WiFi\”,\”Clave_de_tu_WiFi\”\r\n”, 2000);
// delay(10000); // Espera un poco que conecte con el Router.
sendData(“AT+CWMODE=2\r\n”,1000); // NOW IS A SOFT ACCESS POINT, MODE = 2
sendData(“AT+CIFSR\r\n”,1000); // En el Serial Monitor aparece la IP del Servidor Web. (
sendData(“AT+CIPMUX=1\r\n”,1000); // Multiples conexiones.
sendData(“AT+CIPSERVER=1,80\r\n”,1000); // Crea Servidor Web, puerto 80

We must change the IP in the code…

It is also convenient to install the application, since we are going to change the network and the MIT Companion will be in the Router’s network.

Once the application is installed, we go to the WiFi configuration and establish the ESP_81411C network

It is not necessary to put a Password since in this default configuration it does not have it.

If we wanted to change the name of the network and put a password on it, we would put this line:

3.- Remove the Serial Monitor, in case you have it open.

4.- We load this sketch in the IDE and upload it…

It is convenient from time to time to remove the power from the ESP8266 and put it back if it does not load well.


* This sketch demonstrates how to set up a simple HTTP-like server.
* The server will set a GPIO pin depending on the request
* http://server_ip/gpio/0 will set the GPIO2 low,
* http://server_ip/gpio/1 will set the GPIO2 high
* server_ip is the IP address of the ESP8266 module, will be
* printed to Serial when the module is connected.

const char* ssid = “nombredemirouter”;
const char* password = “contraseñadelrouter”;
// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);
void setup() {
// prepare GPIO2
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
// Connect to WiFi network
Serial.print(“Connecting to “);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.println(“WiFi connected”);
// Start the server
Serial.println(“Server started”);
// Print the IP address
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
// Wait until the client sends some data
Serial.println(“new client”);
// Read the first line of the request
String req = client.readStringUntil(‘\r’);
// Match the request
int val;
if (req.indexOf(“/gpio/0”) != -1)
val = 0;
else if (req.indexOf(“/gpio/1”) != -1)
val = 1;
else {
Serial.println(“invalid request”);
// Set GPIO2 according to the request
digitalWrite(2, val);
// Prepare the response
String s = “HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n


\r\nGPIO is now “;
s += (val)?”high”:”low”;
s += ”

// Send the response to the client
Serial.println(“Client disonnected”);
// The client will actually be disconnected
// when the function returns and ‘client’ object is detroyed

5.- When there is upload, remove the GPIO 0 to GND cable and open the Serial Monitor. Restart.

6.- Once the sketch is loaded we can remove the Arduino, connect an LED to the GPIO2 and feed the module with 3.3V

If you don’t have a 3.3V power supply, you can use the Arduino to power the module, note that you don’t need RX or TX.

I saw several projects that integrate APP Inventor with Arduino,
unfortunately I only found projects where data from arduino sensors
are replicated on the mobile screen or actuators are turned on or off.

Would anyone know of an example where the mobile APP can pass a value
to an Arduino variable?

For example, turning on a lamp if the level of the photoresistor is
less than x, and the value of x is can be changed on the application
screen (typing the value or using a slider, etc.)

If you would like to have full control over ESP, send and read data. Also be able to control ESP remotely, e.g. from work, read about the MQTT protocol. There is a nice MQTT extension for appinvwntor and lots of libraries for arduino. There are also many free mqtt brokers (servers) available. You can also create your own server, e.g. using the android application. This way you can also control esp from e.g. the google assistant.

Here is English translated Wifi Led control project, But I am still trying to write correct code for Nodemcu
Also I will have to findout How to upload LEDWifi_ESP_BIJ_1Aia Project file here for community

I want to send temperature sensor data whenever a button named get temperature is pressed on app it should display the current temperature value. I am able to see new client request whenever I click the button and also Arduino serial print but it does not appear on the app text box… Please help


Most of the devices does not have the temperature sensor. See the documentation.

A sensor component that can measure the ambient (external) temperature. Most Android devices do not have this sensor.

They’re using an Arduino Temperature Sensor

Oh, I thought it is an Android sensor

This may help you:

Thanks @NishyanthKumarbut i m using Wifi instead of bluetooth … Here is the sample blocks which i want to use please ignore the cross marks as this is just an example. What i want to do is there is a button on my app which is getTemp when i press that button it sends new client request to esp8266 and whatever output in the form of text i get on serial monitor of arduino should get updated on the text box (temp) located just above the button.ill also provide sample arduino code here i have given constant temp example but it is a variable in my case and its changing


const char* ssid = “JioFi2_C4FFC1”;const char* password = “######”;WiFiServer server(80);

void setup() {Serial.begin(38400);

Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(100); //500 Serial.print("."); } Serial.println(""); Serial.println("Wifi Connected"); Serial.println("Server started "); Serial.println(WiFi.localIP());


}void loop() {string temp=38*cWiFiClient client = server.available();if (!client){return;}Serial.println(“new client”);while(!client.available()){delay(1);}String req = client.readStringUntil(‘\r’);Serial.println(req);

if (req.indexOf("/getTemp")!=-1) { client.println(temp); Serial.println(temp); } String web = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"; client.print(web); client.flush();

Ah, sorry. Didn’t see that.I’m not the best at Arduino (I don’t know C++), but @Juan_Antonio and @NissanCedric are the go-to people to ask in its terms inside of this Community.


Thanks @Juan_AntonioI have already gone through these two links but the problem with in my case is that I want to receive the text that obtained on serial monitor of Arduino but these 2 examples will send data from to esp device do I need to make any change in Arduino code or in app blocks to receive text from esp device to app using wifi.. … Please help

Here many examples with ESP32

Check your phone to see if its web browser can reach that 192.168… address.

You may need to switch from your cell service’s net access to local WiFi access to get there.

thanks for your support @Juan_Antonio I tried your example of analog read from potentiometer… but in my case it displays “Error1101: unable to connect to specific URL”i made the same program as like yours but to get temperature data in form of stringthe only difference here is :this is from your code-if (req.indexOf(“consulta”) != -1){valor = analogRead(Ent_Anilogica);valor_map = map(valor, 0, 4095, 0, 330);Serial.println(valor);}

this is from my code-if (req.indexOf(“/getTemp”)!=-1){client.println(temp);Serial.println(temp);}

I can’t understand why its not working please help.



@Juan_Antonio did but same error

@ABG checked but not working


const char* ssid = “XXXXXXX”;const char* password = “XXXXXXXXXXXX”;

String temperature = “34”;

WiFiServer server(80);

void setup() {Serial.begin(115200);

// Conecta a la red wifi.Serial.println();Serial.print(“Conectando con “);Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {delay(500);Serial.print(“.”);}Serial.println(“Conectado con WiFi.”);

// Inicio del Servidor web.server.begin();Serial.println(“Servidor web iniciado.”);

// Esta es la IPSerial.print(“Esta es la IP para conectar: “);Serial.print(“http://”);Serial.print(WiFi.localIP());}

void loop() {// Consulta si se ha conectado algún cliente.WiFiClient client = server.available();if (!client) {return;}

Serial.print(“Nuevo cliente: “);Serial.println(client.remoteIP());

// Espera hasta que el cliente envíe datos.while(!client.available()){ delay(1); }

/////////////////////////////////////////////////////// Lee la información enviada por el cliente.String req = client.readStringUntil(‘\r’);Serial.println(req);

// Realiza la petición del cliente.if (req.indexOf(“consulta”) != -1){temperature = String(random(1,100));Serial.println(temperature);delay(10);}

//////////////////////////////////////////////// Página WEB. ////////////////////////////client.println(“HTTP/1.1 200 OK”);client.println(“Content-Type: text/html”);client.println(“”); // Importante.


Serial.print(“Cliente desconectado: “);Serial.println(client.remoteIP());// client.flush();}

Here with a potentiometer:

@Sneha_Jangid did it work ?

Điều khiển thiết bị bằng MIT App Inventor sử dụng NodeMCU ESP8266

Trong nội dung bài viết hôm nay mình sẽ giới thiệu với các bạn một chủ đề mới cách có thể tạo một App Android trên MIT App Inventor một cách nhanh chóng mà không cần phải biết về lập trình nhiều.

Bài viết sẽ hướng dẫn các bạn cách tạo một App đơn giản và điều khiển các thiết bị trong gia đình thông qua NodeMCU ESP8266. Để có thể nắm rõ hơn các bạn có thể tìm đọc các bài viết liên quan đến dự án.

MIT APP INVENTOR 2 -nodemcu wifi car control app
MIT APP INVENTOR 2 -nodemcu wifi car control app

Tech Specs


Digital I/O Pins 20
PWM Output
Power Consumption 93 mA
PCB Size 53 x 68.5 mm
Weight 0.025 Kg
Product Code A000133

Arduino Microcontroller

Microcontroller ATmega328
Architecture Atmel AVR 8-bit
Operating Voltage 5 V
Flash memory 32 KB
Clock Speed 16 MHz
Analog I/O Pins
DC Current per I/O Pins 40 mA

Wi-Fi Microprocessor

Processor ESP8266
Architecture Tensilica Xtensa LX106
Operating Voltage 3.3 V
Flash Memory 4 MB
RAM 8 MB instruction, 12 MB data
Clock Speed 80 MHz
WiFi 802.11 b/g/n 2.4 GHz
Wake up time < 2 ms

Keywords searched by users: mit app inventor arduino wifi

See more here:

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *