printText or 'dtostrf' fault?

Error

Arduino: 1.8.5 (Windows 10), Board: "Arduino Due (Programming Port)"

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function 'void setup()':

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:55:43: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    printText("TEMPERATURE", GREEN,30,65,1);  // Temperature Static Text

                                          ^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:56:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    printText("MAX", RED,18,130,1);

                                 ^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:57:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    printText("MIN", BLUE,95,130,1);

                                  ^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function 'void loop()':

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:102:33: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    printText("o", WHITE,90,75,2);

                                ^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:103:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    printText("C", WHITE,105,80,3);

                                 ^

RTCTFT160:108: error: 'dtostrf' was not declared in this scope

      dtostrf(maxTemperature,4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)

                                                     ^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:111:36: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

      printText("o", WHITE,35,140,1);

                                   ^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:112:36: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

      printText("C", WHITE,41,145,1);

                                   ^

RTCTFT160:118: error: 'dtostrf' was not declared in this scope

      dtostrf(minTemperature,4, 1, charMinTemperature); 

                                                     ^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:121:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

      printText("o", WHITE,112,140,1);

                                    ^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:122:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

      printText("C", WHITE,118,145,1);

                                    ^

exit status 1
'dtostrf' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
[b]Code[/b]

[code]
#include  <Adafruit_GFX.h>
#include <Wire.h>
#include "Sodaq_DS3231.h"
#include  <SPI.h>
#include  <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

//Color Definitons
#define BLACK     0x0000
#define BLUE      0x001F
#define GREY      0xCE79
#define LIGHTGREY 0xDEDB
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF


float maxTemperature=0;
float minTemperature=200;
char charMinTemperature[10];
char charMaxTemperature[10];
char timeChar[100];
char dateChar[50];
char temperatureChar[10];

float temperature = 0;
float previousTemperature = 0;

String dateString;
int minuteNow=0;
int minutePrevious=0;

void setup () 
{
    Serial.begin(57600);
    tft.reset();
    uint16_t identifier = tft.readID();
    tft.begin(identifier);
    tft.setRotation (2);
    tft.fillScreen(BLACK);
    
    Wire.begin();
    rtc.begin();
    printText("TEMPERATURE", GREEN,30,65,1);  // Temperature Static Text
    printText("MAX", RED,18,130,1);
    printText("MIN", BLUE,95,130,1);
    setRTCTime();
}

uint32_t old_ts;

void loop () 
{
  float temperature = rtc.getTemperature();
  DateTime now = rtc.now(); //get the current date-time
  uint32_t ts = now.getEpoch();

    if (old_ts == 0 || old_ts != ts) {
 old_ts = ts;
  
  minuteNow = now.minute();
  if(minuteNow!=minutePrevious)
  {
    dateString = getDayOfWeek(now.dayOfWeek())+", ";
    dateString = dateString+String(now.date())+"/"+String(now.month());
    dateString= dateString+"/"+ String(now.year()); 
    minutePrevious = minuteNow;
    String hours = String(now.hour());
    if(now.minute()<10)
    {
      hours = hours+":0"+String(now.minute());
    }else
    {
      hours = hours+":"+String(now.minute());
    }
    
    hours.toCharArray(timeChar,100);
    tft.fillRect(10,0,160,65,BLACK);
    printText(timeChar, WHITE,20,25,3);
    dateString.toCharArray(dateChar,50);
    printText(dateChar, GREEN,8,5,1);
  }
  
  if(temperature != previousTemperature)
  {
    previousTemperature = temperature;
    String temperatureString = String(temperature,1);
    temperatureString.toCharArray(temperatureChar,10);
    tft.fillRect(10,80,128,30,BLACK);
    printText(temperatureChar, WHITE,10,80,3);
    printText("o", WHITE,90,75,2);
    printText("C", WHITE,105,80,3);

if(temperature>maxTemperature)
    {
      maxTemperature = temperature;
      dtostrf(maxTemperature,4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)
      tft.fillRect(3,142,33,20,BLACK);
      printText(charMaxTemperature, WHITE,3,145,1);
      printText("o", WHITE,35,140,1);
      printText("C", WHITE,41,145,1);
    }
if(temperature  < minTemperature) 

 {
      minTemperature = temperature;
      dtostrf(minTemperature,4, 1, charMinTemperature); 
      tft.fillRect(75,140,36,18,BLACK);
      printText(charMinTemperature, WHITE,80,145,1);
      printText("o", WHITE,112,140,1);
      printText("C", WHITE,118,145,1);
      setRTCTime();
    }
  }
}
    delay(1000);
}


