It's just perfect! Thanks a lot..It works on simulator will try assembling this weekend. Btw does it display -ve temperatue eg -10c?
@Halina200116 ай бұрын
Thanks! The current code does not show the negative values but this code will. (i will update it soon on the website) in the mean time here is it: ``` #include #include #include const int oneWireBus = 4; OneWire oneWire(oneWireBus); DallasTemperature sensors(&oneWire); #define CLK 3 #define DIO 2 // if the screen is empty increase this value #define DELAY 10 TM1637Display display = TM1637Display(CLK, DIO, DELAY); const uint8_t celsiusSymbol[] = { SEG_A | SEG_B | SEG_F | SEG_G, SEG_A | SEG_D | SEG_E | SEG_F }; void setup(){ Serial.begin(115200); display.clear(); display.setBrightness(7); sensors.begin(); } int32_t prev = INT32_MAX; void printTemperature(){ // sensors.requestTemperatures(); // float measuredTemperature = sensors.getTempCByIndex(0); float measuredTemperature = -10; // for testing purposes Serial.println(String(measuredTemperature) + "°C"); // convert the value to get the number without the floating point "." // 10.27 => 10 int32_t decValue = measuredTemperature; // if prev number is the same we dont have to draw it again if(decValue == prev){ return; } prev = decValue; String s = String(decValue); // get the length of the number int sLength = s.length(); // clamp the value between 0 and 4 [0, 4] int nLength = max(min(sLength, 4), 0); // align it to the right => "0" => " 0°C" // if the alignment is not wanted just set the index = 0 // int index = 0; int index = (sLength == 1) ? 1 : 0; Serial.println(decValue); // first draw the deg. symbol => "°C" display.clear(); display.setSegments(celsiusSymbol, 2, 2); // because the symbol is written first, the number will overwrite the °C symbol if needed display.showNumberDec(decValue, false, nLength, index); // result // 100 => "100C" // 10 => "10°C" // 0 => " 0°C" // -1 => "-1°C" // -10 => "-10C" // -100 => "-100" } void loop(){ printTemperature(); delay(200); } ```
@krishnakumar65706 ай бұрын
@@Halina20011 Thank you !
@好吧-o7p2 жыл бұрын
Thanks~
@pascualpalacios70992 жыл бұрын
Hello Halina, how can you modify the code so that it marks the decimal 24.1 C
@Halina200112 жыл бұрын
You can't display decimal number on this display, because it does't have decimal separator.
@achuashkar99793 жыл бұрын
Can we use this to monitor engine temperature.?
@Halina200113 жыл бұрын
The maximum and minimum temperature that the DS18B20 can survive and measure is: -55 to 125 ° C. So if the engine you want to monitor does not exceed these values then it should be possible.
@sashakomar32813 жыл бұрын
Измеряет ли отрицательные температуры?
@АлександрКопылов-х7т Жыл бұрын
до -9 показывает, дальше для знака минус нет места. убрал значок С, теперь думаю, как все это сдвинуть вправо чтоб и знак минус поместился
@mvm280110 ай бұрын
@@АлександрКопылов-х7т получилось убрать знак С и сдвинуть знаки вправо?
@chahinejaoued11223 жыл бұрын
the code is not clear if you can copy it or upload the file .ino in the disceiption please and thank you
@Halina200113 жыл бұрын
#include #include #include const int oneWireBus = 4; OneWire oneWire(oneWireBus); DallasTemperature sensors(&oneWire); #define CLK 2 #define DIO 3 TM1637Display display = TM1637Display(CLK, DIO); const uint8_t celsius[] = { // Create degree Celsius symbol: SEG_A | SEG_B | SEG_F | SEG_G, // ° SEG_A | SEG_D | SEG_E | SEG_F // C }; void setup() { Serial.begin(9600); display.clear(); display.setBrightness(7); sensors.begin(); //Start the DS18B20 sensor delay(1000); } void loop() { sensors.requestTemperatures(); float temperatureC = sensors.getTempCByIndex(0); Serial.println(temperatureC); int temperatureN = temperatureC; Serial.println(temperatureN); int temperature = temperatureC; display.showNumberDec(temperatureN, false, 2, 0); display.setSegments(celsius, 2, 2); delay(1000); } Or copy the code from There : github.com/halina20011/Arduino-Thermometer-with-Display/blob/main/Thermometer-DS18B20_TM1637/Thermometer-DS18B20_TM1637.ino
@chahinejaoued11223 жыл бұрын
@@Halina20011 thank you a lot you helped me very much in my project