# Plotly Dash on Respberry pi 3+B

**URL:** <https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705>\
**Category:** Dash Python\
**Tags:** question\
**Created:** [December 9, 2022, 1:12pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705 "2022-12-09T13:12:16Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![alejandrosando](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@alejandrosando](https://community.plotly.com/u/alejandrosando)\
**Post date:** [December 9, 2022, 1:12pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/1 "2022-12-09T13:12:16Z")

</div>

I have a question. I have written a python script in a raspberry pi3 to get data from a sensor and plot it with dash in Browser once per second. It works very well with pretty good accuracy when I do not do anything in browser, whoever when I open a new tab or whatever the dash starts to get two values or more per second or starts to delay for more than a second!  
has any one idea why or how to fix it?  
thanks  
 → the code

```auto
 
app = Dash( __name__ )

#app.layout 
app.layout = html.Div([dcc.Graph(id='live', animate=True),dcc.Interval(id='update', interval = 1000, max_intervals = -1),])
		
	

@app.callback( Output('live', 'figure'),
               Input('update', 'n_intervals'),
               Input('switch', 'on'),
               )
            
def update_Graph(n , on):	
	if on == True:
		x2 = monotonic() - x1
		Timer(1 - x2, sampledata).start() #sample data from sensor and import into db
		####### figuir function
		figure = go.Figure({'data' :data, 'layout' : layout})
		figure 
		return figure
	else:
		
		
		return no_update
           
app.run_server(host = '', port = , debug=True, use_reloader=True)

```

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 9, 2022, 2:14pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/2 "2022-12-09T14:14:00Z")

</div>

Hey @alejandrosando,

I was wondering if you got it working or not.

Have you tried turning off debug and reloaded?

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 9, 2022, 2:46pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/3 "2022-12-09T14:46:33Z")

</div>

Also, question, what is the Pi running?

Is it running pi-hole?

---

<div class="post-metadata">

**Author:** ![alejandrosando](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@alejandrosando](https://community.plotly.com/u/alejandrosando)\
**Post date:** [December 9, 2022, 3:04pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/4 "2022-12-09T15:04:05Z")

</div>

hey,  
I actually need bedug to catch any mistakes in Dash code. And I have tried to turn off the use\_reloder, but it does not make any difference.  
I have Rasbian/raspberry pi os on the Pi

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 9, 2022, 3:05pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/5 "2022-12-09T15:05:47Z")

</div>

What other tasks is the Pi doing, other than running the server?

---

<div class="post-metadata">

**Author:** ![alejandrosando](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@alejandrosando](https://community.plotly.com/u/alejandrosando)\
**Post date:** [December 9, 2022, 3:07pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/6 "2022-12-09T15:07:44Z")

</div>

Nothing, just running this script. I even use another pc to open the browser with the IP

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 9, 2022, 3:10pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/7 "2022-12-09T15:10:11Z")

</div>

What IP is it running on?

Is there anything that would route requests from the router to hit it more often.

Also, have you tried spreading the interval out, 1 second seems rather quick. Maybe try 5 seconds?

---

<div class="post-metadata">

**Author:** ![alejandrosando](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@alejandrosando](https://community.plotly.com/u/alejandrosando)\
**Post date:** [December 9, 2022, 3:15pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/8 "2022-12-09T15:15:32Z")

</div>

I am using LAN with both pc and pi  
I have not tried this yet, the main goal of the project is to get data point once per second.

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 9, 2022, 3:25pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/9 "2022-12-09T15:25:43Z")

</div>

On the pi, can you see how many requests are coming in?

Is it getting duplicated?

---

<div class="post-metadata">

**Author:** ![alejandrosando](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@alejandrosando](https://community.plotly.com/u/alejandrosando)\
**Post date:** [December 9, 2022, 3:36pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/10 "2022-12-09T15:36:59Z")

</div>

I have just tried to get the interval 2 seconds, and it was pretty accurate even while surfing.  
Sorry, How can I found how many requests are coming in pi?

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 9, 2022, 3:51pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/11 "2022-12-09T15:51:02Z")

</div>

You’d have to watch the python console on the pi.

Glad 2 seconds is working.

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 9, 2022, 4:07pm UTC](https://community.plotly.com/t/plotly-dash-on-respberry-pi-3-b/70705/12 "2022-12-09T16:07:58Z")

</div>

Here’s a possible theory:

Your initial timeframe, every 1 second.

Here is what is happening on the network and server side of things:

- it takes .2 seconds for the info to reach your server
- your server takes .1 seconds to process the data
- it takes .2 seconds to jsonify
- it takes .2 seconds to transmit back
- it takes .2 seconds to receive and update the client

So, every 1 second, you are using the network and server for .9 seconds. Which leaves .1 second for wiggle room.

If any part of the process takes slightly longer than expected, you start to run into a backlog of requests, because your requests are at a steady pace of 1 second.

Slowing it down to 2 seconds allows for the wiggle room.

* * *

Things that can effect your processing:

- server heat (server doesnt get a chance to breath between requests)
- network latency increases

This is why people typically will throttle API calls on servers. 😃
