[SOLVED] Udoo Neo and Ubidots?

How connect Udoo neo to Ubidots? Thanks.

I got a Udoo Neo a while back and did some tests with Python. First, I logged in through ssh to the board, make sure you’re connected to WiFi:

sudo nmcli d wifi connect MONTOYA password 3155294058 iface wlan0

Then install Ubidots Python library:

sudo pip install ubidots

Then create a python code to read the Udoo sensors (in this case a gyroscope) and send the data to Ubi:

import time
import sys
import commands
import subprocess
from ubidots import ApiClient

try:

    api = ApiClient(token="4d195c0044fcc3b9f6dab9d653af3")

except:

    print("Couldn't connect to the API, check your Internet connection")
    sys.exit(0)

while(1):
    data = commands.getstatusoutput('cat /sys/class/misc/FreescaleGyroscope/data')
    output = data[1].split(',')
    api.save_collection([{'variable':'5657616d762542269dfb3833','value':output[0]},{'variable':'56576179762542269dfb3849','value':output[1]},{'variable':'5657618476254227de42b754','value':output[2]}])

Just found in Udoo Community that there’s already a Python library to access the Neo’s GPIO’s:
https://github.com/smerkousdavid/Neo.GPIO you can use it in combination with Ubidots’ Python library.

Thanks.
Can i received and send of date from Barometric, Temp bricks (sensor) and sensor (Seeedstudio) which to connect through Grove Shield?

How send data from this sensor?

# A library (example) to get the current values for the outboard sensors such as 
# Temperature sensor
# Barometer

from neo import Temp #import libraries
from neo import Barometer

from time import sleep # import for delays

temp = Temp() # init objects p.s. I auto initialize/reset the modules on these calls
baro = Barometer()

while True:
	tempVal = temp.getTemp("f") # replace f with c to get celcius
	print "Current temp from sensor 1: "+str(tempVal) #need to turn into string before building strings

	pressureVal = baro.getPressure() # gets the pressure in kPA
	print "Current pressure in (kPa):  "+str(pressureVal)

	tempFromBaro = baro.getTemp("c") # slower than temp sensor but still works same as temp sensor replace c with f for different modes
	print "Current temp from sensor 2: "+str(tempFromBaro)

	print "" # newline
	sleep(5) # wait a (5) second

I began to write, but weak in programming

    # A library (example) to get the current values for the outboard sensors such as 
# Temperature sensor
# Barometer

from neo import Temp #import libraries
from neo import Barometer

from time import sleep # import for delays

temp = Temp() # init objects p.s. I auto initialize/reset the modules on these calls
baro = Barometer()

import time
import sys
import commands
import subprocess
from ubidots import ApiClient

try:

    api = ApiClient(token="my1111111")

except:

    print("Couldn't connect to the API, check your Internet connection")
    sys.exit(0)

while(1):
    data = commands.getstatusoutput('cat /sys/class/i2c-dev/i2c-1/device/1-0060/iio\:device0/in_temp_raw')
    output = data[1].split(',')
    api.save_collection([{'variable':'5777bbe67625427a308c0c91','value':output[0]}])

baro = Barometer()

while True:
	tempVal = temp.getTemp("f") # replace f with c to get celcius
	print "Current temp from sensor 1: "+str(tempVal[0]) #need to turn into string before building strings

	tempFromBaro = baro.getTemp("c") # slower than temp sensor but still works same as temp sensor replace c with f for different modes
	print "Current temp from sensor 2: "+str(tempFromBaro)# turn current values (ints) to strings


	print "" # newline
	sleep(5) # wait a (5) second

Hi there, I would recommend doing a Python script to print the sensor readings first, just to make sure you’re being able to see the data. I’m not familiar with the board, but in the case of grove sensors I would look for the documentation to see to which pins (GPIOs) their are connected, and then read those pins from Python.

The code sends data, but first wrote echo: I / O error:

[CODE]#Sensor examples for everything builtin the board such as
#Magnometer -> Magnetic pull on device
#Gyroscope - > xyz tilt degree on the device
#Accelerometer -> xyz directional force measurment

A library (example) to get the current values for the outboard sensors such as

Temperature sensor

Barometer

from neo import Accel # import accelerometer
from neo import Magno # import magnometer
from neo import Gyro # import gyroscope
from neo import Temp #import libraries
from neo import Barometer

from time import sleep # to add delays

gyro = Gyro() # new objects p.s. this will auto initialize the device onboard
accel = Accel()
magno = Magno()
temp = Temp() # init objects p.s. I auto initialize/reset the modules on these calls
baro = Barometer()

accel.calibrate()
gyro.calibrate() # Reset current values to 0
magno.calibrate()

gyroVals = gyro.get() # Returns a full xyz list [x,y,z] realtime (integers/degrees)
magnoVals = magno.get() # Above
accelVals = accel.get() # Same as gyro return xyz of current displacment force
tempVal = temp.getTemp(“f”) # replace f with c to get celcius
pressureVal = baro.getPressure() # gets the pressure in kPA
tempFromBaro = baro.getTemp(“c”) # slower than temp sensor but still works same as temp sensor replace c with f for different modes

Ubidots send

import time
import sys
import commands
import subprocess
from ubidots import ApiClient

try:

api = ApiClient(token="my1111111")

except:

print("Couldn't connect to the API, check your Internet connection")
sys.exit(0)

while(1):
# Gyroscope - gyroVals
api.save_collection([{‘variable’:‘57764c607625426dabe59553’,‘value’:gyroVals[0]}, {‘variable’:‘5777ab807625426b4b374590’,‘value’:gyroVals[1]},{‘variable’:‘5777ad1a76254278d965ab79’,‘value’:gyroVals[2]}])
#Magnometer - magnoVals
api.save_collection([{‘variable’:‘57791489762542273026d016’,‘value’:magnoVals[0]}, {‘variable’:‘577914957625422752d8e2ee’,‘value’:magnoVals[1]},{‘variable’:‘5779149e76254227fe248510’,‘value’:magnoVals[2]}])
#Accelerometer - accelVals
api.save_collection([{‘variable’:‘5779209e762542373fde5702’,‘value’:accelVals[0]}, {‘variable’:‘577920a776254237c318b71a’,‘value’:accelVals[1]},{‘variable’:‘577920ad76254237e23ea12b’,‘value’:accelVals[2]}])
#Temperature sensor - tempVal
api.save_collection([{‘variable’:‘5777bbe67625427a308c0c91’,‘value’:tempVal}])
#Barometer - pressureVal
api.save_collection([{‘variable’:‘5779289a76254218a67eacaf’,‘value’:pressureVal}])
#TempFromBaro
api.save_collection([{‘variable’:‘5777bbee7625427a763c7332’,‘value’:tempFromBaro}])
[/CODE]

Looks good, I think you need to read the sensors inside the while loop and not before it, so the can be updated in real time.