Skip to content

MAX6675 support#4

Open
node-alpha wants to merge 2 commits intoTuckie:masterfrom
node-alpha:master
Open

MAX6675 support#4
node-alpha wants to merge 2 commits intoTuckie:masterfrom
node-alpha:master

Conversation

@node-alpha
Copy link

Added MAX6675 support -- Tested on Raspberry Pi (model B).

node-alpha added 2 commits May 3, 2014 17:05
MAX6675 Raspberry Pi driver.
MAX6675 example.
@abc2006
Copy link

abc2006 commented Nov 8, 2017

After a couple of whiles i got it running on a RPI3ModelBVer1.2:
connect
SCK: PIN 23 SPI_CLK GPIO11
CS: to PIN 24 SPI_CE0_N GPIO8
S0: to PIN 21 SPI_MISO GPIO9
VCC: to PIN 1
GND: to PIN 6

Use following Program:
#!/usr/bin/python
from max6675 import MAX6675, MAX6675Error
import time

cs_pin = 8
clock_pin = 11
data_pin = 9
units = "c"
thermocouple = MAX6675(cs_pin, clock_pin, data_pin, units)
running = True
while(running):
try:
try:
tc = thermocouple.get()
print("tc: {}".format(tc))
except MAX6675Error as e:
tc = "Error: "+ e.value
running = False
print("tc: {}".format(tc))
time.sleep(1)
except KeyboardInterrupt:
running = False
thermocouple.cleanup()

Thanks Draco for your Work!

Greetings, Stephan

@henrique-rsilva
Copy link

henrique-rsilva commented Apr 5, 2020

Hello guys, @node-alpha @Tuckie @abc2006 @dlleigh

Look, there is a short script in the link:

https://github.com/Tuckie/max31855/pull/4/files

Which is the sample in the documentation for max6675:


MAX6675 example
#!/usr/bin/python
from max6675 import MAX6675, MAX6675Error

cs_pin = 24
clock_pin = 23
data_pin = 22
units = "c"
thermocouple = MAX6675(cs_pin, clock_pin, data_pin, units)
print(thermocouple.get())
thermocouple.cleanup()


This snippet of code above doesn't work, at least, for RPi 3 B v1.2

See:

There are two ways of adress pins in the Raspberry Pi.

GPIO.Board -> references the physical numbering of the pins
GPIO.BCM -> is the Broadcom Soc Channel numbering (eg.: GPIO04 .....)

In the library max6675.py implementation, you need to pass the BCM pins.

The code below works well to me at Rapberry Pi 3B (Thanks @abc2006, your tip helped a lot).


#!/usr/bin/python
from max6675 import MAX6675, MAX6675Error
import time

cs_pin = 8
clock_pin = 11
data_pin = 9
units = "c"

thermocouple = MAX6675(cs_pin, clock_pin, data_pin, units)
running = True

while(running):
try:
try:
tc = thermocouple.get()
print("tc: {}".format(tc))
time.sleep(1)
except MAX6675Error as e:
tc = "Error: "+ e.value
running = False
print("tc: {}".format(tc))
time.sleep(2)
except KeyboardInterrupt:
running = False
print("\nStopped by User\n")
thermocouple.cleanup()


@node-alpha , to make the life easier, i'd suggest:

In this part:

Initialize needed GPIO
GPIO.setmode(self.board)
GPIO.setup(self.cs_pin, GPIO.OUT)
GPIO.setup(self.clock_pin, GPIO.OUT)
GPIO.setup(self.data_pin, GPIO.IN)

Please, change this name --> GPIO.setmode(self.board)

This causes a lot of confusion, because you did in the init:

==> board = GPIO.BCM

It's not cool to keep like that.

Because you put together two ways to adress pins at RPi.
And this mixture is confusing the way you did.

I hope it helps.

Thank you very much for your work.

Regards,

Henrique

@nilu0007
Copy link

Can we measure negative Temperature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants