error using floatToString

I trying to display temperature and humidity on a LCD48

84 module. the temperature reading function returns a float, the lcd module expects a string. The floatToString function returns the result as char * name. My code is thus:

[code]#include "LCD4884.h"
#include "DFrobot_bmp.h"
#include <SHT1x.h>

#define dataPin  10   // DATA
#define clockPin 11   // SCK
SHT1x sht1x(dataPin, clockPin);

 #include "floatToString.h"  //set to whatever is the location of floatToStrig

// menu starting points

#define MENU_X	10		// 0-83
#define MENU_Y	1		// 0-5

int  adc_key_val[5] ={50, 200, 400, 600, 800 };

void setup(){
/* loop */

void loop()
  float temp_f;
  float humidity;

  // Read values from the sensor
  char tempString[25]; // just give it plenty to write out any values you want to test
  temp_f = sht1x.readTemperatureF();
  Serial.println("floatToString(tempString, temp_f , 4);");
  tempString += " F"

  humidity = sht1x.readHumidity();
//  lcd.LCD_write_string_big(15,1,

The error I get is:

TEMP_HUM_LCD.cpp: In function ‘void loop()’:
TEMP_HUM_LCD:40: error: invalid operands of types ‘char [25]’ and ‘const char [3]’ to binary ‘operator+’
TEMP_HUM_LCD:40: error: in evaluation of ‘operator+=(char [25], const char [3])’
TEMP_HUM_LCD:41: error: expected `;’ before ‘lcd’
TEMP_HUM_LCD:41: error: expected primary-expression before ‘/’ token

I’m still a newbie, unsure of where to go from here!


The compiler has certain rules about how to write your code, and it is not forgiving about random letters here and there.

Both of these lines have syntax problems.


This has an extra */ on the end

  tempString += " F"

This is missing a semi-colon at the end.

And it is also completely not legal at all. You cannot do math (e.g. +=) on char arrays.

Thanks maniacbug, I have a problem with the ;'s because Quickbasic(the only language I sort know) does not require them. I commented out the other line and it compiles without error. Now I'll work on inserting the "F".