Map block formatting

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
User avatar
richardek
 
Posts: 8
Joined: Sun Mar 26, 2023 6:26 am

Map block formatting

Post by richardek »

Hi!
What is the correct formatting of latitude and longitude in the feed for the map block in dashboards? :)

Thank you!

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Map block formatting

Post by mikeysklar »

This bit might help the format:

https://cdn-learn.adafruit.com/download ... cs-gps.pdf
The Adafruit IO MQTT CSV feed topic expects data published in the following format:

Code: Select all

sensor_value,latitude,longitude,elevation
So if we were sending speed in MPH as our sensor value, the data would look like
this:

Code: Select all

23,39.283277, -76.611818,10

User avatar
richardek
 
Posts: 8
Joined: Sun Mar 26, 2023 6:26 am

Re: Map block formatting

Post by richardek »

Thank you for your reply mikeysklar!
I tried that, but the map is still stuck over New York =/

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Map block formatting

Post by mikeysklar »

Can you post your code? Maybe something is off syntax wise?

User avatar
brubell
Learn User Page
 
Posts: 2010
Joined: Fri Jul 17, 2015 10:33 pm

Re: Map block formatting

Post by brubell »

Please post your code

User avatar
richardek
 
Posts: 8
Joined: Sun Mar 26, 2023 6:26 am

Re: Map block formatting

Post by richardek »

Here is my feed. I have tried to add the value but the map widget is still showing New York.
Screenshot 2023-04-01 204002.jpg
Screenshot 2023-04-01 204002.jpg (67.37 KiB) Viewed 201 times
Screenshot 2023-04-01 211526--.jpg
Screenshot 2023-04-01 211526--.jpg (50.22 KiB) Viewed 201 times

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Map block formatting

Post by mikeysklar »

We will still need to see the code to assist you. The values shown are in the feed match the mapping for NYC.

User avatar
richardek
 
Posts: 8
Joined: Sun Mar 26, 2023 6:26 am

Re: Map block formatting

Post by richardek »

Do I need to code anything for the map block to work? I'm just sending the coordinates from my microcontroller (Arduino C++)

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Map block formatting

Post by mikeysklar »

The code on your microcontroller is what we want to see. There could be some sort of syntax issue or incorrect API usage.

User avatar
richardek
 
Posts: 8
Joined: Sun Mar 26, 2023 6:26 am

Re: Map block formatting

Post by richardek »

Thanks for you reply mikeysklar, here it is =)

Code: Select all

    
char position[] = "23,59.8050101,17.6260959,10";

// Publish the data as raw data to the MQTT server
mqtt.pubRaw(DEFAULT_LINK_ID, "my-account/feeds/position", position);

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Map block formatting

Post by mikeysklar »

Looking at the docs for location publishing you might want to try publishing as CSV instead of pubraw.

https://io.adafruit.com/api/docs/mqtt.h ... ending-csv
Sending CSV
Alternatively, you can send location tagged data to /csv topics. In this example, that would be the topic mosfet/feeds/photocell-one/csv instead of mosfet/feeds/photocell-one. Both store data in the same feed. The format IO expects for location tagged CSV data is VALUE, LATITUDE, LONGITUDE, ELEVATION.

With the example data shown before, that means you could publish the string "22.587,38.1123,-91.2325,112" to mosfet/feeds/photocell-one/csv. to store the value "22.587" in the location latitude: 38.1123, longitude: -91.2325, elevation: 112.

User avatar
richardek
 
Posts: 8
Joined: Sun Mar 26, 2023 6:26 am

Re: Map block formatting

Post by richardek »

Oh that's a great point!! I'll try that.
Thank you mikeysklar! :D

User avatar
richardek
 
Posts: 8
Joined: Sun Mar 26, 2023 6:26 am

Re: Map block formatting

Post by richardek »

Yess!! That made it! 😃🙏
Thank you so much mikeysklar!

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Map block formatting

Post by mikeysklar »

Cool, what syntax did you end up using? Can you paste it in for other that get hung up on this.

User avatar
richardek
 
Posts: 8
Joined: Sun Mar 26, 2023 6:26 am

Re: Map block formatting

Post by richardek »

Just added the /csv at the end of the topic address. =D

Code: Select all

char position[] = "23,59.8050101,17.6260959,10";

// Publish the data as raw data to the MQTT server
mqtt.pubRaw(DEFAULT_LINK_ID, "my-account/feeds/position/csv", position);

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”