# ESP32 board support

**URL:** <https://forum.xod.io/t/esp32-board-support/1489>\
**Category:** Uncategorized\
**Created:** [December 5, 2018, 5:30pm UTC](https://forum.xod.io/t/esp32-board-support/1489 "2018-12-05T17:30:04Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![gilyazov](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gilyazov](https://forum.xod.io/u/gilyazov)\
**Post date:** [December 5, 2018, 5:30pm UTC](https://forum.xod.io/t/esp32-board-support/1489/1 "2018-12-05T17:30:04Z")

</div>

How can I use ESP32 with XOD?

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [December 6, 2018, 4:50pm UTC](https://forum.xod.io/t/esp32-board-support/1489/2 "2018-12-06T16:50:44Z")

</div>

Try to add the `https://dl.espressif.com/dl/package_esp32_index.json` URL to:

`C:\Users\You\xod\ __packages__ \extra.txt`

Then restart IDE and hit Deploy → Upload to Arduino → Refresh boards list

---

<div class="post-metadata">

**Author:** ![gilyazov](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gilyazov](https://forum.xod.io/u/gilyazov)\
**Post date:** [December 6, 2018, 9:27pm UTC](https://forum.xod.io/t/esp32-board-support/1489/3 "2018-12-06T21:27:15Z")

</div>

Thx a lott!  
Before restarting IDE we shall manualy download json file to **packages** dir. Otherwise there will be an error.

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [December 7, 2018, 2:21am UTC](https://forum.xod.io/t/esp32-board-support/1489/4 "2018-12-07T02:21:25Z")

</div>

> [@gilyazov](#):
>
> Can’t compile

 ![%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/55fe85f9793a6717a9e69979920028e06ea9f2df.jpeg)

Ah made a mistake to open the subject, I answer here.  
The compilation error can be due to an error when selecting the pin, for the configuration with correct see `pins_arduino.h`  
C:\Users\*User\*\Documents\Arduino\hardware\espressif\esp32\variants\ ( you board)

Example: LED\_BUILTIN = 2 , declare D2

```auto
    if (!isValidDigitalPort(port)) {
        emitValue<output_ERR>(ctx, 1);
        return;
    }

```

If the port is not correct, it returns error

> error: ‘::analogWrite’ has not been declared  
> ::analogWrite(port, val);  
> ^

it may be the correct pin

 ![ESP32](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/08adc4deb3fae7caf1d5b4509e6748950ef89b58.jpeg)

---

<div class="post-metadata">

**Author:** ![gilyazov](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gilyazov](https://forum.xod.io/u/gilyazov)\
**Post date:** [December 7, 2018, 7:55am UTC](https://forum.xod.io/t/esp32-board-support/1489/5 "2018-12-07T07:55:28Z")

</div>

Hi.  
I make static port to 2 in pwm-write:

> ```
> ::pinMode(port, OUTPUT);
> ::analogWrite(2, val);
> emitValue<output_DONE>(ctx, 1);
> 
> ```

And have same error:

> C:\Temp\xod\_temp\_sketchbook2a0njU\xod\_1544168735833\_sketch\xod\_1544168735833\_sketch.ino: In function ‘void xod::xod\_\_gpio\_\_pwm\_write::evaluate(xod::xod\_\_gpio\_\_pwm\_write::Context)’:  
> C:\Temp\xod\_temp\_sketchbook2a0njU\xod\_1544168735833\_sketch\xod\_1544168735833\_sketch.ino:1108:5: error: ‘::analogWrite’ has not been declared  
> ::analogWrite(2, val);  
> ^
> 
> Error: exit status 1  
> Compilation failed.

Now i think maybe mistake that this is not analog port? Because there is no analog ports on ESP32.

---

<div class="post-metadata">

**Author:** ![gilyazov](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gilyazov](https://forum.xod.io/u/gilyazov)\
**Post date:** [December 7, 2018, 8:01am UTC](https://forum.xod.io/t/esp32-board-support/1489/6 "2018-12-07T08:01:08Z")

</div>

Now I create clean patch. Error on upload:

> Uploading compiled code to the board…  
> No new serial port detected.
> 
> usage: esptool write\_flash [-h] [–flash\_freq {keep,40m,26m,20m,80m}]  
> [–flash\_mode {keep,qio,qout,dio,dout}]  
> [–flash\_size FLASH\_SIZE]  
> [–spi-connection SPI\_CONNECTION] [–no-progress]  
> [–verify] [–compress | --no-compress]  
> […]  
> esptool write\_flash: error: argument : [Errno 2] No such file or directory: ‘C:\Temp\xod\_temp\_sketchbook2a0njU\xod\_1544169358487\_sketch/xod\_1544169358487\_sketch.esp32.esp32.esp32.partitions.bin’
> 
> Error: exit status 2  
> Error during upload.  
> Upload failed  
> Command `C:\Program Files\XOD IDE\resources\arduino-cli.exe --config-file=C:\Temp\arduino-cliFDxphp\.cli-config.yml upload --fqbn esp32:esp32:esp32:UploadSpeed=115200 --port COM13 --verbose -t C:\Temp\xod_temp_sketchbook2a0njU\xod_1544169358487_sketch` failed with code 1  
> Make sure the board is connected, the cable is working, the board model set correctly, the upload port belongs to the board, the board drivers are installed, the upload options (if any) match your board specs.

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [December 7, 2018, 8:30pm UTC](https://forum.xod.io/t/esp32-board-support/1489/7 "2018-12-07T20:30:18Z")

</div>

> [@gilyazov](#):
>
> I make static port to 2 in pwm-write:
> 
> > ```auto
> > ::pinMode(port, OUTPUT);
> > 
> > ```
> 
> ::analogWrite(2, val);  
> emitValue\<output\_DONE\>(ctx, 1);
> 
> > ```auto
> > 
> > ```
> 
> And have same error:

you must change the port in the node inspector., do not need to change the C ++ code

> [@gilyazov](#):
>
> Now i think maybe mistake that this is not analog port? Because there is no analog ports on ESP32.

the vast majority of the pins are analog-digital

> [@gilyazov](#):
>
> Now I create clean patch. Error on upload:
> 
> esp32:esp32:esp32:UploadSpeed=115200 --port COM13 --verbose -t

Change the speed to 921600, it could also be that XOD is not compatible

---

<div class="post-metadata">

**Author:** ![bradzilla84](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/bradzilla84/32/659_2.png) [@bradzilla84](https://forum.xod.io/u/bradzilla84)\
**Post date:** [December 7, 2018, 10:41pm UTC](https://forum.xod.io/t/esp32-board-support/1489/8 "2018-12-07T22:41:28Z")

</div>

Hi gilyazov  
I have been looking into the ESP32 for a while now and I have tried a lot of different things. Zod can compile the code perfectly fine but it seems to have issues uploading still. If you export the code into the Arduino IDE and compile and upload you should have less problems. That said some of the code that is used in incorporating external libraries into Zod does not seem to be compatible with the ESP32 compiler.  
The ESP32 libraries for Arduino are still very young and a lot of not been implemented yet.

---

<div class="post-metadata">

**Author:** ![tech-head](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tech-head](https://forum.xod.io/u/tech-head)\
**Post date:** [January 12, 2019, 6:07am UTC](https://forum.xod.io/t/esp32-board-support/1489/9 "2019-01-12T06:07:02Z")

</div>

Last I programmed ESP32 in Arduino IDE it’s core does not have a simple analogWrite(port,data) since it has I believe TWO different ways to emit an “analogue” signal on most pins as well as a pair of true DACs on two fixed pins. To use standard Arduino analogWrite() you’d need to create a library that emulates it using the most suitable PWM generation mode assuming you want PWM and not an actual DAC generated analogue voltage which an ESP32 can also produce!  
MCPWM is used to generate PWM for PWM controlled servo motors I believe that is accessed using sigmadelta prefixed functions.  
LED\_PWM is used to adjust LED brightness 8 high speed PWM channels and 8 low speed PWM channels  
using ledc prefixed functions.  
and DAC a pair of 8 bit digital to analogue converters fixed to two pins the PWM generators can be assigned to most of the GPIO pins.  
Because of the added functionality I suspect it was not deemed smart to try and force all Arduino IDE users to use a very restricted emulation of analogWrite() when the chip can do so much more.  
In the Arduino IDE with one of the ESP32 toolchains selected go into the Examples and look in the subfolder ESP32 and in the further subfolder AnalogOut for a some examples of LED\_PWM and MCPWM using sigmadelta functions

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [January 12, 2019, 6:30am UTC](https://forum.xod.io/t/esp32-board-support/1489/10 "2019-01-12T06:30:40Z")

</div>

I’ll read a little more about ESP32. Thanks 👍

---

<div class="post-metadata">

**Author:** ![rsstorm1](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/rsstorm1/32/1032_2.png) [@rsstorm1](https://forum.xod.io/u/rsstorm1)\
**Post date:** [March 13, 2019, 11:22pm UTC](https://forum.xod.io/t/esp32-board-support/1489/11 "2019-03-13T23:22:44Z")

</div>

I have the same problem with ESP32  
esptool write\_flash: error is this a problem with ESPTOOL? I do not have an idea anymore. The arduino IDE sketch works but XOD is much easier for me. I hope that the problem will be solved quickly
