JSON结果返回"无"从Raspberry Pi 3向Ubidots发送数据时

时间:2018-01-17 14:57:00

标签: python json raspberry-pi

我正在尝试从我的土壤湿度传感器(连接到一个ADC,然后连接到我的Raspberry Pi)向Ubidots发送数据。

import time
import sys
from time import sleep
import requests
import traceback
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)
    payload={'soil humidity':m}
    try:
       r = requests.post('http://things.ubidots.com/api/v1.6/devices/raspberry/?token={A1E-6l4DwwC86SDR6QRTJWXGDwshTGPHFl}', data=payload)
       print('Moisture Level:{0:>6}'.format(m))
       time.sleep(1)
    except KeyboardInterrupt:
       break
    traceback.print_exc()

我收到以下回复:

Moisture Level: 26508
None

并继续循环播放。 任何帮助如何为此打印traceback也将不胜感激。

链接到Ubidots文档:http://help.ubidots.com/iot-projects-tutorials/diy-raspberry-pi-temperature-system-with-ubidots

0 个答案:

没有答案