Select Page

Handlebar Controller (Software)

Software development steps

  1. Install Arduino IDE and ESP32 library from scratch
  2. Bluetooth Keyboard 
  3. Rotary encoder connexion
  4. Configuration file with Inifile on SDCard
  5. Display with OLED shield

Step 1 – Install Arduino IDE and ESP32 library from scratch

S1.1 Download Arduino IDE from https://www.arduino.cc/en/software

  • Install the current upstream Arduino IDE at the 1.8 level or later. 

S1.2 Install “Expressif ESP32” library https://github.com/espressif/arduino-esp32

as described in https://github.com/espressif/arduino-esp32/blob/master/README.md and https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md       

Preferences 
Network 
Sketchbook location• 
/ Users/ acretet/Documents/Arduino 
Browse 
(requires restart of Arduino) 
Editor language: 
Editor font size: 
Interface scale: 
Theme: 
Show verbose output during: 
Compiler warnings: 
Display line numbers 
o 
Verify code after upload 
English (United Kingdom) (English (United Kingdom)) 
12 
e Automatic 
Default theme 
compilation 
None 
100 
% (requires restart of Arduino) 
(requires restart of Arduino) 
upload 
Enable Code Folding 
Use external editor 
Save when verifying or uploading 
Check for updates on startup 
Use accessibility features 
Additional Boards Manager URLs: https:/Iraw.githubusercontent.com/espressif/arduino-esp32/gh-pages/pacl 
More preferences can be edited directly in the file 
/ Users / acretet/Li brary / Arduino 15 / preferences .txt 
(edit only when Arduino is not running) 
OK 
Cancel
  • Open Boards Manager from Tools > Board > Boards Manager menu 
  • Search “esp32″ platform 
  • Select “esp32” by Espressif Systems and click “Install” button
Boards Manager 
ESP32 
Type All 
esp32 
by Espressif Systems 
Boards included in this package: 
ESP32 Dev Module, WEMOS LoLin32, WE-MOS DI MINI ESP32. 
More Info 
1.0.4 
Install 
Close
All 
Type 
Boards Manager 
Filter your search... 
Industruino SAMD Boards (32-bits ARM Cortex-MO+) 
by Industruino 
Boards included in this package: 
Industrujno D21G. 
esp32 
by Espressif Systems 
Boards included in this package: 
ESP32 Dev MOdUle, WE-MOS L0Lin32, WE-MOS DI MINI ESP32. 
More Info 
Downloading boards definitions. Downloaded 1,914kb of 36,853kb. 
Installing... 
Cancel
Type All 
Boards Manager 
Filter your search... 
Industruino SAMD Boards (32-bits ARM Cortex-MO+) 
by Industruino 
Boards included in this package: 
Industrujno D21G. 
esp32 
by Espressif Systems version 1.0.4 
INSTALLED 
Boards included in this package: 
ESP32 Dev MOdUle, WE-MOS L0Lin32, WE-MOS DI MINI ESP32. 
More Info 
Select version Install 
Remove 
Close

S1.3 Plug and select the device

  • Plug the LOLIN D32 PRO with USB Cable
  • Select the board from Tools > Board > ESP32 Arduino > LOLIN D32 PRO
Arduino 
eo 
SimpleBleDevice 
File 
Edit 
Sketch 
Tools Help 
Auto Format 
Archive Sketch 
Fix Encoding & Reload 
Manage Libraries... 
Serial Monitor 
Serial Plotter 
WiFi101 / WiFiNlNA Firmware Updater 
Board: "LOLIN D32 PRO" 
Upload Speed: "921600" 
Flash Frequency: "80MHz" 
Partition Scheme: "Default" 
Core Debug Level: "None" 
PSRAM: "Disabled" 
BleDevice I Arduino 1.8.1 
Boards Manager... 
Arduino AVR Boards 
ESP32 Arduino 
10 // 
12 // 
13 // 
14 
15 // 
16 // 
17 // 
18 
Copyright 2015-2016 Espressi 
Licensed under the Apache Li 
you may not use this file ex 
You may obtain a copy Of the 
Unless required by applicabl 
distributed under the Licens 
11 // WITHOUT WARRANTIES OR CONDIT 
See the License for the spec 
limitations under the Licens 
Sketch 
Useful 
Button 
shows how to use Simp 
if you want to advert 
is attached between G 
" SimpleBLE. h" 
port 
Get Board Info 
Programmer 
Burn Bootloader 
Please 
make 
run 
menuconfig 
to 
and 
> 
enable 
hange 
time 
it 
it on the press o 
the button is pre 
19 #include 
20 
21 ! 
22 #error Bluetooth is not enabled! 
23 #endif 
ESP32 Dev Module 
ESP32 Wrover Module 
ESP32 Pico Kit 
TinyPlCO 
MagicBit 
Turta 10T Node 
TTGO LORa32-OLED VI 
TTGO Tl 
XinaBox CW02 
SparkFun ESP32 Thing 
u-blox NINA-WI O series (ESP32) 
Widora AIR 
Electronic SweetPeas - ESP320 
Nan032 
LOLIN D32 
LOLIN D32 PRO 
WEMOS LOLIN32 
Dongsen Tech Pocket 32 
WeMos WiFi&Bluetooth Battery 
ESPea32 
Noduino Quantum
  • Select the usb port from Tools > Port (with Mac OS is /dev/cu.usbserial-1440)
