Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import sys
- from time import sleep
- import requests
- import Adafruit_ADS1x15
- # Create an ADS1115 ADC (16-bit) instance.
- adc = Adafruit_ADS1x15.ADS1115()
- GAIN = 1
- print('Reading ADS1x15 values, press Ctrl-C to quit...')
- while True:
- m = adc.read_adc(0, gain=GAIN)
- try:
- r = requests.post('http://things.ubidots.com/api/v1.6/devices/raspberry/?token={A1E-6l4DwwC86SDR6QRTJWXGDwshTGPHFl}', m)
- print('Moisture Level:{0:>6}'.format(m))
- time.sleep(1)
- except KeyboardInterrupt:
- break
- except Exception as e:
- print (e)
Add Comment
Please, Sign In to add comment