Photon Tinker AnalogRead odd behavior

Got my photons today. Thanks!

I’m seeing odd behavior with the Tinker code on the Photon for AnalogReads. The first read is correct, but subsequent reads (e.g. touching the A0 button again in the App) produces values in the range of 260 - 300 regardless of the potentiometer position. But if I modify the Photon Tinker code and comment out this line (from function tinkerAnalogRead, line 62):

pinMode(pinNumber+10, INPUT);

The behavior is correct and I get accurate reads. Is there a different behavior of pinMode() on the Photon? It’s as if calling it more than once puts the pin into a strange state.

I tried reproducing the behaviour by connecting a 10K pot to it. I’m only able to get ±2 variations. Can you tell me more about your circuit setup and confirm that the Photon indeed updated to the latest firmware the first time you connected it to the internet?

Thanks!

Happy Hacking!

Mohit

Thanks for following up. I did a bit more digging. I can confirm your experience - i.e. with the factory version of Tinker running on the Photon, everything is correct. BUT, if I flash the Photon with the version of Tinker from this page:

http://docs.particle.io/photon/tinker/

I get the problem described in my original post. So it seams that there is a discrepancy between what’s on the device by default and what you’ve published in the documentation. Can you point me to the source code version of Tinker that’s the factory default? It would be good to get that and your docs synced up.

Thanks,
.phil

Thanks! That’s some great investigative work there!

Could you link to exactly where on that page the tinker binary is linked? I couldn’t find it. There is a link to the tinker sources, which are unfortunately not entirely correct for the photon, as the photon sources are not (yet) in the master branch. The latest version is under user/src/application.cpp.

@mdma, I believe @pvanallen is referring to the code shown in the section called “Using Tinker with Your Code” some way down the Tinker docs page :smile:

Yes @peekay123 , exactly:

http://docs.particle.io/photon/tinker/#tinkering-with-tinker-using-tinker-with-your-code

On the right hand side