I'm doing tds and temperature project but

Arduino: 1.8.19 (Windows 10), Board: "Arduino Uno"
C:\Users\Kamrulzaman\AppData\Local\Temp\Rar$DIa18232.48156\GravityTDSExample\GravityTDSExample.ino: In function 'void loop()':
GravityTDSExample:53:19: error: 'readTemperature' was not declared in this scope

 temperature = readTemperature();  //add your temperature sensor and read it

               ^~~~~~~~~~~~~~~

C:\Users\Kamrulzaman\AppData\Local\Temp\Rar$DIa18232.48156\GravityTDSExample\GravityTDSExample.ino:53:19: note: suggested alternative: 'temperature'

 temperature = readTemperature();  //add your temperature sensor and read it

               ^~~~~~~~~~~~~~~

               temperature

exit status 1

'readTemperature' was not declared in this scope

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

As your topic does not relate directly to the installation or operation of the IDE it has been moved to the Programming Questions category of the forum

Please post your full sketch, using code tags when you do

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

That should be:
gravityTds.readTemperature();

#include <OneWire.h>

#include <DallasTemperature.h>

#include <EEPROM.h>

#include <GravityTDS.h>

#include <EEPROM.h>
#include "GravityTDS.h"

#define TdsSensorPin A1
GravityTDS gravityTds;

float temperature = 25, tdsValue = 0;

void setup()
{
Serial.begin(115200);

gravityTds.setPin(TdsSensorPin);
gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO
gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC
gravityTds.begin(); //initialization
}

void loop()
{
temperature = readTemperature(); //add your temperature sensor and read it
gravityTds.setTemperature(temperature); // set the temperature and execute temperature compensation
gravityTds.update(); //sample and calculate
tdsValue = gravityTds.getTdsValue(); // then get the value
Serial.print(tdsValue, 0);
Serial.println();
delay(1000);
}

Your two or more topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

Why did you start a new topic and why did you not post the sketch using code tags as requested ?

I had a look at the dfrobot website, that is a wiki for their Gravity TDS Sensor:
https://wiki.dfrobot.com/Gravity__Analog_TDS_Sensor___Meter_For_Arduino_SKU__SEN0244

In the code example there, the line you are having problems with is commented out. They have already declared the temperature as 25 (°C).

If you look at the Frequently Asked Questions at the bottom of that page , you will see just one question:

Q1. Does this sensor have a temperature sensor? How to make the temperature compensation?
A1. This TDS probe has no temperature sensor, but the temperature compensation algorithm is reserved in the sample code. The temperature variable in the sample code will default to 25 °C without a temperature sensor. You can add a waterproof temperature sensor to read the temperature,then update the temperature variable, to make automatic temperature compensation.

You can add your own temperature sensor, they have not specified any particular type of temperature sensor.
This means that you are free to use any temperature sensor you like, but you must also add the library for the particular temperature sensor that you choose.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.