nimaltd / max31865

Max31865 library for stm32 hal
GNU General Public License v3.0
51 stars 20 forks source link

Does this library support reading multiple MAX31865 PT100 sensors with different chip select pins? #10

Closed jkuijpersst closed 6 months ago

nimaltd commented 6 months ago

Yes. You can use different struct

jkuijpersst commented 6 months ago

Thanks for your quick reply. We encountered a problem with multiple sensors. The logic analyzer shows all the SPI signals are correctly generated, but the software is only able to read the correct temperature value from one of the sensors when mulitple are connected. When we connect them one by one individually they all work. Do you have any suggestions?

We define the structs like this:

Max31865_t pt100_ACT, pt100_AWS, pt100_CT;

`void PT100_init() {

//PT100 initializations
Max31865_init(&pt100_ACT, SPI_Slave_select_temperature_ACT_GPIO_Port, SPI_Slave_select_temperature_ACT_Pin, 4, 50);
HAL_Delay(300);
Max31865_init(&pt100_AWS, SPI_Slave_select_temperature_AWS_GPIO_Port, SPI_Slave_select_temperature_AWS_Pin, 4, 50);
HAL_Delay(300);
Max31865_init(&pt100_CT, SPI_Slave_select_temperature_CT_GPIO_Port, SPI_Slave_select_temperature_CT_Pin, 4, 50);
HAL_Delay(300);

}`

bool PT100_read(PT100_t sensor, float* temp) {

    bool isOk = false;

    switch (sensor) {
    case PT100_AWS:
        isOk = Max31865_readTempC(&pt100_AWS, temp);
        break;
    case PT100_CT:
        isOk = Max31865_readTempC(&pt100_CT, temp);
        break;
    case PT100_ACT:
        isOk = Max31865_readTempC(&pt100_ACT, temp);
        break;
    default:
        // Unknown sensor
        break;
    }

    return isOk;
}
nimaltd commented 6 months ago

It should works. Really i have no idea. I did and it works fine. Check gpio and decrease spi speed

jkuijpersst commented 6 months ago

Yes we thought it should work as well. Anyway, thanks for your thoughts! W'll continue debugging