0

long Delay by adafruit
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

long Delay by adafruit

by jay_raval on Mon Mar 25, 2019 2:53 am

it takes so much time to upload my dht11 data from raspberry to adafruit dashboard.And if i press on button for led then led was on after 30-60 seconds.how to reduce this delay?.
Remind you that i have io+ account.
Attachments
Screenshot (44).png
Screenshot (44).png (121.08 KiB) Viewed 198 times

jay_raval
 
Posts: 12
Joined: Fri Mar 22, 2019 6:58 am

Re: long Delay by adafruit

by jay_raval on Mon Mar 25, 2019 5:21 am

jay_raval wrote:it takes so much time to upload my dht11 data from raspberry to adafruit dashboard.And if i press on button for led then led was on after 30-60 seconds.how to reduce this delay?.program stuck after uploading data one time for 2 min.please resolve my isuue.
Remind you that i have io+ account.

jay_raval
 
Posts: 12
Joined: Fri Mar 22, 2019 6:58 am

Re: long Delay by adafruit

by brubell on Mon Mar 25, 2019 9:57 am

And if i press on button for led then led was on after 30-60 seconds.how to reduce this delay?.


How are you sending data to Adafruit IO? Are you using an adafruit library?

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

Re: long Delay by adafruit

by jay_raval on Mon Mar 25, 2019 10:29 am

yes sir/m'am i used adafruitio library to upload the data and for dht11 also i used adafruit_python_DHT library.

jay_raval
 
Posts: 12
Joined: Fri Mar 22, 2019 6:58 am

Re: long Delay by adafruit

by brubell on Mon Mar 25, 2019 2:34 pm

jay_raval wrote:yes sir/m'am i used adafruitio library to upload the data and for dht11 also i used adafruit_python_DHT library.


Thanks! Can you post your Python code so I can give feedback/suggestions re: the speed of IO?

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

Re: long Delay by adafruit

by jay_raval on Mon Mar 25, 2019 11:52 pm

Code: Select all | TOGGLE FULL SIZE
import time
import digitalio
import board
import RPi.GPIO as GPIO
import Adafruit_DHT
from Adafruit_IO import Client,Feed,RequestError

aio=Client(Username,Api_key)
try:
  led_feed=feeds('led-control')
  temp_feed=feeds('temp-control')
  humi_feed=feeds('humi_control')

except RequestError:
 LED=aio.create_feed(Feed(name="led"))
 TEMP=aio.create_feed(Feed(name="temp"))
 Humi=aio.create_feed(Feed(name="humi"))

led=digitalio.DigitalInOut(board.D6)
led.direction=digital.Direction.OUTPUT

led=digitalio.DigitalInOut(board.D17)
led.direction=digital.Direction.INPUT
while True:
  humidity,temperature=Adafruit_DHT.read_retry(11,17)
 data=aio.receive(led_feed.key)
 if int(data.value)==1:
   print('led is on')
 elif int(data.value)==0:
   print('ied is off')
 led.value=int(data.value)

 if humidity is not None and temperature is not None:
    print('Temp={0:0.1f}*C Humi={1:0.1f}%'.format(temperature,humidity))
    temperature='.2f'%(temperature)
    humidity='.2f'%(humidity)
   aio.send(temp_feed.key,str(temperature))
   aio.send((humi_feed.key,str(humidity))

else:
 print('Failed to get data from DHT11')
Last edited by brubell on Tue Mar 26, 2019 9:40 am, edited 1 time in total.
Reason: adding code blocks

jay_raval
 
Posts: 12
Joined: Fri Mar 22, 2019 6:58 am

Re: long Delay by adafruit

by jay_raval on Mon Mar 25, 2019 11:53 pm

thanks sir/m'am for giving us your valuable time.Thank you very much

jay_raval
 
Posts: 12
Joined: Fri Mar 22, 2019 6:58 am

Re: long Delay by adafruit

by brubell on Tue Mar 26, 2019 12:46 pm

Looking at your code:
Code: Select all | TOGGLE FULL SIZE
   aio.send(temp_feed.key,str(temperature))
   aio.send((humi_feed.key,str(humidity))


You're performing a string conversion within the aio.send, possibly remove that from the function and place it on a separate line. The speed of aio.send is limited by your network connection. Possibly try moving your project closer to a wireless router?

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

Re: long Delay by adafruit

by jay_raval on Tue Mar 26, 2019 12:48 pm

okay...i observed that whenever i changed the condition of button on adafruit dashboard,then my raspberry pi stucks.If button is in off condition then it will constantly give response.
also whenever i change button condition pi's red light is glows constantly and after some time it is off and i get output.

jay_raval
 
Posts: 12
Joined: Fri Mar 22, 2019 6:58 am

Re: long Delay by adafruit

by brubell on Tue Mar 26, 2019 3:31 pm

jay_raval wrote:okay...i observed that whenever i changed the condition of button on adafruit dashboard,then my raspberry pi stucks.If button is in off condition then it will constantly give response.


Your code looks OK - could you attach the output from the following snippet of your code:
Code: Select all | TOGGLE FULL SIZE
 if int(data.value)==1:
   print('led is on')
 elif int(data.value)==0:
   print('ied is off')
 led.value=int(data.value)



also whenever i change button condition pi's red light is glows constantly and after some time it is off and i get output.

Are you talking about the red power indicator on the Pi, or another light (in your code, what variable are you referring to)?

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

Re: long Delay by adafruit

by jay_raval on Tue Mar 26, 2019 3:34 pm

yes red power indicator

jay_raval
 
Posts: 12
Joined: Fri Mar 22, 2019 6:58 am

Re: long Delay by adafruit

by jay_raval on Tue Mar 26, 2019 3:38 pm

okay.. as you said..i try for only led on-off by adafruit(removed dht11 code)..but still it got 20 to 45 seconds delay whenever i changed button state.
And still after temperature and humidity value printed on raspberry pi window,it takes time to update on adafruit dashboard.

jay_raval
 
Posts: 12
Joined: Fri Mar 22, 2019 6:58 am

Re: long Delay by adafruit

by brubell on Tue Mar 26, 2019 3:53 pm

jay_raval wrote:okay.. as you said..i try for only led on-off by adafruit(removed dht11 code)..but still it got 20 to 45 seconds delay whenever i changed button state.
And still after temperature and humidity value printed on raspberry pi window,it takes time to update on adafruit dashboard.


Values do take some time to send to Adafruit IO, depending on your network connection, but shouldn't take 20-45secs.

Could you run a speedtest? https://fast.com/

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

Re: long Delay by adafruit

by jay_raval on Tue Mar 26, 2019 3:56 pm

my wifi is gives 6mbps speed.(as per your link)

jay_raval
 
Posts: 12
Joined: Fri Mar 22, 2019 6:58 am

Re: long Delay by adafruit

by jay_raval on Tue Mar 26, 2019 4:18 pm

It seems to be a network issue as i am from india..we are going to interface camera,pir sensor ,co2 sensor,soil moisture sensor ,motor and leds so it's normal that 1 to 2 min delay for response of some action??

jay_raval
 
Posts: 12
Joined: Fri Mar 22, 2019 6:58 am

Please be positive and constructive with your questions and comments.