ESP32-C3-WROOM-02 from Mouser. Using PlatformIO on VSCode.

Almidev
Posts: 6
Joined: Sat Jul 02, 2022 5:52 pm

ESP32-C3-WROOM-02 from Mouser. Using PlatformIO on VSCode.

Postby Almidev » Sat Jul 02, 2022 6:59 pm

Good morning,

I have ESP32-C3-WROOM-02 that I took from Mouser. I based myself on the following datasheet: https://www.mouser.fr/datasheet/2/891/E ... 295851.pdf

I have PlatformIo installed base on VSCODE and I configure my installation with the following ini file.

Code: Select all

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
I will try from this information to see what I was able to make work successfully and what didn’t work for me.

First, on the hardware level, I looked at the power supply, 5V to 3V3 from an LDO and capacitors. There are no fluctuations so we can move on.

3V3 leg with positive voltage of 3V3.
GND leg with GND feed connection.
IO19 tab connected to D+ USB.
IO18 tab connected to D- USB.
I use the JTAG/USB block.

I can flash my card.

Code: Select all

Checking size .pio\build\esp32-c3-devkitm-1\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   3.1% (used 10268 bytes from 327680 bytes)
Flash: [==        ]  16.4% (used 215456 bytes from 1310720 bytes)
Building .pio\build\esp32-c3-devkitm-1\firmware.bin
esptool.py v3.3
Creating esp32c3 image...
Merged 2 ELF sections
Successfully created esp32c3 image.
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: COM6
Uploading .pio\build\esp32-c3-devkitm-1\firmware.bin
esptool.py v3.3
Serial port COM6
Connecting...
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 60:55:f9:85:9c:80
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00047fff...
Flash params set to 0x022f
Compressed 12528 bytes to 9002...
Writing at 0x00000000... (100 %)
Wrote 12528 bytes (9002 compressed) at 0x00000000 in 0.3 seconds (effective 347.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.1 seconds (effective 403.0 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 585.3 kbit/s)...
Hash of data verified.
Compressed 227280 bytes to 125727...
Writing at 0x00010000... (12 %)
Writing at 0x0001b0e1... (25 %)
Writing at 0x00021c62... (37 %)
Writing at 0x0002873e... (50 %)
Writing at 0x0002e9bb... (62 %)
Writing at 0x00034847... (75 %)
Writing at 0x0003c36c... (87 %)
Writing at 0x0004338a... (100 %)
Wrote 227280 bytes (125727 compressed) at 0x00010000 in 3.1 seconds (effective 588.4 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
========================================================================================= [SUCCESS] Took 20.01 seconds =========================================================================================
My first functional program was to test the adhequation between PlatformIo and Paw Numbers. Example here:

Code: Select all

#include <Arduino.h>

// GOIO REEL
#define IO0 0
#define IO1 1
#define IO2 2
#define IO3 3

#define IO4 4
#define IO5 5
#define IO6 6
#define IO7 7
#define IO8 8
#define IO10 10


#define led IO0

unsigned long prevTempo;
const long tempo = 1000;

bool flagLed = false;

void setup() {
  pinMode(led, OUTPUT);
}

void loop() {

  unsigned long currTempo;

  currTempo = millis();

  if (currTempo - prevTempo >= tempo) {
    prevTempo = currTempo;
    
    if(flagLed) {
      flagLed = false;
    }
    else {
      flagLed = true;
    }
  }

  digitalWrite(led, flagLed);
}
All legs functioned correctly by replacing the selected IO0 âr IO and having a led and its resistance connected to the ESP.

Now we come to what did not work for me at all. Two cases important enough in my projects for me to look for many hours in vain.

I have resolved to talk to you about it in order to find a way out.

Believe me, my goal is not to bother you, but to help me find a solution on programming and hardware if necessary.

Do some Serial.println("Ok"); and see if the card answers me. Alas, the screen remains empty!

I typed a rather basic code that allows me to wake up cards such as:

Code: Select all

#include <Arduino.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("OK");
  delay(1000);
}
When I open my termonal I see this without seeing my "Ok". Something has to happen.

Code: Select all

> Executing task in folder FIRST-ESP32C3: C:\Users\Almi Direct\.platformio\penv\Scripts\platformio.exe device monitor <

--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Miniterm on COM6  9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---


Would it be possible to know why it is in the wake?

I decided, since I had access to the pins to make a communication with an LCD screen on I²C. Screen I have already used on another ESP successfully through a level shifting.

I know that the address is good, my communication path is ok, the data transferred also without problem through my class. It’s debugged, functional, so we’ll look elsewhere.

Again, I see no trace of my I²C frames.

At the lcd level, we access a transfer of the address, we also return the timing and I did not notice on other cards of particular concern. Here’s the simple try code I use everywhere.

Code: Select all

#include <Arduino.h>
#include "LcdMidas.h"

#define ADDR_LCD 0x3C
#define NB_COLUMN 16
#define NB_LINES 2



LcdMidasI2c lcd;

void setup() {

  // put your setup code here, to run once:
  lcd.begin(ADDR_LCD, NB_COLUMN, NB_LINES);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Hello World");

}

void loop() {
  // put your main code here, to run repeatedly:

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Hello World");
  delay(100);
}
When I saw that it was nothing, I looked at my pinoches with an oscilloscope. And no trace comes out, not a single frame I²C. All the legs are in the high state with no other form of trial.

Again, I’d like a little help moving forward.

I also looked at the idea of using Espressif-idf directly in VSCode. I knew how to install it, I looked a little. But I didn’t dwell on it because it was coded in Python and I’m not a python specialist. I would prefer to stay on platformIO to remain compatible with all my projects. But in the absence of being able to use it, I have cards that are not usable as is.

I am listening to you, and thank you in advance for taking the time to read me.

lbernstone
Posts: 831
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32-C3-WROOM-02 from Mouser. Using PlatformIO on VSCode.

Postby lbernstone » Sun Jul 03, 2022 5:11 am

The console defaults to UART connection. Add this to your platformio.ini to enable USBCDC

Code: Select all

build_flags= -DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1

Almidev
Posts: 6
Joined: Sat Jul 02, 2022 5:52 pm

Re: ESP32-C3-WROOM-02 from Mouser. Using PlatformIO on VSCode.

Postby Almidev » Sun Jul 03, 2022 10:41 am

First of all, thank you very much for that answer. It allowed me to go a little bit further.

So I confessed to my platformio.ini the configuration the information indicated in the answer. And it works perfectly. That’s what was missing.

So I’m going to add a little bit of information to my code.

Code: Select all

/**
 * To enable serial.print() return on the ESP32-C3, you must add the following code to platformio.ini
 * build_flags=
 *  -DARDUINO_USB_MODE=1
 *  -DARDUINO_USB_CDC_ON_BOOT=1
 * */

#include <Arduino.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("OK");
  delay(1000);
}
So I’m sure I won’t forget it afterwards.

