daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Jan 17th, 2018 55 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top