float a char- colapsa arduino. [SOLUCIONADO] Vean interfaz final.

Hola que tal... el proyecto es sencillo se trata simplemente de un termostato que enciende y apaga una resistencia dependiendo de lo que se necesite.

El menu y los sub-menus asi como las variables funcionan bien, el unico problema que tengo ahora es en la pantalla Splash, que es la que despues de algun tiempo se muestra por default en la LCD.

Aqui el codigo completo;

//=====================================LIBRERIAS==================================================//
#include <OneWire.h>
#include <dht.h>                     //Libreria para DTH
#include <DallasTemperature.h>       //Libreria Ds1820


#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>       //Libreria IC2 
#include <buttons.h>
#include <MENWIZ.h>
#include <EEPROM.h>

//=====================================COSNTRUCTORES =============================================//
// DEFINE ARDUINO PINS FOR THE NAVIGATION BUTTONS
#define UP_BUTTON_PIN       9
#define DOWN_BUTTON_PIN     10
#define LEFT_BUTTON_PIN     7 
#define RIGHT_BUTTON_PIN    8
#define CONFIRM_BUTTON_PIN  12
#define ESCAPE_BUTTON_PIN   11

dht DHT;                             //constructor del objeto 
#define DHT11_PIN 5                  // Pin sensor DTH

#define ONE_WIRE_BUS 2               //Pin Sensor temperatura
OneWire oneWire(ONE_WIRE_BUS);       //define un bus para comunicarse con cualquier sensor 
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature. 
DeviceAddress insideThermometer;     // arrays to hold device address

menwiz menu;
                                     //Constructor objeto LCD 
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//=====================================GLOBAL VARIABLES==============================================//
float ti = 19.00;
float tf = 25.00;

const byte led =13;              //led to chek if the heating element has staring 
const byte rele = 4;             //pin to start or stop heating element
int humidity =  0;               //read the humidity sensor 
float tempC =   0;              //read the sensor temperature  
float tempF =   0;              //farenheit 

//=====================================VOID SET UP ==================================================//
void setup(void)
{
Serial.begin(9600);

  pinMode(A0, INPUT); 
  pinMode(A1, INPUT); 
  pinMode(led, OUTPUT);

//-----------------------------------MENWIZ MENU-------------------------------------------------//
  _menu *r,*s1,*s2;
  _var *v; 
  int  mem;
  
// inizialize the menu object (16 colums x 2 rows)
  menu.begin(&lcd,16,2);
//create the menu tree
 r=menu.addMenu(MW_ROOT,NULL,F("MENU"));             //create a root menu at first (required)
   s1=menu.addMenu(MW_SUBMENU,r,F("AJUSTE TEMPER"));
      
      s2=menu.addMenu(MW_VAR,s1,F("TEMP INCIO"));             //add a terminal node (that is "variable"); 
      s2->addVar(MW_AUTO_FLOAT,&ti,20.00,50.00,0.5);      //create a variable of type "float number"... 
      
      s2=menu.addMenu(MW_VAR,s1,F("TEMP FINAL"));             //add a terminal node (that is "variable"); 
      s2->addVar(MW_AUTO_FLOAT,&tf,20.00,50.00,0.5);      //create a variable of type "float number"... 

  menu.addUsrScreen(msc,10000);

  menu.navButtons(UP_BUTTON_PIN,DOWN_BUTTON_PIN,ESCAPE_BUTTON_PIN,CONFIRM_BUTTON_PIN);

//-----------------------------------SENSOR DS1820-------------------------------------------------//
 // locate devices on the bus
 sensors.begin();
 Serial.print(sensors.getDeviceCount(), DEC);
 //Linea para debug 
 if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
 Serial.print("Device 0 Address: ");
 //Funcion para imprimir la direccion del dispositivo  --printAddress(insideThermometer);
 // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
 sensors.setResolution(insideThermometer, 10);

}


//=====================================VOID LOOP ==================================================//
void loop(void){ 
  menu.draw(); 
  
 if (tempC < tf){          //Chek if the temperature is below the off heating element
  digitalWrite(rele, LOW);  
  digitalWrite( led, ON);
 }
  
 if (tempC > ti){
   digitalWrite(rele, HIGH);  //chek if the temperature is above the start temperature 
   digitalWrite (led, OFF);    
 }

   sensors.requestTemperatures(); // Comando para obtener temperatura
   // It responds almost immediately. Let's print out the data
   printTemperature(insideThermometer); // Use a simple function to print out the data

}

