Black Lives Matter - Action and Equality. ... Adafruit is part of the Stop Hate for Profit campaign. Adafruit is open and shipping.
0

Can't get dashboard to update from Raspberry Pi
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.
Please be positive and constructive with your questions and comments.

Can't get dashboard to update from Raspberry Pi

by sarathchandars on Fri Dec 11, 2015 2:11 am

I've a Raspberry Pi with a Sense HAT, and wanted to give Adafruit IO a whirl. I'm a Python novice and gave my best attempt to monitor Temperature, Humidity and Pressure using a dashboard. The code is below. On Adafruit IO, I created a new dashboard called Environment (currently the only dashboard in my account) and added 5 feeds that are mentioned as comments in the code. Apologies if the mistakes are trivial but I'm just starting and a bit of handholding will go a long way :)

Code: Select all | TOGGLE FULL SIZE
from Adafruit_IO import Client
from sense_hat import SenseHat

aio = Client('intentionally omitted')
sense = SenseHat()

# Adafruit IO: Temperature feed is 'temperature'
# Adafruit IO: Pressure feed is 'pressure'
# Adafruit IO: Humidity feed is 'humidity'
# Adafruit IO: Reset button is 'reset-alarms'
# Adafruit IO: Notification textbox is 'notification'

while True:
# Get data from environmental sensors. Sensor data is of type float.
   temperature = sense.get_temperature()
   humidity = sense.get_humidity()
   pressure = sense.get_pressure()

# Send sensor data to Adafruit IO.
   aio.send = ('temperature', temperature) # in deg C
   aio.send = ('humidity', humidity) # in %rH
   aio.send = ('pressure', pressure) # in millibar

# Check if 'Reset' button is pressed on Adafruit IO
   reset_alarms = aio.receive('reset-alarms')

# Conditions for warnings
   if temperature > 30: #30 deg C
   aio.send = ('notification', 'Temperature alert')

   if humidity > 50: #50% rH
   aio.send = ('notification', 'Humidity alert')

   if pressure < 900: #900 millibar
   aio.send = ('notification', 'Pressure alert')

# Condition for reset & no warning
   if reset_alarms == 1:
   aio.send = ('notification', 'Alerts reset')

   if (temperature <= 30 and humidity <= 50 and pressure >= 900):
   aio.send = ('notification', 'All ok!')

sarathchandars
 
Posts: 6
Joined: Sun Sep 21, 2014 11:08 am

Re: Can't get dashboard to update from Raspberry Pi

by jwcooper on Fri Dec 11, 2015 2:44 pm

Does this python example work for you? https://github.com/adafruit/io-client-p ... /simple.py

Do you get any errors when running your python program?

jwcooper
 
Posts: 679
Joined: Tue May 01, 2012 9:08 pm

Re: Can't get dashboard to update from Raspberry Pi

by sarathchandars on Fri Dec 11, 2015 11:20 pm

Thanks for your response. I logged into my dashboard and noticed that the status bar (the thin line with blue dots) is blinking red. I get the error below for both my program and simple.py

Adafruit_IO.errors.RequestError: Adafruit IO request failed: 500 Internal Server Error

I'll recheck and keep you posted on what happens with both the programs.

sarathchandars
 
Posts: 6
Joined: Sun Sep 21, 2014 11:08 am

Re: Can't get dashboard to update from Raspberry Pi

by rccarman on Fri Dec 11, 2015 11:23 pm

io is toast at the moment. Not a Rasp PI problem. See this thread viewtopic.php?f=56&t=84943

rccarman
 
Posts: 14
Joined: Sun Sep 20, 2015 10:44 pm

Re: Can't get dashboard to update from Raspberry Pi

by jwcooper on Fri Dec 11, 2015 11:30 pm

Repaired now. Please try again.

jwcooper
 
Posts: 679
Joined: Tue May 01, 2012 9:08 pm

Re: Can't get dashboard to update from Raspberry Pi

by sarathchandars on Fri Dec 11, 2015 11:43 pm

This is what I got when I ran simple.py

Retrieved value from Test has attributes: Data(created_epoch=1449891436.99079, created_at=u'2015-12-12T03:37:16.990Z', updated_at=u'2015-12-12T03:37:21.294Z', value=u'42', completed_at=u'2015-12-12T03:37:21.294Z', feed_id=449337, expiration=None, position=None, id=37924767)
Latest value from Test: 42
Retrieved value from Test has attributes: Data(created_epoch=1449891439.13903, created_at=u'2015-12-12T03:37:19.139Z', updated_at=u'2015-12-12T03:37:23.438Z', value=u'bar', completed_at=u'2015-12-12T03:37:23.438Z', feed_id=449725, expiration=None, position=None, id=37924777)
Latest value from Test: bar

Basically it works as I can see the value in "Your Feeds"

