First of all, thank you for this wonderful and easiest to use cloud platform adafruit-io. It works in most cases flawlessly.
Am facing a problem with updating map values on adafruit-io, I don't know if it can be done using REST api, when I tried and read, I thought its only possible to send values to /csv format using mqtt. So i'm using mqtt and it was working properly for a time.
I don't know if its a known issue or not, but the map values posted via MQQT request in CSV format were all working perfectly fine till 10th may, on 11th may, the same values posted are seen differently on IO feeds, and hence, the lat/long are not properly shown which does not update the map
as you can see on this public feed
https://io.adafruit.com/amitrana3348/feeds/location
there are previous published request which are fine, but from yesterday, the location feed published looks like
"{\"value\":\"0\",\"lat\":\"19.86139\",\"lon\":\"75.34701\",\"ele\":\"0\"}" when published using MQQT python library with
client.publish("location/csv",'0,19.86139,75.34701')
Complete code is here
- Code: Select all | TOGGLE FULL SIZE
from Adafruit_IO import *
import os, time
# Define callback functions which will be called when certain events happen.
def connected(client):
# Connected function will be called when the client is connected to Adafruit IO.
# This is a good place to subscribe to feed changes. The client parameter
# passed to this function is the Adafruit IO MQTT client so you can make
# calls against it easily.
print 'Connected to Adafruit IO! Listening for DemoFeed changes...'
# Subscribe to changes on a feed named DemoFeed.
client.subscribe('DemoFeed')
def disconnected(client):
# Disconnected function will be called when the client disconnects.
print 'Disconnected from Adafruit IO!'
sys.exit(1)
def message(client, feed_id, payload):
# Message function will be called when a subscribed feed has a new value.
# The feed_id parameter identifies the feed, and the payload parameter has
# the new value.
print 'Feed {0} received new value: {1}'.format(feed_id, payload)
client = MQTTClient('amitrana3348','3e359482c74e59509c3f50ab76e3a80958f55033')
# Setup the callback functions defined above.
client.on_connect = connected
client.on_disconnect = disconnected
client.on_message = message
client.connect()
client.loop_background()
time.sleep(2)
grandloc = "0,19.86139,75.34701"
print grandloc
client.publish("location/csv",grandloc)
#client.publish("location/csv",'0,19.86139,75.34701')
time.sleep(2)
if there's anything wrong in above code, or anything changed at adafruit IO, please let me know
Thank you
Amit Rana