///////////////////////////////////////////////////////////////////////////////////////////////////

void msc();

EL PROBLEMA ESTA AQUI
///////////////////////////////////////////////////////////////////////////////////////////////////


// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress){
 tempC = sensors.getTempC(deviceAddress);
 tempF = DallasTemperature::toFahrenheit(tempC); // Converts tempC to Fahrenheit
 Serial.print("Temp C: ");
 Serial.print(tempC);
 Serial.print(" Temp F: ");
 Serial.println(tempF); 
}

Y es que en donde va ese problemin, el ejemplo maneja algo asi;

void msc(){
  static  char buf[7];
  strcpy(menu.sbuf,"User screen"); //1st lcd line
  strcat(menu.sbuf,"\nUptime (s): ");strcat(menu.sbuf,itoa((int)(millis()/1000),buf,10));//2nd lcd line
  strcat(menu.sbuf,"\nFree mem  : ");strcat(menu.sbuf,itoa((int)menu.freeRam(),buf,10));//3rd lcd line
  strcat(menu.sbuf,"\n"); //4th lcd line (empty)
 
  menu.drawUsrScreen(menu.sbuf);
  }

Donde strcat es una funcion para concatener strings
strcpy es una funcion para copiar strings
itoa es una funcion para convertir numeros a strings Aqui

la cuestion es que estoy usando dos floats para la temperatura de inicio y final y aparentemente no estan soportados directamente por itoa... ya que el compilador me da un error...

Intente imprimirlo directamente en la LCD;

  static  char buf[10];
  lcd.setCursor(0,0);  lcd.print(tempC);lcd.print(" C");  lcd.print("HUMEDAD"); 
  lcd.setCursor(0,1);  lcd.print(tempF);lcd.print(" F");  lcd.print(humidity); 
  menu.drawUsrScreen(menu.sbuf);

Y funciona pero no se actualiza conforme la temperatura sube... Por lo que me imagino que debo convertir el float a un string y usar la funciones de arriba mencionadas, o el float a un array Aqui

La pregunta seria... cual es el mejor camino para hacer esto?
la pantalla se actualiza con algun cambio dentro de los arrays?

Gracias.
-Alex

Como te respondí por MP, dame un momento y te respondo pero estoy muy ocupado ahora.

Pues me puse a buscar y aparentemente si se puede imprimir un float usando la sprintf... solo que en la libreria C completa, la que se usa para arduino, dejo fuera esa funcion por cuestiones de memoria...

Un poco de investigacion me llevo a Este post

Ahora bien... hay dos soluciones relativamente buenas;

1.- Convertir el float en un string y despues a un char

2.- Convertir directamente un float a un char (Que es lo que usa la pantalla de culaquier modo)

Un poco de investigacion me llevo a este ejemplo, aparentemente hay una funcion que lo hace en arduino; //Atentos todos

float tempC = 23.45; 
  char stempC [10]; 
 
void setup(){
Serial.begin(9600); 

 dtostrf(tempC, 10, 2, stempC); //number, width, decimal places, buffer 
   
}

