8 digit 7 segment module display - two temperature

Hello!

I want to show 6 different temperature from 6 ds18b20 temperature sensors on 3 -
8 digit, 7 segment aduino modul display.
But I have to start to learn at least one sensor to show in first 4 digit.

I’ve never worked with this modul.

With 20x4 lcd display a have no problem.
I use lcd1.setCursor(0, 0); and lcd1.print(“Temp1:”) command and this is for me perfectly understandable.

But with 7 segment, nothing understand. :o :confused:
For first i use this code, but I do not understand NOTHING,

// Libraries for the Dallas Sensor
#include <OneWire.h>
#include <DallasTemperature.h>
//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<deviceCount;i++) {
 
   Serial.print("Sensor Device :: ");
   Serial.print(i);
   Serial.println();
 
    // get the adress of the sensor
    if (!sensors.getAddress(term[i], i)) {
        Serial.print("Unable to find address for Device");
        Serial.println(i,DEC);
    } 
    else {
       Serial.print("Sensor Device ");
       Serial.print(i,DEC);
       Serial.print(" Address is     :: ");
       printAddress(term[i]);
       Serial.println();
    }
 
    //uint8_t* deviceAddress;
    //Serial.println(sensors.getAddress(deviceAddress, 1),HEX);
 
     Serial.print(" +Resolution Byte :: ");
     Serial.println(sensors.getResolution(term[i]),DEC);
     Serial.print(" +getLowAlarmTemp :: ");
     Serial.println(sensors.getLowAlarmTemp(term[i]),DEC);
     Serial.print(" +HighAlarmTemp   :: ");
     Serial.println(sensors.getHighAlarmTemp(term[i]),DEC);
     Serial.println("-----------------------");       
  }
 
 
  //The MAX72XX is in power-saving mode on startup,
  //we have to do a wakeup call
  seg71.shutdown(0,false);  
  //Set the brightness to a medium values
  seg71.setIntensity(0,8);
  //clear the display
  seg71.clearDisplay(0);
 
}
 
 
void loop() {  
 
  Serial.println("Read tempertaur ---------------");
  sensors.requestTemperatures(); // Send the command to get temperatures
 
  //progress dots
  printProgress(30);
 
  int deviceCount=sensors.getDeviceCount();
  //loop over all sensors
  for (int i=0;i<deviceCount;i++) {
    // read the first sensor on the bus
    //tf =sensors.getTempCByIndex(i);
    tf =sensors.getTempC(term[i]);
    integerPart = (int)tf;
    decimalPart = ((int)(tf*N_DECIMAL_POINTS_PRECISION)%N_DECIMAL_POINTS_PRECISION);
 
    Serial.print("Sensor Device temperature ");
    Serial.print(i);
    Serial.print(" :: ");
    Serial.println(tf,4);
 
    //write to 7Segment
    seg71.clearDisplay(0);
    printDigit(integerPart,decimalPart);
    delay(3000);
  } 
}
 
//progress dots
void printProgress(int t){
   //progress dot's 
   seg71.clearDisplay(0);
  for (int i=0;i<9;i++){
    seg71.setChar(0,i,'.',false);
    delay(t);
  }
}
 
//print digits
void printDigit(int t,int p) {  
    int tones;  
    int ttens;  
    int thundreds; 
 
    int pones;  
    int ptens;  
    int phundreds; 
 
    boolean negative=false;
 
    if(t < -999 || t > 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);
  }
}

Can anyone show me working example code for two ds18b20 and 8 digit 7 segment display ?

I want to show first 4 digit for one sensors and second 4 digit for another ds18b20 sensors…

I search for example code with google but nothing suitable for me…

Thankyou

No one .. ?

Doesn't the answer depend on the 8-digit 7-segment display module that you have? No information on it that I can see.

If it's a common cathode display, you can use a MAX7219 to control the display. Then you just need two SPI.transfers to send it the data for each digit:

digitalWrite (ssPin, LOW);
SPI.transfer(registerAddress); // 1 to 8 for the 8 digits
SPI.transfer(dataToDisplay); // chip can decode 0-9, H,E,L,P,- for you
digitalWrite (ssPin, HIGH);

or make up a fontArray and create your own characters, then use this for the 2nd line

SPI.transfer(fontArray[dataToDisplay]); // use 'no decode mode' for own fonts

could be useful if you wanted to use a segments a,b,g,f for a degree symbol for example, or define your own F or C or c

