Arduino for ESP32

Moderator: ESP_flying_raijin

User avatar
ESP_Me-no-dev
Posts: 80
Joined: Mon Jan 04, 2016 6:30 pm

Arduino for ESP32

Postby ESP_Me-no-dev » Thu Oct 06, 2016 2:36 pm

Hello everyone!
I'm glad to announce to you that an initial Arduino environment for the ESP32 has been uploaded HERE.
Not everything is working yet, you can not get it through package manager, but you can give it a go and help us find bugs :)
The framework can also be downloaded as component in an IDF project and be used like that.
Things that "should" work:
  • pinMode
  • digitalRead/digitalWrite
  • attachInterrupt/detachInterrupt
  • Serial (global Serial is attached to pins 1 and 3 by default, there are another 2 serials that you can attach to any pin)
  • SPI (global SPI is attached to VSPI pins by default and HSPI can be attached to any pins)
  • Wire (global Wire is attached to pins 21 and 22 by default and there is another I2C bus that you can attach to any pins)
  • WiFi (about 99% the same as ESP8266)
WiFiClient, WiFiServer and WiFiUdp are not quite ready yet because there are still some small hiccups in LwIP to be overcome.
You can try WiFiClient but you need to disconnect the client yourself to be sure that connection is closed.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Arduino for ESP32

Postby kolban » Fri Oct 07, 2016 4:32 am

I tested the recipe tonight and it worked perfectly for me first time. Major kudos to you and congratulations!!! I ran it on Arduino IDE 1.6.11 on an Ubuntu Linux platform running on VirtualBox on Windows 10 using DevKitC as the board. I tested a "Hello World" to the Serial output in a loop and it behaved as advertized. Just perfect.

I noticed that the instructions here said to run under Arduino IDE 1.6.9:

https://github.com/espressif/arduino-esp32

Is that a hard requirement? (I ran under 1.6.11 as that is what I had to hand and didn't see any adverse side effects).

Would you be able to talk about what "get.py" does? I think it is downloading an xtensa tool chain and a set of pre-compiled ESP-IDF.

Looking forward to studying it further. Congrats again.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
ESP_Me-no-dev
Posts: 80
Joined: Mon Jan 04, 2016 6:30 pm

Re: Arduino for ESP32

Postby ESP_Me-no-dev » Fri Oct 07, 2016 7:28 am

Hey Neil :) Says 1.6.9 because that is the last version I have here and did not put much thought into it yet.
Will test newer versions and will update the tools we have for arduino to cover the new stuff as well.
Currently get.py only downloads the toolchain and nothing more. Will do more things in the future :)
Keep in mind that you can clone the repository to a local IDF project's components folder and build everything from source using your current toolchain and esp-idf head

MarsWarrior
Posts: 6
Joined: Fri Nov 20, 2015 8:34 pm

Re: Arduino for ESP32

Postby MarsWarrior » Sat Oct 08, 2016 11:13 am

Nice development. Will try this with my DevC kit.

Questions:
  • Does it run under Windows? Or is this version only for Linux?
  • Regarding the pin-map:
    Image
    • Thanx for pointing out the default I2C pins. I couldn't find them in the documentation.
    • I also got the VSPI MOSI wrong from other documentation. I thought that would be IO20, which I could not locate...
    • Could you elaborate on the pu/pd pins? I know these have a weak internal pu/pd, but does this mean that you don't need external resistors, as opposed to the ESP8266?
Last edited by MarsWarrior on Sat Oct 08, 2016 3:09 pm, edited 2 times in total.

blackie
Posts: 1
Joined: Sat Oct 08, 2016 12:24 pm

Re: Arduino for ESP32

Postby blackie » Sat Oct 08, 2016 1:21 pm

Nice!

I tried it with Arduino IDE 1.6.11 on OS X 10.11.6, and it is working as expected. I am using the ESP32_Core_board_V2 dev board from Adafruit.

a2retro
Posts: 56
Joined: Tue Dec 01, 2015 3:09 am

Re: Arduino for ESP32

Postby a2retro » Sat Oct 08, 2016 4:58 pm