void loop(){
  
Serial.println(stempC);

El codigo de arriba funciona correctamente, lo he probado en mi propio sketch... asi; //the snip

dtostrf(tempC, 10, 2, stempC);                        // Donde pasa el valor del float temC a el char stemC 
Serial.print("String C"); Serial.println( stempC); //Lo imprime en teminal serial 
dtostrf(tempF, 10, 2, stempF); 
Serial.print("String F"); Serial.println (stempF); 
Serial.println("---------------------------------");   //Espaciador

Ahora bien todo son peras y manzanas, hasta que lo cargue y por alguna razon no se carga la pantalla de inicio, puse las funciones de arriba para ver que efectivamente se estuviera conviriendo a char... y eesta es la salida del terminal serial;

Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10
---------------------------------
Temp C: 24.50 Temp F: 76.10
String C     24.50
String F     76.10

Como se puede apreciar la salida tipo char es correcta y se traduce directamente de el valor float...
Ahora el unico detalle por solucionar a mi punto de ver... es que el programa se detiene dadas algunas interacciones... 36 en este caso... parece ser que algo se come la memoria...
Investigare un poco mas en esto... cualquier sugerencia es bien recibida.

Bueno he hecho dos cosas;

La primera "Limpiar el char" donde se almacenaban los valores para evitar que se sobre-escribiera y se llenara de cosas raras.
Como dice aqui!

La segunda... revisar la memoria que queda libre en el sistema

Aparentemente ninguna de las dos funciono.

Hasta aquí, el codigo completo;

//=====================================LIBRERIAS==================================================//
#include <MemoryFree.h>
#include <OneWire.h>
#include <dht.h>                     //Libreria para DTH
#include <DallasTemperature.h>       //Libreria Ds1820


#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>       //Libreria IC2 
#include <buttons.h>
#include <MENWIZ.h>
#include <EEPROM.h>

//=====================================COSNTRUCTORES =============================================//
// DEFINE ARDUINO PINS FOR THE NAVIGATION BUTTONS
#define UP_BUTTON_PIN       9
#define DOWN_BUTTON_PIN     10
#define LEFT_BUTTON_PIN     7 
#define RIGHT_BUTTON_PIN    8
#define CONFIRM_BUTTON_PIN  12
#define ESCAPE_BUTTON_PIN   11

dht DHT;                             //constructor del objeto 
#define DHT11_PIN 5                  // Pin sensor DTH

#define ONE_WIRE_BUS 2               //Pin Sensor temperatura
OneWire oneWire(ONE_WIRE_BUS);       //define un bus para comunicarse con cualquier sensor 
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature. 
DeviceAddress insideThermometer;     // arrays to hold device address

menwiz menu;
                                     //Constructor objeto LCD 
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//=====================================GLOBAL VARIABLES==============================================//
float ti = 19.00;
float tf = 25.00;

const byte led =13;              //led to chek if the heating element has staring 
const byte rele = 4;             //pin to start or stop heating element
int humidity =  0;               //read the humidity sensor 
float tempC =   0;              //read the sensor temperature  
float tempF =   0;              //farenheit 

char stempC [10];              //Char to hold the temperature on C 
char stempF [10];              //Char to hold the temperature on F 
//=====================================VOID SET UP ==================================================//
void setup(void)
{
Serial.begin(9600);

  pinMode(A0, INPUT); 
  pinMode(A1, INPUT); 
  pinMode(led, OUTPUT);

//-----------------------------------MENWIZ MENU-------------------------------------------------//
  _menu *r,*s1,*s2;
  _var *v; 
  int  mem;
  
// inizialize the menu object (16 colums x 2 rows)
  menu.begin(&lcd,16,2);
//create the menu tree
 r=menu.addMenu(MW_ROOT,NULL,F("MENU"));             //create a root menu at first (required)
   s1=menu.addMenu(MW_SUBMENU,r,F("AJUSTE TEMPER"));
      
      s2=menu.addMenu(MW_VAR,s1,F("TEMP INCIO"));             //add a terminal node (that is "variable"); 
      s2->addVar(MW_AUTO_FLOAT,&ti,20.00,50.00,0.5);      //create a variable of type "float number"... 
      
      s2=menu.addMenu(MW_VAR,s1,F("TEMP FINAL"));             //add a terminal node (that is "variable"); 
      s2->addVar(MW_AUTO_FLOAT,&tf,20.00,50.00,0.5);      //create a variable of type "float number"... 

  menu.addUsrScreen(msc,10000);

  menu.navButtons(UP_BUTTON_PIN,DOWN_BUTTON_PIN,ESCAPE_BUTTON_PIN,CONFIRM_BUTTON_PIN);

//-----------------------------------SENSOR DS1820-------------------------------------------------//
 // locate devices on the bus
 sensors.begin();
 Serial.print(sensors.getDeviceCount(), DEC);
 //Linea para debug 
 if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
 Serial.print("Device 0 Address: ");
 //Funcion para imprimir la direccion del dispositivo  --printAddress(insideThermometer);
 // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
 sensors.setResolution(insideThermometer, 10);

}


//=====================================VOID LOOP ==================================================//
void loop(void){ 
  menu.draw(); 
  
  limpia_char(); 
  
 if (tempC < tf){          //Chek if the temperature is below the off heating element
  digitalWrite(rele, LOW);  
  digitalWrite( led, ON);
 }
  
 if (tempC > ti){
   digitalWrite(rele, HIGH);  //chek if the temperature is above the start temperature 
   digitalWrite (led, OFF);    
 }

   sensors.requestTemperatures(); // Comando para obtener temperatura
   // It responds almost immediately. Let's print out the data
   printTemperature(insideThermometer); // Use a simple function to print out the data

dtostrf(tempC, 10, 2, stempC); 
Serial.print(F("String C")); Serial.println( stempC); 
dtostrf(tempF, 10, 2, stempF); 
Serial.print(F("String F")); Serial.println (stempF); 
Serial.print("freeMemory()=");Serial.println(freeMemory());

Serial.println(F("---------------------------------"));
}



void msc(){
static  char buf[7];
  strcat(menu.sbuf, stempC); strcat(menu.sbuf,"C/n");  //1st lcd line
  strcat(menu.sbuf, stempF); strcat(menu.sbuf,"F/n"); //2nd lcd line
  menu.drawUsrScreen(menu.sbuf);
  }
 
 
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress){
 tempC = sensors.getTempC(deviceAddress);
 tempF = DallasTemperature::toFahrenheit(tempC); // Converts tempC to Fahrenheit
 Serial.print(F("Temp C: "));
 Serial.print(tempC);
 Serial.print(F(" Temp F: "));
 Serial.println(tempF); 
}
  
