Special developer offer: ESP32 (WIFI +BLE) wireless board

This is interesting. ESP32 is nice. Would it be possible to use MicroPython for ESP32 with the Macchina? https://github.com/micropython/micropython-esp32

I don’t see why not. But I’m not sure it supports OTA (Over The Air) updates yet so some sort of gateway in the Due will still be required to flash.

Anyone do anything cool with these boards yet? We’re super curious to hear what everyone is up to.

We’ve been getting some feedback on the design here and there, so we’ll keep track of suggestions in this thread. Feel free to contribute!

  1. Connect LED to a GPIO on the ESP32 instead of just constant +3.3V.
  2. Connect more of the pins from the two 10 pin headers to pins on the ESP32. (need to decide which ones next. There are more open ESP32 pins than pins on the 10 pin headers.

That first one is the most notable think I can think of off hand. Not having any feedback when first getting started slowed progress.

Ive been focused on getting my truck back on the road and just was involved with a big event so I haven’t even tried doing anything with this yet. It does light up when I install it but have not tried to program it or anything yet.

Guess I am waiting to see what you guys come up with since someone is already working on this and I need to get my butt in gear on the J1850 stuff.

Rodney

A post was split to a new topic: Finding projects that need help

are any more of these boards available? Or is there some other ESP32 the could be used?

When will this be available?

I wanted to follow up on this thread. Is this device now working with the M2 and providing usability?

I have one from the special purchase and never tried to use it.

Looking to try and set mine up so I can play with it while I work on building support for ELM/STN etc

Time for a quick update on this. We’re planning a production run of these here soon. Pretty much same functionality as “beta” units that went out so any code written for them will work on new boards. Only differences are the following physical changes:

I’m thinking a good starting point will be to load the AT Command code from Espressif, found here:

The default serial port will need to change (ESP32 has 2 UART ports) and here is a cool video showing how to set it up:

1 Like

Ok so I never really saw a “how to” for this board.

How does it work? Do I load a sketch on it through the M2 and then run it? Then that responds to commands from the M2?

I want to try getting it up and running so I can work with it while working on the ELM/STN compatibility stuff.

Since I will be rewriting some of the files I am looking at changing how M2RET prints to the serial port so it can easily be modified to talk through one of these units but want to test it out.

Let me rephrase my request.

I have the unit as it was delivered to me when I bought it.

I am assuming it has to have firmware loaded onto it and it appears I can use the M2 to do this?

What do I need to do to prepare the unit for use?

After properly prepared then I can use the AT commands with it to control it but looking for what I need to do to make that available.

For those of us that have never used something like this it isn’t obvious and nothing here that I follow tells me what i need to do. I don’t want to brick the ESP32 unit.

Thanks!

Thought I’d run through this again now that we are using M2 specific board definitions and ESP files have been updated many times. I’ll write out each step so everyone can follow along. Result will be compiling and flashing the ESP32 board through M2:

  1. Assuming you already have Arduino IDE installed (I am currently running latest version 1.8.5) , follow the Installation Instructions found here to install Espressif specific files to be able to use Arduino IDE to flask ESP32.

  2. After installing ESP files, modify the file “platform.txt” file found on your computer here:

C:\Users[USER]\Documents\Arduino\hardware\espressif\esp32\platform.txt

by replacing “default_reset” with “no_reset” in 2 places like this:

# ------------------------------

tools.esptool.upload.protocol=esp32
tools.esptool.upload.params.verbose=
tools.esptool.upload.params.quiet=
tools.esptool.upload.pattern="{path}/{cmd}" --chip esp32 --port "{serial.port}" --baud {upload.speed}  --before no_reset --after hard_reset write_flash -z --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size detect 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x1000 "{runtime.platform.path}/tools/sdk/bin/{build.boot}.bin" 0x10000 "{build.path}/{build.project_name}.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin"
tools.esptool.upload.pattern.linux=python "{path}/{cmd}" --chip esp32 --port "{serial.port}" --baud {upload.speed}  --before no_reset --after hard_reset write_flash -z --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size detect 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x1000 "{runtime.platform.path}/tools/sdk/bin/{build.boot}.bin" 0x10000 "{build.path}/{build.project_name}.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin"
tools.esptool.upload.network_pattern={network_cmd} -i "{serial.port}" -p "{network.port}" "--auth={network.password}" -f "{build.path}/{build.project_name}.bin"
  1. Plug ESP32 board into M2 with notches pointed toward the USB connector. Plug M2 into your computer via USB cable.

  2. Select “Macchina M2” from the board menu, and flash the following sketch:

int buttonState1 = 0;
int buttonState2 = 0;

void setup() {
  pinMode(DS2, OUTPUT);
  pinMode(DS3, OUTPUT);
  pinMode(XBEE_RST, OUTPUT);
  pinMode(XBEE_MULT4, OUTPUT);
  pinMode(Button1, INPUT);
  pinMode(Button2, INPUT);
  SerialUSB.begin(115200);
  Serial.begin(115200);
}

char rx_byte = 0;

void loop() {
  if (SerialUSB.available() > 0) {
    rx_byte = SerialUSB.read();
    Serial.write(rx_byte);
  }
  if (Serial.available() > 0) {
    rx_byte = Serial.read();
    SerialUSB.write(rx_byte);
  }

  buttonState1 = digitalRead(Button1);

  if (buttonState1 == LOW) {
    digitalWrite(DS2, LOW);
    digitalWrite(XBEE_RST, LOW);
  } else {
    digitalWrite(DS2, HIGH);
    digitalWrite(XBEE_RST, HIGH);
  }

  buttonState2 = digitalRead(Button2);

  if (buttonState2 == LOW) {
    digitalWrite(DS3, LOW);
    digitalWrite(XBEE_MULT4, LOW);
  } else {
    digitalWrite(DS3, HIGH);
    digitalWrite(XBEE_MULT4, HIGH);
  }
}
  1. Open a the Serial monitor. Press and HOLD the SW2 button (closest to the M in Macchina). The Yellow LED should come on. Then press and RELEASE SW1 button (closest to the A in Macchina). The Red LED should come on. You should see something similar to the following on the Serial terminal:
rst:0x1 (POWERON_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download

This means the ESP32 board is ready to flash!

  1. Select “ESP32 Dev Module” from the boards menu. Set flash mode to DIO, Flash Frequency to 40Mhz, Set Flash size to 2MB, upload speed to 115200 and debug level to None.

  2. Select an example from File -> Examples -> Examples for ESP32 Dev Module. For this example, we’ll try: WIFI -> WifiScan.

  3. Hit the Upload button. After a few seconds you’ll see:

Leaving...
Hard resetting...
  1. Close the Serial monitor window. Change the board to “Macchina M2”. Open the Serial monitor again. Press SW1" to reset the ESP32 module. Soon you will see a list of all of the hotspots near you.

There are tons of cool code examples for the ESP32 board, including BLE.

Next steps will be to stream-line the above process where you don’t need to press any buttons on M2 to flash the ESP32. @captain_morgan did this above by sending commands to M2 via Serial terminal to put ESP32 into Bootload mode. We’ll try to replicate that here soon.

3 Likes

Thank you! I will certainly be doing this shortly!

Ok, at step 5 it was already showing my local wifi spots so I have to assume the board was already programmed?

Everything else works fine.

I am assuming that step 6-7-8 are actually uploading to the unit?

So I should be good to go? So when I want to flash a new program to the ESP32 I just need to load that sketch into the M2 and go from there I am assuming?

Ah yes, we shipped those with the WifiScan sketch loaded. You should be good to go now.

As for AT command code, found here, you’ll need to change the default UART port on the ESP32, compile and flash to M2.

Which UARTport are we using with the M2? I am assuming that code is firmware for the ESP32 and we would just use the Serial.Print command then to talk to it similar to the flashing script?

Rodney

That is correct - XBEE socket is connected to first serial port.

Is anyone currently working with this module to make it work with M2RET?

I know someone had discussed doing something with it.

Otherwise I am going to start looking into setting up the M2 to work with this… Going to try burning a new firmware into my ESP unit and talking to it. As part of my ELM/STN upgrade I will get something running with this first.

Depends on how the ESP unit is seen by the other side. If it is seen as a COM port SavvyCAN should work without any modifications.

Also, can the notes mentioned here be added to the guide in the Communications section? Can have a sub section for bT and WIFI devices or just list out the ESP32 as one of the options since it has both BT and WiFi

Rodney

@josh for the uart question I was refering was this one:

Which ESP32 UART port did you mean needs to be switched and what should it be switched to before compiling?

I may begin tinkering with this this weekend and not sure what was meant. I am assuming the ESP has multiple UART ports and the XBEE port is not connected to the default ESP32 UART and needs to be switched in their code before compiling? Assuming so what port is being used?

The ESP32 has lots of possible functionality available with it. Sort of like having a second Arduino onboard.

Rodney