Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
lukasmaximus89
Published © MIT

M5Stack and MIT App Inventor

Make cool App controllable projects with ease by combining M5Stack, Tuniot and MIT App inventor.

IntermediateFull instructions provided2 hours6,954
M5Stack and MIT App Inventor

Things used in this project

Hardware components

ESP32 Basic Core IoT Development Kit
M5Stack ESP32 Basic Core IoT Development Kit
This project is possible with any of the M5Stack core devices
×1

Software apps and online services

MIT App Inventor 2
MIT App Inventor 2
Arduino IDE
Arduino IDE

Story

Read more

Schematics

led with core

Code

Example

Arduino
/////////////////////////////////
// Generated with a lot of love//
// with TUNIOT FOR ESP32     //
// Website: Easycoding.tn      //
/////////////////////////////////
#include <WiFi.h>
#include <M5Stack.h>

String  ClientRequest;
WiFiServer server(80);

WiFiClient client;

String myresultat;

String ReadIncomingRequest(){
while(client.available()) {
ClientRequest = (client.readStringUntil('\r'));
 if ((ClientRequest.indexOf("HTTP/1.1")>0)&&(ClientRequest.indexOf("/favicon.ico")<0)){
myresultat = ClientRequest;
}
}
return myresultat;
}

void setup()
{
  M5.begin();
ClientRequest = "";

pinMode(26, OUTPUT);
pinMode(36, INPUT);
digitalWrite(17,LOW);
  WiFi.disconnect();
  delay(3000);
  M5.Lcd.println("START");
  WiFi.begin("yourwifinamehere","yourpasswordhere");
  while ((!(WiFi.status() == WL_CONNECTED))){
    delay(300);
    M5.Lcd.println("..");

  }
  M5.Lcd.println("Connected");
  M5.Lcd.println("Your IP is");
  M5.Lcd.println((WiFi.localIP()));
  server.begin();

}


void loop()
{
    client = server.available();
    if (!client) { return; }
    while(!client.available()){  delay(1); }
    ClientRequest = (ReadIncomingRequest());
    ClientRequest.remove(0, 5);
    ClientRequest.remove(ClientRequest.length()-9,9);
    if (ClientRequest == "off") {
      digitalWrite(26,LOW);

    }
       if (ClientRequest == "on") {
      digitalWrite(26,HIGH);
    }
    
    M5.Lcd.println(ClientRequest);
    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("");
    client.println("<!DOCTYPE HTML>");
    client.println("<html>");
    client.println(analogRead(36));
    client.println("</html>");
    client.stop();
    delay(1);
    client.flush();

}

Credits

lukasmaximus89

lukasmaximus89

38 projects • 34 followers
I'm Luke from Manchester, UK. I've been living in shenzhen for 6 years. I do 3D design, Basic Electronics, Casting and other cool stuff.

Comments