Photon hangs using one-wire on Analog pins

So I was under the impression that Analog pins can work fine as Digital I/O pins.
I set up a one-wire temperature sensor to use one.
And it hangs completely. Cannot even re-flash.

This could of course be my code, hardware, or libraries.
And I did have some compile issues at first.

I am using
Particle Verison of OneWire Libary v2.2
Spark-dallas temp library, v 3.7.2

OH: And I am trying to connect TWO of them.

int one_wire_temp_pool = A0;            // Pin
int one_wire_temp_solr = A2;            // Pin
OneWire oneWire_pool(one_wire_temp_pool);
OneWire oneWire_solr(one_wire_temp_solr);
DallasTemperature sensors_pool(&oneWire_pool);
DallasTemperature sensors_solr(&oneWire_solr);


    tempc_pool = sensors_pool.getTempCByIndex(0);

Any ideas where to look first would be welcome.
Or should I not use A0/A3.
I have a 4.7K resistor on each.


I broke it down to simpler code that simply does a onewire bus search, and each port works.
Although it is a bit flaky still.
But no hangs.
So some sort of issues with either my code or the dallas library is my bet.

Gave up on dallas-library, and used/tweaked some code BKO posted.
It works pretty well now, both ports.
Occasional CRC error on temperature data, but rare.

I notice that the one-wire timing values are different from the Arduino library.
I may play around with those.

Final update:

If I use:

And then:

  • Particle.disconnect();
  • Then read temperature on one-wire, which includes disabling interrupts.
  • Particle.connect();
    It seems to work quite reliably.

Interestingly, it also seems to read the temp sensor with less CRC errors.

If I do not do that, it tends to work for a few hours, then die.

My personal code does not touch interrupts, just in the one-wire library.