How to append a global variable fired by an interval for graph a sensor data generated inside the script

Hello everyone, I am trying to graph some measures of almost 9 sensors for a project and had no problems until I deployed my application in heroku.

Reading a bit and after looking for different solutions, I found https://dash.plot.ly/sharing-data-between-callbacks, so it seems that the global variables that I use to collect part of the visualization data are creating conflict.

Try some of the methods to send data between callbacks, like Flask-caching and Hidden Divs,but I am not able to achieve it, I hope and some of you have suggestions, I would really appreciate it.
This is a example of the perform of the app on heroku https://dash-deploy-sensores.herokuapp.com/
and the code

import os
import datetime
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly
import random
from collections import deque
import plotly.graph_objs as go
from dash.dependencies import Input, Output ,State
from dash.exceptions import PreventUpdate

X = deque(maxlen=50)
Y1 = deque(maxlen=50)
Y2 = deque(maxlen=50)

def sensor_read(X,Y1,Y2):

X.append(datetime.datetime.now() - datetime.timedelta()) #Current time
Y1.append(random.randrange(-20,20)) #Sensor value 1
Y2.append(random.randrange(0,5))    #Senro value 2
return X,Y1,Y2

app = dash.Dash(name)
server = app.server

app.layout = html.Div(
html.Div([
html.H4(‘Sensor read data’),
dcc.Store(id=‘local’, storage_type=‘local’),
html.Div(id=‘live-update-text’),
dcc.Graph(id=‘live-graph’),
dcc.Interval(
id=‘interval-component’,
interval=1000,
n_intervals=0
)
])
)

@app.callback(Output(‘live-update-text’, ‘children’),
[Input(‘interval-component’, ‘n_intervals’)])
def update_metrics(n):
style = {‘padding’: ‘5px’, ‘fontSize’: ‘16px’}
return [
html.Span(‘Value 1: {0:.2f}’.format(int(Y1[-1])), style=style),
html.Span(‘Value 2: {0:.2f}’.format(int(Y2[-1])), style=style)
]

@app.callback(Output(‘live-graph’, ‘figure’),
[Input(‘interval-component’, ‘n_intervals’)])
def update_graph_scatter(n):
sensor_read(X,Y1,Y2)

trace1 = go.Scatter(
        x=list(X),
        y=list(Y1),
        name='Altitud',
        mode= 'lines+markers'
        )





return {'data': [trace1],'layout' : go.Layout()}

if name == ‘main’:
app.run_server(debug=True)