Skip to content

Instantly share code, notes, and snippets.

@domadev812
Forked from banasrini/gauge.js
Last active November 15, 2017 21:05
Show Gist options
  • Select an option

  • Save domadev812/37ca780b45632bb7e4f1a6ec54890394 to your computer and use it in GitHub Desktop.

Select an option

Save domadev812/37ca780b45632bb7e4f1a6ec54890394 to your computer and use it in GitHub Desktop.
eon.chart({
channel: 'humeon',
generate: {
bindto: '#chart',
data: {
type: 'gauge',
},
gauge: {
min: 0,
max: 100
},
color: {
pattern: ['#FF0000', '#F6C600', '#60B044'],
threshold: {
values: [30, 60, 90]
}
}
}
});
import os
import time
import sys
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub import PubNub
import Adafruit_DHT as dht
pnconfig = PNConfiguration()
pnconfig.subscribe_key = 'demo'
pnconfig.publish_key = 'demo'
pubnub = PubNub(pnconfig)
eon.chart({
history: true,
channel: 'tempeon',
flow: true,
generate: {
bindto: '#chart',
data: {
x: 'x',
labels: false
},
axis : {
x : {
type : 'timeseries',
tick: {
format: '%H:%M:%S'
}
}
}
}
});
def callback(message):
print(message)
while True:
h,t = dht.read_retry(dht.DHT22, 4)
pubnub.publish().channel('tempeon').message({
'columns': [
['x', time.time()],
['temperature_celcius', t]
]
}).async(publish_callback)
pubnub.publish().channel('humeon').message({
'columns': [
['humidity', h]
]
}).async(publish_callback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment