Analog output(DAC function) using ESP32


#1

Hi,

I get below error when i try to generate analog output using ‘dac.DAC’ function. My code line at line 23 is
dac.DAC(D25.DAC0)

Can’t find name [This board does not support such pin function! D25.DAC0] in [[] at line 23](javascript:app.open_marker(‘c:\adarsh\projects\my thing\code\pilot 2’,’’,23))

Can anyone please guide me here?


#2

hi @Adu
Could you please post the whole code and tell me which board you are using?


#3

I’m using Sparkfun ESP32 Thing.

Code:
import streams
import adc
import dac
import json
from wireless import wifi
from espressif.esp32net import esp32wifi as wifi_driver # choose a wifi chip supporting secure sockets and client certificates

set the analog input.

pinMode(A0,INPUT_ANALOG)
pinMode(A1,INPUT_ANALOG)
pinMode(A2,INPUT_ANALOG)
pinMode(A3,INPUT_ANALOG)
pinMode(A4,INPUT_ANALOG)
pinMode(A5,INPUT_ANALOG)
pinMode(A6,INPUT_ANALOG)
pinMode(A7,INPUT_ANALOG)

set the analog output.

angAO = dac.DAC(D25.DAC0)
angA1 = dac.DAC(D26.DAC)


#4

You have to specify the pin as D25.DAC.
Here is a code that compiles without errors, Please try it and tell me if it works.
It follows the DAC example.

#set the analog output.
angAO = dac.DAC(D25.DAC)
angAO.start()
angAO.write([100,200,900,800],1000,MILLIS,circular=True)

angA1 = dac.DAC(D26.DAC)
angA1.start()
angA1.write([100,200,900,800],1000,MILLIS,circular=True)

#5

Tried this code did not work. PFB the error screenshot.


#6

I used the same code on my ESP32 Devkit C without errors.
This is strange because by looking at the pinout map of the Sparkfun ESP32 Thing, You can find the D25 as DAC and D26 as DAC.

We would look into this matter and let you know of any updates.


#7

Hello @Adu,

it seems you are using an old Zerynth version, can you update to r2.2.0 p02?


#8

Updating to r2.2.0 did not help,