Hi, totally new to ESP32. I saw a couple of example sketches that showed how to implement the two things I needed for my project: basic HTTP usage (Examples for XIAO_ESP32S3 WiFiClientBasic) and connecting a USB keyboard (ESP32 USB host HID) . BTW the project I’m working on is a remote page turner for a jailbroken Kindle Oasis running KOReader. In case you didn’t know most ereaders allow for connecting a bluetooth HID device. I love this feature because it allows me to place the ereader on a support and read with my hands under the covers turning pages using a small 3 key bluetooth keyboard (PCSensor MK321BT). However Kindles although they have bluetooth connectivity don’t implement this feature. The alternative I found is enabling the HTTP inspector plugin in KOReader and send HTTP GET requests for it to go forward or backwards one page. I tested both functionalities separately, first made sure the HTTP GET would work, and it did, then the more involved USB keyboard connection following quite closely esp32beans’ implementation, only using a very small 2 key USB keyboard. When I had both things working independently I joined both and got the contraption to work, i.e., pressing PgDn on the keyboard sent the correct GET to the ereader and it moved to the next page, same thing backwards. So far so good. BUT then, I connected a 3.7V LiPo battery to the battery connections on the back of the Xiao board and … nothing happened. If I unplug the keyboard and plug a usb c charger the indicator lights blinks as expected. But if I try powering the board from the battery it just doesn’t work. I haven’t tried simpler programs to validate if the board is working at all or not, just to make sure it’s the USB host functionality the problem, but I’m pretty sure it is. Also I read somewhere that you’ll have no power on the 5V pin when using battery power. I think this also means the USB 5V won’t be present to power the USB keyboard? If that is the case, is there anything that can be done to have the USB power a device connected to it while running on battery power? Could I use a battery voltage to 5V dc-dc converter and somehow feed it to the USB 5V? Of course I could ditch the USB keyboard idea and just use a couple of buttons connected to GPIO pins and it surely would work battery powered. But I like these small keyboards look and feel and I’m so used to their bluetooth versions that I really want to build on top of that. Any help would be very welcome.
Hi there,
and welcome here…
So that is a pretty good example or "Necessity is the mother of Invention " and yes You seem to have been gotcha by the Serial port waiting for the usb to be plugged in…
“While Serial”
// While Serial
comment out that in the code and it will work AOK…
HTH
GL PJ
Hi PJ_Glasso, thanks for your welcome and your reply. Unfortunately I’m not using serial so that can’t be the issue. This is the sketch I’m running, pretty basic, no error checking nothing extra, just the bare minimum for it to work.
KindlePageTurner - Copy.zip (661 Bytes)
Hi there,
Ok , so which BSP are you using ?
and if you would, could you provide the 3 three lines of the compiler output and the last 10 before it uploads please, Use the Code tags above “</>” paste it in there, after some reply’s you will gain enough forum credz to post pictures, links, etc…
HTH
GL PJ
also provide a link to the keyboard device…
Thanks for your help.
I assume BSP means board support package. I used the arduino ESP32 board support by Espressif systems v3.2.0
The first three lines on the output screen are:
FQBN: esp32:esp32:XIAO_ESP32S3:CDCOnBoot=cdc
Using board 'XIAO_ESP32S3' from platform in folder: C:\Users\daBigR--\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0
Using core 'esp32' from platform in folder: C:\Users\daBigR--\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0
and the last 10:
"C:\\Users\\daBigR--\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esptool_py\\4.9.dev3/esptool.exe" --chip esp32s3 merge_bin -o "C:\\Users\\daBigR--\\AppData\\Local\\arduino\\sketches\\500D4EE10F0114991CC0740821C5E548/KindlePageTurner.ino.merged.bin" --fill-flash-size 8MB --flash_mode keep --flash_freq keep --flash_size keep 0x0 "C:\\Users\\daBigR--\\AppData\\Local\\arduino\\sketches\\500D4EE10F0114991CC0740821C5E548/KindlePageTurner.ino.bootloader.bin" 0x8000 "C:\\Users\\daBigR--\\AppData\\Local\\arduino\\sketches\\500D4EE10F0114991CC0740821C5E548/KindlePageTurner.ino.partitions.bin" 0xe000 "C:\\Users\\daBigR--\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.2.0/tools/partitions/boot_app0.bin" 0x10000 "C:\\Users\\daBigR--\\AppData\\Local\\arduino\\sketches\\500D4EE10F0114991CC0740821C5E548/KindlePageTurner.ino.bin"
esptool.py v4.8.1
Wrote 0x800000 bytes to file C:\Users\daBigR--\AppData\Local\arduino\sketches\500D4EE10F0114991CC0740821C5E548/KindlePageTurner.ino.merged.bin, ready to flash to offset 0x0
Using library WiFi at version 3.2.0 in folder: C:\Users\daBigR--\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi
Using library Networking at version 3.2.0 in folder: C:\Users\daBigR--\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\Network
Using library EspUsbHost at version 1.0.1 in folder: D:\Dropbox\Arduino\libraries\EspUsbHost
"C:\\Users\\daBigR--\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esp-x32\\2411/bin/xtensa-esp32s3-elf-size" -A "C:\\Users\\daBigR--\\AppData\\Local\\arduino\\sketches\\500D4EE10F0114991CC0740821C5E548/KindlePageTurner.ino.elf"
Sketch uses 902354 bytes (26%) of program storage space. Maximum is 3342336 bytes.
Global variables use 45124 bytes (13%) of dynamic memory, leaving 282556 bytes for local variables. Maximum is 327680 bytes.
Finally I can’t find a link to the keyboard manufacturers’ site only Aliexpress 2 key USB but I know the manufacturer is Sayo and it can be configured and has documentation on Sayodevice
So this is quite straightforward with the XIAO ESP32-S3 boards. I just use a standard PC keyboard as a OTG device but should be similar for your “keypad”.
To add the 5V you can either inject (special cable or diy) or just add the 5V to the XIAO ESP32-S3’s VBus pin (14 or J1 Pin 7).
I haven’t noticed anything “untoward” with that approach.
For uploading, I use the secondary serial port connections D6/TX and D7/RX connected to a standard USB-232 device. With some USB-232’s there is 5V available, so you could potentially use that (but I haven’t tried).
Just make sure USB CDC on boot is “Disabled”. No issues with BSP - I used latest (same as yours).
Hi grobasoz, thank you very much for your reply. However it seems I wasn’t completely clear on this point. I do have the project working from a 5V supply, namely a small power bank. The problem is how to make it work with a 3.7 V LiPo battery. Because the same configuration that works perfectly well fed from 5V does not when trying to use a battery directly connected to the battery pads on the board.
@daBigR - I probably wasn’t clear enough either…
Unfortunately it’s not possible using the XIAO LiPo battery/charger interface.
That’s why I add an “external” 5V supply to the VBus pin of the XIAO.
The 5V from my Solar/LiPo has a built in (3.7->5V) booster (HT4936).
I was thinking it might be a limitation of the board’s circuitry, now you confirm it. So your solution is using a 3.7 V battery not connected directly to the board but using a 5V booster into VBus and obviously having a separate charging circuit. I’ll look for a charger/booster module locally to try. Thanks a lot.
Hi, I found an IP5306 - more properly a FM5324GA - based module from a local provider. I couldn’t find a manufacturer link but this is an Aliexpress equivalent. It does exactly what I needed given @grobasoz input. You connect a 1s LiPo battery to couple of terminals, and the load to another pair and it provides 5V to the load and charging through a USB C port.
Gadget working perfectly.
Thank you very much.
Hi there,
WoW, I Like it… All of it
anyone else on this too, may like this Xiao Button device also.
Great work getting it going and PLEASE do mark @grobasoz post knocking it out of the park with some good insight.as the Solution.
So others can find it fast .
HTH
GL PJ