Compatibility issue with Temperature sensor between Photon and Electron

I’m trying to run an application I originally wrote for the Electron on a Photon and am not quite sure where I’m going wrong. My application is simply trying to read the temperature off a probe and spit the results into the serial output. The code/wiring works fine on the Electron but not on the Photon(1kΩ pull-up between VCC and the OneWire Bus, tried different resistances but still encountering the same problem)

The issue occurring is that the Photon configuration only intermittently(<25%) recognizes a probe on the bus, but it works fine when running on the electron. I’ve tried switching probes around and trying different devices but I’m kinda stuck as to what’s going on, aside from some hardware difference between the Electron and Photon that I may have missed.

Link of the code I’m running.

I haven’t looked at your code yet, but one difference between Electron and Photon that might impact your readings is the execution speed of the background task between iterations of loop() on single-threaded mode (i.e. not using SYSTEM_THREAD(ENABLED)).

While the cellular connection only allows loop() to run aproximately 100 times per second, on the Photon it’s called about 1000 times.
If the probe can’t keep up with the faster reading speed, that could impact the outcome.

On first glance at your code, I see you are using spark-dallas-temperature library which isn’t that well maintained by the original contributor.
Can you try the DS18B20 library instead? (I know this library is maintained and has currently no open issues in the GitHub repo :wink: )

BTW, how many sensors are you actually reading?

Looks like adding SYSTEM_THREAD(ENABLED) was all I needed to do. My probes are recognized consistently by the Photons now, still need to test the Electron’s though.

I’m currently only reading one device but my goal for the code was to be able to read an arbitrary number of sensors connected to the bus.

Thanks for the recommendation on the alternative library, I’ll be sure to check it out.

1 Like