Multiple DS18B20 with Photon

@Ric , thanks for coming back!
Here is your original “Dallas.cpp”:


#include "Dallas.h"
// Choose one of 2 possibilities:
// 1) For use in the IDE:
//#include "OneWire/OneWire.h"
// 2) For use with Particle Dev:
#include "OneWire.h"

double celsius;

// Group sensors in their bus (on one I/O pin) ; [6][8] means: 6 sensor codes with 8 bytes.
// Attention: If the 2 types of sensors are mixed, you must group DS18S20 sensors in one bus and DS18B20 in another bus. You must adapt below code (if(select == 0 or 1)) to the sensor type...
byte addrs0[12][8] = {{0x28,0xFF,0x0D,0x4C,0x05,0x16,0x03,0xC7}, {0x28,0xFF,0x25,0x1A,0x01,0x16,0x04,0xCD}, {0x28,0xFF,0x89,0x19,0x01,0x16,0x04,0x57}, {0x28,0xFF,0x21,0x9F,0x61,0x15,0x03,0xF9}, {0x28,0xFF,0x16,0x6B,0x00,0x16,0x03,0x08}, {0x28,0xFF,0x90,0xA2,0x00,0x16,0x04,0x76}, {0x28,0x3A,0xBC,0x07,0x00,0x00,0x80,0x58}, {0x28,0x72,0x03,0x04,0x00,0x00,0x80,0x24}, {0x28,0xD4,0xE7,0x03,0x00,0x00,0x80,0x89}, {0x28,0x78,0xF9,0x03,0x00,0x00,0x80,0x76}, {0x28,0x70,0xAD,0x07,0x00,0x00,0x80,0x53}, {0x28,0x40,0xE1,0x03,0x00,0x00,0x80,0x78}}; // 12x DS18B20 Waterproof wired sensors
byte addrs1[3][8] = {{0x10,0xE9,0x6B,0x0A,0x03,0x08,0x00,0xAC}, {0x10,0x44,0x4E,0x0B,0x03,0x08,0x00,0x1F}, {0x28, 0xD, 0xD3, 0xE2, 0x3, 0x0, 0x0, 0xEE}};// 2x DS18S20 TO92 sensors (Third code is from Ric, not on the bus: Test error handling!)


void getTemperatures(float temps[], int tempsCount, int pin, int select)
{
    OneWire ds = OneWire(pin);
    ds.reset();
    ds.skip();          // Make all devices start the temperature conversion
    ds.write(0x44, 0);  // Tell it to start a conversion (second argument: 1 = parasite power, 0 = powered mode)

    delay(1000);       //  Wait 1 sec for conversion
    ds.reset();

    for (int i=0; i<tempsCount; i++)
    {
        switch (select)
        {
            case 0:
                ds.select(addrs0[i]);
                break;
            case 1:
                ds.select(addrs1[i]);
                break;
        }

        ds.write(0xBE,0);

        byte data0 = ds.read();
        byte data1 = ds.read();
        ds.reset();

        // If you mix both types of sensors, you need this branching:
        if (select == 0)
        {
            int16_t raw = (data1 << 8) | data0;
            celsius = (float)raw * 0.0625; // DS18B20 sensor = 12 bit resolution device
        }
        else if (select == 1)
        {
            int16_t raw = data0;
            celsius = (float)raw * 0.5; // DS18S20 sensor = 9 bit resolution device
        }

        /*
        // If you use only DS18B20 sensors, you can keep it simpler:
        int16_t raw = (data1 << 8) | data0;
        celsius = (float)raw * 0.0625; // For DS18B20 sensors
        */

        temps[i] = celsius;
    }
}