Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, psutil, os
- import Adafruit_BBIO.PWM as PWM
- import time
- import datetime
- LED = "P8_13"
- PWM.start(LED, 0)
- thing_name = "6d073d05-4f53-b8a2-1040318ecfbb_dote"
- def dweet(thing, **vals):
- url = "http://dweet.io/dweet/for/{}".format(thing)
- requests.post(url, params=vals)
- def get_uptime():
- with open("/proc/uptime", "r") as f:
- raw = f.read()
- seconds = float(raw.split()[0])
- return seconds
- def LEDII():
- try:
- while True:
- for i in range(0, 100):
- PWM.set_duty_cycle(LED, i)
- time.sleep(0.2)
- for i in range(100, 0, -1):
- PWM.set_duty_cycle(LED, i)
- time.sleep(0.2)
- while True:
- uptime = get_uptime()
- uptime_datetime = datetime.datetime.fromtimestamp(uptime)
- uptime_datetime.strftime("%H:$M:$S")
- load = psutil.cpu_percent(interval=2)
- mem = psutil.virtual_memory()[2]
- LEDI = LEDII()
- dweet(thing_name, uptime=uptime, cpu_load=load, memory=mem, LEDII=LEDI)
- print(os.getloadavg())
- except KeyboardInterrupt:
- PWM.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement