Short Tutorial on Writing an I2C Device Driver #17087
Replies: 3 comments 8 replies
-
Thanks Dave , |
Beta Was this translation helpful? Give feedback.
-
Excellent @DavesCodeMusings, thanks for pulling this together! I hope you don't mind if, at some point in the future, I steal (with attribution!) heavily from this? :) I'd like to extend it to explain how to allow mip installation and potentially mocking/unit testing. And possibly clarifying a few points - like why it's a good idea to pass in an I2C device (as you've done!) rather than configure it inside the driver, which is a common anti-pattern for the inexperienced. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the encouragement, everyone! I've been eyeing the Sensirion SHT30 temperature humidity sensor for my next I2C attempt. The datasheet makes it look pretty straightforward. So maybe more coming. @mattytrentini , feel free to borrow / steal whatever you like. That's why I published it. Also, you mentioned mip installation. I think the GitHub action that creates the .mpy file whenever code changes are merged is particularly useful in that respect. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I got my hands on a BH1750 ambient light sensor recently and ended up writing my own driver module for it. I learned a lot about I2C in the process and wrote it all up as a short tutorial.
If anyone is interested in some tips on how to go from datasheet to MicroPython module, I have it laid out in the README in this repository:
https://github.com/DavesCodeMusings/BH1750-MicroPython
If you just want the BH1750 driver, details are in the QUICKSTART document.
Hopefully this will be useful to the next person who finds a nifty I2C device and wants to use it with MicroPython.
Beta Was this translation helpful? Give feedback.
All reactions