from machine import Pin from urequests import get from time import sleep_ms from gc import collect pin = Pin(2, Pin.IN) pin_value = pin.value() while True: current_value = pin.value() if pin_value != current_value: get('http://192.168.44.174:6543/value/%s' % current_value) pin_value = current_value collect()