ESP32 Easy short tutorial
Introduction
My ESP32 is 32WROOM-32
- https://docs.cirkitdesigner.com/component/61475118-b098-4ce5-a041-f984abcb9607/esp32-wroom
- https://www.az-delivery.de/en/products/esp32-developmentboard
- (https://www.mouser.com/datasheet/2/891/esp-wroom-32_datasheet_en-1223836.pdf)
-
Front side
-
Back side and connections
-
Tx light blinks when serial connection transfers data
Leds:
- Tx led blinks when transmitting data.
Pull Up Resistors
Enable pull up:
pinMode(13, INPUT_PULLUP); // Enable built-in pullup on pin 13
Pull up resistors are between a digital input pin and the VCC. Two main purposes:
- Avoids issues with floating inputs.
- The default "ON" state for inputs like buttons and switches which actively pull the pin low. The pull up resistor keeps the circuit reading high until the button grounds the pin.
Some pins do not have pullup resistors:
- GPIO34
- GPIO35
- GPIO36
- GPIO39
Others do:
Pin Name | GPIO Number | Pull Up? |
---|---|---|
GPIO0 | 0 | Yes |
GPIO2 | 2 | Yes |
GPIO4 | 4 | Yes |
GPIO5 | 5 | Yes |
GPIO12 | 12 | Yes |
GPIO13 | 13 | Yes |
GPIO14 | 14 | Yes |
GPIO15 | 15 | Yes |
GPIO25 | 25 | Yes |
GPIO26 | 26 | Yes |
GPIO27 | 27 | Yes |
GPIO32 | 32 | Yes |
GPIO33 | 33 | Yes |
For pins without built-in pull ups, or in output applications needing precise levels, you can add external pull up resistors. See the references for more information.
References:
Serial and Tx blink
Check that ESP32 works
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("luntti.net");
delay(500);
}
This should write a text to serial monitor every 0.5 secs and blink the Tx led at the same time.
Blink
Blink an internal led
No:(
Blink a led
-
Blinking led. It is connected to pin18 and GND. Note that the (current limiting) resistor resistor is missing.
void setup() {
pinMode(18, OUTPUT);
}
void loop() {
digitalWrite(18, LOW);
delay(1000);
digitalWrite(18, HIGH);
delay(1000);
}
Wifi
Bluetooth
CANbus TJA1051 T/3
Adafruit T/3 should mean that it is 3.3V compatible. All TJA1051 variants are not.
Connections
Note that Rx pin need not to be connected while uploading programs into ESP32.
Pins
- Vcc: the same power as the logic level of your microcontroller (Arduino: 5V, ESP32 3.3V)
- GND - common ground for power and logic.
- RX - CAN receive/input. Connect to ESP32's RX. Do not connect when uploading.
- TX - CAN transmit/output. Despite sharing the 'RX' and 'TX' name with UART, they're not at all the same interface. Connect to ESP32's TX.
- CANh
- CANl
CarCluster
esp32_can library
ESP32-TWAI-CAN library
Install the library using Arduino IDEs library tools.
https://github.com/handmade0octopus/ESP32-TWAI-CAN
References
References
- Adafruit https://learn.adafruit.com/adafruit-can-pal
- Datasheet https://www.nxp.com/docs/en/data-sheet/TJA1051.pdf
Linux tutorial
Great linux tutorial: https://curiousstuff.eu/post/how-to-blink-the-damn-esp32-built-in-led/