This is a continuation of Post#4 , data received through UART in Beaglebone board is displayed in terminal. My problem the last time is that I can't send data to AirVantage using MQTT since my Beaglebone is behind university proxy. MQTT is using default port 1883 as reserved with IANA. To avoid this problem, I will be using REST API instead.
In this post, data will be sent to AirVantage using Python with REST API.
About AirVantage:
Sierra Wireless AirVantage M2M Cloud provides a seamless connection between devices, M2M cloud and the enterprise. Devices include Sierra wireless' modules and gateways but third party hardware like Beaglebone may be used instead which may communicate to AirVantage Cloud using standard protocols like MQTT and HTTP. AirVantage platform offers secure big data storage and management with good features like data and communication monitoring. Stored data may be retrieved and integrated with multiple backend systems, web and mobile application. All of this can be tried for six months with up to 5 connected devices through this link Sierra Wireless - AirVantage Enterprise Platform (AVEP)
Connecting Beaglebone to AirVantage Cloud with Python using REST:
Here are some guides on how to setup system on AirVantage:
1. Video Link: Building IoT Projects on the AirVantage M2M Cloud
2. To interface with AirVantage: Using REST API for devices
Command to access Beaglebone serial number:
# hexdump -e '8/1 "%c"' /sys/bus/i2c/devices/0-0050/eeprom -s 16 -n 12 2>&1
After AirVantage setup is to write a code in Beaglebone for publishing data. You will need to install "requests" to use example code below:
# pip install requests
Edited version of post#4 Python code ( added sending data to AirVantage )
import serial import time from xbee import XBee import json import requests serial_port = serial.Serial('/dev/ttyO2', 9600) #UART2 of Beaglebone host = "https://na.airvantage.net" url = "{}/device/messages".format( host ) def print_data(data): if 'source_addr' in data: hex_data = data['rf_data'] sensor_data = map(ord, hex_data) doxy = sensor_data[1] data = [ { "algal.doxy": [ { "value" : doxy } ] }, { "algal.threshold": [ { "value" : "30" } ] } ] requests.post( url, auth=("XXXXXXXX", "1234"), #replace XXXXXXXX with Beaglebone serial number data=json.dumps(data), headers={'Content-type': 'application/json'} ) print 'D.O. = %d'%sensor_data[1] xbee = XBee(serial_port, callback = print_data) while True: try: time.sleep(0.01) except KeyboardInterrupt: break xbee.halt() serial_port.close()
Run the python code in Beaglebone and monitor updates in AirVantage cloud.
Data History: D.O. chart for last 3 hours
Next post: Since I have already tested Beaglebone and AirVantage, I might shift my work on CC3200 and post my experience with it next week.
Top Comments