Connecting ESP8266 (NodeMCU) with Android app (MIT APP inventor) especially the longitude and latitude from a gps module

This is the value of latitude and longitude in my serial Arduino.


This is my example design in Mit App inventor

This is the blocks of my design in Mit app

Gps Code:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

static const int RXPin = 3, TXPin = 4;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup(){
  Serial.begin(9600);
  ss.begin(GPSBaud);
}

void loop(){
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0){
    gps.encode(ss.read());
    if (gps.location.isUpdated()){
      Serial.print("Latitude= "); 
      Serial.print(gps.location.lat(), 6);
      Serial.print(" Longitude= "); 
      Serial.println(gps.location.lng(), 6);
    }
  }
}

Nodemcu Esp8266 Code

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

const char* host = "GPS_NodeMCU";
const char* ssid = "GPS_BOT";

ESP8266WebServer server(80);

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


// Connecting WiFi

  WiFi.mode(WIFI_AP);
  WiFi.softAP(ssid);
// Starting WEB-server

     server.on ( "/", HTTP_handleRoot );
     server.onNotFound ( HTTP_handleRoot );
     server.begin();    

}

void loop() {
  server.handleClient();
   delay(50);
}

void HTTP_handleRoot(void) {

if( server.hasArg("State") ){
       Serial.println(server.arg("State"));
  }
  server.send ( 200, "text/html", "" );
}

How to send the value of latitude and longitude in my serial using Arduino to my android application created in Mit App. The connection is using nodemcu esp8266.

Is it Possible to do?. Sorry, I’m just a beginner in the Arduino :slight_smile: :slight_smile:

The AI2 can use any HTTP request, can use JSON data. On the ESP side it is depends on things.

This code makes the ESP8266 an Access Point.

Gateway IP = 192.168.4.1

It will supply your device with an IP of the form: 192.168.4.X

Every time you load, update the code to ESP8266, you must go to the Device Settings and set the WiFi network to: GPS_BOT

Enter a Browser (Chrome) on your device and type: 192.168.4.1
you will see Latitude and Longitude (random numbers)

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

const char* host = "GPS_NodeMCU";
const char* ssid = "GPS_BOT";
String latitude, longitude;

ESP8266WebServer server(80);

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


// Connecting WiFi

  WiFi.mode(WIFI_AP);
  WiFi.softAP(ssid);
// Starting WEB-server

 server.on ( "/", HTTP_handleRoot );
 server.onNotFound ( HTTP_handleRoot );
 server.begin();    
}

void loop() {
  server.handleClient();
   delay(50);
   latitude = "Latitud = " + (String) random(1,90);
   longitude = "Longitud = " + (String) random(-90,-1);
}

void HTTP_handleRoot(void) {
  server.send(200, "text/plain", latitude + "," + longitude);

if( server.hasArg("State") ){
   Serial.println(server.arg("State"));
  }
  server.send(200,"text/html","" );
}

App Inventor:
esp8266_lat_lot2

Install the application (Build) and in the device configuration set the network: GPS_BOT

More info:
https://groups.google.com/forum/#!topic/mitappinventortest/4meDrhidSvk