Arduino 
File 
eo 
SimpleBleDevice 
Edit 
Sketch 
Tools Help 
Auto Format 
Archive Sketch 
Fix Encoding & Reload 
Manage Libraries... 
Serial Monitor 
Serial Plotter 
WiFi101 / WiFiNlNA Firmware Updater 
. Board: "LOLIN D32 PRO" 
Upload Speed: "921600" 
Flash Frequency: "80MHz" 
Partition Scheme: "Default" 
Core Debug Level: "None" 
PSRAM: "Disabled" 
port 
Get Board Info 
Programmer 
Burn Bootloader 
•OS€M 
10 // 
12 // 
13 // 
14 
15 // 
16 // 
17 // 
18 
Copyright 2015-2016 Espressi 
Licensed under the Apache Li 
you may not use this file ex 
You may obtain a copy Of the 
Unless required by applicabl 
distributed under the Licens 
11 // WITHOUT WARRANTIES OR CONDIT 
See the License for the spec 
liditations under the Licens 
Sketch 
Useful 
Button 
shows how to use Simp 
if you want to advert 
is attached between G 
"SimpleBLE. h" 
19 #include 
20 
21 ! 
BleDevice I Arduino 1.8.13 
Serial ports 
Idev/cu.Bluetooth-lncoming-Port 
Idev/cu.debug-console 
Idev/cu.usbserial- 1140 
Idev/cu.wlan-debug
  • Open the terminal with Tools > Serial Monitor
Arduino File 
eo 
SimpleBleDevice 
Edit 
Sketch 
Tools Help 
Auto Format 
Archive Sketch 
Fix Encoding & Reload 
Manage Libraries... 
Serial Monitor 
Serial Plotter 
WiFi101 1 WiFiNlNA Firmware updater 
Board: "LOLIN D32 PRO" 
Upload Speed: "921600" 
Flash Frequency: "80MHz" 
Partition Scheme: "Default" 
Core Debug Level: "None" 
PSRAM: "Disabled" 
Port: "Idev/cu.usbserial-1140" 
Get Board Info 
Programmer 
Burn Bootloader 
08M 
09€L 
10 // 
11 // 
12 // 
13 // 
14 
15 // 
16 // 
17 // 
Copyright 2015-2016 Espressif 
Licensed under the Apache Lic 
you may not use this file exc 
You may obtain a copy Of the 
Unless required by applicable 
distributed under the License 
WITHOUT WARRANTIES OR CONDITI 
See the License for the speci 
limitations under the License. 
Sketch 
Useful 
Button 
shows how to use Simpl 
if you want to adverti 
is attached between GP 
18 
19 
20 
#include 
"SimpleBLE. h" 
C 'ABC* 
cm

S1.4 Compile the first sample code

  • LOLIN D32 PRO Sample codes are available into File > Examples 
