[SOLVED] Maps with http rest api

you answered my question of ‘Can I do this’ with ‘no you can’t’

I dont understand why your system marks a device as ‘offline’ even though it’s getting active updates through the rest api. Maybe have some logic on your end that says ‘if we got a rest api update in the past 5 minutes, then mark the device as online’. Then work on getting the map portion working with rest api.

'This is default behavior as Blynk was designed to work with real devices. ’
I think my devices are real and don’t believe this problem has been [SOLVED]

Also why can’t I tell the eventor to write to virtual pins?

Anyway I really enjoy using blynk. Awesome app guys!

Well, this HTTP API was designed to update state of hardware in first place. So indication of “hardware is offline” is very important here, especially for the initial setup. I agree, that in case when you update state of the map widget it doesn’t make any sense.

You can.

@thefatmoop Let’s start from begging as I’m lost the initial problem of this topic.

Please describe your setup. What would you expect and how Blynk works right now.

Nowadays, there is a more and more popular SIGFOX network.
Sigfox and the Blynk app come together nicely.
I have built a low power gps tracker that sends location to Sigfox backend.
It would be great to be able to see in Blynk where my stolen car or my lost dog is.
Take this as a little motivation.
I believe that this would appeal to many and many new users and have moved your application a long way forward.

Thank you for your great job and I wish you were there for as long as possible! (Otherwise half of my house will stop working :slight_smile: )

I would like to post map coordinate information through rest API.
I am using the following command:
curl -v http://blynk-cloud.com/auth-token/update/V30?value=1,52.2949,-4.8610,"Test"
The response of curl is fine:

*   Trying
* Connected to "blynk-cloud.com ( port 80 (#0)
> GET /auth-token/update/V30?value=30,52.2949,-4.8610,Test HTTP/1.1
> User-Agent: curl/7.54.0
> Accept: */*
< HTTP/1.1 200 OK
< connection: keep-alive
< content-length: 0

So all is fine, I can see the values in terminal if I connect terminal to Virtual pin V30.
When I connect a map to virtual pin V30 nothing happens.
Why can’t maps use the information in V30 to display the info on a map?

I believe they can if you provide the right code in your sketch.
What are you currently using to read the Terminal and parse the data into the map?

1 Like

Dear Costas,
I amusing the following statement to parse the data into the app, issued from a raspberry pi bash script:
curl -v http://blynk-cloud.com/auth-token/update/V30?value=1,52.2949,-4.8610,"Test"
I can create a terminal in the iphone app and connect the terminal to virtual pin 30 (V30)
The data displays in the terminal app.
But wne I connect the map to pin V30, no data or position is displayed

Precisely how are you doing this connection in your sketch?
It’s the parsing out of terminal and into your MCU that I was enquiring about not the parsing in.

What do you mean by MCU?
I am not parsing out of terminal on the blynk app.
I connect in the blynk app to the map by selecting pin V30 in the map widget

MCU stands for: Micro Controller Unit ex. ESP8266, ESP32, Arduino Uno etc

The MCU is the raspberry pi, that gets the coordinates from a GPS tracker and then submits the data with the curl command to be used by the blynk app:

@JFdB Ok let’s try to work out what you are doing and then the fix for your problem.

GPS device passes data to a Pi, Pi sends data to Blynk server via curl to a Terminal on V30 and this appears on your phone in the Terminal widget.
You want to see these details in the map widget.

Well I can say we have a similar system and I have previously posted Google Earth maps of the tracks we have created that appeared in the map widget on the phone.

Our system is similar but subtly different and more straightforward than yours. We have a GPS tracker that looks like it’s hooked up to one of our Pi’s but in actual fact it’s hooked up to a mighty WeMos that happens to reside in a Pi case.

So the WeMos does everything for us with a bit of C++ code to update the map widget as the WeMos is connected to Blynk’s server i.e. no API / curl involved.

Question: in your project which hardware device do you have as connected to the Blynk server? The one and only Pi that is connected to the GPS device, another Pi, an ESP8266, an Arduino, something else or “nothing”?

Short answer, nothing is connected to the blynk server. The pi is the only hardware. But I can use a python script on the pi to connect to the blynk server, Is there a simple phyton script to submit map data to the blynk server that I can call from a bash shell with the GPS coordinates?

I suspected the answer was going to be “nothing” and it’s a concept I find quite strange.
So Blynk has nothing to control.

Ignore my rambling it’s sleep deprivation and a different mindset I have about iOT.

That said have you considered hooking up a $3 MCU to Blynk and writing a few lines of C++?

Until such time as Blynk adds the map widget to the API then I think the line above is the only solution for you. It doesn’t have to be C++ and you can use the Pi that’s hooked up to the GPS device if you wanted and have the correct coding skillset.

Terminal shows what you sent - a single string value. The Map widget accepts multiple values.

Try the following:

curl -v -L --include \
     --request PUT \
     --header "Content-Type: application/json" \
     --data-binary "[
    \"1\", \"52.2949\", \"-4.8610\", \"Test\"
]" \
1 Like

Or - Blynk HTTP Api - Add and Write value to table row

Dear Eugene, absolutely brilliant!!!
This solved it, it works for me, I can see the indicator on the map.
So the problem was that I was sending a single string, what needed to be done is sending 4 separate values (strings).
Now I will try the solution proposed by Dmitriy

1 Like

Dmitriy, your method does also work.
curl -v http://blynk-cloud.com/auth-token/update/V30?"value=30&value=52.2949&value=4.8610&value=Test"

does also work (note the quotes around the values being send)
Now this truly can be considered
SOLVED MAPS with http rest api

After a few hours sleep I was going to suggest what @Dmitriy wrote and it’s nice to see the curl syntax from @Eugene

I think quotes are not necessary.