Code: Select all

> Executing task in folder FIRST-ESP32C3: C:\Users\Almi Direct\.platformio\penv\Scripts\platformio.exe device monitor <

--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Miniterm on COM6  9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
OK
OK
OK
OK
I’m glad to have some feedback. I can make progress.

Now all that remains is to solve the I²C problem and how to reassign the pins to the I²C. The datasheet says that any leg can be declared SDA and SCL. I tried from Wire.begin(Addr, SDA, SCL) without success.

Almidev
Posts: 6
Joined: Sat Jul 02, 2022 5:52 pm

Re: ESP32-C3-WROOM-02 from Mouser. Using PlatformIO on VSCode.

Postby Almidev » Mon Jul 04, 2022 10:25 am

Good morning,

The night wears advice, as they say in my country.

So I undertook to use what is indicated here: https://espressif-docs.readthedocs-host ... o_mux.html

This put me on the trail of the following code:

Code: Select all

Wire.setPins(2,3);
Wire.begin(0x3C);
Wire.beginTransmission(_addr);
Wire.write(0x00);
Wire.write(0x00);
Wire.endTransmission();
delay(1);

Wire.begin(0x3C);
Wire.beginTransmission(_addr);
Wire.write(0x00);
Wire.write(data);
Wire.endTransmission();
delay(1);
Without success!

but when I looked further, I typed the following code:

Code: Select all

Wire.begins(2,3);
Wire.begin(0x3C);
Wire.beginTransmission(_addr);
Wire.write(0x00);
Wire.write(0x00);
Wire.endTransmission();
delay(1);

Wire.begin(0x3C);
Wire.beginTransmission(_addr);
Wire.write(0x00);
Wire.write(data);
Wire.endTransmission();
delay(1);
And that started to work.

However, it is ambiguous. We are supposed to use setPins(SDA, SCL) and we end up using begin(SDA, SCL), which relies internally on setPins().

This would mean that the documentation is not correct and that PlatformIo itself is not correct.

First of all, I accept this amendment because it allows me to continue my development. But I still suggest that we define the two functions so that the ambiguity is removed in the future.

In any case, I put my solution here, see what I wrote above. Thank you. I leave the subject open to allow others to add a more perennial solution.

Who is online

Users browsing this forum: Google [Bot] and 30 guests