DS 1820 library - help and modification

Dear forum,

I'm new to arduino and this is my first topic here.

I have question about dallas 1-wire temperature sensors. I have code where i am reading 4 this DS1820 chips and displaying valuses with time stamps on serial monitor and lcd and also i am logging these data to SD card.
Everithing works OK mainly thanks to all great guys from several forums. Many thanks to them.

My only problem is that when i get temperature from DS1820 it is in format 19.25°C but i need 19,25°C. So i need decimal separator with comma not a dot ! ! !
Is this possible to fix this i my code or library, I need this because the other program I am using to analyze these data. And i trully need t fix this, so please guys hep me :~

Here is the coede:
// libraries
#include <Wire.h>
#include "RTClib.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>

//Connection through I2C
LiquidCrystal_I2C lcd(0x20,20,4); // set the LCD address to 0x20 for a 16 chars and 2 line display

// DS18B20 sensors on I/O pin 9
#define ONE_WIRE_BUS 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress DS0 = { 0x10, 0x7C, 0xAD, 0x74, 0x02, 0x08, 0x00, 0x5E};
DeviceAddress N05 = { 0x28, 0x80, 0x02, 0x24, 0x03, 0x00, 0x00, 0xED };
DeviceAddress N10 = { 0x10, 0x5D, 0xAA, 0x74, 0x02, 0x08, 0x00, 0x8E };
// DeviceAddress N17 = { 0x10, 0xBB, 0x1B, 0x57, 0x02, 0x08, 0x00, 0x6F };
DeviceAddress N17 = { 0x10, 0xE2, 0xA5, 0x74, 0x02, 0x08, 0x00, 0xC2 };

long ID = 1; //Use this to store the id # of our reading.
// RTC??
RTC_DS1307 RTC; // define the Real Time Clock object
uint32_t syncTime = 0; // time of last sync()
const int chipSelect = 10;// for the data logging shield, we use digital pin 10 for the SD cs line
// Logfile ?

void error(char *str)
Serial.print("Chyba: ");
while(1);// lock up if error

// main setup
void setup(void)

// LCD I2C setup
lcd.init(); // initialize the lcd
lcd.backlight(); // blacklight of the lcd
lcd.clear(); // clear the LCD screen

// Start up the library
// set the resolution to 10 bit (good enough?)
sensors.setResolution(DS0, 12);
sensors.setResolution(N05, 12);
sensors.setResolution(N10, 12);
sensors.setResolution(N17, 12);

// RTC setup

if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(DATE, TIME));

Serial.println("ID Cas Datum DS0 N05 N10 N17 ");

// DS1820 setup
float TempC = 0;
void printTemperature(DeviceAddress deviceAddress)
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
} else {
lcd.print(tempC,2); // 2 means decimal places

Serial.print(tempC,2); // 2 means decimal places
Serial.print(' ');


void loop(void)
DateTime now;


// fetch the time
now = RTC.now();

Serial.print(ID); // ID na serial
Serial.print(" ");

//datum ve tvaru 19/02/2013
if (now.day() < 10) {
Serial.print("0"); //insert leading zero if day value is less than 10
Serial.print(now.day(),DEC); //display current day
else Serial.print(now.day(),DEC); //display current day

if (now.month() < 10) {
Serial.print("0"); //insert leading zero if month value is less than 10
Serial.print(now.month(),DEC); //display current month
else Serial.print(now.month(),DEC); //display current month

Serial.print(now.year(), DEC);
Serial.print(' ');

//cas ve tvaru 09:50:02

if (now.hour() < 10) {
Serial.print("0"); //insert leading zero if hour value is less than 10
Serial.print(now.hour(),DEC); //display current hour
else Serial.print(now.hour(),DEC); //display current hour

if (now.minute() < 10) {
Serial.print("0"); //insert leading zero if minute value is less than 10
Serial.print(now.minute(),DEC); //display current minute
else Serial.print(now.minute(),DEC); //display current minute

if (now.second() < 10) {
Serial.print("0"); //insert leading zero if seconds value is less than 10
Serial.print(now.second(),DEC); //display current seconds
else Serial.print(now.second(),DEC); //display current seconds


lcd.setCursor(0, 0);

//datum ve tvaru 19/02/2013
if (now.day() < 10) {
lcd.print("0"); //insert leading zero if day value is less than 10
lcd.print(now.day(),DEC); //display current day
else lcd.print(now.day(),DEC); //display current day

if (now.month() < 10) {
lcd.print("0"); //insert leading zero if month value is less than 10
lcd.print(now.month(),DEC); //display current month
else lcd.print(now.month(),DEC); //display current month

lcd.print(now.year()-2000, DEC);
lcd.print(' ');

//cas ve tvaru 09:50:02

lcd.setCursor(12, 0);

if (now.hour() < 10) {
lcd.print("0"); //insert leading zero if hour value is less than 10
lcd.print(now.hour(),DEC); //display current hour
else lcd.print(now.hour(),DEC); //display current hour

if (now.minute() < 10) {
lcd.print("0"); //insert leading zero if minute value is less than 10
lcd.print(now.minute(),DEC); //display current minute
else lcd.print(now.minute(),DEC); //display current minute

if (now.second() < 10) {
lcd.print("0"); //insert leading zero if seconds value is less than 10
lcd.print(now.second(),DEC); //display current seconds
else lcd.print(now.second(),DEC); //display current seconds

// Zde se vypisuje trvání celého záznamu v sekundách
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
lcd.print("Cas: "); // ID na serial
lcd.print(millis()/60000); // display seconds elapsed since power-up

lcd.setCursor(0, 1);
lcd.print("ID: "); // ID na serial
lcd.print(ID); // ID na serial

Serial.print(' ');
// #endif //ECHO_TO_SERIAL


Serial.print(" ");
// delay(prodleva);
Serial.print(" ");
Serial.print(" ");
Serial.print(" ");
// delay(prodleva);
Serial.print(" ");



//Increment ID number


Looks like you can "hack" your library files if you wish. If that's what you do, start by copying the "official" version to the libraries folder in your sketch storage area. Or you could drop down a level and get the raw data from the chips. I don't know any thing about the library, never used it so I'd just get the info from the sensor and format it the way I wanted it to look.

Don't post code without code tags!

What you are looking for is in the Print.cpp file (hardware/arduino/cores/arduino/Print.cpp) at line 255:

    n += print(".");

change that to

    n += print(",");

and all your float get a comma instead of the decimal point.


Thanks a lot pylon, that is the solution which i needed :slight_smile:
Thanks a lot again :slight_smile: