Saturday, 6 January 2018

How to use a TTGO ESP32 module with OLED display and 18650 battery holder

TTGO ESP32 dev module

I got this very complete dev module from Banggood for review.


TTGO ESP32 Development Module

  Features:

  • ESP-WROOM-32 Module
    (=Wifi, Bluetooth, two cores)
  • USB to serial bridge with Silicon Labs CP210X Chip
    (supported by Windows and Linux)
  • Charge Circuit for an 18650 battery (backside of board)
  • OLED display (SSD1306 or compatible) I2C version
  • LED on GPIO16
  • power switch

Notes from my experiments:

IDE

It was no problem getting the module to work with both the Arduino IDE and a generic ESP-32 developmnent environment (as provided by Espressif).
I set up a dedicated virtual machine running Ununtu with VirtualBox under Windows 10.
For the setup I simply followed the instructions provided by Espressif.

OLED

Unlike on other ESP32 boards with OLEDs, the OLED's I2C SDA and SCL pins are connected as follows:

SCL - Pin 4
SDA - Pin 5

It does not require an "enable" signal on GPIO16 as suggested in some programs I found. So comment these out if you see them.


Power requirements

When I didn't have a battery inserted, my powered USB hub apparently could not provide enough power when I activated WiFi and the ESP32's brownout detection triggered.
I haven't investigated that further. Either my USB hub dies not provide enough power, or the board's regulator is too weak to handle the current.

Example Project: Web Radio

As my first project, I ran a very simple web radio firmware on the module. The code was easy to find here on Github. A six minute video of my 5-minute project is available on my Youtube channel here.



17 comments:

  1. Very nice project, good job!

    I wonder if you can redirect the audit to bluetooth, and turn a dumb bluetooth speaker to a full webradio?

    ReplyDelete
    Replies
    1. There is some very basic code for a BT audio source in Espressif's repostory:
      https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/a2dp_source
      I haven't looked at the options to pipe web audio to the a2dp source. (And on to a connected BT-Speaker)

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. hello,

    can the battery voltage be monitored by the esp32?

    ReplyDelete
    Replies
    1. The ESP32 by itself can't. A solution is to weld a cable from the positive 4.2 V battery terminal, put it to a voltage divider that outputs 3.3 v and put that voltage to an analog input of ESP32. Be aware that the analog reading of esp32 is not so linear, so try to put a 10uF capacitor in the input.

      Delete
  4. Hi andreas!
    My ESP32 OLED BATTERY TTGO card, loosened the connector (the USB port, broke the weld, very fragile).
    I can not record the programs anymore.
    How do I use the ESP32 RX and TX pins?
    What are the RX / TX pins for using a TTL converter?
    Thank you.

    ReplyDelete
    Replies
    1. My way of fixing connectors that broke loose from the PCB (usually ripping off the copper traces) is this:
      a) I superglue the connector to the board
      b) I trace the broken copper traces to a point where I can either scratch off the soldermask or find a clean contact spot.
      c) I use a piece of thin, insulated wire and connect the connector's leg to that copper trace.

      Delete
  5. By itself, the ESP32 can'nt. It can be monitored by welding a cable from the 4.2 v battery terminal to a voltage divider that gives you a 3.3 voltage, and put it to an Analog input of the ESP32. Just be aware that the analog read of the ESP32 is not so linear, try to place a 10uF capacitor in the input, to make it the most precise possible

    ReplyDelete
  6. Hi there! :)
    First of all, thanks for your instructions.
    I've been trying to use a MPU6050 with my ESP32, but the I2C connection isn't working. Could you please help me?

    ReplyDelete
  7. No matter what I do I cannot get the ESP8266Wifi library working with the board. It simply will not compile there are always "files missing" even though I have tried several ways to install the library. Can you show me some code that will utilize the board as a wifi device?

    ReplyDelete
    Replies
    1. This board has the newer, and much more powerful ESP32 chip, so not all ESP8266 related libraries will work with that board.
      There are many tutorials on the web on how to set up your IDE for an ESP32.

      Delete
  8. Hello Andres, I am new in ESP, I will buy the set shown in the link below the youtbue viede. I would like to build an internet radio. I did not see the step where you can set the stream address. 2nd question is, can I set 2 or 3 stream addresses and some how choose between stream 1,2 and 3? This would be very helpful as a kitchen radio. Vielen Dank im Voraus,

    ReplyDelete
    Replies
    1. Check out the readme for the Project on GitHub: https://github.com/kodera2t/ESP32_OLED_webradio
      Looks like you can change stations with GPIO16.

      Delete
  9. Thank you for your answer, Andreas. I got it working on the ESP32. I see that I can change station over the web interface (local ip and then I get a menu for prev or next station, etc). Regarding changing stations with GPIO16, since I am new in ESP32, I do not understand the statement "Push 'GPIO-16' (chaned from 'boot') switch to change next station." in the readme in GitHub. Does it mean I have to connect GPIO16 pin to GND (shortcircuit GPIO16 pin to GND) to switch the station? Do I have to care about this shortcircuiting somehow? For your information, I got it working after downloading the componets from the MrBuddyCasino/ESP32_MP3_Decoder git and replaced only the app_main and the webradio component. I also had to choose "use custom partition table" in the menuconfig and then everything worked fine. Thank you again.

    ReplyDelete
  10. can you publish a arduino ide version. I cant seem to get your version to work. my lack of knowledge.
    ideally how to port the script into ide as a .ino file.
    Thanks John

    ReplyDelete
  11. I have a question that how many add online radio links? Can we add more than 50? Possible?

    ReplyDelete
  12. Do you know where I can find more documentation on the pinout of this module? Also looking for the default firmware (demo?) that comes with this module. Can you point me to it?

    ReplyDelete