// Libraries for the Dallas Sensor #include #include //Control the MAX7219 #include "LedControl.h" //---------------------- //to create int values from the float temperature value #define N_DECIMAL_POINTS_PRECISION (1000) // n = 3. Three decimal points. #define TEMPERATURE_PRECISION 12 //---------------------- // Data wire is plugged to pin 2 #define ONE_WIRE_BUS 2 // Setup a oneWire instance to communicate OneWire oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature. DallasTemperature sensors(&oneWire); //remember the devices for max 5 devices DeviceAddress term[5]; //---------------------- // add the 7 Segment LED // pin 12 is connected to the DataIn // pin 11 is connected to the CLK // pin 10 is connected to LOAD // only one MAX72xx Chip // LedControl(dataPin,clockPin,csPin,numDevices) LedControl seg71=LedControl(12,11,10,1); //---------------------- // globals float tf=0; int integerPart = 0; int decimalPart = 0; //---------------------- void setup() { // Open serial communications Serial.begin(57600); // wait for serial port to connect. Needed for native USB port only while (!Serial) { ; } Serial.println("Start reading temperature"); // Start the Dallas Library sensors.begin(); // set to asyncron sensors.setWaitForConversion(false); //set the resolution sensors.setResolution(TEMPERATURE_PRECISION); //Power Mode Serial.print("Sensors Power Mode :: "); if ( sensors.isParasitePowerMode() ) { Serial.println("Parasite Power Mode"); } else { Serial.println("Power line connected"); } //show settings int deviceCount=sensors.getDeviceCount(); //sensor Count Serial.print("Sensors :: "); Serial.print(deviceCount, DEC); Serial.println(" connected"); //loop over all sensors for (int i=0;i 999) return; if(t<0) { negative=true; t=t*-1; } tones=t%10; pones=p%10; t=t/10; p=p/10; ttens=t%10; ptens=p%10; t=t/10; thundreds=t; p=p/10; phundreds=p; if(negative) { //print character '-' in the leftmost column seg71.setChar(0,7,'-',false); } else { //print a blank in the sign column seg71.setChar(0,7,' ',false); } seg71.setDigit(0,6,(byte)thundreds,false); seg71.setDigit(0,5,(byte)ttens,false); seg71.setDigit(0,4,(byte)tones,true); seg71.setDigit(0,3,(byte)phundreds,false); seg71.setDigit(0,2,(byte)ptens,false); seg71.setDigit(0,1,(byte)pones,false); seg71.setChar(0,0,'C',false); } // function to print a device address // from https://github.com/adafruit/MAX31850_DallasTemp/blob/master/examples/Multiple/Multiple.pde void printAddress(DeviceAddress deviceAddress) { for (uint8_t i = 0; i < 8; i++){ // zero pad the address if necessary if (deviceAddress[i] < 16) Serial.print("0"); Serial.print(deviceAddress[i], HEX); } }