Read GPS data from thingspeak and show it in the Google map using ESP12e Nodemcu and GPS Neo 6M Module

Showing Thingspeak GPS data in Google Maps using Javascript and HTML

Introduction

In previous tutorial, we succesfully uploaded the data from Neo 6M GPS Module using ESP12E Node MCU module on the thingspeak server. In this tutorial, we are going to get the json data from the thingspeak server and parse it using HMTL and javascript to show it in Google Maps along with a marker. I hope that you already have a google or gmail account. Follow the below steps to get the Google Maps API key which will be used in our code to get the json data and show it in the marker on Google Maps.

  1. Goto https://developers.google.com/maps/documentation/javascript/get-api-key and click on "Get A Key" on the top right corner as shown in the below image.
Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (1)

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (1)

2. Now Click on "Select or Create Project" in the dialog box which appears after clicking on "Get A Key" as shown below.

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (2)

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (2)

 

3. Select the "Create a new project" from the list as shown below.

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (3)

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (3)

4. Give a name to your project and click on "Enable API"

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (4)

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (4)

5. Now you will get an API Key in a text box. Click on "copy clipboard" icon (the file on file icon) and hit "Finish". You now have Google Maps API key which you can use in your HTML code to show map.

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (5)

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (5)

6. Now copy and paste the following file in notepad++ and save it as "index.html".

7. Now replace the following credentials:
1. Your copied, google api key
2. Your Thingspeak Read API key
3. Your Thingspeak Read API Key
4. Your Thingspeak Channel ID
5. Your Thingspeak Channel ID

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (6)

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (6)

8. Now double click on your webpage "index.html" and wait for some time. It will take some time to load the map and marker. If you have done everything right, then you will get the following output.(blurred my location because I don't want any stalker 😀 )

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (7)

Showing-Thingspeak-GPS-data-in-Google-Maps-using-Javascript-and-HTML (7)

And here is the final output video:

Hope you like my tutorials. Please subscribe to my youtube channel for more cool tutorials.

https://www.youtube.com/channel/UCduc9YE9oZlw36YmTQ6rDEQ

 

Please login to get access to the quiz
Programming ESP12E NodeMCU Module to upload GPS data on Thingspeak (Prev Lesson)
Back to Read GPS data from thingspeak and show it in the Google map using ESP12e Nodemcu and GPS Neo 6M Module

Comments ( 30 )

  • Sha

    How do i show alarm event . I want the marker to indicate alarm occurred on the map. Eg. flood at X location which sensor gave 1 as alarm value and 0 for no alarm

    • On thingspeak, you can define ‘react’. Where if the channel meets certain condition, then it will send an sms, call or tweet. Check out ‘React’ on thingspeak

  • Freddie Snijman

    Thank you! Excellent, working just fine!

    • I am glad that it worked for you. Please share this website with your friends. 🙂

  • Ayesha Hanif

    Hell sir,hru
    sir how can we get gps data from things peaks and show it on our webpage as well as how can we store it in our web database?

    • Ayesha, you can use firebase to do that. You can use firebase to save the web database. Or you can use Mongodb along with nodejs to store the the data locally on your computer first and then update it in thingspeak.

  • Ayesha Hanif

    please guide me.waiting for your positive response.

    • Check my response to previous question you asked. Hope it helps.

  • PRANEET KUMAR

    in connecting gps to nodemcu you connected rx to 13 & tx to 12 but in programming you assigned rx to 12 & tx to 13 …

  • Sarang

    Not getting any value from ThingSpeak, in variable x and y

  • Vasan

    Thank you Vivek. This is awesome.

  • Vinod Kolte

    Sir,
    html page is not opening,
    data is generating on thingspeak channel but html page not loading map\
    so what should i do??

  • Chetan

    Is there any way through which we can group lat ,long values and plot it against another parameter?

    • Yes, simply change the field using which you want to plot it against.

  • Muhammad Ega

    Hello vivek, I have a problem on my GPS, what is happening and what is the solution if my serial monitor showing invalid time? thanks in advance

    • Can you post what it is printing in serial monitor?

  • Wan

    this used to work but it doesnt work anymore. I am so frustated because I dont know how to fix it

    • Check if you google api key is still valid or not.

  • Diab

    Hi Vivek.
    Congratulations for this great job..
    I followed your instructions, the part related to Thinspeak is working fine but the html page is shown as a text in my web browser and not as a web page.
    Is there a way to change this in the code itself which copied from your site?
    Thanks.

  • Teddy

    help me, i got this on serial monitor
    INVALID Date/Time: 0/0/2000 00:00:00.00

    • Hi Teddy,
      Its problem with your GPS not programming. Sometimes GPS don’t work indoors or even outdoors at other locations. What I would recommend you is try to switch place probably at your friends place and see again the output.

  • Teddy

    Update: Now I got this on serial monitor
    INVALID Date/Time: 6/25/2018 02:39:45.00

    • Hi Teddy,
      Its problem with your GPS not programming. Sometimes GPS don’t work indoors or even outdoors at other locations. What I would recommend you is try to switch place probably at your friends place and see again the output.

    • You need to sign in into developer account to get logged in. Also hit on get started and follow the screens.

Post a Reply