Skip to content

Commit 45453f6

Browse files
committed
board: esp32 use nodemcu-32s and LED_BUILTIN for better compatibility
Also update motor parameters and use BOARD_INIT to setup i2c pins and clock. Signed-off-by: Thomas Chou <[email protected]>
1 parent 9164104 commit 45453f6

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

config/custom/esp32_config.h

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2021 Juan Miguel Jimeno
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.esp32
4+
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
77
// http://www.apache.org/licenses/LICENSE-2.0
@@ -15,7 +15,7 @@
1515
#ifndef ESP32_CONFIG_H
1616
#define ESP32_CONFIG_H
1717

18-
#define LED_PIN 2 //used for debugging status
18+
#define LED_PIN LED_BUILTIN //used for debugging status
1919

2020
//uncomment the base you're building
2121
#define LINO_BASE DIFFERENTIAL_DRIVE // 2WD and Tracked robot w/ 2 motors
@@ -59,14 +59,14 @@ ROBOT ORIENTATION
5959
#define MOTOR_OPERATING_VOLTAGE 12 // motor's operating voltage (used to calculate max RPM)
6060
#define MOTOR_POWER_MAX_VOLTAGE 12 // max voltage of the motor's power source (used to calculate max RPM)
6161
#define MOTOR_POWER_MEASURED_VOLTAGE 12 // current voltage reading of the power connected to the motor (used for calibration)
62-
#define COUNTS_PER_REV1 550 // wheel1 encoder's no of ticks per rev
63-
#define COUNTS_PER_REV2 550 // wheel2 encoder's no of ticks per rev
64-
#define COUNTS_PER_REV3 550 // wheel3 encoder's no of ticks per rev
65-
#define COUNTS_PER_REV4 550 // wheel4 encoder's no of ticks per rev
62+
#define COUNTS_PER_REV1 450 // wheel1 encoder's no of ticks per rev
63+
#define COUNTS_PER_REV2 450 // wheel2 encoder's no of ticks per rev
64+
#define COUNTS_PER_REV3 450 // wheel3 encoder's no of ticks per rev
65+
#define COUNTS_PER_REV4 450 // wheel4 encoder's no of ticks per rev
6666
#define WHEEL_DIAMETER 0.0560 // wheel's diameter in meters
6767
#define LR_WHEELS_DISTANCE 0.224 // distance between left and right wheels
68-
#define PWM_BITS 10 // PWM Resolution of the microcontroller
69-
#define PWM_FREQUENCY 20000 // PWM Frequency
68+
#define PWM_BITS 12 // PWM Resolution of the microcontroller
69+
#define PWM_FREQUENCY 100 // PWM Frequency
7070

7171
// INVERT ENCODER COUNTS
7272
#define MOTOR1_ENCODER_INV false
@@ -198,8 +198,8 @@ ROBOT ORIENTATION
198198
#define LIDAR_SERVER { 192, 168, 1, 100 } // eg IP of the desktop computer
199199
#define LIDAR_PORT 8889
200200
#define BAUDRATE 115200
201-
// #define SDA_PIN 21 // specify I2C pins
202-
// #define SCL_PIN 22
201+
#define SDA_PIN 21 // specify I2C pins
202+
#define SCL_PIN 22
203203
#define NODE_NAME "esp32"
204204
// #define TOPIC_PREFIX "esp32/"
205205

@@ -218,7 +218,11 @@ const int16_t ADC_LUT[4096] = { /* insert adc_calibrate data here */ };
218218
// #define ECHO_PIN 32
219219
#define USE_SHORT_BRAKE // for shorter stopping distance
220220
// #define WDT_TIMEOUT 60 // Sec
221-
// #define BOARD_INIT sleep(5) // wait to begin IMU calibration
221+
#define BOARD_INIT { \
222+
Wire.begin(SDA_PIN, SCL_PIN); \
223+
Wire.setClock(400000); \
224+
}
225+
// #define BOARD_INIT_LATE {}
222226

223227
#ifdef USE_SYSLOG
224228
#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){ \

firmware/platformio.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ build_flags =
6363

6464
[env:esp32]
6565
platform = espressif32
66-
board = esp32dev
66+
board = nodemcu-32s
6767
board_build.f_flash = 80000000L
6868
board_build.flash_mode = qio
6969
board_build.partitions = min_spiffs.csv

0 commit comments

Comments
 (0)