RFD77402

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
giants
Posts: 25
Joined: Fri Apr 26, 2019 2:07 pm

RFD77402

Post by giants » Mon Apr 29, 2019 1:58 pm

Hi everyone!
i'm new of this forum and i'm new with python language. I write this topic because i start to work with ESP8266 and this sensor RFD77402. When i work with C i write my own library fo r the sensor so Python is a OOP and my doubt is better in this case and generally write a module or class ?
Thank you soo much
Sergio

User avatar
jimmo
Posts: 1420
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: RFD77402

Post by jimmo » Mon Apr 29, 2019 2:24 pm

You should write a class, that way you can have one instance of that class per sensor. (And even if you only plan to plug in a single one, it's still a good idea).

Here's a good example of a class for a temperature sensor that you can use as a reference: https://github.com/micropython/micropyt ... ds18x20.py

Note that it takes the onewire bus as a parameter to the constructor -- in your case you'll take an i2c instance (e.g. constructed from machine.I2C).

giants
Posts: 25
Joined: Fri Apr 26, 2019 2:07 pm

Re: RFD77402

Post by giants » Mon Apr 29, 2019 6:54 pm

Thank you soo much

User avatar
tuupola
Posts: 54
Joined: Sun Sep 17, 2017 12:10 am
Contact:

Re: RFD77402

Post by tuupola » Wed May 01, 2019 5:41 am

I also personally also like to follow some parts of Circuit Python design guide. Especially the naming the sensor properties and units part.

Post Reply