Location data along fields vs channel settings

Hello,
Could you please help in explaining what is the difference between location data along the 8 available fields and location data on channel settings? Shouldn't be it be the same data?
Below is an example:
I set the location data:
POST /update.json HTTP/1.1
Host: api.thingspeak.com
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Postman-Token: XX
api_key=XX&lat=45.01&lon=27.01&1=44.444&elevation=10.1
I get the data from channel fields:
{
"channel": {
"id": 1094740,
"name": "Caravan_ESP32",
"latitude": "44.412",
"longitude": "26.123",
"field1": "Humidity",
"field2": "Temperature",
"field7": "boot_count",
"field8": "h_thres",
"created_at": "2020-07-06T13:59:32Z",
"updated_at": "2020-07-10T06:11:42Z",
"last_entry_id": 11298
},
"feeds": [
{
"created_at": "2020-07-10T05:51:33Z",
"entry_id": 11298,
"field1": "44.444",
"latitude": "45.01",
"longitude": "27.01",
"elevation": "10.1"
}
]
}
I get the data from channel settings:
{
"id": 1094740,
"name": "Caravan_ESP32",
"description": "",
"latitude": "44.412",
"longitude": "26.123",
"created_at": "2020-07-06T13:59:32Z",
"elevation": "",
"last_entry_id": 11298,
"public_flag": false,
"url": "",
"ranking": 30,
"metadata": "",
"license_id": 0,
"github_url": null,
"tags": [],
"api_keys": [
{
"api_key": "XX",
"write_flag": true
},
{
"api_key": "XX",
"write_flag": false
}
]
}
As you can see above, location data is different. When I write location data as above, I would like to see it updated in the channel location. Is this possible?
Thanks,
George

 Accepted Answer

The lat-lon of the channel is where the channel is located. The lat-lon of the feed is where the actual feed was measured.
To take a concrete example, say you had one channel for your farm. On your farm you had multiple sensors (maybe an autonomous lawn mower?). Each sensor might make a reading at a different GPS location, but, your farm itself (and the channel) doesn't move. The channel lat-lon is used to show the map on the channel view. The feed lat-lon may be used to overlay the location of each individual sensor reading on the map, like this example.

5 Comments

Thanks, Vinod. Excellent explanation, it’s very clear now.
What I would like is to use channel location since I only have one sensor. The channel location already provides a nice looking map. So, I would update channel location for every new sensor read (which could move, is in fact a caravan). The problem is that the ThingsSpeak library I use for Arduino only handles feed write / read and I thought I could use that. But as I see, channel location is a different call and I cannot use the library for it. Maybe a writeRaw call but I am not sure how to structure the message.
Since the channel location doesn't change often, you can set the lat-lon for the channel on the channel settings page. No need to try and do that from your device using an API, though you could do that if you wish using the channel API and your user API key.
You can also use a MATLAB visualization to add a map that shows your location data in the feed. Then you can still use the library to update the position.
Have a look at the third example on this page: Create Customized ThingSpeak Channel View
(The second example shows the channel map that you are already aware of)
Thanks Christopher.
I did that. I am not happy on how it looks like, referring to the map created with geoscatter and geobasemap commands. I could not change the scale, so the location is like a little dot on the whole earth map :). In addition, you cannot zoom in / out like you can do on the channel map.
Code is below:
mapData = thingSpeakRead(readChannelID,'ReadKey',readAPIKey,...
'numpoints',10,'location',1,'outputformat','timetable');
disp(mapData);
% gx = geoaxes;
geoscatter(mapData.Latitude,mapData.Longitude,'r');
%geobasemap('satellite');
geobasemap('streets');
% geobasemap(gx,'streets');

Sign in to comment.

More Answers (0)

Communities

More Answers in the  ThingSpeak Community

Categories

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!