mattosuarez
Posts: 5
Joined: Wed Sep 13, 2017 2:12 pm

Multiple spi max6675 in a single raspberry

Fri Dec 01, 2017 12:17 pm

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

DirkS
Posts: 9956
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Multiple spi max6675 in a single raspberry

Fri Dec 01, 2017 12:28 pm

According to the specs it uses SPI so it should be possible. https://pinout.xyz/pinout/spi

User avatar
DougieLawson
Posts: 36302
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Multiple spi max6675 in a single raspberry

Fri Dec 01, 2017 12:31 pm

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
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

mattosuarez
Posts: 5
Joined: Wed Sep 13, 2017 2:12 pm

Re: Multiple spi max6675 in a single raspberry

Fri Dec 01, 2017 3:39 pm

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?

User avatar
DougieLawson
Posts: 36302
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Multiple spi max6675 in a single raspberry

Fri Dec 01, 2017 6:58 pm

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)
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: Multiple spi max6675 in a single raspberry

Fri Dec 01, 2017 9:21 pm

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

mattosuarez
Posts: 5
Joined: Wed Sep 13, 2017 2:12 pm

Re: Multiple spi max6675 in a single raspberry

Tue Dec 05, 2017 12:57 pm

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.

mattosuarez
Posts: 5
Joined: Wed Sep 13, 2017 2:12 pm

Re: Multiple spi max6675 in a single raspberry

Tue Dec 05, 2017 1:27 pm

Thanks everyone for your help:

solution:

viewtopic.php?f=29&t=146291

disable the bluetooth module.

User avatar
DougieLawson
Posts: 36302
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Multiple spi max6675 in a single raspberry

Tue Dec 05, 2017 1:53 pm

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “General discussion”