-
21Add Accel
#!/usr/bin/python3 import os import time import sys accel_x_raw = open("/sys/bus/iio/devices/iio:device1/in_accel_x_raw", "r") accel_y_raw = open("/sys/bus/iio/devices/iio:device1/in_accel_y_raw", "r") accel_z_raw = open("/sys/bus/iio/devices/iio:device1/in_accel_z_raw", "r") devID = "i2c_adxl345" accel_x_raw_value = int(accel_x_raw.read()) accel_x_raw.seek(0) accel_x_raw.close() accel_y_raw_value = int(accel_y_raw.read()) accel_y_raw.seek(0) accel_y_raw.close() accel_z_raw_value = int(accel_z_raw.read()) accel_z_raw.seek(0) accel_z_raw.close() print("metric:id=%s,n=accel_x,vd=%0.1d,u=U" % (devID, accel_x_raw_value)) print("metric:id=%s,n=accel_y,vd=%0.1d,u=U" % (devID, accel_y_raw_value)) print("metric:id=%s,n=accel_z,vd=%0.1d,u=U" % (devID, accel_z_raw_value))
-
22Add SHT35
#!/usr/bin/python3 import os import time import sys hwmon_temp = open("/sys/class/hwmon/hwmon0/temp1_input", "r") hwmon_hum = open("/sys/class/hwmon/hwmon0/humidity1_input", "r") devID = "i2c_sht35" hwmon_temp_value = int(hwmon_temp.read()) hwmon_temp_f = ((hwmon_temp_value * 9/5) + 32000)/ 1000 hwmon_temp.seek(0) hwmon_temp.close() hwmon_hum_value = int(hwmon_hum.read()) hwmon_hum_rh = (hwmon_hum_value /1000) hwmon_hum.seek(0) hwmon_hum.close() print("metric:id=%s,n=Temperature,vd=%0.1f,u=F" % (devID, hwmon_temp_f)) print("metric:id=%s,n=Humidity,vd=%0.2f,u=%%" % (devID, hwmon_hum_rh))
-
23Add Button
#!/usr/bin/python3 import os import time import evdev import sys devID = "U4_Button" class BUTTON: def __init__(self): try: self.button = evdev.InputDevice("/dev/input/event1") except IOError as err: GetCmdReturn('sudo chmod 777 /dev/input/event1') self.button = evdev.InputDevice("/dev/input/event1") def GetKeyStatus(self): """Get two button's Value return:[](Button isn't pressed),[256],[257](Button is pressed) """ return self.button.active_keys() def read_loop(self): """Read two button's status constantly return:two button's status """ return self.button.read_loop() def main(): d = BUTTON() for event in d.read_loop(): if event.type == evdev.ecodes.EV_KEY: #print(d.GetKeyStatus()) #print(evdev.categorize(event)) c = evdev.categorize(event) if c.keystate == c.key_down: print("metric:id=%s,n=State,vb=1,u=S" % (devID)) sys.stdout.flush() elif c.keystate == c.key_up: print("metric:id=%s,n=State,vb=0,u=S" % (devID)) sys.stdout.flush() if __name__ == "__main__": main()
-
24All Collectors
-
25Live Data
-
26DashBoard
-
27Rules
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Just in case someone else runs into this problem, if the wlan0 device is unrecognized, check that the PocketBeagle board pins are schmooshed down all the way.
Are you sure? yes | no