Exemplo n.º 1
0
# py.sign_in(plotly_user_config["plotly_username"], plotly_user_config["plotly_api_key"])

# url = py.plot([
#     {
#         'x': [], 'y': [], 'type': 'scatter',
#         'stream': {
#             'token': plotly_user_config['plotly_streaming_tokens'][0],
#             'maxpoints': 200
#         }
#     }], filename='Raspberry Pi Streaming Example Values')

# print "View your streaming graph here: ", url

# temperature sensor middle pin connected channel 0 of mcp3008
sensor_pin = 0
readadc.initialize()

# stream = py.Stream(plotly_user_config['plotly_streaming_tokens'][0])
# stream.open()

#the main sensor reading and plotting loop
while True:
    sensor_data = readadc.readadc(sensor_pin, readadc.PINS.SPICLK,
                                  readadc.PINS.SPIMOSI, readadc.PINS.SPIMISO,
                                  readadc.PINS.SPICS)

    millivolts = sensor_data * (3300.0 / 1024.0)
    # 10 mv per degree
    temp_C = ((millivolts - 100.0) / 10.0) - 40.0
    # convert celsius to fahrenheit
    temp_F = (temp_C * 9.0 / 5.0) + 32
def setup():
    readadc.initialize()
MIN_TEMP = 30
MAX_TEMP = 40
SEEN_THRESHOLD = 5


## Variables
counter = 0
total = 0
seen = 0
plot_counter = 0

conn = sqlite3.connect(config['db_path'], isolation_level=None)
cursor = conn.cursor()

## Initializ
readadc.initialize()

py.sign_in(config["plotly_username"], config["plotly_api_key"])
url = py.plot([
    {
        'type': 'scatter',
        'stream': {
            'token': config['plotly_streaming_tokens'][0],
        }
    }], filename=config['plotly_filename'],
    fileopt='extend'
)


stream = py.Stream(config['plotly_streaming_tokens'][0])
stream.open()
Exemplo n.º 4
0
def setup():
    readadc.initialize()
Exemplo n.º 5
0
def setup():
    
    GPIO.setup(chan_list, GPIO.OUT,initial=GPIO.LOW)
    
    readadc.initialize()
Exemplo n.º 6
0
 def __init__(self):
     self.sensor_pin = 0
     readadc.initialize()