Hi all,
This is my first post on this forum so please bear with me.
Does anybody have a micropython driver for the MAX31865 amplifier board? I've seen the CircuitPython code but am not quite proficient in differentiating cPy code from uPy to make a working uPy version.
For context, I'm a student building a sensor payload for the University of Western Australia's Aerospace club and I'm wanting to use micropython to program a multi-input datalogger.
Thank you in advance,
Thomas
MAX31865 micropython driver?
Re: MAX31865 micropython driver?
Hi,
change the imports to:
change the constructor's first few lines to
(i.e. remove the DRDY_pin, add cs, and replace the self.spi line)
Replace usage of the pyb module.
Toggle the CS pin when reading/writing
I _think_ that should just work? Copy MAX31865.py and FIR.py to your board, then
You've probably already seen the more sophisticated CircuitPython driver at https://github.com/adafruit/Adafruit_Ci ... ax31865.py
You could adapt this to MicroPython too. In summary:
- Replace the use of SPIDevice with just using machine.SPI directly.
- Replacing the use of @property, @auto_convert, etc with just regular methods.
Let me know, can provide more detailed instructions.
Which MicroPython board are you using? If it's a pyboard, then https://github.com/B3AU/micropython/blo ... AX31865.py might just work. It's 5 years old, so it has its own bit-bang SPI implementation, but here's roughly what I'd do to bring it up to date (or to make it work on other ports).
change the imports to:
Code: Select all
import time
import machine
import FIR
Code: Select all
def __init__(self, spi, cs):
self.spi = spi
cs.init(mode=machine.Pin.OUT)
cs.value(1)
self.cs = cs
self.fir = FIR.FIR(16)
Replace usage of the pyb module.
Code: Select all
pyb.millis() --> time.ticks_ms()
Code: Select all
cs.value(0)
self.spi.write(buf)
cs.value(1)
Code: Select all
cs.value(0)
MSB = self.spi.read(0x01,1)[0]
LSB = self.spi.read(0x02,1)[0]
cs.value(1)
Code: Select all
spi = machine.SPI('X', polarity=0, phase=1) # if you're using a Pyboard, other boards you'll have to look at https://docs.micropython.org/en/latest/library/machine.SPI.html for the alternatives to using 'X'
cs = machine.Pin('X5')
import MAX31865
max31865 = MAX31865.MAX31865(spi, cs)
You could adapt this to MicroPython too. In summary:
- Replace the use of SPIDevice with just using machine.SPI directly.
- Replacing the use of @property, @auto_convert, etc with just regular methods.
Let me know, can provide more detailed instructions.
That was me once too!
Re: MAX31865 micropython driver?
Thanks Jimmo for the quick and comprehensive reply!
[quote=jimmo post_id=39646 time=1569160199 user_id=3071]
Which MicroPython board are you using?
[/quote]
In between submitting this post, and now typing this reply, I've managed to find a thread ( viewtopic.php?t=5181 ) containing discussion on this amplifier board in relation to a very similar board to the one that I'm attempting to use (Lolin D32 Pro).
I think I'm going to edit just the pins in the lopy driver that's linked in that thread, then I'll give that a whirl tonight.
Since you seem fairly knowledgeable on external component related things, I was wondering if you'd know if the fact that my reference resistor is the *wrong* one on my amplifier board (as I bought the pt1000 version board, not the pt100 version which I need) will adversely affect the hardware? I understand that I'll have to change the value of the 'RefR' variable in the driver, but I can't find any discussion on whether there are any other compatibility issues due to the difference. I'd love to not fry this board as the launch is so soon!
[quote=jimmo post_id=39646 time=1569160199 user_id=3071]
Which MicroPython board are you using?
[/quote]
In between submitting this post, and now typing this reply, I've managed to find a thread ( viewtopic.php?t=5181 ) containing discussion on this amplifier board in relation to a very similar board to the one that I'm attempting to use (Lolin D32 Pro).
I think I'm going to edit just the pins in the lopy driver that's linked in that thread, then I'll give that a whirl tonight.
Since you seem fairly knowledgeable on external component related things, I was wondering if you'd know if the fact that my reference resistor is the *wrong* one on my amplifier board (as I bought the pt1000 version board, not the pt100 version which I need) will adversely affect the hardware? I understand that I'll have to change the value of the 'RefR' variable in the driver, but I can't find any discussion on whether there are any other compatibility issues due to the difference. I'd love to not fry this board as the launch is so soon!
Re: MAX31865 micropython driver?
So you have a PT100 sensor, but you've got the PT1000 board? From a quick read of the adafruit page and the max31865 datasheet, yes all you have to do is replace the reference resistor (the boards are otherwise identical), and configure the driver appropriately.T-Wilko wrote: ↑Mon Sep 23, 2019 3:48 amSince you seem fairly knowledgeable on external component related things, I was wondering if you'd know if the fact that my reference resistor is the *wrong* one on my amplifier board (as I bought the pt1000 version board, not the pt100 version which I need) will adversely affect the hardware? I understand that I'll have to change the value of the 'RefR' variable in the driver, but I can't find any discussion on whether there are any other compatibility issues due to the difference. I'd love to not fry this board as the launch is so soon!
Or are you asking if you can use the board with the 4300ohm resisitor with a PT100? It sounds like that might work but you'll loose accuracy. But I'm not 100% sure on that. I think the other way around is not so good though.
(I've never used this chip or a platinum rtd before, so all this is just what I could learn in a few mins of reading)