ESP32 multiple SPI Max31865

marius_sch_priv
Posts: 8
Joined: Wed Jul 01, 2020 6:51 am

ESP32 multiple SPI Max31865

Postby marius_sch_priv » Wed Jul 01, 2020 7:46 am

Hey together,

I really hope you can help me. I am developing software for an ESP32 DevKit V1. There are connected several Max31865 (exactly 8) to read data from the temperature sensor attached.
I've to poll those values in a given time.
So I've tried to use the following library:

https://github.com/jamieparkinson/ESP32-MAX31865

My understanding is, that if I need to get 2 SPI connections working I've to generate two objects of class Max31865 and so on.
So my code is the following:

Code: Select all

#define PIN_NUM_MISO 12
#define PIN_NUM_MOSI 13
#define PIN_NUM_CLK 14

// Starting with 1, because of the labels on the device.

Max31865 device_1 = Max31865(PIN_NUM_MISO, PIN_NUM_MOSI, PIN_NUM_CLK, 13);
Max31865 device_2 = Max31865(PIN_NUM_MISO, PIN_NUM_MOSI, PIN_NUM_CLK, 14);

    max31865_config_t tempConfig = {};
    tempConfig.autoConversion = true;
    tempConfig.vbias = true;
    tempConfig.filter = Max31865Filter::Hz60;
    tempConfig.nWires = Max31865NWires::Four;
    // max31865_rtd_config_t rtdConfig = {};
    // rtdConfig.nominal = 100.0f;
    // rtdConfig.ref = 430.0f;

    ESP_ERROR_CHECK(device_1.begin(tempConfig));
    ESP_ERROR_CHECK(device_2.begin(tempConfig));
If im doing so, im getting the following error:
E (952) spi: spi_bus_initialize(462): SPI bus already initialized.
E (952) Max31865: Error initialising SPI bus: ESP_ERR_INVALID_STATE
The error only occurs while calling the "begin"-Function on a device.

Please help me, am I missing out on something?

Thanks in advance!

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 multiple SPI Max31865

Postby ESP_Sprite » Wed Jul 01, 2020 12:01 pm

That library does not seem to support two of those chips on the same bus... it assumes it can use an entire SPI peripheral per chip, and by default it uses the HSPI host for that. You'd need to rewrite the library so you can instantiate the SPU host controller yourself, then use the modified library to attach the chips to it.

marius_sch_priv
Posts: 8
Joined: Wed Jul 01, 2020 6:51 am

Re: ESP32 multiple SPI Max31865

Postby marius_sch_priv » Wed Jul 01, 2020 12:07 pm

Thanks for your fast response!
My understanding of SPI isnt that big.
Is there an example for the ESP32 on ESP-IDF which initiates more than one SPI Device?

I do not need this library if I can easily poll the Resistance values, if easier.

I nearly up to everything what helps to get this done. Could also use a different library, if possible.

marius_sch_priv
Posts: 8
Joined: Wed Jul 01, 2020 6:51 am

Re: ESP32 multiple SPI Max31865

Postby marius_sch_priv » Thu Jul 02, 2020 6:43 am

So the Author of the library helped me out on that.
Now its working on many devices but it always returns zero as resistance value.
Is there a way to find out which PINS as MISO, MOSI and CLK I need to use?
Do i need to use VSPI or HSPI?

The problem is, that I did not connect the devices to the ESP, someone other preconfigured it.

marius_sch_priv
Posts: 8
Joined: Wed Jul 01, 2020 6:51 am

Re: ESP32 multiple SPI Max31865

Postby marius_sch_priv » Fri Jul 03, 2020 5:38 am

Im registering more than one device to the bus.
When I am adding the 7th device, im getting the following error:

Error adding SPI device: ESP_ERR_NO_MEM

So my question is, is there a way to reduce the memory which is getting allocated by the devices?
Do I have any chance?

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 multiple SPI Max31865

Postby ESP_Sprite » Fri Jul 03, 2020 6:52 am

The SPI buses only have 3 CS channels per master, I think you're running into that limit.

marius_sch_priv
Posts: 8
Joined: Wed Jul 01, 2020 6:51 am

Re: ESP32 multiple SPI Max31865

Postby marius_sch_priv » Fri Jul 03, 2020 7:02 am

But I've already registered more than 3 devices. Also its working on Arduino on the same esp32.

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 multiple SPI Max31865

Postby ESP_Sprite » Fri Jul 03, 2020 12:02 pm

Hm, I initially thought that the library maker might automatically switch to HSPI if VSPI is full, getting to a total of max 6 devices, but on second thought that does not make sense. Without looking at their code, I can't tell what's up there.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: ESP32 multiple SPI Max31865

Postby Ritesh » Sat Mar 27, 2021 4:37 am

marius_sch_priv wrote:
Wed Jul 01, 2020 7:46 am
Hey together,

I really hope you can help me. I am developing software for an ESP32 DevKit V1. There are connected several Max31865 (exactly 8) to read data from the temperature sensor attached.
I've to poll those values in a given time.
So I've tried to use the following library:

https://github.com/jamieparkinson/ESP32-MAX31865

My understanding is, that if I need to get 2 SPI connections working I've to generate two objects of class Max31865 and so on.
So my code is the following:

Code: Select all

#define PIN_NUM_MISO 12
#define PIN_NUM_MOSI 13
#define PIN_NUM_CLK 14

// Starting with 1, because of the labels on the device.

Max31865 device_1 = Max31865(PIN_NUM_MISO, PIN_NUM_MOSI, PIN_NUM_CLK, 13);
Max31865 device_2 = Max31865(PIN_NUM_MISO, PIN_NUM_MOSI, PIN_NUM_CLK, 14);

    max31865_config_t tempConfig = {};
    tempConfig.autoConversion = true;
    tempConfig.vbias = true;
    tempConfig.filter = Max31865Filter::Hz60;
    tempConfig.nWires = Max31865NWires::Four;
    // max31865_rtd_config_t rtdConfig = {};
    // rtdConfig.nominal = 100.0f;
    // rtdConfig.ref = 430.0f;

    ESP_ERROR_CHECK(device_1.begin(tempConfig));
    ESP_ERROR_CHECK(device_2.begin(tempConfig));
If im doing so, im getting the following error:
E (952) spi: spi_bus_initialize(462): SPI bus already initialized.
E (952) Max31865: Error initialising SPI bus: ESP_ERR_INVALID_STATE
The error only occurs while calling the "begin"-Function on a device.

Please help me, am I missing out on something?

Thanks in advance!
Hello,

Have you faced any difficulties while using for single SPI Module over VSPI or HSPI Interface? are you able to compile it successfully without any issue? which ESP32 IDF you have used?

Because one of our team member tried to port driver with example but some how not able to compile it .

can you please help for the same?
Regards,
Ritesh Prajapati

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: ESP32 multiple SPI Max31865

Postby Ritesh » Sun Mar 28, 2021 11:09 am

Hello marius_sch_priv,

Any update regarding query which I have posted into my last comment?
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: Bing [Bot] and 90 guests