void setRTCTime()
{
  DateTime dt(2018, 6, 11, 15, 40, 30, 1); // Year, Month, Day, Hour, Minutes, Seconds, Day of Week
  rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above 
}void printText(char *text, uint16_t color, int x, int y,int textSize)
{
  tft.setCursor(x, y);
  tft.setTextColor(color);
  tft.setTextSize(textSize);
  tft.setTextWrap(true);
  tft.print(text);
}

String getDayOfWeek(int i)
{
  switch(i)
  {
    case 1: return "Monday";break;
    case 2: return "Tuesday";break;
    case 3: return "Wednesday";break;
    case 4: return "Thursday";break;
    case 5: return "Friday";break;
    case 6: return "Saturday";break;
    case 7: return "Sunday";break;
    default: return "Monday";break;
  }
}

Ive read the ‘dtostrf’ on this forum and others and it seems like its still not working. I’m not sure if its maybe the printText ?

Any case I need professional help as Ive been stuck on this for a long time. Thanks[/code]

The warnings should be fixed by:

void printText(const char *text, uint16_t color, int x, int y,int textSize) {
.
.
.
}

is that for every line printText? Thanks

fnb111:
is that for every line printText? Thanks

No. You should change the signature of the method/function, in one place.

No, in the function definition.

Arduino: 1.8.5 (Windows 10), Board: "Arduino Due (Programming Port)"

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function 'void setup()':

RTCTFT160:55: error: 'printText' was not declared in this scope

printText("TEMPERATURE", GREEN,30,65,1); // Temperature Static Text

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function 'void loop()':

RTCTFT160:75: error: 'getDayOfWeek' was not declared in this scope

dateString = getDayOfWeek(now.dayOfWeek())+", ";

^

RTCTFT160:90: error: 'printText' was not declared in this scope

printText(timeChar, WHITE,20,25,3);

^

RTCTFT160:101: error: 'printText' was not declared in this scope

printText(temperatureChar, WHITE,10,80,3);

^

RTCTFT160:108: error: 'dtostrf' was not declared in this scope

dtostrf(maxTemperature,4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)

^

RTCTFT160:118: error: 'dtostrf' was not declared in this scope

dtostrf(minTemperature,4, 1, charMinTemperature);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function 'void setRTCTime()':

RTCTFT160:135: error: a function-definition is not allowed here before '{' token

void printText(char *text, uint16_t color, int x, int y,int textSize){

^

RTCTFT160:157: error: expected '}' at end of input

}

^

exit status 1
'printText' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Thanks for that. I still have the printText error and I'm not sure how to fix that. Ive gone through all and they have 5 declarations each.

Thanks

Ive gone through all and they have 5 declarations each.

I have no idea what that means.

But, you changed your code and then failed to post the revised code.

BEFORE you post your code again, though, look through it.

}void printText(char *text, uint16_t color, int x, int y,int textSize)
{

NO code EVER follows the } of a function, on the same line.

#include  <Adafruit_GFX.h>
#include <Wire.h>
#include "Sodaq_DS3231.h"
#include  <SPI.h>
#include  <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

//Color Definitons
#define BLACK     0x0000
#define BLUE      0x001F
#define GREY      0xCE79
#define LIGHTGREY 0xDEDB
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF


float maxTemperature=0;
float minTemperature=200;
char charMinTemperature[10];
char charMaxTemperature[10];
char timeChar[100];
char dateChar[50];
char temperatureChar[10];

float temperature = 0;
float previousTemperature = 0;

String dateString;
int minuteNow=0;
int minutePrevious=0;

