Skip to content

Commit 8aeda24

Browse files
author
Greg Toth
committed
add pre-defined board selectors BOARD_SELECT_*
1 parent dee270c commit 8aeda24

File tree

2 files changed

+58
-8
lines changed

2 files changed

+58
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Default settings are for Adafruit HUZZAH32 board.
3535

3636
In esp32_mediumone_bridge.ino ```#define CLIENT_SERIAL``` controls which serial port is used for the UART AT command input/output. Only TX & RX lines are used with no hardware flow control lines. Since this app is based on the Arduino programming model, it will typically be ```Serial```, ```Serial1``` or ```Serial2```. Usually ```Serial``` refers to the primary USB serial port on the ESP32 board which may or may not be the one you want to use for AT commands. See the source code for details about UART TX/RX pin mappings for Serialx on certain target boards. For Adafruit HUZZAH32 CLIENT_SERIAL is Serial1, REMAP_UART_PINS is 0, and Serial1 TX & RX are on the board's Feather connector.
3737

38+
A set of pre-defined board selections are available in the source code based on #defines that begin with ```BOARD_SELECT_```. Each defined board selects an appropriate serial port configuration for that particular board, with variants for swapped TX and RX pins. To select a particular board configuration, set that #define to 1 and set all the rest to 0. The ```BOARD_SELECT_CUSTOM``` selector allows you to define custom settings.
39+
3840
### Programming the ESP32 Board
3941

4042
For ESP32 boards that have a USB serial port, connect the ESP32 board to your computer using a USB cable, then compile and upload the program to the board.

esp32_mediumone_bridge.ino

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,73 @@
1616
*/
1717

1818
#define IDENT "MediumOne ESP32 Bridge"
19-
#define VERSION "0.8.2"
19+
#define VERSION "0.8.3"
2020

2121
#include <WiFiClientSecure.h> // https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFiClientSecure
2222
#define MQTT_MAX_PACKET_SIZE 1024
2323
#include <PubSubClient.h>
2424
#include <ArduinoJson.h>
2525

