problem when upload location data | General | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
problem when upload location data
Avatar
alessio31183

Silver
Forum Posts: 6
sp_UserOfflineSmall Offline
1
November 10, 2014 - 4:42 am
sp_Permalink sp_Print

Hi every one,
I'm developing some sensor nodes that measure some parameter for the air quality monitoring and upload data on thingspeak platform.
This is the channel: https://thingspeak.com/channels/17333
The issue is that I'm trying to upload also the position with latitude, longitude and elevation attribute but I don't see the correct data on my node.
This is a part of my .py code:

import httplib, urllib

__version__ = '0.1.1'

NUMOFCHANNELS = 8
field_keys = ['field' + str(n) for n in xrange(1,NUMOFCHANNELS+1)]
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}

def non_null_values(**kwargs):
return [(k,v) for (k,v) in kwargs.iteritems() if v != None]

class wrongFields(ValueError):
pass

class channel(object):
def __init__(self, write_key, cid=0 ):
"""write_key is the Write API Key.
cid is the read_key"""
self.write_key = write_key

def update(self, field_vals, lat=None, long=None, elevation=None, status=None):
if len(field_vals) != NUMOFCHANNELS:
raise wrongFields('update can only handle NUMOFCHANNELS field values per channel')
# this verbosity, rather than just using kwargs,
# so that callers get a prompt error if they supply an arg `update` cannot handle
named_args = non_null_values(lat=lat, long=long, elevation=elevation, status=status)
print named_args #FOR DEBUG ONLY
params = urllib.urlencode(zip(field_keys, field_vals) + [('key', self.write_key)] + named_args)
conn = httplib.HTTPConnection("api.thingspeak.com:80")
conn.request("POST", "/update", params, headers)
response = conn.getresponse()
conn.close()
return response

def fetch(self, format):
conn = httplib.HTTPConnection("api.thingspeak.com:80")
path = "/channels/{0}/feed.{1}".format(self.cid, format)
params = urllib.urlencode([('key',self.key)])
conn.request("GET", path, params, headers)
response = conn.getresponse()
return response

when I create th string to upload data by HTTP request I obtain something like this:
field1=(Field 1 Data)&field2=(Field 2 Data)&field3=(Field 3 Data)&field4=(Field 4 Data)&field5=(Field 5 Data)&field6=(Field 6 Data)&field7=(Field 7 Data)&field8=(Field 8 Data)&lat=(Latitude in Decimal Degrees)&long=(Longitude in Decimal Degrees)&elevation=(Elevation in meters)&status=(140 Character Message)

Every channel works correctly, also the status field, but the location is wrong.
I don't know what's the problem regarding.....

Any help?

Thanks in advance guys

Avatar
lee

Forum Posts: 457
sp_UserOfflineSmall Offline
2
November 10, 2014 - 8:42 am
sp_Permalink sp_Print

Hi,

Are you including the parameter "location=true" when retrieving your Channel feed? https://thingspeak.com/docs/channels#get_feed

lee

Avatar
alessio31183

Silver
Forum Posts: 6
sp_UserOfflineSmall Offline
3
November 13, 2014 - 4:35 am
sp_Permalink sp_Print

Yes,
I send out a message like this one:
field6=33.4&field1=23.0&long=51.490664&location=true&lat=25.375852&elevation=19&field8=0.0&key=**************

But it doesn't work, the location isn't updateCryCry
this is the channel: https://thingspeak.com/channels/17333

Thanks

Avatar
lee

Forum Posts: 457
sp_UserOfflineSmall Offline
4
November 13, 2014 - 9:08 am
sp_Permalink sp_Print

Hi,

I don't see any data in your Channel, are you sure you are adding the data correctly? Is the HTTP request sent properly with an API key?

lee

Avatar
Hans
Natick, MA

Forum Posts: 385
sp_UserOfflineSmall Offline
5
November 13, 2014 - 10:49 am
sp_Permalink sp_Print

Use "location=true" when reading the data back from your channel.

Avatar
alessio31183