void setup () 
{
    Serial.begin(57600);
    tft.reset();
    uint16_t identifier = tft.readID();
    tft.begin(identifier);
    tft.setRotation (2);
    tft.fillScreen(BLACK);
    
    Wire.begin();
    rtc.begin();
    printText("TEMPERATURE", GREEN,30,65,1);  // Temperature Static Text
    printText("MAX", RED,18,130,1);
    printText("MIN", BLUE,95,130,1);
    setRTCTime();
  }

uint32_t old_ts;

void loop () 
 {
  float temperature = rtc.getTemperature();
  DateTime now = rtc.now(); //get the current date-time
  uint32_t ts = now.getEpoch();

    if (old_ts == 0 || old_ts != ts) {
	old_ts = ts;
  
  minuteNow = now.minute();
  if(minuteNow!=minutePrevious)
  {
    dateString = getDayOfWeek(now.dayOfWeek())+", ";
    dateString = dateString+String(now.date())+"/"+String(now.month());
    dateString= dateString+"/"+ String(now.year()); 
    minutePrevious = minuteNow;
    String hours = String(now.hour());
    if(now.minute()<10)
     {
      hours = hours+":0"+String(now.minute());
       }else
      {
      hours = hours+":"+String(now.minute());
       }
    
    hours.toCharArray(timeChar,100);
    tft.fillRect(10,0,160,65,BLACK);
    printText(timeChar, WHITE,20,25,3);
    dateString.toCharArray(dateChar,50);
    printText(dateChar, GREEN,8,5,1);
     }
  
  if(temperature != previousTemperature)
  {
    previousTemperature = temperature;
    String temperatureString = String(temperature,1);
    temperatureString.toCharArray(temperatureChar,10);
    tft.fillRect(10,80,128,30,BLACK);
    printText(temperatureChar, WHITE,10,80,3);
    printText("o", WHITE,90,75,2);
    printText("C", WHITE,105,80,3);

if(temperature>maxTemperature)
     {
      maxTemperature = temperature;
      dtostrf(maxTemperature,4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)
      tft.fillRect(3,142,33,20,BLACK);
      printText(charMaxTemperature, WHITE,3,145,1);
      printText("o", WHITE,35,140,1);
      printText("C", WHITE,41,145,1);
       }
if(temperature  < minTemperature) 

 {
      minTemperature = temperature;
      dtostrf(minTemperature,4, 1, charMinTemperature); 
      tft.fillRect(75,140,36,18,BLACK);
      printText(charMinTemperature, WHITE,80,145,1);
      printText("o", WHITE,112,140,1);
      printText("C", WHITE,118,145,1);
      setRTCTime();
      }
    }
  }
    delay(1000);
 }


void setRTCTime()
 {
  DateTime dt(2018, 6, 11, 15, 40, 30, 1); // Year, Month, Day, Hour, Minutes, Seconds, Day of Week
  rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above 
  }void printText(char *text, uint16_t color, int x, int y,int textSize)
    {
  tft.setCursor(x, y);
  tft.setTextColor(color);
  tft.setTextSize(textSize);
  tft.setTextWrap(true);
  tft.print(text);
     }

String getDayOfWeek(int i)
 {
  switch(i)
  {
    case 1: return "Monday";break;
    case 2: return "Tuesday";break;
    case 3: return "Wednesday";break;
    case 4: return "Thursday";break;
    case 5: return "Friday";break;
    case 6: return "Saturday";break;
    case 7: return "Sunday";break;
    default: return "Monday";break;
   }
 }

Arduino: 1.8.5 (Windows 10), Board: “Arduino Due (Programming Port)”

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function ‘void setup()’:

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:55:43: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“TEMPERATURE”, GREEN,30,65,1); // Temperature Static Text

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:56:34: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“MAX”, RED,18,130,1);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:57:35: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“MIN”, BLUE,95,130,1);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function ‘void loop()’:

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:102:33: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“o”, WHITE,90,75,2);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:103:34: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“C”, WHITE,105,80,3);

^

RTCTFT160:108: error: ‘dtostrf’ was not declared in this scope

dtostrf(maxTemperature,4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:111:36: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“o”, WHITE,35,140,1);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:112:36: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“C”, WHITE,41,145,1);

^

RTCTFT160:118: error: ‘dtostrf’ was not declared in this scope