Hi Folks, looking for some direction on how to remap pins under Arduino IDE for esp functions.

"Serial (global Serial is attached to pins 1 and 3 by default, there are another 2 serials that you can attach to any pin)"

For example I have my programmer on pins 1 and 3 and would like to attach a camera to the second serial port.

I am digging through Arduino files but any pointers appreciated.

Edit: Investigation

From - esp32-hal-gpio.h
//GPIO FUNCTIONS
#define INPUT 0x01
#define OUTPUT 0x02
#define PULLUP 0x04
#define INPUT_PULLUP 0x05
#define PULLDOWN 0x08
#define INPUT_PULLDOWN 0x09
#define OPEN_DRAIN 0x10
#define OUTPUT_OPEN_DRAIN 0x12
#define SPECIAL 0xF0
#define FUNCTION_0 0x00
#define FUNCTION_1 0x20
#define FUNCTION_2 0x40
#define FUNCTION_3 0x70
#define FUNCTION_4 0x80

So for the default second serial port it would seem I need to

pinMode(9,FUNCTION_4) # U1RXD
pinMode(10,FUNCTION_4) # U1TXD

So in order for the second serial port to be accessible is it required to support SoftwareSerial library or can HardwareSerial support more then one port at the same time?

Edit2: I expect I am not doing things correctly but here goes

Code: Select all

HardwareSerial cameraconnection = HardwareSerial(1);
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);

void setup() {
  pinMode (9, FUNCTION_4); // U1RXD 
  pinMode (10, FUNCTION_4); // U1TXD
  cameraconnection.begin(38400,SERIAL_8N1,10,9);
}
Things go south with the first pinMode setting - Looks like some kind of software reset to me.

samjulien
Posts: 3
Joined: Sat Oct 08, 2016 10:25 pm

Re: Arduino for ESP32

Postby samjulien » Sat Oct 08, 2016 10:41 pm

Thanks for doing this.

I'm running Windows 8.1 -- I followed the instructions on getting set up and receiving the following when trying to upload a blinking light sketch:

Code: Select all

Traceback (most recent call last):

  File "C:\Program Files (x86)\Arduino\hardware\espressif\esp32/tools/esptool.py", line 25, in <module>

    import serial

ImportError: No module named serial

exit status 1
Error compiling for board ESP32 Dev Module.
Any ideas?

papagenic
Posts: 1
Joined: Mon Oct 10, 2016 9:47 am

Re: Arduino for ESP32

Postby papagenic » Mon Oct 10, 2016 9:55 am

Hello,

I noticed the PWM stuff has been removed from that release. Any particular reason for this?

Rgrds

User avatar
ESP_Me-no-dev
Posts: 80
Joined: Mon Jan 04, 2016 6:30 pm

Re: Arduino for ESP32

Postby ESP_Me-no-dev » Mon Oct 10, 2016 10:01 am

@a2retro You can attach all 3 UARTs to any pins you like (almost). Pins 9 and 10 are tied to your flash chip, so I would not use them for Serial. You can check esp32-hal-uart.h if you want C style api to the serial or just use HardwareSerial Serial1(1); and then Serial1.begin(baudrate, SERIAL_8N1, rxPin, txPin); to start and use it like any other Arduino Serial

@samjulien You need to install pyserial for python "pip install serial"

@papagenic It's not added yet rather than removed ;) Will add as soon as the driver is ready.

User avatar
ESP_Me-no-dev
Posts: 80
Joined: Mon Jan 04, 2016 6:30 pm

Re: Arduino for ESP32

Postby ESP_Me-no-dev » Mon Oct 10, 2016 10:11 am

@MarsWarrior default I2C pins are defined only in software. There are no default pins for I2C actually and they are all attached through the pin matrix. Me and Ivan have decided to use those particular ones as they are attached to the gpio power and do not have any other major Arduino uses (like ADC).
Decision to make VSPI to be the default SPI bus was made in a similar fashion :) HSPI runs as JTAG by default and it's nice to have it there for guys that want to debug deeper. HSPI pins are also attached through the matrix so they do not really need to be attached to those pins, but it's nice for clarity.

Who is online

Users browsing this forum: No registered users and 35 guests