A program to measure the temperature using the Max6675 board. The temperature is shown on 8x8 Max7219 matrix display and it is saved on SD as well.

Dependencies:   MAX7219 SDFileSystem mbed

Fork of MAXREFDES99_demo by Maxim Integrated

The program measures the temperature using the Max6675 board designed for Arduino. The temperature is shown on Max7219 8x8 matrix display (designed for Arduino as well) as text marque from right to left. The fonf size is 5x7 so the last row is used to show some info:

- All leds off: Normal temperature measuring - Leds shifting: Saving on SD card - Leds blinking: SD card missing or damaged

The Blue "user button" is used to save measured temperature on SD card. First click start saving, the second stop the process. Together the temperature is saved also the time. The time is reset when the process start. Connecting the USB to PC it's possible to see instant temperature and all saved data on SD.

Committer:
lore71
Date:
Thu Oct 04 11:37:43 2018 +0000
Revision:
12:1bd4a9f09a8d
A program to measure the temperature using the Max6675 board.; The temperature is shown on 8x8 Max7219 matrix display and it is saved on SD as well.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lore71 12:1bd4a9f09a8d 1
lore71 12:1bd4a9f09a8d 2 #include <mbed.h>
lore71 12:1bd4a9f09a8d 3 #include "max6675.h"
lore71 12:1bd4a9f09a8d 4
lore71 12:1bd4a9f09a8d 5 max6675::max6675(SPI& _spi, PinName _ncs) : spi(_spi), ncs(_ncs) {
lore71 12:1bd4a9f09a8d 6
lore71 12:1bd4a9f09a8d 7 }
lore71 12:1bd4a9f09a8d 8
lore71 12:1bd4a9f09a8d 9 float max6675::read_temp() {
lore71 12:1bd4a9f09a8d 10 short value = 0;
lore71 12:1bd4a9f09a8d 11 float temp = 0;
lore71 12:1bd4a9f09a8d 12
lore71 12:1bd4a9f09a8d 13 uint8_t highByte=0;
lore71 12:1bd4a9f09a8d 14 uint8_t lowByte=0;
lore71 12:1bd4a9f09a8d 15
lore71 12:1bd4a9f09a8d 16 select();
lore71 12:1bd4a9f09a8d 17 wait(.25); //This delay is needed else it does'nt seem to update the temp
lore71 12:1bd4a9f09a8d 18
lore71 12:1bd4a9f09a8d 19 highByte = spi.write(0);
lore71 12:1bd4a9f09a8d 20 lowByte = spi.write(0);
lore71 12:1bd4a9f09a8d 21 deselect();
lore71 12:1bd4a9f09a8d 22
lore71 12:1bd4a9f09a8d 23
lore71 12:1bd4a9f09a8d 24 if (lowByte & (1<<2)) {
lore71 12:1bd4a9f09a8d 25 error("No Probe");
lore71 12:1bd4a9f09a8d 26 } else {
lore71 12:1bd4a9f09a8d 27 value = (highByte << 5 | lowByte>>3);
lore71 12:1bd4a9f09a8d 28 }
lore71 12:1bd4a9f09a8d 29
lore71 12:1bd4a9f09a8d 30 temp = (value*0.25); // Multiply the value by 0.25 to get temp in ˚C or
lore71 12:1bd4a9f09a8d 31 // * (9.0/5.0)) + 32.0; // Convert value to ˚F (ensure proper floats!)
lore71 12:1bd4a9f09a8d 32
lore71 12:1bd4a9f09a8d 33 return temp;
lore71 12:1bd4a9f09a8d 34 }
lore71 12:1bd4a9f09a8d 35
lore71 12:1bd4a9f09a8d 36 void max6675::select() {
lore71 12:1bd4a9f09a8d 37 ncs = 0;
lore71 12:1bd4a9f09a8d 38 }
lore71 12:1bd4a9f09a8d 39
lore71 12:1bd4a9f09a8d 40 void max6675::deselect() {
lore71 12:1bd4a9f09a8d 41 ncs = 1;
lore71 12:1bd4a9f09a8d 42 }