void limpia_char(){
  stempC[10] = 0 ;
  stempF[10] = 0 ;
  }

Los resultados en el monitor serial;

---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=519
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=519
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=519
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=519
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=519
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=519
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=519
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=519
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=519
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=519
---------------------------------

Bueno... aqui otro sintoma... Intente implementar un contador para saber cuantas veces exactamente se imprimian los datos....

Mas o menos asi;

int iteracion = 0; 

void loop(){
iteracion = iteracion +1
//iteracion = iteracion++
//iteracion++

Ninguno de los tres me funciono!!!!!!

El resultado;

Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=531
Numero de iteracion = 0
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=531
Numero de iteracion = 0
---------------------------------
Temp C: 23.50 Temp F: 74.30
String C     23.50
String F     74.30
freeMemory()=531
Numero de iteracion = 0
---------------------------------

Como sea dejo el codigo completo;

//=====================================LIBRERIAS==================================================//
#include <MemoryFree.h>
#include <OneWire.h>
#include <dht.h>                     //Libreria para DTH
#include <DallasTemperature.h>       //Libreria Ds1820


#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>       //Libreria IC2 
#include <buttons.h>
#include <MENWIZ.h>
#include <EEPROM.h>

//=====================================COSNTRUCTORES =============================================//
// DEFINE ARDUINO PINS FOR THE NAVIGATION BUTTONS
#define UP_BUTTON_PIN       9
#define DOWN_BUTTON_PIN     10
#define LEFT_BUTTON_PIN     7 
#define RIGHT_BUTTON_PIN    8
#define CONFIRM_BUTTON_PIN  12
#define ESCAPE_BUTTON_PIN   11

dht DHT;                             //constructor del objeto 
#define DHT11_PIN 5                  // Pin sensor DTH

#define ONE_WIRE_BUS 2               //Pin Sensor temperatura
OneWire oneWire(ONE_WIRE_BUS);       //define un bus para comunicarse con cualquier sensor 
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature. 
DeviceAddress insideThermometer;     // arrays to hold device address

menwiz menu;
                                     //Constructor objeto LCD 
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//=====================================GLOBAL VARIABLES==============================================//
float ti = 19.00;
float tf = 25.00;

const byte led =13;              //led to chek if the heating element has staring 
const byte rele = 4;             //pin to start or stop heating element
int humidity =  0;               //read the humidity sensor 
float tempC =   0;              //read the sensor temperature  
float tempF =   0;              //farenheit 

char stempC [10];              //Char to hold the temperature on C 
char stempF [10];              //Char to hold the temperature on F 
int iteracion = 0; 
//=====================================VOID SET UP ==================================================//
void setup(void)
{
Serial.begin(9600);

  pinMode(A0, INPUT); 
  pinMode(A1, INPUT); 
  pinMode(led, OUTPUT);

//-----------------------------------MENWIZ MENU-------------------------------------------------//
  _menu *r,*s1,*s2;
  _var *v; 
  int  mem;
  
// inizialize the menu object (16 colums x 2 rows)
  menu.begin(&lcd,16,2);
//create the menu tree
 r=menu.addMenu(MW_ROOT,NULL,F("MENU"));             //create a root menu at first (required)
   s1=menu.addMenu(MW_SUBMENU,r,F("AJUSTE TEMPER"));
      
      s2=menu.addMenu(MW_VAR,s1,F("TEMP INCIO"));             //add a terminal node (that is "variable"); 
      s2->addVar(MW_AUTO_FLOAT,&ti,20.00,50.00,0.5);      //create a variable of type "float number"... 
      
      s2=menu.addMenu(MW_VAR,s1,F("TEMP FINAL"));             //add a terminal node (that is "variable"); 
      s2->addVar(MW_AUTO_FLOAT,&tf,20.00,50.00,0.5);      //create a variable of type "float number"... 

  menu.addUsrScreen(msc,10000);

  menu.navButtons(UP_BUTTON_PIN,DOWN_BUTTON_PIN,ESCAPE_BUTTON_PIN,CONFIRM_BUTTON_PIN);

//-----------------------------------SENSOR DS1820-------------------------------------------------//
 // locate devices on the bus
 sensors.begin();
 Serial.print(sensors.getDeviceCount(), DEC);
 //Linea para debug 
 if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
 Serial.print("Device 0 Address: ");
 //Funcion para imprimir la direccion del dispositivo  --printAddress(insideThermometer);
 // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
 sensors.setResolution(insideThermometer, 10);

}


//=====================================VOID LOOP ==================================================//
void loop(void){ 
  iteracion = iteracion+1;

  menu.draw(); 
 
  limpia_char(); 
  
 if (tempC < tf){          //Chek if the temperature is below the off heating element
  digitalWrite(rele, LOW);  
  digitalWrite( led, ON);
 }
  
 if (tempC > ti){
   digitalWrite(rele, HIGH);  //chek if the temperature is above the start temperature 
   digitalWrite (led, OFF);    
 }

   sensors.requestTemperatures(); // Comando para obtener temperatura
   // It responds almost immediately. Let's print out the data
   printTemperature(insideThermometer); // Use a simple function to print out the data

dtostrf(tempC, 10, 2, stempC); 
Serial.print(F("String C")); Serial.println( stempC); 
dtostrf(tempF, 10, 2, stempF); 
Serial.print(F("String F")); Serial.println (stempF); 
Serial.print(F("freeMemory()="));Serial.println(freeMemory());
Serial.print(F("Numero de iteracion = ")); Serial.println(iteracion); 
Serial.println(F("---------------------------------"));
}



void msc(){
static  char buf[7];
  strcat(menu.sbuf, stempC); strcat(menu.sbuf,"C/n");  //1st lcd line
  strcat(menu.sbuf, stempF); strcat(menu.sbuf,"F/n"); //2nd lcd line
  menu.drawUsrScreen(menu.sbuf);
  }
 
 
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress){
 tempC = sensors.getTempC(deviceAddress);
 tempF = DallasTemperature::toFahrenheit(tempC); // Converts tempC to Fahrenheit
 Serial.print(F("Temp C: "));
 Serial.print(tempC);
 Serial.print(F(" Temp F: "));
 Serial.println(tempF); 
}
  
