Arduino, Thermocouples, MAX31855K (vs MAX6675) and SPI - The Fine Points

Поделиться
HTML-код
  • Опубликовано: 9 июл 2024
  • It can’t be that hard to get a MAX31855K up and running …
    ↓↓↓ Complete description, time index and links below ↓↓↓
    Or so you might think. But if you have one of those simpler Chinese modules you’re facing a challenge right out of the gate: it won’t work without modification. And if you have to 5V MCU, you’ll need some level shifting down to 3.3V.
    There’s a nice MAX31855 library available for Arduino, but you can also bit bang the SPI bus directly. Multiple slaves on the SPI bus are a must of course. But do you really need a MAX31855K or will a MAX6675 just do fine.
    00:00 Intro - Arduino, MAX31855K and past MAX6675 videos
    01:04 MAX31855K vs MAX6675 - datasheets, differences, similarities
    07:53 Input filtering - strongly recommended, in fact required
    09:33 5V operation - connecting the 3.3V MAX31855 to a 5V MCU
    12:49 MAX31855 library - by Rob Tillaart, easy and lean
    17:57 Bit banging - code for the MAX31855K with just the SPI library
    29:08 Multiple MAX31855Ks - on the same SPI bus
    31:47 Mixing 5V and 3.3V - devices on a SPI bus is complicated
    32:58 5V compliant modules - they are not, at least not fully
    35:06 Shorting things - and destroying MAX31855s
    36:22 Wrap-up - verdict, link to code and bye
    Tutorials: • Tutorials
    Mini Mailbag: Breakout PCBs for HB100 Doppler Radar and MAX31855K Module • Video
    Arduino, Thermocouples, MAX6675 and SPI - The Fine Points • Arduino, Thermocouples...
    Faulty Chinese MAX31855K Modules: Fake Chips? No! Just a Capacitor Missing! • Faulty Chinese MAX3185...
    Galvanic Isolation of SPI Devices (e.g. Arduino, MAX6675 and SI8631) • Galvanic Isolation of ...
    My Arduino code drive.google.com/drive/folder...
    GitHub - RobTillaart / MAX31855_RT github.com/RobTillaart/MAX318...
    Adafruit Thermocouple Amplifier MAX31855 breakout board (MAX6675 upgrade) www.adafruit.com/product/269
    #thermocouple #MAX31855 #Arduino #SPI #tutorials #tutorial #how-to #robertssmorgasbord
  • НаукаНаука

