def __init__(self): super(GroveBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( i2c_bus=6 ) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.pin_mappings.i2c_bus = 512 self.screen = Jhd1313m1(self.pin_mappings.i2c_bus, 0x3E, 0x62) self.accelerometer = MMA7660(self.pin_mappings.i2c_bus, 0x4C) # accelerometer setup self.ax = accel_float() self.ay = accel_float() self.az = accel_float() self.accelerometer.setModeStandby() self.accelerometer.setSampleRate(0x01) self.accelerometer.setModeActive() self.acceleration_detected = False
def __init__(self): super(DfrobotBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( motion_pin=16, screen_register_select_pin=8, screen_enable_pin=9, screen_data_0_pin=4, screen_data_1_pin=5, screen_data_2_pin=6, screen_data_3_pin=7, screen_analog_input_pin=0 ) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.motion = BISS0001(self.pin_mappings.motion_pin) self.screen = SAINSMARTKS( self.pin_mappings.screen_register_select_pin, self.pin_mappings.screen_enable_pin, self.pin_mappings.screen_data_0_pin, self.pin_mappings.screen_data_1_pin, self.pin_mappings.screen_data_2_pin, self.pin_mappings.screen_data_3_pin, self.pin_mappings.screen_analog_input_pin ) self.last_motion = False
def __init__(self): super(GroveBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( air_pin=0, speaker_pin=5 ) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.air = TP401(self.pin_mappings.air_pin) self.speaker = Speaker(self.pin_mappings.speaker_pin)
def __init__(self): super(DfrobotBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( gas_pin=3, speaker_pin=16 ) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.air = MQ2(self.pin_mappings.gas_pin) self.speaker = Gpio(self.pin_mappings.speaker_pin) self.speaker.dir(DIR_OUT)
def __init__(self): super(GroveBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( motion_pin=4, i2c_bus=6 ) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.pin_mappings.i2c_bus = 512 self.motion = BISS0001(self.pin_mappings.motion_pin) self.screen = Jhd1313m1(self.pin_mappings.i2c_bus, 0x3E, 0x62) self.last_motion = False
def __init__(self): super(GroveBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( interrupter_pin=2, uart_bus=0 ) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.gps_baud = HARDWARE_CONFIG.gps_baud self.gps = NMEAGPS(self.pin_mappings.uart_bus, self.gps_baud, -1) self.interrupter = RFR359F(self.pin_mappings.interrupter_pin) self.obj_detected_state = False self.nmea_stream_reader = NMEAStreamReader()
def __init__(self): super(GroveBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings(buzzer_pin=6, button_pin=5, rotary_pin=0, i2c_bus=6) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.pin_mappings.i2c_bus = 512 self.screen = Jhd1313m1(self.pin_mappings.i2c_bus, 0x3E, 0x62) self.buzzer = Gpio(self.pin_mappings.buzzer_pin) self.rotary = Rotary(self.pin_mappings.rotary_pin) self.button = Button(self.pin_mappings.button_pin) self.buzzer.dir(DIR_OUT) self.rotary_value = 0 self.button_state = False
def __init__(self): super(DfrobotBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( buzzer_pin=15, button_pin=16, rotary_pin=3, screen_register_select_pin=8, screen_enable_pin=9, screen_data_0_pin=4, screen_data_1_pin=5, screen_data_2_pin=6, screen_data_3_pin=7, screen_analog_input_pin=0, ) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.screen = SAINSMARTKS( self.pin_mappings.screen_register_select_pin, self.pin_mappings.screen_enable_pin, self.pin_mappings.screen_data_0_pin, self.pin_mappings.screen_data_1_pin, self.pin_mappings.screen_data_2_pin, self.pin_mappings.screen_data_3_pin, self.pin_mappings.screen_analog_input_pin, ) self.buzzer = Gpio(self.pin_mappings.buzzer_pin) self.rotary = Rotary(self.pin_mappings.rotary_pin) self.button = Button(self.pin_mappings.button_pin) self.buzzer.dir(DIR_OUT) self.rotary_value = 0 self.button_state = False
def __init__(self): super(GroveBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( mic_pin=0, i2c_bus=6 ) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.pin_mappings.i2c_bus = 512 self.mic = Microphone(self.pin_mappings.mic_pin) self.screen = Jhd1313m1(self.pin_mappings.i2c_bus, 0x3E, 0x62) self.mic_ctx = micThresholdContext() self.mic_ctx.averageReading = 0 self.mic_ctx.runningAverage = 0 self.mic_ctx.averagedOver = 2
def __init__(self): super(DfrobotBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( temperature_pin=2, buzzer_pin=15, screen_register_select_pin=8, screen_enable_pin=9, screen_data_0_pin=4, screen_data_1_pin=5, screen_data_2_pin=6, screen_data_3_pin=7, screen_analog_input_pin=0 ) self.voltage_adjust = 1.0 if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.voltage_adjust = 0.66 self.screen = SAINSMARTKS( self.pin_mappings.screen_register_select_pin, self.pin_mappings.screen_enable_pin, self.pin_mappings.screen_data_0_pin, self.pin_mappings.screen_data_1_pin, self.pin_mappings.screen_data_2_pin, self.pin_mappings.screen_data_3_pin, self.pin_mappings.screen_analog_input_pin ) self.temperature = LM35(self.pin_mappings.temperature_pin) self.temperature.setScale(self.voltage_adjust) self.buzzer = Gpio(self.pin_mappings.buzzer_pin) self.buzzer.dir(DIR_OUT)
def __init__(self): super(DfrobotBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( accel_x_pin=3, accel_y_pin=2, accel_z_pin=1, screen_register_select_pin=8, screen_enable_pin=9, screen_data_0_pin=4, screen_data_1_pin=5, screen_data_2_pin=6, screen_data_3_pin=7, screen_analog_input_pin=0 ) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.screen = SAINSMARTKS( self.pin_mappings.screen_register_select_pin, self.pin_mappings.screen_enable_pin, self.pin_mappings.screen_data_0_pin, self.pin_mappings.screen_data_1_pin, self.pin_mappings.screen_data_2_pin, self.pin_mappings.screen_data_3_pin, self.pin_mappings.screen_analog_input_pin ) # accelerometer setup self.ax = Aio(self.pin_mappings.accel_x_pin) self.ay = Aio(self.pin_mappings.accel_y_pin) self.az = Aio(self.pin_mappings.accel_z_pin) self.acceleration_detected = False
def __init__(self): super(GroveBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( temperature_pin=0, buzzer_pin=5, i2c_bus=6 ) self.voltage_adjust = 1.0 if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.pin_mappings.i2c_bus = 512 self.voltage_adjust = 0.66 self.screen = Jhd1313m1(self.pin_mappings.i2c_bus, 0x3E, 0x62) self.temperature = Temperature(self.pin_mappings.temperature_pin) self.buzzer = Gpio(self.pin_mappings.buzzer_pin) self.buzzer.dir(DIR_OUT)
def __init__(self): super(GroveBoard, self).__init__() # pin mappings self.pin_mappings = PinMappings( touch_pin=4, buzzer_pin=5, i2c_bus=6 ) if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata: addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0") self.pin_mappings += 512 self.pin_mappings.i2c_bus = 512 self.screen = Jhd1313m1(self.pin_mappings.i2c_bus, 0x3E, 0x62) self.touch = TTP223(self.pin_mappings.touch_pin) self.buzzer = Gpio(self.pin_mappings.buzzer_pin) self.buzzer.dir(DIR_OUT) self.touch_state = False self.stop_buzzer()
# The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE import mraa print (mraa.getVersion()) # open connection to Firmata mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0") import time, sys, signal, atexit import pyupm_curieimu as curieimu sensor = curieimu.CurieImu() ## Exit handlers ## def SIGINTHandler(signum, frame): raise SystemExit def exitHandler(): print "Exiting" sys.exit(0) # Register exit handlers atexit.register(exitHandler)
# without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import mraa import time print (mraa.getVersion()) mraa.addSubplatform(mraa.BLE_FIRMATA_BY_NAME, "FIRMATA") try: x = mraa.Aio(0+512) for i in range(50): print (x.read()) print ("%.5f" % x.readFloat()) time.sleep(1) except: print ("Are you sure you have an ADC?")
#!/usr/bin/env python # Author: Ron Evans (@deadprogram) # Copyright (c) 2016 Intel Corporation. # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import mraa print (mraa.getVersion()) mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0");
import time from upm import pyupm_th02 as grove import mraa mraa.addSubplatform(mraa.GROVEPI, "0") def main(): th02 = grove.TH02() print(th02.name()) # Create the temperature sensor object using AIO pin 0 temp = th02.getTemperature() print(temp) # Read the temperature ten times, printing both the Celsius and # equivalent Fahrenheit temperature, waiting one second between readings for i in range(0, 1000): temp = th02.getTemperature() temp1 = th02.getHumidity() print(temp, temp1) time.sleep(1) # Delete the temperature sensor object del temp if __name__ == '__main__': main()