dtostrf(minTemperature,4, 1, charMinTemperature);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:121:37: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“o”, WHITE,112,140,1);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:122:37: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“C”, WHITE,118,145,1);

^

exit status 1
‘dtostrf’ was not declared in this scope

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

Ive staggered the { and the error is still there. Thanks

Is that new code? You didn't do as suggested in Replies #1 & #6.

Your original code had a printText() function. Your new code does not. Why not?

Ive staggered the { and the error is still there.

You mean that you've f**ked the indenting every which way possible. Now, use Tools + Auto Format, and do it right.

#include  <Adafruit_GFX.h>
#include <Wire.h>
#include "Sodaq_DS3231.h"
#include  <SPI.h>
#include  <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

//Color Definitons
#define BLACK     0x0000
#define BLUE      0x001F
#define GREY      0xCE79
#define LIGHTGREY 0xDEDB
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF


float maxTemperature = 0;
float minTemperature = 200;
char charMinTemperature[10];
char charMaxTemperature[10];
char timeChar[100];
char dateChar[50];
char temperatureChar[10];

float temperature = 0;
float previousTemperature = 0;

String dateString;
int minuteNow = 0;
int minutePrevious = 0;

void setup ()
{
  Serial.begin(57600);
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation (2);
  tft.fillScreen(BLACK);

  Wire.begin();
  rtc.begin();
  printText("TEMPERATURE", GREEN, 30, 65, 1); // Temperature Static Text
  printText("MAX", RED, 18, 130, 1);
  printText("MIN", BLUE, 95, 130, 1);
  setRTCTime();
}

uint32_t old_ts;

void loop ()
{
  float temperature = rtc.getTemperature();
  DateTime now = rtc.now(); //get the current date-time
  uint32_t ts = now.getEpoch();

  if (old_ts == 0 || old_ts != ts) {
    old_ts = ts;

    minuteNow = now.minute();
    if (minuteNow != minutePrevious)
    {
      dateString = getDayOfWeek(now.dayOfWeek()) + ", ";
      dateString = dateString + String(now.date()) + "/" + String(now.month());
      dateString = dateString + "/" + String(now.year());
      minutePrevious = minuteNow;
      String hours = String(now.hour());
      if (now.minute() < 10)
      {
        hours = hours + ":0" + String(now.minute());
      }
      else
      {
        hours = hours + ":" + String(now.minute());
      }

      hours.toCharArray(timeChar, 100);
      tft.fillRect(10, 0, 160, 65, BLACK);
      printText(timeChar, WHITE, 20, 25, 3);
      dateString.toCharArray(dateChar, 50);
      printText(dateChar, GREEN, 8, 5, 1);
    }

    if (temperature != previousTemperature)
    {
      previousTemperature = temperature;
      String temperatureString = String(temperature, 1);
      temperatureString.toCharArray(temperatureChar, 10);
      tft.fillRect(10, 80, 128, 30, BLACK);
      printText(temperatureChar, WHITE, 10, 80, 3);
      printText("o", WHITE, 90, 75, 2);
      printText("C", WHITE, 105, 80, 3);

      if (temperature > maxTemperature)
      {
        maxTemperature = temperature;
        dtostrf(maxTemperature, 4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)
        tft.fillRect(3, 142, 33, 20, BLACK);
        printText(charMaxTemperature, WHITE, 3, 145, 1);
        printText("o", WHITE, 35, 140, 1);
        printText("C", WHITE, 41, 145, 1);
      }
      if (temperature  < minTemperature)

      {
        minTemperature = temperature;
        dtostrf(minTemperature, 4, 1, charMinTemperature);
        tft.fillRect(75, 140, 36, 18, BLACK);
        printText(charMinTemperature, WHITE, 80, 145, 1);
        printText("o", WHITE, 112, 140, 1);
        printText("C", WHITE, 118, 145, 1);
        setRTCTime();
      }
    }
  }
  delay(1000);
}


void setRTCTime()
{
  DateTime dt(2018, 6, 11, 15, 40, 30, 1); // Year, Month, Day, Hour, Minutes, Seconds, Day of Week
  rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above
}
void printText(char *text, uint16_t color, int x, int y, int textSize)
{
  tft.setCursor(x, y);
  tft.setTextColor(color);
  tft.setTextSize(textSize);
  tft.setTextWrap(true);
  tft.print(text);

}
String getDayOfWeek(int i)
{
  switch (i)
  {
    case 1: return "Monday"; break;
    case 2: return "Tuesday"; break;
    case 3: return "Wednesday"; break;
    case 4: return "Thursday"; break;
    case 5: return "Friday"; break;
    case 6: return "Saturday"; break;
    case 7: return "Sunday"; break;
    default: return "Monday"; break;
  }
}

Arduino: 1.8.5 (Windows 10), Board: “Arduino Due (Programming Port)”

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function ‘void setup()’:

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:55:44: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“TEMPERATURE”, GREEN, 30, 65, 1); // Temperature Static Text

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:56:35: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“MAX”, RED, 18, 130, 1);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:57:36: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“MIN”, BLUE, 95, 130, 1);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function ‘void loop()’:

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:103:38: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“o”, WHITE, 90, 75, 2);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:104:39: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“C”, WHITE, 105, 80, 3);