Комментарии • 94

  • @bartek102842
    @bartek102842 Год назад

    Just amazing video. I’m stunned !! Thank you for your time to create it !!

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад

      I thank you for taking the time watching it! And I'm happy if my video was helpful to you 😀

  • @thomasrimer1611
    @thomasrimer1611 Год назад

    Thank you so much! I spent 6+ hours trying to troubleshoot why my boards wouldn't work. Just like you described, the manufacturer said the boards were good with 5v. I even looked at the data sheet and saw 4v max but decided the amazon seller was more reliable. That was a mistake. Your video went over everything in perfect detail, thank you!

  • @prashkd7684
    @prashkd7684 Год назад +1

    Thanks for saving me research time.

  • @p1366
    @p1366 2 года назад

    Very helpful, thanks!

  • @de-bugger
    @de-bugger Год назад +1

    After digging a bit more into temperature measurement and control, Ii was surprised to find out that popular and cheap PID controllers such as the REX-C100 don't use such fancy chips but just simple a OPAMP and even no galvanic isolation.

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад +1

      Well, I guess the important word is "cheap" here. These REX-C100 sell for as low as 15 € on eBay and you can get them for 8 € if you order them directly via AliExpress. You can't expect them to use Maxim's top of the line thermocouple chip or to implement galvanic isolation.

  • @SommerSkaP
    @SommerSkaP 2 года назад

    thank you for making these great and easy to follow videos!
    very helpfull!
    you deserve way more views!!

    • @robertssmorgasbord
      @robertssmorgasbord  2 года назад

      I thank you for watching them! I'm always happy when my videos are helpful to somebody. Regarding more views: I would have to monetize my channel to get more views on RUclips (the evil algorithm). And that's something I'm very ambivalent about. Anyway, my 5000 subscribers video is coming up, and I'll ask my viewers what they think about this issue.

  • @rompipelotas
    @rompipelotas 2 года назад

    thanks a lot Robert !!!!!!!!!!

  • @rene-jeanmercier6517
    @rene-jeanmercier6517 3 года назад

    This is really an excellent comparison video, Robert. At first glance you would think that the 31855 is a superior chip, but you demonstrated that it is not. It is essentially for the 3.3V application. Thank you very much for this exhaustive démonstration. Will you put your library available some where ? Regards, RJM

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад

      Hello René-Jean! Thank you very much for the praise! I totally forgot to include the link to my code in the description - my bad (meanwhile I remedied that): drive.google.com/drive/folders/1n4mfDdrUys5nqH7YQpUEliWQ6_eDBjya?usp=sharing

  • @MarcelHuguenin
    @MarcelHuguenin 3 года назад +1

    Excellent video Robert! Thank you for this very detailed review and analysis of both chips. I have both of them (31855 is already in a project and 6675 is on a breakout board). I will take this video as my reference when doing the experiments. I still get dizzy from your waving hands though 🤢😉

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +1

      Thank you very much! I'm always happy if my videos are useful to somebody. And I will try to wave my hands less or at least a bit slower 😉

    • @benfabian1740
      @benfabian1740 2 года назад

      I guess it is quite off topic but does anybody know a good place to watch newly released movies online ?

    • @mustafabeau4782
      @mustafabeau4782 2 года назад

      @Ben Fabian Flixportal :P

    • @benfabian1740
      @benfabian1740 2 года назад

      @Mustafa Beau thanks, signed up and it seems like a nice service :) Appreciate it !

  • @andymouse
    @andymouse 3 года назад +1

    This is the definitive work on these chips and I find it invaluable, thanks !..oh yeah, Dangermouse and CB radio are responsible for my nick name 'Mousey' so I do remember !...cheers.

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +1

      Well, thank you! I don't know about "definitive", just tried to cover the most important points. BTW did you play it on the Sinclair ZX Spectrum the Commodore 64 or the Amstrad CPC?

    • @andymouse
      @andymouse 3 года назад

      @@robertssmorgasbord Honestly cant remember ! C64 most likely but cartoon sticks in my mind vividly !...cheers.

    • @andymouse
      @andymouse 3 года назад

      @@robertssmorgasbord Oh, sorry forgot to ask is your software available to look at on GitHub please ?

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +1

      @@andymouse Don't be sorry - my bad! I forgot to put the link to the Google Drive folder (still no GitHub) into the description (did that just now): drive.google.com/drive/folders/1n4mfDdrUys5nqH7YQpUEliWQ6_eDBjya?usp=sharing

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +2

      @@andymouse I myself was a Sinclair kid: First the ZX80 (bought as kit), then the ZX81 (bought as kit too), after that the ZX Spectrum (Danger Mouse!) and finally the QL. Then Sinclair died and I went via the Atari ST to PCs.

  • @syaifulannam
    @syaifulannam 5 месяцев назад

    Hello sir, I want to ask. is the max31855k pin connected randomly and not according to spi? because I use a raspberry pi pico but I didn't install the pin according to the spi pinout

    • @robertssmorgasbord
      @robertssmorgasbord  5 месяцев назад

      Which of the MAX31855Ks pins are you talking about? The CS pin? You can connect that to any I/O pin of your microcontroller. Can't tell you how to program a Rasberry Pi Pico to talk to an SPI device though. never worked with a Rasberry Pi Pico.

  • @ivanadiego6067
    @ivanadiego6067 Год назад

    Hi Robert, I have a question regarding the breakout board you made for the max31855. I know that it is necessary to use compensated cable (same metals as the K thermocouple) to connect the thermocouple to the MAX3185 module. I understand that this done so that he cables don't act as a different type of thermocouple themselves introducing an error to the measurement. My question is: if the small breakout board has copper leads to the terminals where the compensated wire is connected, couldn't this cause the previously described problem, or is the introduced error small enough to be ignored dur to the length of this connectors?

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад +2

      Indeed, additional joints between dissimilar metals could introduce an error due to generating their own thermocouple (Seebeck) voltages. However, as long as these joins are symmetric for the positive and negative connection, and all pairs of joints are at the same temperatures, these voltages will negate each other.

  • @Gocast2
    @Gocast2 3 года назад

    thank goodness I found your videos. I'm just wondering if the thermocouple's need to be on the SPI bus, or can they be connected to any digital pins?

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад

      I guess you're talking about the MAX31855K (or MAX6675) digital (SPI bus) pins and not the thermocouple wires themselves: There are "software SPI" libraries for the Arduino (and other MCUs) that enable you to connect SPI devices to arbitrary digital I/O pins or your Arduino (MCU). Hope that answers your question.

    • @Gocast2
      @Gocast2 3 года назад +1

      @@robertssmorgasbord Thank you! after a long and frustrating ordeal, including some clueless teenager selling me the wrong filter capacitor, I finally got it working using your videos. Yes, it turns out I was confused and referring to the "software SPI" and not the hardware one :D.

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +1

      @@Gocast2 You're welcome. The important thing is you got it working in the end :-)

    • @Gocast2
      @Gocast2 3 года назад

      @@robertssmorgasbord Not sure if you mentioned this in the videos, but another problem I just fixed is that the MAX31855 modules I was using registers occasional NAN error when using "grounded thermocouples", i.e. ones with the 2 thermocouple wires welded to a metal probe tubing. These errors only occurred every 15 or so seconds apart when I rapidly ramped the temperature up or down. You could easily edit the code to ignore these errors, as the actual temperature readings were pretty spot on.
      I eliminated this error entirely by using an "ungrounded" thermocouple; one were the wires are housed in a ceramic tube (used in kilns) and not a metal tube. ungrounded also gives better accuracy apparently, but a slightly slower response time.
      I didn't seem to have any problem using grounded ones with the MAX6675 module though.

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад +1

      @@Gocast2 Thanks for the info! And no, I didn't know that, respectively, mentioned that in the video. I do have some metal encapsulated thermocouples somewhere, but I've never used them, so I really never stumbled about that problem.
      The MAX6675 is designed to use grounded probes, so it's not surprising it's working with those, while the MAX31855 requires floating probes.
      Anyway, all this confirms my conclusions in the video: The MAX31855 is not an "upgraded" MAX6675. The chips are designed for different thermocouple application, the MAX31855 being somewhat of a "diva" (required input filtering etc.).

  • @jamesmac6102
    @jamesmac6102 2 года назад

    Hi Robert, thank you for teaching us! I'm working with MAX31865. Is there a way to contact you for the technical questions?

    • @robertssmorgasbord
      @robertssmorgasbord  2 года назад +1

      You're welcome! Regarding contacting me: RUclips is just a hobby for me, so for privacy reasons the only way to contact me is through the comment sections of my videos. Hope you understand.

  • @patrickmutai7567
    @patrickmutai7567 2 года назад

    why don't you do a demonstration on Adafruit Thermocouple Amplifier MAX31850 breakout board(one wire)..I want to use it for various temperature logging.

    • @robertssmorgasbord
      @robertssmorgasbord  2 года назад

      Currently I have no need for a 1-wire thermocouple amplifier. But I put it on my wall of video ideas - no promises though.

  • @dutchman1891
    @dutchman1891 6 месяцев назад

    Thanks so much for your great videos Robert. Very informative and helpful.
    I'm just wondering if you know what would be the maximum amount of thermocouple readings you could do at the one time with say a Arduino mega and some expansion? I would like to setup a K-type thermocouple data logger running a chart like the Arduino serial monitor function. I would only want the thermocouple reading though. Not the board reading.
    Thanks in advance.
    James

    • @robertssmorgasbord
      @robertssmorgasbord  5 месяцев назад

      What do you mean by "the maximum amount of thermocouple readings you could do at the one time"?

    • @dutchman1891
      @dutchman1891 5 месяцев назад

      Hi Robert. Thank you for your reply.
      I was referring to how many Max31855 modules could be connected and logging temperature at one time on say a Arduino Mega 2560? I am wanting to log 6 seperate temperatures at the one time. All 6 thermocouples may be connected together by being attached to the same piece of metal. Not floating thermocouples. Thanks.

    • @robertssmorgasbord
      @robertssmorgasbord  5 месяцев назад +1

      @@dutchman1891 Ah, OK! You need a dedicated slave select (SS) line for each of the MAX31855s. So for your six MAX31855s you need six free I/O pins on your Arduino Mega 2560 (shouldn't be a problem). Have a look at my MAX6675 video ( ruclips.net/video/qub3yzqEwek/видео.htmlsi=z6n4XKSJbNKeWeUz ) were I connect two MAX6675 to an Arduino Nano.

    • @dutchman1891
      @dutchman1891 5 месяцев назад

      Ah I see! That makes sense. I will check out the other video. Thanks a lot for your assistance!

    • @robertssmorgasbord
      @robertssmorgasbord  5 месяцев назад

      @@dutchman1891 You're welcome!

  • @jamesmac6102
    @jamesmac6102 2 года назад

    Hi Robert, what is the Ferrite spec/model you used for the RTD input?

    • @robertssmorgasbord
      @robertssmorgasbord  2 года назад

      I'm a little confused here. There are not RTD inputs on the MAX31855K/MAX6675 I've used in the video. Both have type K thermocouple inputs. Plus, I didn't use any ferrites on any inputs in this video. I guess you're referring to the Adafruit breakout board I mentioned / referred to (link in the description). Unfortunately their schematic doesn't specify what ferrite beads they are using.

    • @jamesmac6102
      @jamesmac6102 2 года назад

      @@robertssmorgasbord I'm using Max31865 with RTD (pt100 100Ohms) I'm thinking to use 0hms Ferrits

    • @robertssmorgasbord
      @robertssmorgasbord  2 года назад

      @@jamesmac6102 Ah, OK. And sorry, I've never used ferrites in that kind of application, so I can't tell you anything about it.

  • @andreaslundback
    @andreaslundback 10 месяцев назад

    Hi Robert, thank you for the in-depth review and explanations. I will add the noice reduction to my "rig". I have a question/problem though. I have a set-up with 5 MAX31855 sensors. It works fine when the thermocouples are separated from eachother. However, if I put one thermocouple in contact with another thermocouple I get an error in the output. You mentioned that the 31855 can detect if its connected to ground. Is that whats happening when I connect two thermocouples? That I get some kind of short circiut? (I'm on a quite beginner level on this stuff :) ). Is it possible to mitigate the reading error when thermocouples are connected to eachother? When in use on my charcoal kiln, at least 3 thermocouples will be electrically in contact.
    BTW, I have been running the sensors on 5V x) As you and someone already mentioned in the comments, they are claimed to be working on 5V in some specs.

    • @robertssmorgasbord
      @robertssmorgasbord  10 месяцев назад +1

      Hi Andreas, fortunately I've already described the solution for your problem in a video (though for the MAX6675, but it works exactly the same): "Galvanic Isolation of SPI Devices (e.g. Arduino, MAX6675 and SI8631)" ruclips.net/video/6rEJh4yPekg/видео.html
      Hope that helps!
      BTW the MAX31855K is DEFINITELY a 3.3V device, do not run it at 5V!

    • @andreaslundback
      @andreaslundback 10 месяцев назад

      @@robertssmorgasbord thanks for your response. I saw that video after I had posted my question. I ordered the digital isolator and dc/dc converter. Good to hear that it should work with the 31855 too. I will definitely add the voltage splitter that you proposed in the video.

    • @robertssmorgasbord
      @robertssmorgasbord  9 месяцев назад

      @@andreaslundback I'm glad I could be of assistance. Hope you've ordered DC/DC converters with 3.3V output (either from the Arduino's 3.3V rail - or even better, because there is more juice - from the Arduino's 5V rail, so a 5V to 3.3V DC/DC converter). The SI8631 works fine with 5V on one side (Arduino) and 3.3V on the other (MAX31855). If you use the galvanic isolation with 3.3V supply on the MAX31855 side you won't need the voltage dividers. Those are only necessary when connection the digital inputs of the MAX31855 directly to digital outputs of a 5V Arduino.

  • @dseletrica7597
    @dseletrica7597 Год назад

    hello, Do you can write the tip of capacitor, please.

    • @robertssmorgasbord
      @robertssmorgasbord  Год назад

      I made a video about that:
      Faulty Chinese MAX31855K Modules: Fake Chips? No! Just a Capacitor Missing! ruclips.net/video/PywHVgJAMu8/видео.html
      Hope that helps.

  • @gustavoya
    @gustavoya 3 года назад

    Hello Robert, thanks for your videos! I'm having a problem with my MAX31855, I made an oven controller and placed the chip inside, in a place that is not too hot, but the temp varies there.
    The thing is that when the chip gets heated the prob temp rises too, is this normal behavior? for example I tested it at room conditions, tc@22c chip@24c, I put a lighter near the chip and of course it start rising the chip temp, but the tc rises too at the same rate. if I heat the chip to 70c the tc reads about 70c too, It doesnt happen the other way arround, if I heat the tc the temp reads jus fine and the chip reads room temp. Maybe you can help me out. TIA

    • @gustavoya
      @gustavoya 3 года назад

      Btw I'm using this board and Adafruit_MAX31855 library
      es.aliexpress.com/item/32889208223.html?spm=a2g0s.9042311.0.0.4d1b63c0SL9KMS

    • @gustavoya
      @gustavoya 3 года назад

      I added 100nf instead of 10nf, might that be the problem? As I said before temps are reading just fine if I don't apply heat to the chip

    • @gustavoya
      @gustavoya 3 года назад

      I'll repply to myself in case someone make the same mistake that I did, it was in fact the 100nf capacitor, now is running just fine, I might be wrong buy it seems that it kind of put some delay if the decoupling cap is to big? anyway, stick with 10nf. But Robert, in case you are willing to respond, I'm using the adafruit library and is working fine, I didn't need to add another library for it to work, is there any advantage on using Rob library that I might be missing? Thanks again and sorry to bother you.

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад

      @@gustavoya Sorry for the late reply! BTW you're welcome and it's no bother at all :-) And yes, the 100nF is far too big. The MAX31855 internally switches the thermocouple inputs T+/T- for calibration, fault detection etc. between the input amplifier, the fault detection circuit and ground around. If the filter capacity is too large, the voltage can't recover fast enough between those switching actions. I guess the MAX31855 is a leally finicky thing ;-)

    • @robertssmorgasbord
      @robertssmorgasbord  3 года назад

      Sorry for the late reply! More info in the other reply I posted ...

  • @user-hr5dc4ly3q
    @user-hr5dc4ly3q 4 месяца назад

    When i use it for oven in analog thermometer show 130c in max31855 shows 93c i thank you very much for your this research because you helped me to show the 100% temperature degree in this chip now analog thermometer and this shows same degree

    • @robertssmorgasbord
      @robertssmorgasbord  3 месяца назад

      You're welcome! These MAX31855Ks are a wee bit trickier to use than the MAX6675.

  • @user-hr5dc4ly3q
    @user-hr5dc4ly3q 3 месяца назад

    When I used 4 relays to control heating elements i2c LCD received reverse power affects on LCD and show wrong letters and numbers and symbols so one of people say put 0.1uF capacitor and 100ohm rissistor between relays current contacts so if this true can you test this problem

    • @robertssmorgasbord
      @robertssmorgasbord  3 месяца назад

      Well, unfortunately I can't test this, because I neither have relays, heating elements nor your specific LCD display at hand. But a 0.1uF/100Ohm snubber network (that's what this is) parallel to a relay coil is an established. But I probably would start by adding a freewheeling diode first and putting more decoupling capacitors on the VCC line of the LCD.

    • @user-hr5dc4ly3q
      @user-hr5dc4ly3q 3 месяца назад

      @@robertssmorgasbord at the coil contacts available diode why it’s not blocking spikes inside relay

    • @user-hr5dc4ly3q
      @user-hr5dc4ly3q 3 месяца назад

      @@robertssmorgasbord i put diod on VCC of LCD even this way not successful 😢

    • @robertssmorgasbord
      @robertssmorgasbord  3 месяца назад

      @@user-hr5dc4ly3q Reply to "at the coil contacts available diode why it’s not blocking spikes inside relay": To be honest, I have no idea. A diode should do the job. Can you upload a circuit diagram somewhere?

    • @robertssmorgasbord
      @robertssmorgasbord  3 месяца назад

      @@user-hr5dc4ly3q Replay to " i put diod on VCC of LCD even this way not successful": Sorry, maybe I was not clear. The freewheeling diodes go across the relay coils. The VCC of the LCD might need more decoupling capacitors (e.g. 10nF + 100nF + 1uF in parallel).

  • @rene-jeanmercier6517
    @rene-jeanmercier6517 11 месяцев назад

    Hi Robert, Long time no talk ! I hope I find you well. I have a question for you. If I have 1 MAX6675 and 1 MAX31855 in the same working environment, is there a way, software wise, to identify which is which ? This is a design problem I am faced with. Thank you for your help. ...This would make great video as well since even chatGPT does not have the answer to this problem :-). Regards RJM.

    • @robertssmorgasbord
      @robertssmorgasbord  11 месяцев назад

      Hello René-Jean! I'm well, though a bit overworked, and so I'm currently on a short vacation 🙂 Hope you are well too. Anyway, here's an idea: If you read 4 consecutive bytes (CS kept low all the time) from your unknow device, the last two bytes from a MAX6675 should either be a just a repeat of the first two bytes or all 0, respectively, 1. You will have to experiment there a bit. Hope that works. Best regards, Robert.

    • @rene-jeanmercier6517
      @rene-jeanmercier6517 11 месяцев назад

      @@robertssmorgasbord Thank you very much Robert. I will try and get back to you with my findings. In the meantime have a good vacation. Regards, René-Jean

    • @robertssmorgasbord
      @robertssmorgasbord  11 месяцев назад

      @@rene-jeanmercier6517 No problem René-Jean! I'm back from my vacation by now. Hope my suggestions will work. Best Regards, Robert

  • @electronic7979
    @electronic7979 3 года назад +1

    👍

  • @antonymorvan7441
    @antonymorvan7441 8 месяцев назад

    Hello, It is possible to use a max31855 without arduino ?

    • @robertssmorgasbord
      @robertssmorgasbord  8 месяцев назад +1

      Yes. That's what I'm doing in this video, isn't it?

    • @antonymorvan7441
      @antonymorvan7441 7 месяцев назад +1

      Thank you for your time, I have work on it since my comment, and I understand it better. But I want to use thermocouple type E , I have actually a Max31855 E, do you know how I can change the code to make it work with type E

    • @robertssmorgasbord
      @robertssmorgasbord  7 месяцев назад +1

      @@antonymorvan7441 There is no difference in the software interface of the different MAX31855K versions (K, J, N, T, S, R, E). Bits 18 to 31 always contain a signed (bit 31) 14 number with the last two bits (19, 18) designating 1/2 and 1/4 degrees (see datasheet page 10).

  • @user-hr5dc4ly3q
    @user-hr5dc4ly3q 2 месяца назад

    If you don’t mind iwant send you my full arduino sketch to solve beep problem its not stopping

    • @robertssmorgasbord
      @robertssmorgasbord  2 месяца назад +1

      Just upload the code somewhere (Google drive, DropBox etc.) and publish the link here.

    • @user-hr5dc4ly3q
      @user-hr5dc4ly3q 2 месяца назад

      @@robertssmorgasbord this is the file and problem discription inside after ////
      drive.google.com/file/d/1tCZ_NkM0HEveFCHqxZuukFYLet_wMK_W/view?usp=drive_link

  • @johnfrancis923
    @johnfrancis923 5 месяцев назад

    I am using the STM32C011F6U6 controller, MAX31855 chip and I am facing issues with the clock and data signals not being received correctly. Upon examining Adafruit's schematics, I noticed they have pull-up resistors on the SO (Slave Out) and clock pins. Should I include pull-up resistors to ensure proper reception of data and clock signals?
    My SPI Configuration

    PA5 ------> SPI1_SCK
    PA6 ------> SPI1_MISO
    PB7 ------> SPI1_Chip_Select
    /**SPI1 GPIO Configuration
    GPIO_InitStruct.Pin = GPIO_PIN_5 | GPIO_PIN_6;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF0_SPI1;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
    /*Configure GPIO pin : CHIP_SELECT_Pin */
    GPIO_InitStruct.Pin = CHIP_SELECT_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    HAL_GPIO_Init(CHIP_SELECT_GPIO_Port, &GPIO_InitStruct);
    /* SPI1 parameter configuration*/
    hspi1.Instance = SPI1;
    hspi1.Init.Mode = SPI_MODE_MASTER;
    hspi1.Init.Direction = SPI_DIRECTION_2LINES_RXONLY;
    hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
    hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
    hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
    hspi1.Init.NSS = SPI_NSS_SOFT;
    hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
    hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
    hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
    hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
    hspi1.Init.CRCPolynomial = 7;
    hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
    hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
    // Main Logic
    while (1)
    {
    // Read temperature data from the slave MAX31855KASA Thermocouple Chip

    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
    ret = HAL_SPI_Receive(&hspi1, buf, 4, 1000);
    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);
    HAL_Delay(1000);
    }
    I am consistently receiving a buffer value of 1, except in cases of error status(short circuit, open circuit and so on...) where it is always 0."

    • @robertssmorgasbord
      @robertssmorgasbord  5 месяцев назад

      Sorry, can't really help you there. Never worked with STMs. But SPI does NOT require pull-up resistors. Unless ... the output pins of your STM are configured for some reason as open collector/drain.