Arduino 
eo 
SimpleBleDevic 
Copyrigh 
Li censed 
you may 
5 // You may 
Unless r 
distribu 
File 
New 
Open... 
Edit 
Sketch Tools 
Help 
Open Recent 
Sketchbook 
Examples 
Close 
Save 
Save As... 
Page Setup 
Print 
> 
6 
10 // 
12 // 
13 // 
14 
15 // 
16 // 
17 // 
18 
11 // WITHOUT WARRANTIES OR CONDITION 
See the License for the speci fi 
limitations under the License. 
Sketch 
Useful 
Button 
19 #include 
20 
shows how to use SimpleB 
if you want to advertise 
is attached between GPIO 
"SimpleBLE. h" 
21 Il 
22 #error 
Bluetooth is 
not enabled! 
23 #endif 
24 
SimpleBLE ble; 
25 
26 
27 void 
28 
29 
30 
31 
32 } 
33 
Stri ng 
= "BLE32 name: 
out 
out String(rnillis / 
Serial . pri ntl n(out) ; 
ble. begin(out) ; 
1000) 
34 void setup() { 
35 
36 
37 
38 
39 
40 
41 
42 } 
43 
Serial . begin 
(115200) ; 
Serial . setDebugOutput( 
true); 
pi nModeCØ 
, INPUT_PULLUP); 
Serial SDK: 
Serial . pri ntln 
(ESP. getSdkVersi 
SimpleBLE")•, 
Serial the butt 
44 void loop() { 
45 
46 
47 
48 
49 
50 
51 
52 } 
static uint8_t 
lastPinState 
uint8_t pinState 
= digitalRead 
onButton() ; 
lastPinState = pinState; 
whi le(Serial . avai eC)) 
Seri 
Built-in Examples 
01. Basics 
02. Digital 
03.Analog 
04.Communication 
05.Control 
06. Sensors 
07. Display 
08.Strings 
09.USB 
10.StarterKit_BasicKit 
11 .ArduinolSP 
Examples for any board 
Adafruit Circuit Playground 
Bridge 
Ethernet 
Firmata 
LiquidCrystal 
SD 
Stepper 
Temboo 
RETIRED 
Examples for LOLIN D32 PRO 
ArduinoOTA 
BluetoothSerial 
DNSServer 
EEPROM 
ESP32 
ESP32 Async UDP 
ESP32 Azure IOT Arduino 
ESP32 BLE Arduino 
ESPmDNS 
F Fat 
HTTPClient 
HTTPUpdate 
NetBIOS 
Preferences 
SD(esp32) 
SD_MMC 
SimpleBLE 
SPI 
> 
SimpleBleDevice 
e 
plied. 
d 
ice and change it 
nges each time the 
enable it 
SimpleBleDevice
  • Select into Build-in Examples the Blink code with File > Examples > 01.Basics > Blink
Arduino 
eo 
SimpleBleDevic 
File 
New 
Open... 
Edit 
Sketch Tools 
Help 
Copyrigh 
Li censed 
you may 
You may 
Unless r 
distribu 
Open Recent 
Sketchbook 
Examples 
Close 
Save 
Save As... 
Page Setup 
Print 
098 P 
> 
> 
> 
> 
> 
> 
SimpleBleDevice I 
AnalogReadSerial 
BareMinimum 
I Blink 
DigitalReadSerial 
Fade 
ReadAnalogVoltage 
10 // 
12 // 
13 // 
14 
15 // 
16 // 
17 // 
11 // WITHOUT WARRANTIES OR CONDITION 
See the License for the specifi 
limitations under the License. 
Sketch 
Useful 
Built-in Examples 
01 .Basics 
02.Digital 
03.Analog 
04.Communication 
05.Control 
06.Sensors 
07 Display 
08.Strings 
09.USB 
10. StarterKit_BasicKit 
1 1 .ArduinoISP 
pl ied. 
ice and change 
shows how to use SimpleB 
if you want to advertise 
CDTn 
it on
  • Compile the code with Sketch > Verify/Compile
  • Send the code to the device with Sketch > Upload
  • Or directly with following button
Blink S 
26avoid setup() { 
Blink I Arduino 1.8.13 
UPLOAD 
COMPILE 
// initialize digital pin LED_BUILTIN 
27 
28 
OUTPUT); 
29 } 
30 
31 // the loop function runs over and over 
32avoid loop() { 
digitalWrite(LED_BUILTIN, 
33 
34 delay 
(5000) ; 
35 
delay 
(1000) ; 
36 
37 
ne uploading. 
Compressed 8192 bytes to 47... 
HIGH) 
LOW) ; 
as an output. 
again forever 
turn the LED on (HIGH is the voltage level) 
wait for a second 
turn the LED off by making the voltage LOW 
wait for a second 
Wrote 8192 bytes (47 compressed) at Øx0ØØØeØOØ in 0.0 seconds (effective 2575.6 kbit/s). 
Hash of data verified. 
Flash params set to ØxØ24f 
Compressed 15856 bytes to 10276. 
Wrote 15856 bytes (10276 compressed) at OxØØØØIØØO in 0.2 seconds (effective 808.0 kbit/s). 
Hash of data verified. 
Compressed 253600 bytes to 118413... 
Wrote 253600 bytes (118413 compressed) at ØxØØØIØØØØ in 2.3 seconds (effective 889.5 kbit/s)... 
Hash of data verified. 
Compressed 3072 bytes to 128. 
Wrote 3072 bytes (128 compressed) at OxØØØØ8ØØØ in 0.0 seconds (effective 904.8 kbit/s). 
Hash of data verified. 
Leaving. 
Hard resetting via RTS pin... 
17 
COLIN 032 PRO on /dev/cu.wchusbseria11410
  • In the device the blue led is blinking

