Page 1 of 1

RFD77402

Posted: Mon Apr 29, 2019 1:58 pm
by giants
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

Re: RFD77402

Posted: Mon Apr 29, 2019 2:24 pm
by jimmo
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).

Re: RFD77402

Posted: Mon Apr 29, 2019 6:54 pm
by giants
Thank you soo much

Re: RFD77402

Posted: Wed May 01, 2019 5:41 am
by tuupola
I also personally also like to follow some parts of Circuit Python design guide. Especially the naming the sensor properties and units part.