Error: cannot convert 'UINT16_t' to 'uint16_t {aka unsigned i

Hi,

I am trying to modify the Arduino code for the Thinxtra (Sigfox) module to replace some of the standard sensors measurements with others. e.g. pressure with ORP.

For the 2 sensors that I have added so far I get the error:

Test_pool3:116:28: error: cannot convert 'UINT16_t' to 'uint16_t {aka unsigned int}' in assignment

phValue.number = (phValue*100);

Test_pool3:118:30: error: cannot convert 'UINT16_t' to 'uint16_t {aka unsigned int}' in assignment

orpValue.number = (orpValue*10);

I think the problem is in this section:

UINT16_t tempt;
UINT16_t phValue;
UINT16_t orpValue;

tempt.number = (tSensors->getTemp() * 100);
Serial.print("Temp: "); Serial.println(tempt.number / 100);

phValue.number = (phValue*100);
Serial.print("pH Value: "); Serial.println(phValue.number/100);

orpValue.number = (orpValue*10);
Serial.print("ORP: "); Serial.println(orpValue.number/10);

The tempt.number (original sensor) does not give an error and getTemp() returns a float.

I am very new to this and struggling so any help would be appreciated.

Thanks

Kim

Test_pool3.ino (6.95 KB)

Tsensors.cpp (9.75 KB)

Tsensors.h (5.19 KB)

'UINT16_t' and 'uint16_t' are different things as far as the compiler is concerned as case matters, try changing the uppercase UINT16_t to lowercase (uint16_t) and try compiling again.

Thanks for the suggestion but if I try that I get the error:

Test_pool3:131:25: error: request for member 'bytes' in 'orpValue', which is of non-class type 'uint16_t {aka unsigned int}'

Also I do not understand why it works for "tempt" which is a float from GetTemp() but not for ph or ORP.

I have tried declaring ph and ORP as float and also using ConvertToUInt but no luck?

Any other thoughts.

Thanks

Kim

I should have downloaded the code instead of just referring to the inline code but I can now see UINT16_t is a union so should remain the same case as defined.

Your defining variables (phValue & orpValue) with no values and then multiplying by 100 (I assume to remove decimal point) but your not reading the union variable type correctly. It should read with (phValue.number100) instead of (phValue100)

Altering the below code now makes it compile (but not work)

  tempt.number = (tSensors->getTemp() * 100);
  Serial.print("Temp: "); Serial.println(tempt.number / 100);
  phValue.number = (phValue.number*100);
  Serial.print("pH Value: "); Serial.println(phValue.number/100);
  orpValue.number = (orpValue.number*10);
  Serial.print("ORP: "); Serial.println(orpValue.number/10);

Thanks again, But how do I get phValue which is the measurement value to equal phValue.number to be used in the data packet?

For starters don't use the same name for two different variables.