Silver
Forum Posts: 6
sp_UserOfflineSmall Offline
6
November 18, 2014 - 4:13 am
sp_Permalink sp_Print

lee said

Hi,

I don't see any data in your Channel, are you sure you are adding the data correctly? Is the HTTP request sent properly with an API key?

lee

Yes, I'm sure, you can see data in the channel.
Why don't you see data?

Avatar
alessio31183

Silver
Forum Posts: 6
sp_UserOfflineSmall Offline
7
November 18, 2014 - 4:14 am
sp_Permalink sp_Print

Hans said

Use "location=true" when reading the data back from your channel.

...but my question is: why the location data doesn't upload correctly?
I don't want read location data but write the location of my node and see it on the map

Avatar
lee

Forum Posts: 457
sp_UserOfflineSmall Offline
8
November 18, 2014 - 8:58 am
sp_Permalink sp_Print

Your location data is being updated correctly, you can see it here: https://thingspeak.com/channels/17333/feed.json?results=5&location=true .

lee

Avatar
alessio31183

Silver
Forum Posts: 6
sp_UserOfflineSmall Offline
9
November 18, 2014 - 10:26 am
sp_Permalink sp_Print

lee said

Your location data is being updated correctly, you can see it here: https://thingspeak.com/channels/17333/feed.json?results=5&location=true .

lee

Thank you lee, but why I don't see the map and the correct position in the public channel view?

Avatar
lee

Forum Posts: 457
sp_UserOfflineSmall Offline
10
November 18, 2014 - 2:58 pm
sp_Permalink sp_Print

Hi,

The map is based on the Channel's latitude and longitude, which is configured under the "Channel Settings" tab. This is different from the Channel feed's latitude and longitude, which is updated via the API (as you're doing now).

We don't currently have a visualization for the feed locations, but may add one in the future which would display a path of the updates on a map.

lee

Avatar
alessio31183

Silver
Forum Posts: 6
sp_UserOfflineSmall Offline
11
November 19, 2014 - 7:21 am
sp_Permalink sp_Print

lee said

Hi,

The map is based on the Channel's latitude and longitude, which is configured under the "Channel Settings" tab. This is different from the Channel feed's latitude and longitude, which is updated via the API (as you're doing now).

We don't currently have a visualization for the feed locations, but may add one in the future which would display a path of the updates on a map.

lee

Ok, thank you lee
Now everything is clear.
I think that a map's visualization based on the feed locations it will be very useful for the future.
thinking about a node with a GPS module onboard...........that is moving from position to position

Thanks

Alessio

Avatar
Things4U
New Member
Forum Posts: 1
sp_UserOfflineSmall Offline
12
February 25, 2016 - 6:46 am
sp_Permalink sp_Print

A long time has past since last post. Are there still plans to add updates to the map?
GPS location and map view is one of the most important functions when showing people how their IoT are doing and where they are.
It should not be too difiicult to add this function to the existing show map view, I'm surprised it takes so long.

If not, I need to start looking for another platform...

Thanks,

Maarten,

Avatar
testing
New Member
Forum Posts: 1
sp_UserOfflineSmall Offline
13
July 17, 2017 - 5:21 pm
sp_Permalink sp_Print

Hello, I need to do something similar- is there a way to automatically update the map that is already on the Channel Stats page with lat/lon data that is coming in from a RockBlock unit? Else, what is the other solution- create a Google Map api and read the Thingspeak data into that as a ThingHTTP? Thank you for any help. 

Avatar
cstapels

Gold
Forum Posts: 83
sp_UserOfflineSmall Offline
14
July 18, 2017 - 8:35 am
sp_Permalink
Awaiting Moderation

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
13 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 250

Vinod: 154

cstapels: 83

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

webone

KMVp

aamir786

sugengprayogi

vickysam@gmail.com

farmerkjs

Forum Stats:

Groups: 4

Forums: 17

Topics: 1289

Posts: 4481

 

Member Stats:

Guest Posters: 1

Members: 5652

Moderators: 0

Admins: 2

Administrators: Hans, lee