Step 2 – Bluetooth Keyboard 

S2.1 Install “ESP32 BLE Keyboard” https://github.com/T-vK/ESP32-BLE-Keyboard

Arduino File 
eo 
BTRemoteControler01 
Edit 
Sketch Tools 
Verify/Compile 
Upload 
Help 
TRemoteControler01 1 Arduino 1.8.' 
Upload Using Programmer 
Export compiled Binary 
Show Sketch Folder 
Include Library 
Add File... 
x-j€s 
> 
3 
4 
6 
* 
* 
* 
Bluetooth Remote C 
This device emulat 
GP1015: ZOOM-IN 
Manage Libraries... 
Add .ZIP Library... 
OXI
Arduino 
File 
Name 
Edit 
Sketch 
Tools 
Help 
BTRemoteControler01 1 Arduino 1.8.13 
Select a zip file or a folder containing the library you'd like to add 
Téléchargements 
ESP32-BLE-Keyboard 
File Format: 
1 
Date Modified 
Tuesday, 20 October 2020 21:47 
ZIP files or folders 
Cancel

You can now go to “File” -> “Examples” -> “ESP32 BLE Keyboard” and select any of the examples to get started.

Arduino 
eo o El 
SendKeyStrok 
2 * This ex 
4 #include < 
6 BleKeyboar 
8 void setup 
File 
New 
Open... 
Edit 
Sketch Tools 
Help 
SendKeyStrokes I Arduino 1.8.1 
Open Recent 
Sketchbook 
Examples 
Close 
Save 
Save As... 
Page Setup 
Print 
Built-in Examples 
01 .Basics 
02.Digital 
03.Analog 
04.Communication 
05.Control 
06.Sensors 
07. Display 
08.Strings 
09.USB 
10. StarterKit_BasicKit 
1 1 .ArduinolSP 
Examples for any board 
Adafruit Circuit Playground 
Bridge 
Ethernet 
Firmata 
LiquidCrystal 
SD 
Stepper 
Temboo 
RETIRED 
Examples for LOLIN D32 PRO 
ArduinoOTA 
BluetoothSerial 
DNSServer 
EEPROM 
ESP32 
ESP32 Async UDP 
ESP32 Azure 10T Arduino 
ESP32 BLE Arduino 
ESPmDNS 
FFat 
HTTPClient 
HTTPUpdate 
NetBIOS 
Preferences 
SD(esp32) 
SD_MMC 
SimpleBLE 
SPI 
SPIFFS 
Ticker 
Update 
WebServer 
WiFi 
WiFiClientSecure 
Libraries 
ESP32 BLE Keyboard 
s the words, 
presse 
9 
10 
11 
12 
13 
Serial. b 
Serial. p 
bleKeyboard. begin() 
14 void loop() { 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
35 
36 
37 
38 
39 
40 
41 
if(bleKeyboard. isConnected()) { 
Serial Sending 'Hell 
worl 
delay 
Serial . Enter 
delay 
(1000); 
Serial . Play/ 
bleKeyboard. write 
(1000); 
delay 
Serial . Ctrl* 
bleKeyboard.press 
bleKeyboard.press 
delay 
(100); 
bleKeyboard. rel easeA11 ; 
Serial. print1nC"Waiting 5 secon 
delay(5øøø) 
> 
SendKeyStrokes

Step 3 – Rotary encoder connexion

Step 3 – Configuration file with Inifile on SDCard

Step 4 – Display with OLED shield

ESP8266 OLED Driver SSD1306 https://github.com/ThingPulse/esp8266-oled-ssd1306

AFArray library https://github.com/TechLabCommunity/AFArray

IniFile library https://github.com/stevemarple/IniFile

SimpleRotary Arduino library https://github.com/mprograms/SimpleRotary