Allocated the highest temperature on the sensors

I have few temperature sensors, and I want to catch the biggest temperature on one senser of several:

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial
#define TEMPERATURE_PRECISION 1
/* Blynk credentials /
char auth[] = "
************";

/* WiFi credentials /
char ssid[] = "
";
char pass[] = "
**";

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress *sensorsUnique;
int countSensors;

void printAddress(DeviceAddress deviceAddress) {
for (uint8_t i = 0; i < 8; i++) {
if (deviceAddress < 16) Serial.print("0");
_ Serial.print(deviceAddress*, HEX);_
_
}_
_
}_
void setup() {
_
Serial.begin(115200);_
_
while (!Serial);_
_
sensors.begin();_
_
Blynk.begin(auth, ssid, pass);_
_
countSensors = sensors.getDeviceCount();_
_
Serial.print("Found sensors: ");_
_
Serial.println(countSensors);*_

* sensorsUnique = new DeviceAddress[countSensors];*
* if (sensors.isParasitePowerMode()) {*
* Serial.println("Mode power is Parasite");*
* } else {*
* Serial.println("Mode power is Normal");*
* }*
* for (int i = 0; i < countSensors; i++) {*
_ sensors.getAddress(sensorsUnique*, i);
}
for (int i = 0; i < countSensors; i++) {
Serial.print("Device ");
Serial.print(i);
Serial.print(" Address: ");
printAddress(sensorsUnique);
Serial.println();
}
Serial.println();
for (int i = 0; i < countSensors; i++) {
sensors.setResolution(sensorsUnique, 12);
}
}
void loop() {
float temperature[10];
sensors.requestTemperatures();
for (int i = 0; i < countSensors; i++) {
temperature = sensors.getTempCByIndex(i);
}*_

* for (int i = 0; i < countSensors; i++) {*
* Serial.print("Device ");*
* Serial.print(i);*
* Serial.print(" Temp C: ");*
Serial.print(temperature*, TEMPERATURE_PRECISION);
_ Serial.println();*
Blynk.virtualWrite(10, temperature );_

* }*
* Serial.println();*
* delay(1000);*
}
Dalastemp.ino (1.94 KB)

Please edit your post and put the code inside code tags, so we don't have to squint at italics.

Hint: If I gave you a ruler, and a box of sticks and asked you to make a procedure to find the longest stick, would you be baffled? Is the second stick you pull out bigger than the first one? The way that you would do it, is exactly how you would code it.

you have some errors trying to set the array to a value instead of an element of an array

but why not just capture the max instead of multiple values?

Ok, I post full sketch and attached .ino

My goal is catch max tempertature in this parametr:

Blynk.virtualWrite(10, temperature );

antons15:
My goal is catch max tempertature in this parametr:
Blynk.virtualWrite(10, temperature );

why not something like following (simulated)

struct {
    void  requestTemperatures (void) {};
    float getTempCByIndex (int)      { return rand () / 1000.; };
} sensors;

struct {
    void virtualWrite (int i, int x) {};
} Blynk;

#define N_SENSORS  10

// -----------------------------------------------------------------------------
void loop()
{
    sensors.requestTemperatures();

    int max = sensors.getTempCByIndex(0);

    for (int i = 1; i < N_SENSORS; i++) {
        int  t =  sensors.getTempCByIndex(i);
        if (max < t)
            max = t;
    }

    char s [50];
    sprintf (s, "  Max Temp (C): %d", max);
    Serial.println (s);
    Blynk.virtualWrite(10, max);

    delay(1000);
}

// -----------------------------------------------------------------------------
void setup (void) {
    Serial.begin (115200);
}

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Please repost your
[ code ] tagged code in a new post please.

Thanks.. Tom.... :slight_smile:

Yes, it's wokr fine, and one more question, how to do decimal fractions? Exemple 26,6 C dergees, because now I have 26 C deg.
Thanks a lot.

"Report to moderator" is not a regular reply option ;D

Sorry, it's my fault wrong button :)))

Common guys help me :grin:

Where I can to enter the option for decimal thermometer ?

Thanks a lot.

Cmon antons15 put your code up properly.

It looks orrible :grin:

Hi,
Can you please post your working code please?

Thanks.. Tom... :slight_smile:

struct {
    void  requestTemperatures (void) {};
    float getTempCByIndex (int)      { return rand () / 1000.; };
} sensors;

struct {
    void virtualWrite (int i, int x) {};
} Blynk;

#define N_SENSORS  10

// -----------------------------------------------------------------------------
void loop()
{
    sensors.requestTemperatures();

    int max = sensors.getTempCByIndex(0);

    for (int i = 1; i < N_SENSORS; i++) {
        int  t =  sensors.getTempCByIndex(i);
        if (max < t)
            max = t;
    }

    char s [50];
    sprintf (s, "  Max Temp (C): %d", max);
    Serial.println (s);
    Blynk.virtualWrite(10, max);

    delay(1000);
}

// -----------------------------------------------------------------------------
void setup (void) {
    Serial.begin (115200);
}

you can use dtostrf()

struct {
    void  requestTemperatures (void) {};
    float getTempCByIndex (int)      { return rand () / 1000.; };
} sensors;

struct {
    void virtualWrite (int i, int x) {};
} Blynk;

#define N_SENSORS  10

// -----------------------------------------------------------------------------
void loop()
{
    sensors.requestTemperatures();

    double max = sensors.getTempCByIndex(0);

    for (int i = 1; i < N_SENSORS; i++) {
        double  t =  sensors.getTempCByIndex(i);
        if (max < t)
            max = t;
    }

    char t [20];
    dtostrf (max, 5, 1, t);

    char s [50];
    sprintf (s, "  Max Temp (C): %s", t);
    Serial.println (s);
    Blynk.virtualWrite(10, max);

    delay(1000);
}

// -----------------------------------------------------------------------------
void setup (void) {
    Serial.begin (115200);
}