// standard 7-segment layout
    a
f       b
    g
e       c
    d

sory, i have this modul:

8 digit 7 segment display module

Features:

100% Brand new and high quality
MAX7219 digital display control module
This module is compatible with 5V and 3.3V microcontrollers. 
You you can use it for Arduino
MAX7219 is an integrated serial input / output common-cathode display driver, which connects your microprocessor to a 7-segment digital LED display with 8 digits.
Only three IO ports are used to drive the eight digit display. MAX7219 supports flicker free displays as well as cascading displays.

Wiring instructions(for example, it can connect any IO port, modified the Port Definition in the program):
VCC: 5V
GND: GND
DIN: P00
CS: P01
CLK: P02

svedr: No one .. ?

Not everyone here reads the Installation and Troubleshooting section because it's

For problems with Arduino itself, NOT your project

I apologize!

I will try to explain again…

I have CODE with 3 x ds18b30 and 16x2 LCD display, work fine…

I want change this code, to display temperature to 8 digit 7 segment display module.
One value in left part of display ( 4 digit ( 22,3 ) and second value in right part of display ( 4 digit (10.30 ) degrees…

( a third sensor is not important, )

thank you for your help

Here is my CODE :

#include <SPI.h>

#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#define ONE_WIRE_BUS 2 //pin 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

DeviceAddress Thermometer1 = { 0x28, 0xFF, 0x01, 0x22, 0x85, 0x16, 0x05, 0xDC };//In
DeviceAddress Thermometer2 = { 0x28, 0xFF, 0xF6, 0x21, 0x85, 0x16, 0x05, 0xA3 };//Out
DeviceAddress Thermometer3 = { 0x28, 0xFF, 0xA1, 0x43, 0x84, 0x16, 0x04, 0x05 };//Out2

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // LCD KEYPAD SHIELD - 

void setup() {
  Serial.begin(9600);
  lcd.begin(16,2);         // initialize the lcd for 20 chars 4 lines, turn on backlight
  }


void loop() {
  delay(250);
  
  float temp1 = sensors.getTempC(Thermometer1); //In
  float temp2 = sensors.getTempC(Thermometer2); //Out
  float temp3 = sensors.getTempC(Thermometer3); //Out2
  
  sensors.requestTemperatures(); //Get temperature of all sensors
   
    
    // 1 row 
    lcd.setCursor(0, 0);
    lcd.print("IN:");
    lcd.setCursor(4, 0);
    if (temp1 == -127 || temp1 == 85){
          lcd.print("N/A");
          }
          else{
          lcd.print(temp1,1);
           }
    
      // 1 row-right 
    lcd.setCursor(9, 0);
    lcd.print("OUT:");
    lcd.setCursor(12, 0);
    if (temp2 == -127 || temp2 == 85){
          lcd.print("N/A");
          }
          else{
          lcd.print(temp2);
           }
    
    // 2 row
    lcd.setCursor(9, 1);
    lcd.print("OUT2:");
    lcd.setCursor(12, 1);
    if (temp3 == -127 || temp3 == 85){
          lcd.print("N/A");
          }
          else{
          lcd.print(temp3);
           }
    Serial.print("Sensors DS18B20 - PIN 2 ");
    Serial.print('\n');
    Serial.print("IN: ");
    Serial.println(temp1);
    Serial.print("OUT: ");
    Serial.println(temp2);
    Serial.print("OUT2: ");
    Serial.println(temp3);
    Serial.print("--------------------------------- ");
    Serial.print("repeat..... ");
    Serial.print('\n');
    delay (5000);
  }

I will try to explain again....

Sorry, you still failed.

What 8 characters are being displayed? What 8 characters are you expecting to see?

  float temp1 = sensors.getTempC(Thermometer1); //In
  float temp2 = sensors.getTempC(Thermometer2); //Out
  float temp3 = sensors.getTempC(Thermometer3); //Out2

  sensors.requestTemperatures(); //Get temperature of all sensors

Why do you request temperatures AFTER you read the temperatures?

Why is your indenting so crappy? Use Tools + Auto Format to PROPERLY indent your code.

I have an 8-digit display that looks strikingly similar to yours, I used the LedControl library to control it.

Here is some code that will put numbers from 0 - 9 on each digit one second apart, so you should see seven zeros, seven 1’s, etc. Pin numbers are specified in the code and it’s tested working on an Uno.

// Seven Segment Tube Demo
//

#include <LedControl.h>


int counter = 0;          // initial value to display
unsigned long nextTick;   // time to update dounter


// Arduino Pins:          DIN, Clk, CS, no.of devices is 1
LedControl lc = LedControl(12, 11, 10,  1);

void setup()
{

  // Initialize the MAX7219 device
  lc.shutdown(0, false);  // Enable display
  lc.setIntensity(0, 8); // Set brightness level (0 is min, 15 is max)
  lc.clearDisplay(0);     // Clear display register


  // first tick will happen right away
  nextTick = millis();


}

void loop()
{

  // tick timer
  updateTimer();


}


// updateTimer
//
// Call to tick timer
//
void updateTimer()
{

  // if it's time to update display
  if ( millis() >= nextTick )
  {

    // while more digits
    for (int d = 0; d < 8; d++)
    {

      // write this digit
      lc.setDigit(0, d, byte(counter % 10), false);


    }  // while

    // increment number to display
    counter++;

    // set next update time
    nextTick = millis() + 1000;

  }

}

The above code was adapted from the following, which I had from a project, it counts down from 360 to 0.

// Seven Segment Tube Demo
//

#include <LedControl.h>


int counter = 360;        // initial value for countdown
unsigned long nextTick;   // time to update dounter


// Arduino Pins:          DIN, Clk, CS, no.of devices is 1
LedControl lc = LedControl(12, 11, 10,  1);

void setup()
{

  // Initialize the MAX7219 device
  lc.shutdown(0, false);  // Enable display
  lc.setIntensity(0, 8); // Set brightness level (0 is min, 15 is max)
  lc.clearDisplay(0);     // Clear display register


  // first tick will happen right away
  nextTick = millis();


}

void loop()
{

  // tick timer
  updateTimer();


}

// updateTimer
// 
// Call to tick timer
//
void updateTimer()
{
  // if it's time to update counter
  if( millis() >= nextTick )
  {

    // if there are any seconds left
    if( counter >= 0 ) 
    {
      // clear display
      lc.clearDisplay(0);

      // write next number
      printNum(counter);
      
      // decrement counter
      counter--;
      
    } // if

    // set next update time 
    nextTick = millis() + 1000;

  } //if

}

// printNum
//
// Print passed number to diaplay (only works with positve numbers)
//
void printNum(int num)
{
  int dig = 1;
  int digCnt = 0;

  // if number is greater than zero 
  if( num > 0 )
  {

    // count # of digits
    while( num >= dig ) { 
      dig *= 10;
      digCnt++;

    } // while

    // while more digits
    for(int d=0, dig=10; d < digCnt; d++)
    {
      // wite this digit
      lc.setDigit(0,d,byte(num%10),false);

      // writing from right to left
      num /= 10;

    }  // while

  } 
  else {

    // just write a zero
    lc.setDigit(0,0,(byte)0,false);

  }  // else

}

PaulS: Sorry, you still failed.

What 8 characters are being displayed? What 8 characters are you expecting to see?

Uff Paul, what do you not understand ?? I expecting temperature value .... Example: 22.34 12.50 (degrees Celsius)

Understand now ?

Blueeyes, thankyou..... can you send complete code ?

svedr: Uff Paul, what do you not understand ?? I expecting temperature value .... Example: 22.34 12.50 (degrees Celsius)

Understand now ?

Blueeyes, thankyou..... can you send complete code ?

I count 11 characters there. How will you display that on an 8 character display?

aarg: I count 11 characters there. How will you display that on an 8 character display?

Most seven segment displays have a decimal point per character, but that still leaves the problem of the space.

Understand now ?

I understand now what you want to see. I still haven't a clue what you ACTUALLY see.

AWOL: Most seven segment displays have a decimal point per character, but that still leaves the problem of the space.

I actually built a project almost exactly like this. I never found a library that would automatically place a decimal with a digit. So I had to write my own functions to do that - the result was similar to sprintf(). In addition to leading zero suppression, I also had to factor in space for a minus sign for negative temperatures.

Does this mean that no one uses 7 segment display for show temperature? :o

I still haven’t a clue what you ACTUALLY see.

ACTUALLY I see nothing, because I can not find a single case CODE,
where it has been in use 7 segment display and a temperature sensor DS 18B20 :confused:

If the problem is with the number of characters, can be only one decimal digit,

if it is easier, I’ll buy 4digit 7 segment modules ( but at home I have 5pcs , 8 digit 7 segment segment and want to use )

I want something like show in this video :stuck_out_tongue:

again ask for help!

svedr:
ACTUALLY I see nothing, because I can not find a single case CODE

But, isn’t that because you haven’t written any? I didn’t just throw my hands in the air and give up because there were no examples online… I rolled up my sleeves and researched all the components and requirements and did it. There is no high-level mathematics or anything to it. I would post my code here if you appeared willing to provide some feedback that would indicate some effort towards discovering the elements of the solution.

I write code ( 8xds18b20 and lcd 20xd )
Now i try with 7 segment…

Right now i find this code:

/**
 * @file        max7219_7segment_date_time_temp.c
 *
 * @brief       view DATE/TIME/TEMPERATURE using an 8-digit 
 *              7-Segment display
 *
 * @history     Feb 6th, 2017
 *
 * @author      Allan Schwartz <allans@CodeValue.net>
 *              Michael Diamond <m.diamond.il@gmail.com>
 *
 * @notes       The following Arduino Pins are attached:
 *
 *              name    Arduino   7 Segment display
 *              -----   ----      -----
 *                      +5V       VCC
 *                      GND       GND
 *              DIN     D11/MOSI  DIN
 *              CS      D10/SS    CS
 *              CLK     D13/SCK   CLK
 *
 *              name    Arduino   RTC module
 *              -----   ----      -----
 *                      nc        32K
 *                      nc        SQW
 *              SCL     SCL/A5    SCL
 *              SDA     SDA/A4    SDA
 *                      3v3       VCC
 *                      GND       GND
 */

#include <DS3231.h>           // import library from rinkydink.com

// define pins attached to MAX7219 (and also see notes above)
#define MAX7219_DIN           11
#define MAX7219_CS            10
#define MAX7219_CLK           13

// enumerate the MAX7219 registers
// See MAX7219 Datasheet, Table 2, page 7
enum {  MAX7219_REG_DECODE    = 0x09,  
        MAX7219_REG_INTENSITY = 0x0A,
        MAX7219_REG_SCANLIMIT = 0x0B,
        MAX7219_REG_SHUTDOWN  = 0x0C,
        MAX7219_REG_DISPTEST  = 0x0F };

// enumerate the SHUTDOWN modes
// See MAX7219 Datasheet, Table 3, page 7
enum  { OFF = 0,  
        ON  = 1 };

const byte DP = 0b10000000;  
const byte C  = 0b01001110;  
const byte F  = 0b01000111;


// create an instance of the DS3231 called 'rtc', 
// and specify the hardware interface PINS
DS3231 rtc(SDA, SCL);


// ... setup code here, to run once
void setup()  
{
    // initialize the serial port:
    Serial.begin(115200);           // initialize serial communication
    Serial.println("max7219_7segment_date_time_temp");

    // define type of pin
    pinMode(MAX7219_DIN, OUTPUT);   // serial data-in
    pinMode(MAX7219_CS, OUTPUT);    // chip-select, active low    
    pinMode(MAX7219_CLK, OUTPUT);   // serial clock
    digitalWrite(MAX7219_CS, HIGH);

    resetDisplay();                 // reset the MAX2719 display

    rtc.begin();                    // init. the DS3231 RTC interface

    // Uncomment the following lines to set the RTC
    //rtc.setDOW(WEDNESDAY);        // Set Day-of-Week to WEDNESDAY
    //rtc.setTime(16, 20, 0);       // Set the time to 4:20pm
    //rtc.setDate(8, 2, 2017);      // Set the date to 8-Feb-2017
}


void loop()  
{
    String str;                     // scratch or working string

    // ... display Date, dd.mm.yyyy
    // read the date as a string from the RTC
    str = rtc.getDateStr(FORMAT_LONG);
    Serial.println(str);            // debug
    displayDate(str);               // display on the 7-segment 
    delay(6000);

    // ... display Time, hh-mm-ss
    for ( int i = 0; i < 6; i++ ) {
        // read the time as a string from the RTC
        str = rtc.getTimeStr(FORMAT_LONG);
        Serial.println(str);        // debug
        displayTime(str);           // display on the 7-segment 
        delay(1000);
    }

    // ... display Temperature in Celsius, xx.xx C
    // read the temperature, as a float, from the RTC
    float t = rtc.getTemp();
    str = String(t, 2);             // format that value
    Serial.println(str);            // debug
    displayTemp(str, C);            // display on the 7-segment
    delay(3000);

    // ... display Temperature in Fahrenheit, xx.xx F
    t = t * 1.8 + 32.0;             // convert the value to Fahrenheit
    str = String(t, 1);             // format that value
    Serial.println(str);            // debug
    displayTemp(str, F);            // display on the 7-segment
    delay(3000);
}


// ... write a value into a max7219 register 
// See MAX7219 Datasheet, Table 1, page 6
void set_register(byte reg, byte value)  
{
    digitalWrite(MAX7219_CS, LOW);
    shiftOut(MAX7219_DIN, MAX7219_CLK, MSBFIRST, reg);
    shiftOut(MAX7219_DIN, MAX7219_CLK, MSBFIRST, value);
    digitalWrite(MAX7219_CS, HIGH);
}


// ... reset the max7219 chip
void resetDisplay()  
{
    set_register(MAX7219_REG_SHUTDOWN, OFF);   // turn off display
    set_register(MAX7219_REG_DISPTEST, OFF);   // turn off test mode
    set_register(MAX7219_REG_INTENSITY, 0x0D); // display intensity
}


// ... display the DATE on the 7-segment display
void displayDate(String dateString)  
{
    set_register(MAX7219_REG_SHUTDOWN, OFF);  // turn off display
    set_register(MAX7219_REG_SCANLIMIT, 7);   // scan limit 8 digits
    set_register(MAX7219_REG_DECODE, 0b11111111); // decode all digits

    set_register(1, dateString.charAt(9));
    set_register(2, dateString.charAt(8));
    set_register(3, dateString.charAt(7));
    set_register(4, dateString.charAt(6));
    set_register(5, dateString.charAt(4) | DP); // plus decimal point
    set_register(6, dateString.charAt(3));
    set_register(7, dateString.charAt(1) | DP);
    set_register(8, dateString.charAt(0));

    set_register(MAX7219_REG_SHUTDOWN, ON);   // Turn on display
}


// ... display the TIME on the 7-segment display
void displayTime(String timeString)  
{
    set_register(MAX7219_REG_SHUTDOWN, OFF);  // turn off display
    set_register(MAX7219_REG_SCANLIMIT, 7);   // scan limit 8 digits
    set_register(MAX7219_REG_DECODE, 0b11111111); // decode all digits

    set_register(1, timeString.charAt(7));
    set_register(2, timeString.charAt(6));
    set_register(3, timeString.charAt(5));
    set_register(4, timeString.charAt(4));
    set_register(5, timeString.charAt(3));
    set_register(6, timeString.charAt(2));
    set_register(7, timeString.charAt(1));
    set_register(8, timeString.charAt(0));

    set_register(MAX7219_REG_SHUTDOWN, ON);   // Turn on display
}


// ... display the TEMP on the 7-segment display
void displayTemp(String tempString, char C_or_F )  
{
    set_register(MAX7219_REG_SHUTDOWN, OFF);  // turn off display
    set_register(MAX7219_REG_SCANLIMIT, 5);   // scan limit 6 digits
    set_register(MAX7219_REG_DECODE, 0b00111100); // decode 4 digits

    set_register(1, C_or_F);
    set_register(2, 0);                       // blank
    set_register(3, tempString.charAt(4));
    set_register(4, tempString.charAt(3));
    set_register(5, tempString.charAt(1) | DP); // plus decimal point
    set_register(6, tempString.charAt(0));

    set_register(MAX7219_REG_SHUTDOWN, ON);   // Turn On display
}

Code show DATE/TIME/TEMPERATURE from RTC module on 8 digit 7 segment display…

I tried to change the code that will work with DS18B20 temperature sensors…

any help is welcome

I tried to change the code that will work with DS18B20 temperature sensors....

What changes did you make? What were the results?

If you can display ANY numbers on a seven segment display, it doesn't matter if the number represents the number of people frustrated by your lack of responses, the temperature, or the number of replies it is going to take until you can mark this thread solved.

Here is my change CODE

/**
 *
 *              name    Arduino   7 Segment display
 *              -----   ----      -----
 *                      +5V       VCC
 *                      GND       GND
 *              DIN     D11/MOSI  DIN
 *              CS      D10/SS    CS
 *              CLK     D13/SCK   CLK

 */


#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// define pins attached to MAX7219 (and also see notes above)
#define MAX7219_DIN           11
#define MAX7219_CS            10
#define MAX7219_CLK           13
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress Thermometer1 = { 0x28, 0xFF, 0x7F, 0x6A, 0x84, 0x16, 0x04, 0x1A };//ok

// enumerate the MAX7219 registers
// See MAX7219 Datasheet, Table 2, page 7
enum {  MAX7219_REG_DECODE    = 0x09,  
        MAX7219_REG_INTENSITY = 0x0A,
        MAX7219_REG_SCANLIMIT = 0x0B,
        MAX7219_REG_SHUTDOWN  = 0x0C,
        MAX7219_REG_DISPTEST  = 0x0F };

// enumerate the SHUTDOWN modes
// See MAX7219 Datasheet, Table 3, page 7
enum  { OFF = 0,  
        ON  = 1 };

const byte DP = 0b10000000;  
const byte C  = 0b01001110;  
const byte F  = 0b01000111;


// ... setup code here, to run once
void setup()  
{
    // initialize the serial port:
    Serial.begin(115200);           // initialize serial communication
    Serial.println("max7219_7segment_date_time_temp");

    // define type of pin
    pinMode(MAX7219_DIN, OUTPUT);   // serial data-in
    pinMode(MAX7219_CS, OUTPUT);    // chip-select, active low    
    pinMode(MAX7219_CLK, OUTPUT);   // serial clock
    digitalWrite(MAX7219_CS, HIGH);

    resetDisplay();                 // reset the MAX2719 display
}


void loop()  
{
    String str;                     // scratch or working string

float temp1 = sensors.getTempC(Thermometer1);
sensors.requestTemperatures(); //Get temperature of all sensors


    

    // ... display Temperature in Celsius, xx.xx C
    // read the temperature, as a float, from the RTC
    //float t = rtc.getTemp();
    str = String(temp1, 2);             // format that value
    Serial.println(str);            // debug
    displayTemp(str, C);            // display on the 7-segment
    delay(500);

    
}


// ... write a value into a max7219 register 
// See MAX7219 Datasheet, Table 1, page 6
void set_register(byte reg, byte value)  
{
    digitalWrite(MAX7219_CS, LOW);
    shiftOut(MAX7219_DIN, MAX7219_CLK, MSBFIRST, reg);
    shiftOut(MAX7219_DIN, MAX7219_CLK, MSBFIRST, value);
    digitalWrite(MAX7219_CS, HIGH);
}


// ... reset the max7219 chip
void resetDisplay()  
{
    set_register(MAX7219_REG_SHUTDOWN, OFF);   // turn off display
    set_register(MAX7219_REG_DISPTEST, OFF);   // turn off test mode
    set_register(MAX7219_REG_INTENSITY, 0x0D); // display intensity
}



// ... display the TEMP on the 7-segment display
void displayTemp(String tempString, char C_or_F )  
{
    set_register(MAX7219_REG_SHUTDOWN, OFF);  // turn off display
    set_register(MAX7219_REG_SCANLIMIT, 5);   // scan limit 6 digits
    set_register(MAX7219_REG_DECODE, 0b00111100); // decode 4 digits

    set_register(1, C_or_F);
    set_register(2, 0);                       // blank
    set_register(3, tempString.charAt(4));
    set_register(4, tempString.charAt(3));
    set_register(5, tempString.charAt(1) | DP); // plus decimal point
    set_register(6, tempString.charAt(0));

    set_register(MAX7219_REG_SHUTDOWN, ON);   // Turn On display
}

I see on display value from DS18B20 ( 22.44 C ) thats all ok , But

problem is:

  1. When the sensor is not connected can not see -127 ( value when it is not connected to the sensor )

I only see strange characters… L1.7P C ( see attachment )

How do I fix this?

  1. How can move value-number to left ( start with first left digits )
    String str;                     // scratch or working string

Get rid of the String. There is NOTHING that you can do with a String that you can't do with a string except make swiss cheese of memory (which you do NOT want to do).

    str = String(temp1, 2);             // format that value

dtostrf() uses a LOT less resources.

float temp1 = sensors.getTempC(Thermometer1);
sensors.requestTemperatures(); //Get temperature of all sensors

Think about the order of these two statements. Do that make ANY sense in that order?

Is all that

white space

really necessary?