JSON result returning “None” when sending data to Ubidots from Raspberry Pi 3


#1

I am trying to send data from my soil moisture sensor (which is connected to an ADC which is in turn connected to my Raspberry Pi) to Ubidots.

This is my code:

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()

I am getting the following response:

Moisture Level: 26508
None

#2

I followed this tutorial: https://ubidots.com/docs/es/devices/raspberrypi.html and it worked.


#3

Hi there, what is the responde code or the answer from the server? May you share it with us please