pycom / pycom-libraries

MicroPython libraries and examples that work out of the box on Pycom's IoT modules
333 stars 375 forks source link

Implement fixes of PR #95 #145

Closed gijsio closed 3 years ago

CLAassistant commented 3 years ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

gijsio commented 3 years ago

Adding to the description in #95, the branch includes 2 new API calls to enable / disable the internal heating element of the temperature sensor (SI7006A20). This can be used to temporarily heat up the sensor in order to remove any condensation and can be used as follows:

# py = Pycoproc
si = SI7006A20(py)
si.heater_control(False) # disable heater
time.sleep(10)
print(si.temperature()) # returns ~20*C
si.write_heater_reg(15) # set maximum heater current
si.heater_control(True) # enable heater
time.sleep(10)
print(si.temperature()) # returns ~45*C
si.write_heater_reg(1) # set low heater current
time.sleep(10)
print(si.temperature()) # returns ~30*C

Another API call for the light sensor (LTR329ALS01) is the calculation of illuminance in lux, implemented according to Appendix A of the datasheet (not publically available)

# py = Pycoproc
lt = LTR329ALS01(py)
print("Light (channel Blue lux, channel Red lux): " + str(lt.light()), str(lt.lux()))