void limpia_char(){
  stempC[10] = 0 ;
  stempF[10] = 0 ;
  }

Porque no usas simplemente esto

Serial.print(F("Numero de iteracion = ")); Serial.println(++iteracion);

Elimina interacion = interacion +1;

Igualmente me sorprende que no funcione.

Poner el ++ previo a la variable hace que la incremente y muestre ese valor incrementado. Si estuviera luego empezaría por 0 y luego 1 2 3 ...

Te manda un MP.

Que tal @Surbyte ya agregue la linea que me comentas... y nada
esta es la salida del monitor serial;

1Device 0 Address: Temp C: 22.25 Temp F: 72.05
String C     22.25
String F     72.05
Numero de iteracion = 1
---------------------------------
Temp C: 22.25 Temp F: 72.05
String C     22.25
String F     72.05
Numero de iteracion = 1
---------------------------------
Temp C: 22.25 Temp F: 72.05
String C     22.25
String F     72.05
Numero de iteracion = 1
---------------------------------
Temp C: 22.25 Temp F: 72.05
String C     22.25
String F     72.05
Numero de iteracion = 1
---------------------------------
Temp C: 22.25 Temp F: 72.05
String C     22.25
String F     72.05
Numero de iteracion = 1
---------------------------------
Temp C: 22.25 Temp F: 72.05
String C     22.25
String F     72.05
Numero de iteracion = 1
---------------------------------
Temp C: 22.25 Temp F: 72.05
String C     22.25
String F     72.05
Numero de iteracion = 1
---------------------------------
Temp C: 22.25 Temp F: 72.05
String C     22.25
String F     72.05
Numero de iteracion = 1
---------------------------------
dtostrf(tempC, 10, 2, stempC); 
Serial.print(F("String C")); Serial.println( stempC); 
dtostrf(tempF, 10, 2, stempF); 
Serial.print(F("String F")); Serial.println (stempF); 
//Serial.print(F("freeMemory()="));Serial.println(freeMemory());
Serial.print(F("Numero de iteracion = ")); Serial.println(++iteracion); 
Serial.println(F("---------------------------------"));

