Send string from MIT APP text box to ESP8266 and ArduinoMega

I am trying to read the data from a slider(values from 0 to 255), display it in the text box, and when i press a button to send that value to ESP8266 and Arduino Mega. With that value i want to light up a led with the intensity given by the value of the slider. For the ESP8266 i have just the small chip (

), and in the arduino code i manage to do a function and set up the ESP8266 "manualy" to say so.

This is my arduino code:

    void setup() 
        Serial.begin(9600);     // communication with the host computer
        Serial.println("Remember to to set Both NL & CR in the serial monitor.");
    void loop() 
        // listen for communication from the ESP8266 and then write it to the serial monitor
        if ( Serial1.available() )   {  Serial.write( );  }
        // listen for user input and send it to the ESP8266
        if ( Serial.available() )       {  Serial1.write( );  }

    void configESP(void){
                trimiteESP("AT+RST\r\n", 2000); // reset
                trimiteESP("AT+UART_DEF=9600,8,1,0,0\r\n",2000); //set baud rate at 9600
                trimiteESP("AT+CWMODE=2\r\n", 1000); // config as acces point
                trimiteESP("AT+CIFSR\r\n", 1000); // read IP adress
                trimiteESP("AT+CWSAP?\r\n", 2000); // read  SSID 
                trimiteESP("AT+CIPMUX=1\r\n", 1000); // allow multiple conexions
                trimiteESP("AT+CIPSERVER=1,80\r\n", 1000); // start server on port 80

    void trimiteESP(String command, const int timeout)
           String response = "";
           Serial1.print(command); // send command
           long int time = millis();
                 while ((time + timeout) > millis()) {
                 while (Serial1.available()) {
                      char c =; // read next char
                      response += c;

This is something i tried with the app builder:

-with the fisrt block a write the round value of the slider in the text box
-button 1 and 3 are things that i tried to send data to the ESP and arduino
-button 2 is just a delete text from textbox

Can somebody help, please? :slight_smile:

Can you link to the page where you found this arduino code and esp code?

Try in Button1

Library ESP8266

The arduino code is written by me.
The function trimiteESP is from my college.
The commands ar just from random sites, and i tried to give them an order. Same with the app builder.
This is the output of serial monitor:

With this output i know that the commands are sent correct.
The problem is that i cand send any data from my app to arduino...

I tried in button 1, it does nothing
I tried to get your library, and i did it this way:
-File - Preferences- Additional Boards Manager URLs: and then hit ok
-Sketch - include library - add .ZIP library - go to Arduino-master folder-libraries- click on ESP8266WiFi and then hit ok.
When i go to Sketch - include library and click on ESP8266WiFi it adds all this: image
If i try to compile my code it says that there is an "Error compiling for board Arduino Mega or Mega 2560"
If i delete all the libraries beside the on on line 3, wich is ESP8266WiFi its the same error
This is the error message:

And if i try to use some example it is incompatible:

  • This page is in Spanish.
  • Look example 8.
    8.- Presenta un página web ( con dos botones, con ellos podemos encender o apagar el LED13 del Arduino.

This is about turning the Arduino's LED13 on and off using the ESP8266-01 with a web page.

From App Inventor you can turn on the LED using the WebViewer component: