Introduction: Bluetooth Speaker + Clock + Environment Monitor

About: I am an ex-BT engineer and ex Network Manager, I work as an A level computer science teacher in a local school now. I specialise in Python, electronics, microcontrollers (ESP32,8266, pico), raspberry pi. I als…

This project builds a fine looking bluetooth speaker powered by 26650 LiPo batteries. As an extra bolt-on (!) I decided to add a clock and temp/humidity sensor to it using an ESP32 microcontroller. It's all programmed in (micro)Python and the code is included. Originally I wanted a clock time-sync'ed to the UK atomic clock using a 60KHz receiver, but alas the microcontroller is too noisy with stray EM radiation, so I've used internet NTP time to set the clock upon power on.

The speaker is a tiny 2" Monacor drive unit within a tuned ported enclosure to help it make some bass; it also has a bass-boost analogue circuit to help it a bit more! Seems to work well and sounds really quite good for the size.

The clock uses wifi to get its date-time information; if it doesn't manage to get data then it falls back to its internal Real Time Clock Module, which is updated every time we do get a time sync signal.



Supplies

You will need :

  1. Timber of your choice. I used Sapele. see below.
  2. Solid Sapele Mahogany Hardwood Timber - Kiln Dried 1.5 m x 145mm x 12mm £26.55
  3. ESP32 WROOM . About £6 ish.
  4. DS1302 Real time Clock module with Lipo coin battery.
  5. 4 x 26650 Lipo batteries and two twin battery holders. see below.
  6. 4 x SKYWOLFEYE 26650 Battery 3.7V 8000mAh £15.15
  7. 2PCS Nylon Shell Brass Series Connection 2 x 26650 Batteries Storage Holder £7.14
  8. 18V to 5V buck downconverter to power esp32.
  9. 12V/24V Car Bluetooth 4.2 Audio Receiver Board Wireless Stereo Sound Module £6.08
  10. LIPO battery charge indicator £3.49
  11. Lithium Battery BMS 4S 16.8V 40A Li-ion Balance Charge 18650 21700. £4.16
  12. TDA2050 Mono Audio Power Amplifier Board Module 12-24V 5W-120W 1-Channel . about £6.
  13. Dupont 2.54mm Connector Housing Male Female Crimp Terminals
  14. Pack Size: 100 MPN: 985834 Female Quantity: 2 £4.78
  15. 2" Monacor speaker drive unit from Connevans:
  16. MZMSPX21M - Hi-Fi full range speaker, 25W MAX, 4 Ohm   £14.73    
  17. 18 volt DC Mains charger.   
  18. The use of a Desktop PC with Thonny installed (Python)  
  19. Some 0.1" pitch dupont pin and socket connectors 
  20. A DC power socket to suit the mains charger you use.        

Step 1: Woodwork: Making the Cabinet

The cabinet will use sapele (mahogany) wood. It's a brilliant material to work with and looks super when it's done. There are cheaper woods out there, but we don't need much for this so I've gone upmarket here. The enclosure is in 4 parts: main exterior case, interior partition with speaker port/labrinth, base and rear panel. Base holds the batteries, amplifier and voltage downconverter. The speaker drive unit is the Monacor SPX21M:

https://www.monacor.com/products/components/speaker-technology/hi-fi-full-range-speakers-/spx-21m/


Step 2: BlueTooth and Audio Stuff

The amplifier used is a the TDA2050 mono amplifier module. Works well with 16-18V DC power and the 4 Ohm speaker. A bass boost circuit is also used here to compensate for the small size of this drive unit. Circuit is shown. It's not my design - not sure where I 'acquired' it(!) but it works well enough. Bluetooth receiver is just an LQSC one from ebay. Accepts 5-35V power. Be very careful here to isolate and suppress any power supply noise from this unit - it's very electrically noisy. Ferrite core choke and a large electrolytic capacitor seems to sort it. Speaker enclosure is a tuned cavity with a bass reflex port at the rear (ported box).

Enclosure calculations are from https://www.diyaudioandvideo.com/Calculator/ It was tricky to tune box to optimum cutoff as it's so high to start with, but I managed to tune it to increase bass down to about 100Hz. This, together with the bass boost circuit I 'acquired' makes it sound really quite good. Bass boost circuit is switchable with a dpst toggle switch.

Step 3: Battery and Power

16V power is supplied by four internal 26650 Lipo batteries in series. You'll also need a balancer/charger board in order to charge them from an external 18V dc power supply. A 4S battery state monitor is used also; be sure to configure the monitor for 4S (i.e. 4 x 4V batteries in series). On the left hand side of the unit, a DC power socket is fitted for the 18V recharge power. This wires directly into the battery balancer board. The board then connects to each voltage level in the battery pack; I used dupont 0.1" pins/sockets to connect to board. It'll handle the current. (but not much more!)

Step 4: ESP32 Setup / Programming

A standard ESP32 WROOM module is used here. I'm a python person so I immediately flashed micropython onto the device and then proceeeded to program the device in micropython. You'll need to install Thonny on your desktop computer in order to program and connect to your esp32. Just click on Run - Configure Interpreter in Thonny and you get an option to use ESP32. You could as easily have used a Pico or esp8266 or any other suitable microcontroller instead of the esp32. The ESP32 must have wifi included - this one does, with an externally connected antenna. The program will do the following :

Connect and authenticate to a named WiFi network. Use NTP (network time protocol) to get the real datetime from the internet. If the device cannot connect for any reason (eg you're not at home or internet down) then it will use it's own DS1302 local real time clock which has its own internal coin battery.

Note - every time it connects to internet and gets NTP successfully, it will update its local realtime clock.

In order to run the python program, you'll need to open the following files (included in next section) and save them onto the ESP32 :

DS1302.py this is the device driver python module for the real time clock.

MAX7219_8digit.py this is the device driver python module for the LED 7 segment displays.

NTPclock_1302_V1.py this is the main python script.


You will need to rename the main python script to main.py It will then run automatically when the device is powered up.