def plot(x, y, z): global count val_list.append((x, y, z)) print('value', count, x, y, z) count += 1 if count % 1000 == 0: print('writing to file') with open('dump.txt', 'w') as f: for i, (x, y, z) in enumerate(val_list): f.write(f'{i} {x} {y} {z}\n') class Motion(System): x = ArduinoAnalogSensor(service=0, pin=0, active_condition=Value(True), update_condition=Value(True), on_update=Func(plot, 'x', 'y', 'z'), exclude_triggers={'y', 'z'}) y = ArduinoAnalogSensor(service=0, pin=1) z = ArduinoAnalogSensor(service=0, pin=2) s = Motion(services=[ ArduinoService( device="/dev/ttyUSB0", device_type='arduino"', sample_rate=100, ), WebService(), ], )
source_a4 = ArduinoAnalogSensor(service=0, pin=4) class Remote(Group): awds1 = ArduinoRemoteDigitalSensor(service=1, device=source_dev, pin=2) # receives via VW awds2 = ArduinoRemoteAnalogSensor(service=1, device=source_dev, pin=0) # receives via VW vw_speed = 7 s = ArduinoSystem( services=[ ArduinoService( device="/dev/ttyUSB0", sample_rate=500, home_address=source_home, device_address=source_dev, #virtualwire_ptt_pin=9, # virtualwire_tx_pin=11, keep_alive=True, #wakeup_pin=2, virtualwire_speed=vw_speed, #lcd_port=0x3F, #lcd_reporting=True, ), ArduinoService( device="/dev/ttyUSB1", sample_rate=8000, home_address=target_home, device_address=target_dev, virtualwire_rx_pin=10, virtualwire_speed=vw_speed, ), TextUIService(),
a1 = ArduinoAnalogSensor(service=0, pin=0) d12 = ArduinoDigitalSensor(service=0, pin=12, pull_up_resistor=True, inverted=True) d13 = ArduinoDigitalActuator(service=0, pin=13) # LED on Arduino board #servo = ArduinoServoActuator(min_pulse=200, max_pulse=8000, service=0, pin=3, default=50, slave=True) # pwm = ArduinoPWMActuator(dev = 0, pin = 4, slave = True) #interp = ConstantTimeActuator(change_time=2., change_frequency=20., slave_actuator=servo) u3 = UserStrSensor(on_update=SetStatus('lcd', 'u3')) lcd = ArduinoLCDActuator() #prog = Program( # # triggers=[a1], # on_update=Run(Log("Value: %s", Value(a1)), SetStatus(d13, d12), SetStatus(interp, Value(180) * Value(a1))) # ) s = ArduinoSystem( services=[ArduinoService( device="/dev/ttyUSB0", device_type="arduino", instant_digital_reporting=False, sample_rate=2500, log_level=logging.DEBUG, ), WebService(read_only=False), TextUIService(), ], )
user_tags={'quick'}, read_only=False, default_view='tags_view', static_dirs={'/webcam/(.*)': 'public_html/webcam/'}, custom_pages={'Webcam': webcam_page}, django_settings={ 'SESSION_FILE_PATH': 'sessions' if is_raspi() else '/tmp', 'SESSION_COOKIE_AGE': 52560000, 'SECRET_KEY': os.getenv('AUTOMATE_SECRET_KEY', 'unsecure-default'), }, ) arduino_service = ArduinoService( device="/dev/ttyUSB0", sample_rate=2500, lcd_port=0x3F, instant_digital_reporting=False, analog_reference=0 if is_raspi() else 1, # EXTERNAL log_level=logging.INFO, ) rpcs = RpcService( http_port=3030, view_tags={'quick'}, ) s = Aquarium.load_or_create( filename='aquarium.dmp', services=[ web, rpcs, arduino_service,
fan_set = UserBoolSensor(on_update=SetStatus('fan', 'fan_set')) light_set = UserBoolSensor( on_update=Run(SetStatus('light', 'light_set'), )) fan = ArduinoRemoteDigitalActuator(device=50, pin=3) light = ArduinoRemoteDigitalActuator(device=50, pin=8) tester = ArduinoRemoteDigitalActuator(device=50, pin=13) light_intensity = ArduinoRemoteAnalogSensor(device=50, pin=3) s = PlantLamp( services=[ ArduinoService( device="/dev/ttyUSB0", sample_rate=30000, # every 30 seconds home_address=1, device_address=51, virtualwire_rx_pin=10, virtualwire_tx_pin=11, keep_alive=True, #wakeup_pin=2, virtualwire_speed=4, log_level=logging.DEBUG, ), TextUIService(), WebService(read_only=False), ], )
from automate import * from automate.extensions.arduino import ArduinoAnalogSensor, ArduinoService from automate.extensions.webui import WebService class Moisture(System): meas = ArduinoAnalogSensor(pin=3) if __name__ == '__main__': s = Moisture(services=[ WebService(), ArduinoService(sample_rate=8000, virtualwire_rx_pin=11), ])