diff --git a/lib/sensor/click_boards/noise/README.md b/lib/sensor/click_boards/noise/README.md new file mode 100644 index 0000000..5ded7f8 --- /dev/null +++ b/lib/sensor/click_boards/noise/README.md @@ -0,0 +1,16 @@ +noise click Library +=============== + +MicroPython library for I2C interface to Texas Instruments noise click noise +sensor. + +Supported platforms +------------------- + +* Digi XBee3 Zigbee 3 - minimum firmware version: 1006 +* Digi XBee3 802.15.4 - minimum firmware version: 2003 +* Digi XBee3 DigiMesh 2.4 - minimum firmware version: 3002 +* Digi XBee3 Cellular LTE-M/NB-IoT - minimum firmware version: 11410 +* Digi XBee3 Cellular LTE Cat 1 - minimum firmware version: x10 +* Digi XBee Cellular 3G - minimum firmware version: 1130B +* Digi XBee Cellular LTE Cat 1 - minimum firmware version: 100B diff --git a/lib/sensor/click_boards/noise/noise.py b/lib/sensor/click_boards/noise/noise.py new file mode 100644 index 0000000..c6c6ad5 --- /dev/null +++ b/lib/sensor/click_boards/noise/noise.py @@ -0,0 +1,54 @@ +from umachine import ADC, Pin +import time + +# PINS +ADC_PIN_ID = "D2" +DIO_PIN_INT = "D4" + +# CONSTANTS +THRESHOLD = 50 + +# 12 bits --> 4096 values +adc_pin = ADC(ADC_PIN_ID) +int_pin_in = Pin(DIO_PIN_INT, Pin.IN) +int_pin_out = Pin(DIO_PIN_INT, Pin.OUT) + + +class noiseClick: + + def __init__(self, THRESHOLD): + self.THRESHOLD = THRESHOLD + int_pin_in.value(0) + + def noise_command_value(self): + """ + Sets the **interruption value** to 1 if the noise level is above the threshold, otherwise is set to 0 + """ + if self.noise_read() > self.THRESHOLD: + int_pin_in.value(1) + + else: + int_pin_in.value(0) + + def check_int_pin(self): + """ + Returns the value of the interruption pin + + :return: returns the value of the interruption pin + """ + return int_pin_out.value() + + def noise_read(self): + """ + Returns the value of the noise level + + :return: returns the value of the noise level + """ + return adc_pin.read() + + def set_threshold(self, value): + """ + Sets a new threshold + """ + self.THRESHOLD = value +