Bueno, pense que estaba relaciona directamente con dtostfr ... asi que las comente fuera del codigo y nada...
borre freememory para ahorrar un poco de espacio y deje solo las librerias estrictamente necesarias...
Nada aun... no funciona ni el iteracion++ ni nada... el programa se frezeea despues de algunas interaciones.

Cosa mas rara...

Saludos.
Algo rápido coloca un whatchdog de 2 segundos. JAjaja

Bueno trata incrementando iteraccion y luego impriemdola luego.

Iteracion++;
Serial.println(Iteracion);

@max_saeta ... como que un watchdog???

Ya lo habia intentado

variable global;
byte iteraciones = 0;

void loop();
iteraciones = iteraciones++

Serialprint(F(La iteracion es ")) Serial.println(iteraciones)

y nada...
De casualidad sabes como revisar el consumo de SRAM?

me encontré este articulo Measuring Memory Usage | Memories of an Arduino | Adafruit Learning System
Pero no se exactamente que hacer con la funcion...

int freeRam () 
{
  extern int __heap_start, *__brkval; 
  int v; 
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
}

El whatchdog es un sistema de los micro que te permite reiniciarlo en caso de que se congee y no se reinicie el whatchdog.

Yo en verdad no he podido leer el uso de RAM real. He intentado varias formas y lo que he tenido que hacer es limitar cada variable y calcular el uso de cada codigo.

@max_saeta
Vaya... entiendo como un restart en el software... es bueno saberlo aunque para mi aplicacion no me va...

Ahora bien... se que los strings y los chars consumen memoria pero se supone que por eso los estamos pasanfo a flash con F en los seriales... Tu ves algo mas en el codigo que haga que se congele ?

O alguna otra manera sencilla de poner los limites inferior y superior de temperatura?

Gracias.

Vamos otra vez.
Si yo te sugiero algo y no lo ejecutas a mi me dan ganas de no responderte mas: asi de simple!!
Te mando MP me preocupo y tu vuelves a preguntar por interacción y su incremento.

Esto es está mal.

void loop();
iteraciones = iteraciones++

Serialprint(F(La iteracion es ")) Serial.println(iteraciones)

Si usas incrementos de variables =>
debes usar alguna de estas opciones

iteraciones = iteracciones +1;
o
iteraciones += 1;
o
iteraciones++;
o
++iteracciones;

Ningunta otra alternativa

Yo que te había sugerido? Una sola instrucción para poder ver que ocurría:

Serialprint(F(La iteracion es ")) Serial.println(++iteraciones)

que hacía en la primer pasada => La iteraccion es 1
en el primer paso.

Ahora si no funciona existe otra razón.
Normalmente tiene que ver con algun mal uso de un puntero que este dando vueltas por ahi.
Esto es un puntero char *variable

Algo que esta generando problemas.

surbyte:
Vamos otra vez.
Si yo te sugiero algo y no lo ejecutas a mi me dan ganas de no responderte mas: asi de simple!!
Te mando MP me preocupo y tu vuelves a preguntar por interacción y su incremento.

Esto es está mal.

void loop();

iteraciones = iteraciones++

Serialprint(F(La iteracion es ")) Serial.println(iteraciones)




Si usas incrementos de variables =>
debes usar alguna de estas opciones



iteraciones = iteracciones +1;
o
iteraciones += 1;
o
iteraciones++;
o
++iteracciones;




Ningunta otra alternativa

Yo que te había sugerido? Una sola instrucción para poder ver que ocurría:



Serialprint(F(La iteracion es ")) Serial.println(++iteraciones)




que hacía en la primer pasada => La iteraccion es 1 
en el primer paso.

Ahora si no funciona existe otra razón. 
Normalmente tiene que ver con algun mal uso de un puntero que este dando vueltas por ahi. 
Esto es un puntero char *variable

Algo que esta generando problemas.

Efectivamente lo implemente arriba esta el resultado... Nada solo hace =1
Dices q son los char....yo solo defini dos de buffer conocido para hacer la conversión de valores.

Los unicos pointers que andan por ahí... Son los q tiene la librería.... Quizás si definiera su tamaño? De acuerdo a los menus q se van a utilizar?
Aunque honestamente no tengo idea como hacer eso... Todavía no estoy tan avanzado en esto del código.

Si solo da 1 es porque siempre se esta poniendo a 0 o como dijo Max se esta reseteando tu Arduino.
En el setup no veo una linea que ayude a darse cuenta
Agrega en el setup
Serial.prinln("Iniciando programa");
por ejemplo y si la lees es porque efectivamente se esta reseteando a cada momento.

hay un error grave declaras 2 array

char stempC [10];              //Char to hold the temperature on C 
char stempF [10];              //Char to hold the temperature on F 
int iteracion = 0;

y luego en lipia_char, que no limpia nada

void limpia_char(){
  stempC[10] = 0 ;
  stempF[10] = 0 ;
  }

asignas a la posicion 10 pero los array van del 0 al 9, si queres limpiar tenes que agregar en la posicion 0 el terminador, para que ignore el resto.

Eso te puede estar haciendo que se resetee porque vaya a saber que hay en el byte 10.

maxid:
hay un error grave declaras 2 array

char stempC [10];              //Char to hold the temperature on C 

char stempF [10];              //Char to hold the temperature on F
int iteracion = 0;




y luego en lipia_char, que no limpia nada



void limpia_char(){
  stempC[10] = 0 ;
  stempF[10] = 0 ;
  }




asignas a la posicion 10 pero los array van del 0 al 9, si queres limpiar tenes que agregar en la posicion 0 el terminador, para que ignore el resto.

Eso te puede estar haciendo que se resetee porque vaya a saber que hay en el byte 10.

Efectivamente..... Lo vi es stakoverflow... Pero el de ellos decía algo así
Char[0]={0}

Y a mi el compilador no me dejo hacer eso por los curvy brackets.

Entonces... debe ser
Char[9] = 0?

O sencillamente lo dejo de lado? Digo la limpieza?

Gracias @Surbyte no lo había pensado así... En cuanto regrese a la PC... Investigó mas!

Gracias también @maxid !!!

Los mantengo informados!

poner stempC[9] = 0 ; solo le dices que en la posicion 9 ponga un cero. en el 0,1,2,3,4,5,6,7 y o seguirá habiendo basura o lo anterior.

si pones stempC[0]= '\0'; e imprimes no tendras nada en pantalla.

@Surbyte, @maxid

Bueno, aqui ya comenzo a destrabarse algo la situacion...
como me lo recomentadon.
Agregue la linea

Serial.println(F("Programa iniciando"));

Y cambien el valor de la funcion, limpia char a;
stempC[9] = 0 ;
stempF[9] = 0 ;

Ahora bien... tenemos algo nuevo; la salida del monitor serial;

StriþPrograma iniciando
1Device 0 Address: Temp C: 22.50 Temp F: 72.50
String C
String F
Numero de iteracion = 1
---------------------------------
Temp C: 22.50 Temp F: 72.50
String C
String F
Numero de iteracion = 2
---------------------------------
Temp C: 22.50 Temp F: 72.50
String C
String F
Numero de iteracion = 3
---------------------------------

Temp C: 22.50 Temp F: 72.50
String C
String F
Numero de iteracion = 33
---------------------------------
Temp C: 22.50 Temp F: 72.50
String C
String F
Numero de iteracion = 34
---------------------------------
Temp C: 22.50 Temp F: 72.50
String C
String Æ

Ahora bien... removi la funcion limpiaChar
y la llamada a la misma, de momento no estoy conviertiendo los valores, asi que deje la
pantalla de incio como venia en el ejemplo... Vuelve a cargar 35 veces el loop y despues se
detiene.