daily pastebin goal
67%
SHARE
TWEET

Untitled

a guest Jan 17th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2. import sys
  3. from time import sleep
  4. import requests
  5. import Adafruit_ADS1x15
  6.  
  7. # Create an ADS1115 ADC (16-bit) instance.
  8. adc = Adafruit_ADS1x15.ADS1115()
  9.  
  10. GAIN = 1
  11.  
  12. print('Reading ADS1x15 values, press Ctrl-C to quit...')
  13.  
  14. while True:
  15.    m = adc.read_adc(0, gain=GAIN)
  16.   try:
  17.    r = requests.post('http://things.ubidots.com/api/v1.6/devices/raspberry/?token={A1E-6l4DwwC86SDR6QRTJWXGDwshTGPHFl}', m)
  18.    print('Moisture Level:{0:>6}'.format(m))
  19.    time.sleep(1)
  20.  except KeyboardInterrupt:
  21.    break
  22.  except Exception as e:
  23.    print (e)
RAW Paste Data
Top