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

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

Correct, according to the repo readme:

The ESP32 Board sends AT commands through UART1 by default.

GPIO16 is RXD
GPIO17 is TXD
...

We’ve got UART0 from ESP32 connected to M2 as seen on schematic, so you’ll need to change this in the ESP32 AT command code before compiling and flashing to ESP32 board.

Ok, was having issues flashing the ESP32 but figured it out…

Have to hold the first button WHILE pressing then releasing the second button.

I was pressing the first button, then pressing the second button and it wasn’t doing it.

I flashed the CHIPID sketch to it first, got that to print out then flashed the wifiscan back in.

So the instructions are correct but just have to make sure you hold the 1st button while pressing the second one.

I messed around with the ESP32- AT library for a little while… I don’t believe it will work with Arduino-ESP32 as is. It appears to be missing a bunch of libraries to make it work.

Looks like the console will have to be disabled but not sure how to do that either. MAY have to manually change it to put the console on UART1 or something so it doesn’t conflict with the UART AT datastream.

I posted a message on their forum asking for further help with this so shall see what they say.

Rodney

Glad you got the flashing to work. Regarding ESP32-AT library, compiling the esp32-at is the same as compiling any other project based on the ESP-IDF.

Take a look at the readme for details. In other words, you won’t be able to compile and flash with Arduino IDE.

Ok, can the ESP-IDF be used with the Macchina ESP32 ?

I would think if there is a way to compile the binaries offline then upload the binary via the Arduino IDE that could also work?

Sorry for all the questions but this hardware is new to me and I am learning…

One other thing… If we use the sketch posted here would it be possible to use that as a passthrough and just use the ESP-IDF to program normally? Just have to hit the buttons the same as if we were flashing via Arduino?

Rodney

Rodney & Josh
Now that i have completed the changes to M2RET ADC/DMA i am now able to get back to the library i started for the M2Wifi
Proposed functions:

  1. Detect that the M2Wifi is actually installed (completed)
  2. Detect the revision of the sketch installed in the WIFI module if different Update from M2 memory. This is transparent to the User. (25% complete)
  3. Announce to the wold that the M2Wifi is available as WIFI or BTE. Important to have security in place
  4. Initial Basic support for BTE interpret local AT configuration commands & pass through any appropriate AT commands to the M2
  5. Act as a pass through either WIFI or BTE to M2RET from SavyCan & future sketches/software
  6. Long term add support to M2Wifi module to support OTA sketch updates to M2Wifi & possibly Macchina M2. ( Bold move )

Appreciate any comments
Tony

1 Like

@t_doust
Are you using the ESP32-AT library installed on the ESP32?

Assuming your using that library how did you flash it and how are you progressing with the library? Are you planning on wrapping all of the AT commands within a sketch then call the functions required from M2RET as function calls from the new library?

I planned on building a new set of functions to setup and redirect the SerialUSB calls to an XBEE connected device then change all of the SerialUSB calls to point to those new functions. This would allow redirection to the Xbee device.

This will allow for other devices to be added easily if other BT or WiFi devices are added or a cellular device.

I also want it separate because when i do the ELM/STN stuff I want to from the start use the new functions with them.

So I guess if your already working on the library I can start making the changes to M2RET.

Rodney

I am able to access the M2 via minicom in a Ubuntu VM and I am able to compile the program but it times out when it tries to flash from ESP-IDF. When I say I can access the M2 I mean I am seeing the Wifi scan the same as I did with Putty on windows.

I just tried to do the hello_world example to try and see if I can flash the ESP32 from linux using the “flash sketch” and the ESP-IDF function. Of course I hit the flash sequence, saw the response on the screen and then exited the terminal before trying to flash.

I will try seeing if I can compile the ESP32-AT project as well at a later time and give @t_doust or @josh a chance to respond if I am on the right track.

Hopefully it is just a simple thing I am missing.