AlejandroHuerta

AlejandroHuerta

Help communicating to a MAX31855 over hardware SPI

Hey everyone, I’m new to working with hardware and decided to learn by interfacing with some MAX31855 thermocouple sensors. I’ve successfully read temperatures from them using a software SPI, basically doing all of the CLK switching manually, and decided to give the hardware SPI a try but I’m unsure how to correctly interface with it.

I’m using the Circuits.SPI library. I’ve connected the MAX31855 pins according to this layout

DO → SPI_MISO
CLK → SPI_SCLK
CS → SPI_CE0

I’ve done Circuits.SPI.bus_name which returns ["spidev0.0", "spidev0.1"] I assume spidev0.0 corresponds to CE0, so I then proceeded to do SPI.open("spidev0.0", speed_hz: 5_000_000, delay_ns: 100) The opts I’ve added by looking at the MAX31855 datasheet (https://datasheets.maximintegrated.com/en/ds/MAX31855.pdf). I’m really not sure what to do from here, I’ve tried, as a test, SPI.transfer(ref, <<0>>) and it just returns {:ok, <<0>>}.

Any help would be appreciated as I’m pretty lost here since the example for Circuits.SPI is interfacing with an ADC.

Most Liked

ConnorRigby

ConnorRigby

Nerves Core Team

I’ve never used this device myself, but couple things i notice here.. SPI usually requires more wires.

The main signals are

  • MISO - Master In Slave Out
  • MOSI - Master Out Slave In
  • CLK - Clock

Optional signals will be

  • CS - Cable Select
  • CE - Chip Enable

And occasionally you will have
*INT - interups

As far as i know the Linux driver will not operate CS or CE themselves. You usually will need to use
Circuits.GPIO to toggle these. You will probably want to use spidev0.0, but it depends on the bus you used. If you are on Raspberry pi, the 0.0 bus is the top one. You will also want to look at your data sheet to see how to use CS or CE. (It looks like you have CS). CS needs to be set high or low for a SPI device to know that it is it’s turn to use the bus. if you have a CE, it tells the chip to be on or off. You will need to look at the datasheet to tell for sure. You also need to get another data line for MOSI (master out, slave in) this is the wire that will be transmitting data TO the device from Nerves

AlejandroHuerta

AlejandroHuerta

Just replying to say that I was able to use 2 sensors without issue, using the same method, with the second sensors CS pin connected to SPI_CS1. It seems like the Circuits.SPI library handles the CS/CE switching.

mmmries

mmmries

Thanks for posting this! I’m still trying to wrap my head around how to talk over an SPI interface and found it helpful to read through your posts

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: &lt;h1&gt;Create Post&lt;/h1&gt; &lt;%= ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29703 241
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New

We're in Beta

About us Mission Statement