Skip to main content
How To Make IoT Tweet with Python
Add This Script to your Project Directory and Save it As (iot.py)
Open your Python Script and Add the iot.py :
from iot import *
Add your IoT name to the Database this Step is Very Important :
addData('iot','pythonscript') # First Add The Name of IoT mine is "pythonscript"
Okay, if i want add the IP Address of my IoT i did this :
from subprocess import check_output
# This is to get The IP address of IoT
ip = check_output("ifconfig docker0 | grep 'inet ' | awk '{print $2}'", shell=True)
ip = ip.rstrip()
params = addData('MyIP',ip) # Add the IP address to Your IoT
Let's Say we finished and ready to tweet my Data :
saveData(alldata['iot'],params) # Now Save Your Data
To Get Your Data in the Browser open This and Change the name with your IoT.
To Get Your Data with Python Script you Need to Do This :
from iot import *
MyData = loadData("pythonscript") # This To Load Your Data
print MyData['iot'] # To print The Name
print MyData['ip'] # To print saved Data the IP etc..
That's it.
Comments
Post a Comment