I have to confess that my brain is almost stucked…
Please show me the way to call a function with Virtual Pin number as a parameter?
I mean how to call the function
printTemperature(Probe05,V15);
and how to declare the printTemperature function at the V15 part of declaration ???
Dear @Lichtsignaal ,
thanks for your helping hands.
For some reason I get in trouble to pass the virtual pin as a parameter in my calling function.
Shortly I want to have a general type temperature printing function with parameters the temperature probe name {Probe01, Probe02 etc} and the Virtual pin that is used on History Graph widget {V11, V12 etc}.
Although I don’t like to see virtual pins referenced without the V prefix I believe you can use them without as the others are either gpX, (Digital) or adcX (Analogue).
That said, many months ago when I was working with virtual pins I seem to remember joining a char (V) to and integer (0 to 127) to make VX. This suggests you have to call them as Strings.
/// START of DS18B20 temperature sensors printing Function printTemperature ///
void printTemperature(DeviceAddress deviceAddress, char Vport)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print("Error getting temperature ");
}
else
{
Serial.print("°C: ");
Serial.print(tempC);
/// Send it to the server and to history widget
Blynk.virtualWrite(Vport, tempC);
}
}
/// END of DS18B20 temperature sensors printing Function printTemperature ///
/// START of DS18B20 temperature sensors process Function reportTemperature() this will be running using simpletimer each ex 5 seconds ///
void reportTemperature()
{
clockDisplay();
Serial.println();
Serial.print("Number of Devices found on bus = ");
Serial.println(sensors.getDeviceCount());
Serial.print("Getting temperatures... ");
Serial.println();
// Command all devices on bus to read temperature
sensors.requestTemperatures();
Serial.print("Probe 01 temperature is: ");
printTemperature(Probe01,V11); /// Probe01 holds the temperature in C for 1sr DS18B20 temperature sensor ///
Serial.println();
Serial.print("Probe 02 temperature is: ");
printTemperature(Probe02,V12); /// Probe02 holds the temperature in C for 2nd DS18B20 temperature sensor ///
Serial.println();
Serial.print("Probe 03 temperature is: ");
printTemperature(Probe03,V13); /// Probe03 holds the temperature in C for 3rd DS18B20 temperature sensor ///
Serial.println();
Serial.print("Probe 04 temperature is: ");
printTemperature(Probe04,V14); /// Probe04 holds the temperature in C for 4th DS18B20 temperature sensor ///
Serial.println();
///Serial.print("Probe 05 temperature is: ");
///printTemperature(Probe05,V15); /// Probe05 holds the temperature in C for 5th DS18B20 temperature sensor ///
///Serial.println();
}
/// END of DS18B20 temperature sensors process Function reportTemperature() ///
Dear @vshymanskyy do you mean as @Costas already posted, to reference ex V1 simple as 1 ?
Yes I tested already and it is working but can you suggested me/us a way to referenced as V1 ? ( for better consistency ) What is the proper declaration type and how to handle it???