^

RTCTFT160:109: error: ‘dtostrf’ was not declared in this scope

dtostrf(maxTemperature, 4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:112:41: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“o”, WHITE, 35, 140, 1);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:113:41: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“C”, WHITE, 41, 145, 1);

^

RTCTFT160:119: error: ‘dtostrf’ was not declared in this scope

dtostrf(minTemperature, 4, 1, charMinTemperature);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:122:42: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“o”, WHITE, 112, 140, 1);

^

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:123:42: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

printText(“C”, WHITE, 118, 145, 1);

^

exit status 1
‘dtostrf’ was not declared in this scope

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

PaulS Theirs no need to get angry or impatient. Swearing does not work. If you don’t want to help I understand.

The code is the same each time. Thanks

Now do as I suggested way back in Reply #1.

 rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above
}
void printText(char *text, uint16_t color, int x, int y, int textSize) {
  tft.setCursor(x, y);
  tft.setTextColor(color);
  tft.setTextSize(textSize);
  tft.setTextWrap(true);
  tft.print(text);

}
String getDayOfWeek(int i)

[code]

Yes, I did follow step #1 and the same error in this line [code]  dtostrf(minTemperature, 4, 1, charMinTemperature);[code]


Thanks
void printText(char *text,

That does not LOOK like const char * as the type.

Why are you just jacking around? Make the damned change. It isn't rocket surgery.

Read Reply #1 again:

void printText(const char *text, uint16_t color, int x, int y,int textSize) {
.
.
.
}

This won't fix what ever your dtostrf() problem is, but it should get rid of the warnings and make the rest of the compiler messages easier to go through.

Post complete updated code and the error messages. Put the error messages in Code Tags too as that makes them more readable.

Arduino: 1.8.5 (Windows 10), Board: "Arduino Due (Programming Port)"

C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function 'void loop()':

RTCTFT160:109: error: 'dtostrf' was not declared in this scope

         dtostrf(maxTemperature, 4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)

                                                         ^

RTCTFT160:119: error: 'dtostrf' was not declared in this scope

         dtostrf(minTemperature, 4, 1,charMinTemperature);

                                                        ^

exit status 1
'dtostrf' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
[code]



[code]

#include  <Adafruit_GFX.h>
#include <Wire.h>
#include "Sodaq_DS3231.h"
#include  <SPI.h>
#include  <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

//Color Definitons
#define BLACK     0x0000
#define BLUE      0x001F
#define GREY      0xCE79
#define LIGHTGREY 0xDEDB
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF


float maxTemperature = 0;
float minTemperature = 200;
char charMinTemperature[10];
char charMaxTemperature[10];
char timeChar[100];
char dateChar[50];
char temperatureChar[10];

float temperature = 0;
float previousTemperature = 0;

String dateString;
int minuteNow = 0;
int minutePrevious = 0;

void setup ()
{
  Serial.begin(57600);
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation (2);
  tft.fillScreen(BLACK);

  Wire.begin();
  rtc.begin();
  printText("TEMPERATURE", GREEN, 30, 65, 1); // Temperature Static Text
  printText("MAX", RED, 18, 130, 1);
  printText("MIN", BLUE, 95, 130, 1);
  setRTCTime();
}

uint32_t old_ts;

void loop ()
{
  float temperature = rtc.getTemperature();
  DateTime now = rtc.now(); //get the current date-time
  uint32_t ts = now.getEpoch();

  if (old_ts == 0 || old_ts != ts) {
    old_ts = ts;

    minuteNow = now.minute();
    if (minuteNow != minutePrevious)
    {
      dateString = getDayOfWeek(now.dayOfWeek()) + ", ";
      dateString = dateString + String(now.date()) + "/" + String(now.month());
      dateString = dateString + "/" + String(now.year());
      minutePrevious = minuteNow;
      String hours = String(now.hour());
      if (now.minute() < 10)
      {
        hours = hours + ":0" + String(now.minute());
      }
      else
      {
        hours = hours + ":" + String(now.minute());
      }

      hours.toCharArray(timeChar, 100);
      tft.fillRect(10, 0, 160, 65, BLACK);
      printText(timeChar, WHITE, 20, 25, 3);
      dateString.toCharArray(dateChar, 50);
      printText(dateChar, GREEN, 8, 5, 1);
    }

    if (temperature != previousTemperature)  {
      
      previousTemperature = temperature;
      String temperatureString = String(temperature, 1);
      temperatureString.toCharArray(temperatureChar, 10);
      tft.fillRect(10, 80, 128, 30, BLACK);
      printText(temperatureChar, WHITE, 10, 80, 3);
      printText("o", WHITE, 90, 75, 2);
      printText("C", WHITE, 105, 80, 3);

      if (temperature > maxTemperature)
      {
        maxTemperature = temperature;
        dtostrf(maxTemperature, 4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)
        tft.fillRect(3, 142, 33, 20, BLACK);
        printText(charMaxTemperature, WHITE, 3, 145, 1);
        printText("o", WHITE, 35, 140, 1);
        printText("C", WHITE, 41, 145, 1);
      }
      if (temperature  < minTemperature)

      {
        minTemperature = temperature;
        dtostrf(minTemperature, 4, 1,charMinTemperature);
        tft.fillRect(75, 140, 36, 18, BLACK);
        printText(charMinTemperature, WHITE, 80, 145, 1);
        printText("o", WHITE, 112, 140, 1);
        printText("C", WHITE, 118, 145, 1);
        setRTCTime();
      }
    }
  }
  delay(1000);
}


void setRTCTime()
{
  DateTime dt(2018, 6, 11, 15, 40, 30, 1); // Year, Month, Day, Hour, Minutes, Seconds, Day of Week
  rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above
}
void printText( const char *text, uint16_t color, int x, int y, int textSize) {
  tft.setCursor(x, y);
  tft.setTextColor(color);
  tft.setTextSize(textSize);
  tft.setTextWrap(true);
  tft.print(text);

}
String getDayOfWeek(int i)
{
  switch (i)
  {
    case 1: return "Monday"; break;
    case 2: return "Tuesday"; break;
    case 3: return "Wednesday"; break;
    case 4: return "Thursday"; break;
    case 5: return "Friday"; break;
    case 6: return "Saturday"; break;
    case 7: return "Sunday"; break;
    default: return "Monday"; break;
  }
}

Thanks. I appreciate the help.

Not sure what the problem is. I don’t have all those libraries, so I can’t try to compile it. Maybe an unprintable garbage character somewhere? I’d start from scratch (no copy / paste) and write a small MCVE that just tries the dtostrf() function. Leave out everything else. That way others can try to reproduce the errors.

I did a web search and found this

#include <avr/dtostrf.h>.

The compiler said its included by defalt but I added it and the problem is fixed.

Thanks a lot for your help.

The compiler said its included by defalt

The compiler told you that? I doubt that.

On an AVR board, the IDE might include the file by default. On an ARM board (that the Due has), that would not be the case.

.Thanks.

This is the results

#include  <Adafruit_GFX.h>
#include <Wire.h>
#include "Sodaq_DS3231.h"
#include  <SPI.h>
#include  <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#include <avr/dtostrf.h>.
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

//Color Definitons
#define BLACK     0x0000
#define BLUE      0x001F
#define GREY      0xCE79
#define LIGHTGREY 0xDEDB
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF


float maxTemperature = 0;
float minTemperature = 200;
char charMinTemperature[10];
char charMaxTemperature[10];
char timeChar[100];
char dateChar[50];
char temperatureChar[10];

float temperature = 0;
float previousTemperature = 0;

String dateString;
int minuteNow = 0;
int minutePrevious = 0;

void setup ()
{
  Serial.begin(57600);
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation (2);
  tft.fillScreen(BLACK);

  Wire.begin();
  rtc.begin();
  printText("TEMPERATURE", GREEN, 30, 65, 1); // Temperature Static Text
  printText("MAX", RED, 18, 130, 1);
  printText("MIN", BLUE, 95, 130, 1);
  setRTCTime();
}

uint32_t old_ts;

void loop ()
{
  float temperature = rtc.getTemperature();
  DateTime now = rtc.now(); //get the current date-time
  uint32_t ts = now.getEpoch();

  if (old_ts == 0 || old_ts != ts) {
    old_ts = ts;

    minuteNow = now.minute();
    if (minuteNow != minutePrevious)
    {
      dateString = getDayOfWeek(now.dayOfWeek()) + ", ";
      dateString = dateString + String(now.date()) + "/" + String(now.month());
      dateString = dateString + "/" + String(now.year());
      minutePrevious = minuteNow;
      String hours = String(now.hour());
      if (now.minute() < 10)
      {
        hours = hours + ":0" + String(now.minute());
      }
      else
      {
        hours = hours + ":" + String(now.minute());
      }

      hours.toCharArray(timeChar, 100);
      tft.fillRect(10, 0, 160, 65, BLACK);
      printText(timeChar, WHITE, 20, 25, 3);
      dateString.toCharArray(dateChar, 50);
      printText(dateChar, GREEN, 8, 5, 1);
    }

    if (temperature != previousTemperature)  {
      
      previousTemperature = temperature;
      String temperatureString = String(temperature, 1);
      temperatureString.toCharArray(temperatureChar, 10);
      tft.fillRect(10, 80, 128, 30, BLACK);
      printText(temperatureChar, WHITE, 10, 80, 3);
      printText("o", WHITE, 90, 75, 2);
      printText("C", WHITE, 105, 80, 3);

      if (temperature > maxTemperature)
      {
        maxTemperature = temperature;
        dtostrf(maxTemperature, 4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)
        tft.fillRect(3, 142, 33, 20, BLACK);
        printText(charMaxTemperature, WHITE, 3, 145, 1);
        printText("o", WHITE, 35, 140, 1);
        printText("C", WHITE, 41, 145, 1);
      }
      if (temperature  < minTemperature)

      {
        minTemperature = temperature;
        dtostrf(minTemperature, 4, 1,charMinTemperature);
        tft.fillRect(75, 140, 36, 18, BLACK);
        printText(charMinTemperature, WHITE, 80, 145, 1);
        printText("o", WHITE, 112, 140, 1);
        printText("C", WHITE, 118, 145, 1);
        setRTCTime();
      }
    }
  }
  delay(1000);
}


void setRTCTime()
{
  DateTime dt(2018, 6, 11, 22, 59, 30, 1); // Year, Month, Day, Hour, Minutes, Seconds, Day of Week
  rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above
}
void printText( const char *text, uint16_t color, int x, int y, int textSize) {
  tft.setCursor(x, y);
  tft.setTextColor(color);
  tft.setTextSize(textSize);
  tft.setTextWrap(true);
  tft.print(text);

}
String getDayOfWeek(int i)
{
  switch (i)
  {
    case 1: return "Monday"; break;
    case 2: return "Tuesday"; break;
    case 3: return "Wednesday"; break;
    case 4: return "Thursday"; break;
    case 5: return "Friday"; break;
    case 6: return "Saturday"; break;
    case 7: return "Sunday"; break;
    default: return "Monday"; break;
  }
}