Project
Implement a function to simulate a Sensor, data will be based on system-wide network I/O statistics using psutil python library, the Simulated Sensor is implemented in case no physical sensor is available
Go to your git "TheIoTLearningInitiative" repository, under "InternetOfThings101" directory
root@board:~# cd TheIoTLearningInitiative/InternetOfThings101
root@board:~/TheIoTLearningInitiative/InternetOfThings101#root@edison:~/TheIoTLearningInitiative/InternetOfThings101# vi main.py#!/usr/bin/python
import psutil
import signal
import sys
import time
def functionDataSensor():
netdata = psutil.net_io_counters()
data = netdata.packets_sent + netdata.packets_recv
return data
def functionSignalHandler(signal, frame):
sys.exit(0)
if __name__ == '__main__':
signal.signal(signal.SIGINT, functionSignalHandler)
while True:
print "Hello Internet of Things 101"
print "Data Sensor: %s " % functionDataSensor()
time.sleep(5)
# End of FileLast updated