How to install Esp32 for Arduino and Visual Micro

Esp32 please note:-

1) Silicon Labs CP210 v10.x usb driver does not work. It has been reported. Please use the v6.x silicon labs usb driver which should be available via 'device manager > cp210 > change driver'

2) Serial Monitor DTR and RTS will be off by default for the ESP32 boards. If they are switched on the Serial will not work, switching them Off again will allow the Serial Monitor to work.

Generally you can always follow standard Arduino IDE install guides for Visual Micro. This page is just a little extra help for items not support by the Arduino IDE...

The Esp32 web site provides a more advanced install but DFRobot provide a simple esp32 installation for Arduino using the standard Arduino board manager. Add the following url to the board support packages in the visual micro IDE location window or follow the guide

Arduino IDE Board Manager Guide

Esp32 Debug Tips (applies only when the tool bar is set to Debug, not Release)

  • WiFi debug is not yet fully supported. Serial debug is recommended even when using WiFi upload.
  • To use Serial debug alongisde wifi upload set the "vMicro>Debugger>Local Port" to the COM port for the Serial, set "vMicro>Debugger>Remote Port" to Serial.
  • If you code already uses Serial at a speed other than 115200 then set the LocalSpeed and RemoteSpeed properties to the speed your code uses.
  • If Serial debug is paused in a breakpoint when OTA upload is attempted it might be required to send the char 'c' via the Serial/Debug monitor to force the mcu to continue. It should then detect the waiting OTA request.

NOTE: There is a full OTA code example below.

NOTE: Make sure the Serial Monitor DTR and RTS checkboxes are OFF when using esp32 devices alongside Serial, otherwise you will find youself pressing the reset button quite often :)

NOTE: December 2016 - WiFi (with OTA) Debug Beta has been released. Update of variables during debug is not yet supported. Uses UDP messaging. Breakpoints and debugging auto-deactivates when a debug session ends. To upload with USB and debug with WiFi set the "Remote Transport" project property to "Udp" and the "Local Port" to the IpAddress. For OTA devices there is no configuration required except to switch the tool bar from "Release" to "Debug". It is also recommended to switch on "vMicro>Debugger>Full Speed".  BETA - Do not use the WiFi debugger with remote devices that can not be manually reset.

Tip: If new hardware is installed outside of visual micro (ie: in the arduino ide) then click 'tools>visual micro>reload toolchains' or restart Visual Micro

 

SPIFFS File System

To publish a file system to an ESP32 create a sub folder called "data" below any Arduino project and then click "vMicro>Publish Server Data Files".

note: This feature currently ignores the solution explorer and uploads all files and folders that exist in the "[project]\data" sub folder.

tip: The Board options provide various SPIFFS settings. Read more

 

Serial Exception Reporting

Visual Micro provides flexible options that enable exceptions and stack addresses to be resolve back to source code. A small ! icon apears when an exception is discovered in the serial monitor. Clicking the icon produces clickable error and output reports inside the ide as shown below.

...

 

 

OTA with auto-discovery

"Apple Bonjor for Windows" must be installed for IP address auto discovery to work. This will automatically look for IP addresses on the local network.

If an upload password has been set in the espcode, a password dialog will appear when OTA begins

OTA configuration is automatic. The image shows two esp boards have been discovered using the Apple Bonjour Service.

 

OTA without requiring Apple Bonjour auto-discovery (optional)

Ip addresses can be manually entered into the Visual Micro ports (serial) list when the combo box is in the collapsed state. After entering the Ip address, press the ENTER key to confirm.

mDNS properties such as {network.port} will not be available when an ip address is entered manually (and the address has not been discovered by the Bonjour Service)

Instead of using mDNS a local project "board.txt" file can be added to the project.

The image shows the project's board.txt in the lower editor. Apple Bonjour or IP Auto-Discovery is not required. You can manually enter an ip address and press the ENTER key. 

 

Visual Micro Pro users can use board.txt in the project folder to provide overrides (instead of using Bonjour)

Board.txt password required example:-

 # local project board.txt overrides
  network.password=123
  network.auth_upload=yes
  network.port=8266

Board.txt password not required example:-

 # local project board.txt overrides
  network.port=8266

 

Full working ESP32 OTA Code Example:-

Tested with Esp OTA code (esp core v2.3.0) :-


#include <ArduinoOTA.h>
bool ota_started;

const char* ssid = "YOUR_ROUTER_SSID";
const char* password = "YOUR_ROUTER_WIFI_PASSWORD";
void setup() 
{
Serial.begin(115200);
ConnectToWiFi();
StartOTAIfRequired();
PrintWifiStatus();
Serial.println("Connected to wifi");
}
void loop() 
{
//Serial.println("Hello world");
HandleOTA();
}

void ConnectToWiFi()
{

Serial.println("Booting");
WiFi.mode(WIFI_STA);
Serial.println("Mode set");
WiFi.begin(ssid, password);
Serial.println("Begin complete");
}
void HandleOTA()
{
StartOTAIfRequired();
ArduinoOTA.handle();
}
void StartOTAIfRequired()
{
if (ota_started)
return;
// Port defaults to 8266
// ArduinoOTA.setPort(8266);
// Hostname defaults to esp8266-[ChipID]
//if (ArduinoOTA.getHostname() && ArduinoOTA.getHostname().length())

// No authentication by default
ArduinoOTA.setPassword((const char *)"123");
ArduinoOTA.onStart([]() {
Serial.println("OTA Start");
});
ArduinoOTA.onEnd([]() {
Serial.println("\nOTA End");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r\n", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
ArduinoOTA.begin();
ota_started = true;
delay(500);

}
void PrintWifiStatus() 
{
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
//using dhcp? wait for ip or ip not set!
if (WiFi.localIP()[0] == 0)
{
Serial.println("DHCP: Waiting for IP Address ...");
while (WiFi.localIP()[0] == 0)
{
yield();
}
}
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
//Serial.println(WiFi.status());
}