Page 1 of 1

Multiple spi max6675 in a single raspberry

Posted: Fri Dec 01, 2017 12:17 pm
by mattosuarez
Hello, I would like to ask for help to be able to read several max 6675 sensors with only one Raspberry. Ideal would be in Python, I would like to 3 but if in 2 equal I appreciate all your support

Re: Multiple spi max6675 in a single raspberry

Posted: Fri Dec 01, 2017 12:28 pm
by DirkS
According to the specs it uses SPI so it should be possible. https://pinout.xyz/pinout/spi

Re: Multiple spi max6675 in a single raspberry

Posted: Fri Dec 01, 2017 12:31 pm
by DougieLawson
Two is trivial. Three isn't much harder.

Wire the first two to the normal SPI pins (GPIO7 (CE0.1), GPIO8 (CE0.0), GPIO9 (MISO0), GPIO10 (MOSI0) & GPIO11 (SCLK0)) except one device goes to CE0.0, the other to CE0.1.

https://pinout.xyz/pinout/pin24_gpio8
https://pinout.xyz/pinout/pin26_gpio7

That means the devices appear at /dev/spidev0.0 and /dev/spidev0.1

Add

Code: Select all

dtoverlay=spi1-3cs
to /boot/config.txt.

For devices #3, #4 & #5 use SPi1 (GPIO 16 (CE1.2), GPIO17(CE1.1), GPIO18 (CE1.0), GPIO19 (MISO1), GPIO20 (MOSI1) & GPIO21 (SCLK1))
https://pinout.xyz/pinout/spi

They'll appear at /dev/spidev1.0 and /dev/spidev1.1 and /dev/spidev1.2

Re: Multiple spi max6675 in a single raspberry

Posted: Fri Dec 01, 2017 3:39 pm
by mattosuarez
thanksĀ”

Currently I use the keiichishima library, I use the example to read a sensor:


import spidev
import max6675
sensor = max6675.Max6675 (0, 0)
print sensor.temperature


How should the code to read the 4?

Re: Multiple spi max6675 in a single raspberry

Posted: Fri Dec 01, 2017 6:58 pm
by DougieLawson

Code: Select all

sensor1 = max6675.Max6675 (0, 0)

Code: Select all

sensor2 = max6675.Max6675 (0, 1)

Code: Select all

sensor3 = max6675.Max6675 (1, 0)

Code: Select all

sensor4 = max6675.Max6675 (1, 1)

Re: Multiple spi max6675 in a single raspberry

Posted: Fri Dec 01, 2017 9:21 pm
by OutoftheBOTS
There is 2 SPI buses on the RPi. The first bus (SPI0) can handle 2 devices on that bus. If you activate the second bus (SPI1) it can handle another 3 devices.

As posted above by Dougie you add the line

Code: Select all

dtoverlay=spi1-3cs
to config.txt but I also found that to make SPI1 to work you also need turn off the serial console by removing

Code: Select all

console=ttyS0,115200
from the file /boot/cmdline.txt

Re: Multiple spi max6675 in a single raspberry

Posted: Tue Dec 05, 2017 12:57 pm
by mattosuarez
I'm grateful for your help, please reason does not appear:

/dev/spidev1.0 and /dev/spidev1.1

how else can I activate spi 1?

add a to /boot/config.txt. the line dtoverlay = spi1-3cs, restart and nothing ... what could be wrong ??

thanks.

Re: Multiple spi max6675 in a single raspberry

Posted: Tue Dec 05, 2017 1:27 pm
by mattosuarez
Thanks everyone for your help:

solution:

viewtopic.php?f=29&t=146291

disable the bluetooth module.

Re: Multiple spi max6675 in a single raspberry

Posted: Tue Dec 05, 2017 1:53 pm
by DougieLawson
Ah ha, just as I got it working on my RPiA+ for a test.

Edit: I'm running the 4.14 (experimental (aka broken) BRANCH=next rpi-update kernel) and had to add

Code: Select all

spi = spidev.SpiDev()
spi.open(0,0)
spi.max_speed_hz=1000000
to force the SPI bus speed to get the three thermocouples connected to my A+ running.