But Dashboard still has the red line blinking and the value doesn't get displayed over there. And my program doesn't update the values, still.
Attachments
Feed values.tiff
Feed values.tiff (136.92 KiB) Viewed 668 times

sarathchandars
 
Posts: 6
Joined: Sun Sep 21, 2014 11:08 am

Re: Can't get dashboard to update from Raspberry Pi

by rccarman on Fri Dec 11, 2015 11:57 pm

I'm not an expert on Python, but perhaps this is the problem:

# Send sensor data to Adafruit IO.
aio.send = ('temperature', temperature) # in deg C

I think the second line should be:
aio.send('temperature', temperature) # in deg C

rccarman
 
Posts: 14
Joined: Sun Sep 20, 2015 10:44 pm

Re: Can't get dashboard to update from Raspberry Pi

by sarathchandars on Sat Dec 12, 2015 12:15 am

rccarman wrote:I'm not an expert on Python, but perhaps this is the problem:

# Send sensor data to Adafruit IO.
aio.send = ('temperature', temperature) # in deg C

I think the second line should be:
aio.send('temperature', temperature) # in deg C


That worked ! Looks like I'm even less of an expert :) But I'm getting there... Thanks a lot

sarathchandars
 
Posts: 6
Joined: Sun Sep 21, 2014 11:08 am

Re: Can't get dashboard to update from Raspberry Pi

by sarathchandars on Sat Dec 12, 2015 2:34 am

jwcooper wrote:Repaired now. Please try again.


I've suddenly started getting this error after what appears to be one loop fo the program as one value is updated on the dashboard and the program exits.

aio.send('temperature', temperature) # in deg C
TypeError: 'tuple' object is not callable

Something wrong at IO?

sarathchandars
 
Posts: 6
Joined: Sun Sep 21, 2014 11:08 am

Re: Can't get dashboard to update from Raspberry Pi

by rccarman on Sat Dec 12, 2015 1:14 pm

Did you update the other lines of your program to replace all the "aio.send = " with "aio.send(" ?

rccarman
 
Posts: 14
Joined: Sun Sep 20, 2015 10:44 pm

Re: Can't get dashboard to update from Raspberry Pi

by sarathchandars on Sat Dec 12, 2015 1:28 pm

Yes I did. The error I was getting earlier was definitely due to some issue at IO, not the code. It works like a dream now :)

sarathchandars
 
Posts: 6
Joined: Sun Sep 21, 2014 11:08 am

Re: Can't get dashboard to update from Raspberry Pi

by geekguy on Thu Jan 21, 2016 12:16 am

I am getting a rate limit error right after I send my very first value to adafruit.io.

Publishing a new message every 24 seconds (press Ctrl-C to quit)...
Publishing 65 to TempLivingRoom.
Publishing 7% to HumidLivingRoom.
Traceback (most recent call last):
File "./my_mqtt_client.py", line 73, in <module>
aio.send('humidlivingroom', humidity)
File "build/bdist.macosx-10.11-intel/egg/Adafruit_IO/client.py", line 90, in send
File "build/bdist.macosx-10.11-intel/egg/Adafruit_IO/client.py", line 72, in _post
File "build/bdist.macosx-10.11-intel/egg/Adafruit_IO/client.py", line 53, in _handle_error
Adafruit_IO.errors.ThrottlingError: Exceeded the limit of Adafruit IO requests in a short period of time. Please reduce the rate of requests and try again later.

8-Dale

geekguy
 
Posts: 271
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Re: Can't get dashboard to update from Raspberry Pi

by rccarman on Thu Jan 21, 2016 12:41 am

Actually, the rate limit error is not occurring after your first value, but after your second. Is there a 24 second delay between temp and humidity? Or between each round of both temp and humidity?

rccarman
 
Posts: 14
Joined: Sun Sep 20, 2015 10:44 pm

Re: Can't get dashboard to update from Raspberry Pi

by nic61rkd on Thu Jan 21, 2016 12:56 am

I'm having very similar issues with the "ThrottlingError". I had code running for weeks now which was updating 3 feeds every 3 minutes with no delay between them. I also a motion sensor feed which updates every time it senses motion and resets 15 to 20 seconds after the motion stops. Both of these started to have problems today.

nic61rkd
 
Posts: 3
Joined: Sun Dec 20, 2015 10:21 am

Re: Can't get dashboard to update from Raspberry Pi

by geekguy on Thu Jan 21, 2016 1:00 am

rccarman wrote:Actually, the rate limit error is not occurring after your first value, but after your second. Is there a 24 second delay between temp and humidity? Or between each round of both temp and humidity?

You are correct! I have four feeds that are to be updated at an interval - two temperature, and two humidity. The error occurs when it tries to update the second feed.

8-D

geekguy
 
Posts: 271
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Please be positive and constructive with your questions and comments.


cron