Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Throttling Error Issue w/ Adafruit IO, Rpi4 and AM2302
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.

Throttling Error Issue w/ Adafruit IO, Rpi4 and AM2302

by lionel_hutz_esq on Sat Jan 09, 2021 10:31 pm

Hi all,

I am pretty new to all of this so apologies if this is a dumb question.

I followed Jeremy Morgan's Easy IOT w Adafrut IO and Raspberry Pi Guide https://www.jeremymorgan.com/tutorials/raspberry-pi/how-to-iot-adafruit-raspberrypi/. My hope is to have this setup in fridge that I will use as a curing chamber.

I finally got everything up and running but after about a minute of the script running I get the following error

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "sensor.py", line 20, in <module>
    aio.send_data(humfeed.key, humidity)       
  File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_IO/client.py", line 154, in send_data
    return self.create_data(feed, payload)
  File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_IO/client.py", line 254, in create_data
    return Data.from_dict(self._post(path, data._asdict()))
  File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_IO/client.py", line 127, in _post
    self._handle_error(response)
  File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_IO/client.py", line 102, in _handle_error
    raise ThrottlingError()
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.



I have the AM2302 taking samples every 30 seconds so I am not sure why it is sending so much data so quickly to the IO and throttling.

Any help would be appreciated.

lionel_hutz_esq
 
Posts: 4
Joined: Fri Jan 08, 2021 9:52 pm

Re: Throttling Error Issue w/ Adafruit IO, Rpi4 and AM2302

by brubell on Mon Jan 11, 2021 10:41 am

Could you please post the exact code you're using below?

brubell
 
Posts: 1347
Joined: Fri Jul 17, 2015 10:33 pm

Re: Throttling Error Issue w/ Adafruit IO, Rpi4 and AM2302

by lionel_hutz_esq on Mon Jan 11, 2021 12:30 pm

For sure here it is (removed client info so it stays private)
Code: Select all | TOGGLE FULL SIZE
#!/usr/bin/env python3

import time
import adafruit_dht
import board

dht = adafruit_dht.DHT22(board.D4)

from Adafruit_IO import Client
aio = Client (deleted this so it is private)


while True:
    try:
         temperature = (dht.temperature * 9/5) + 32
         smalltemp = round(temperature, 2)
         humidity = dht.humidity       

         humfeed = aio.feeds('roomhumidity')
         aio.send_data(humfeed.key, humidity)       

         tempfeed = aio.feeds('roomtemperature')
         aio.send_data(tempfeed.key, round(temperature,2))   

    except RuntimeError as e:
         print("Reading from DHT failure: ", e.args)
         time.sleep(30)

lionel_hutz_esq
 
Posts: 4
Joined: Fri Jan 08, 2021 9:52 pm

Re: Throttling Error Issue w/ Adafruit IO, Rpi4 and AM2302

by brubell on Wed Jan 13, 2021 11:46 am

You are immediately sending data to Adafruit IO after taking measurements. The maximum amount of data points to send to adafruit io for a free account is 30/min.

You may want to try inserting a call to time.sleep at the end of the while True: loop before it runs again.
Code: Select all | TOGGLE FULL SIZE
while True:
    try:
         temperature = (dht.temperature * 9/5) + 32
         smalltemp = round(temperature, 2)
         humidity = dht.humidity       

         humfeed = aio.feeds('roomhumidity')
         aio.send_data(humfeed.key, humidity)       

         tempfeed = aio.feeds('roomtemperature')
         aio.send_data(tempfeed.key, round(temperature,2))   

    except RuntimeError as e:
         print("Reading from DHT failure: ", e.args)
         time.sleep(30)
time.sleep(30)

brubell
 
Posts: 1347
Joined: Fri Jul 17, 2015 10:33 pm

Re: Throttling Error Issue w/ Adafruit IO, Rpi4 and AM2302

by lionel_hutz_esq on Wed Jan 13, 2021 10:55 pm

I just tried this out and still got the same throttling issue.

Am I wrong that the time.sleep(30) means that the AM2302 only taking one reading every 30 seconds?

If so how could it be sending more than that to the Adafruit IO dashboard?

lionel_hutz_esq
 
Posts: 4
Joined: Fri Jan 08, 2021 9:52 pm

Re: Throttling Error Issue w/ Adafruit IO, Rpi4 and AM2302

by brubell on Fri Jan 15, 2021 11:21 am

My indentation was incorrect, sorry!

Am I wrong that the time.sleep(30) means that the AM2302 only taking one reading every 30 seconds?

In the code below, this is true.

The `exceptRunTimeError as e` will only wait 30 seconds IF a runtime error is thrown.


Code: Select all | TOGGLE FULL SIZE
while True:
    try:
         temperature = (dht.temperature * 9/5) + 32
         smalltemp = round(temperature, 2)
         humidity = dht.humidity       

         humfeed = aio.feeds('roomhumidity')
         aio.send_data(humfeed.key, humidity)       

         tempfeed = aio.feeds('roomtemperature')
         aio.send_data(tempfeed.key, round(temperature,2))   

    except RuntimeError as e:
         print("Reading from DHT failure: ", e.args)
         time.sleep(30)
    time.sleep(30)

brubell
 
Posts: 1347
Joined: Fri Jul 17, 2015 10:33 pm

Re: Throttling Error Issue w/ Adafruit IO, Rpi4 and AM2302

by lionel_hutz_esq on Fri Jan 15, 2021 12:14 pm

This worked. Thank you so much!

lionel_hutz_esq
 
Posts: 4
Joined: Fri Jan 08, 2021 9:52 pm

Please be positive and constructive with your questions and comments.