1

Is there a way to change arduino analog reference to EXTERNAL IN PYTHON using pyfirmata or any other library ? Necessary Links : https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/

My sensor has a 3.3 volt operating voltage , my arduino has a 5 volt operating voltage. As such in arduino using C++ and arduino module the scaling can be done using analogReference(External) and providing reference voltage to analog read?

IS there any equivalent to this in python, pyfirmata ?

1 Answers1

1

No, not as far as I know. The firmata protocol does not include a command to set the analog reference. However, you can of course modify the firmata firmware to your liking. In the simplest case, just add the appropriate command to the setup() function of the main .ino.

PMF
  • 1,184
  • 3
  • 16
  • I have been using pyfirmata for the previous projects. Since pyfirmata doesnt include the necessary function , you suggest adding analogreference(External) to the firmata module that i would have to upload and run on arduino , would that make the analog reference voltage external when accessing with pyfirmata and python? – Shahan hasan May 03 '21 at 20:24
  • 1
    @Shahanhasan Yes. Firmata doesn't use `analogReference()` anywhere in the code, so when you add `analogReference(EXTERNAL)` to the startup code, it should change the behavior when accessing it from pyfirmata. – PMF May 04 '21 at 05:03