26+
/* Board select */
27+
#define BOARD_SELECT_HUZZAH32 0
28+
#define BOARD_SELECT_HUZZAH32_SWAPPED 1
29+
#define BOARD_SELECT_ESP32_DEVKITC 0
30+
#define BOARD_SELECT_ESP32_DEVKITC_SWAPPED 0
31+
#define BOARD_SELECT_MIKRO_WIFI_BLE_CLICK 0
32+
#define BOARD_SELECT_CUSTOM 0
33+
34+
#if defined(BOARD_SELECT_HUZZAH32) && BOARD_SELECT_HUZZAH32 == 1
35+
/* Adafruit HUZZAH32 with default TX/RX pins */
36+
#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */
37+
#define CLIENT_SERIAL Serial1 /* client serial port for incoming AT commands */
38+
#define REMAP_UART_PINS 0 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */
39+
#define HAS_LED_BUILTIN 1 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */
40+
#elif defined(BOARD_SELECT_HUZZAH32_SWAPPED) && BOARD_SELECT_HUZZAH32_SWAPPED == 1
41+
/* Adafruit HUZZAH32 with swapped TX/RX pins */
42+
#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */
43+
#define CLIENT_SERIAL Serial1 /* client serial port for incoming AT commands */
44+
#define REMAP_UART_PINS 1 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */
45+
#define CLIENT_SERIAL_RX_GPIO 17 /* GPIO17 = chip pin 28 (IO17) = JP1-2 on HUZZAH32 */
46+
#define CLIENT_SERIAL_TX_GPIO 16 /* GPIO16 = chip pin 27 (IO16) = JP1-3 on HUZZAH32 */
47+
#define HAS_LED_BUILTIN 1 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */
48+
#elif defined(BOARD_SELECT_ESP32_DEVKITC) && BOARD_SELECT_ESP32_DEVKITC == 1
49+
/* ESP32 DevKitC with default TX/RX pins */
50+
#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */
51+
#define CLIENT_SERIAL Serial2 /* client serial port for incoming AT commands */
52+
#define REMAP_UART_PINS 0 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */
53+
#define HAS_LED_BUILTIN 1 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */
54+
#elif defined(BOARD_SELECT_ESP32_DEVKITC_SWAPPED) && BOARD_SELECT_ESP32_DEVKITC_SWAPPED == 1
55+
/* ESP32 DevKitC with swapped TX/RX pins */
2656
#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */
2757
#define CLIENT_SERIAL Serial2 /* client serial port for incoming AT commands */
58+
#define REMAP_UART_PINS 1 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */
59+
#define CLIENT_SERIAL_RX_GPIO 4 /* GPIO4 = chip pin 26 = IO4 = J3-13 on DevKitC */
60+
#define CLIENT_SERIAL_TX_GPIO 2 /* GPIO2 = chip pin 24 = IO2 = J3-15 on DevKitC */
61+
#define HAS_LED_BUILTIN 1 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */
62+
#elif defined(BOARD_SELECT_MIKRO_WIFI_BLE_CLICK) && BOARD_SELECT_MIKRO_WIFI_BLE_CLICK
63+
/* Mikro Wi-Fi BLE Click */
64+
#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */
65+
#define CLIENT_SERIAL Serial2 /* client serial port for incoming AT commands */
66+
#define REMAP_UART_PINS 0 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */
67+
#define HAS_LED_BUILTIN 1 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */
68+
#elif defined(BOARD_SELECT_CUSTOM) && BOARD_SELECT_CUSTOM == 1
69+
/* Custom board definition */
70+
#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */
71+
#define CLIENT_SERIAL Serial1 /* client serial port for incoming AT commands */
72+
#define REMAP_UART_PINS 0 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */
73+
#define HAS_LED_BUILTIN 0 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */
74+
#else
75+
/* Default settings if no pre-defined board selected */
76+
#define CONSOLE_SERIAL Serial /* console serial port for info & debug messages */
77+
#define CLIENT_SERIAL Serial1 /* client serial port for incoming AT commands */
2878
#define REMAP_UART_PINS 0 /* 0=use default TX/RX pin mappings, 1=remap to alternate pins */
2979
#define HAS_LED_BUILTIN 0 /* 0=board does not have LED_BUILT_IN, 1=has LED_BUILTIN */
80+
#endif
81+
3082
/* Defaults on Adafruit HUZZAH32 ESP32 Feather:
3183
* Serial RX & TX are mapped to USB-to-Serial converter.
32-
* Serial1 RX is mapped to GPIO16 = chip pin 27 (IO16) = JP3-3 (RX),
33-
* Serial1 TX is mapped to GPIO17 = chip pin 28 (IO17) = JP3-2 (TX).
84+
* Serial1 RX is mapped to GPIO16 = chip pin 27 (IO16) = JP1-3 (RX),
85+
* Serial1 TX is mapped to GPIO17 = chip pin 28 (IO17) = JP1-2 (TX).
3486
* For HUZZAH32 use CONSOLE_SERIAL=Serial, CLIENT_SERIAL=Serial1, REMAP_UART_PINS=0, and HAS_LED_BUILTIN=1.
3587
* Defaults on ESP32 DevKitC:
3688
* Serial RX & TX are mapped to USB-to-Serial converter
@@ -48,11 +100,7 @@
48100
* For Mikro WiFi BLE Click use CONSOLE_SERIAL=Serial, CLIENT_SERIAL=Serial2, REMAP_UART_PINS=0,
49101
* and HAS_LED_BUILTIN=0.
50102
*/
51-
#if defined(REMAP_UART_PINS) && REMAP_UART_PINS == 1
52-
/* Optional serial RX & TX port pin remapping used with CLIENT_SERIAL. */
53-
#define CLIENT_SERIAL_RX_GPIO 4 /* GPIO4 = chip pin 26 = IO4 = J3-13 on DevKitC */
54-
#define CLIENT_SERIAL_TX_GPIO 2 /* GPIO2 = chip pin 24 = IO2 = J3-15 on DevKitC */
55-
#endif
103+
56104
/* Serial data rates */
57105
#define CONSOLE_SERIAL_BAUD 115200
58106
#define CLIENT_SERIAL_BAUD 115200

0 commit comments

Comments
 (0)