DAC Problem

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Posts: 2
Joined: Thu Apr 15, 2021 8:25 pm

DAC Problem

Post by msg_otomasyon » Thu Apr 15, 2021 8:38 pm

Hi to everyone..
I am having a problem with DAC hardware for ESP32.

My code is as follows.

from machine import DAC
from machine import Pin
d = DAC(Pin(25,Pin.OUT))

While I should read 0 volts on pin 25, I am reading about 0.1 volts.
This is a serious problem for me.

Does anyone have a solution suggestion on the subject.

Best Regards.

Posts: 54
Joined: Fri Jan 17, 2020 5:19 am
Location: Ohio, USA

Re: DAC Problem

Post by stanely » Fri Apr 16, 2021 3:36 am

I'm also dealing with this issue. It is not uncommon for ADC outputs not to swing rail-to-rail. It could also be the result of input offset voltage. Either way, an external circuit might be needed. I'm getting better than 0.1V, but it's still not 0.

I plan to use a low voltage rail-to-rail opamp configured as a differential amplifier to get 0 at the oputput. I'll add a small offset voltage to the (-) input to force the output to 0. Scale range can be set by the gain of the resistors. Equations can be seen here: https://www.electronics-tutorials.ws/opamp/opamp_5.html

There's a brief discussion of this issue here, https://electronics.stackexchange.com/q ... zero-volts

I'm waiting for parts. I ordered some MCP602 chips. They're about the only through-hole low-voltage, rail-to-rail opamps I found. The LM358LV (not to be confused with the LM358P) has the right specs but is only available in surface-mount.

Hope this helps.

User avatar
Posts: 5143
Joined: Fri Jul 18, 2014 8:01 am
Location: UK

Re: DAC Problem

Post by pythoncoder » Fri Apr 16, 2021 11:26 am

The other option is to use a host with a decent DAC such as a Pyboard. Note that, in my testing, the ESP32 DAC is also adrift at the high end of its range.
Peter Hinch

Posts: 2
Joined: Thu Apr 15, 2021 8:25 pm

Re: DAC Problem

Post by msg_otomasyon » Fri Apr 16, 2021 7:38 pm

Apparently we can't handle it without using extra hardware.
I will try with difference amplifier or external DAC.
Thank you very much for your answers.

Posts: 25
Joined: Fri Feb 15, 2019 9:22 am

Re: DAC Problem

Post by wangshujun@tom.com » Sun Apr 18, 2021 1:48 pm

This situation is determined by the internal circuit of the chip. As described in the manual, the internal DAC output goes through an operational amplifier to the pin, and it is difficult to achieve the rail to rail output with this structure
The DAC of STM32 has a similar feature after the buffer is turned on, but the buffer of STM32 can be turned off.

Post Reply