Open node-alpha opened 10 years ago
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:
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
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
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).
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
Can we measure negative Temperature
Added MAX6675 support -- Tested on Raspberry Pi (model B).