ESP32 wireless SHC (wSHC)


Dave Schwartz
 

So there's been quite a discussion over the last few weeks about a wireless version of the SHC that we're calling a wSHC over on the developer-talk subgroup. Its now become useful and stable enough so that I thought I'd spill the beans and let the general members know about it as well as how I've implemented a battery solution for it. How I did it is not the only way but is pretty much the only way that it can be done without adding any size to the SHC and being able to use off the shelf AAA batteries in an emergency if your rechargeables die.

Way back when Khalid ported the SHC to the ESP32 I asked him about creating a wireless version since the ESP32 has built-in WiFi capability. That would have been a significant programming effort instead of just a porting exercise so nothing came of it. Now our enterprising member Jesco Topp has done just this and Howard has integrated it and tweaked it so that it has reached a good point of stability. Several of us have been using it so I think its time to set it free for the adventurous.

The rest of this post is about how I integrated an internal battery solution into my SHC case design for the V1.03 PCB.

The easiest way to do it is to simply plug an external mobile device power bank into it using the same micro-USB port you use to program it. The drawbacks to this are that it adds bulk to what you have to hold on to and it has a cable connecting the two. Also, if your power bank runs out of charge and you don't have a spare, you're done.

So I looked for a way to put the batteries inside and, at Khalid's request, to be able to use standard alkaline batteries as a backup (requiring easy access for quick changes).

The solution I came up with involves 2 AAA batteries in a minimal-sized holder with a DC-to-DC booster to 5 volts and an optional on/off switch (if just taking the batteries out isn't your preferred way of turning it off for storage). I've done some testing with the wireless software loaded on a standard SHC and then powered by a USB cable directly to the ESP32 and this works. Using a USB power monitor dongle shows that the SHC in active mode (data polling) consumes between 50 and 80 milliamps and when in low power mode (display blanked, no data polling thus no transceiver activity) takes about 20Ma. Accounting for the 2.1x increased current required to step up the battery voltage to 5V and the slight loss in the step-up module, 750mAh Ni-MH rechargeable batteries ought to be able to power a wSHC for a full night if most of the time is spent in low-power mode. Good alkalines have capacities up to 1200mAh but they're not rechargeable. The more time spent in active mode, the shorter your batteries are going to last.

The parts you need are pretty minimal... a 2xAAA holder, a DC-DC boost module (I use the IC Station MT3608) and, optionally, a small slide switch. This cost me around $3 Canadian dollars.



Assembly and integrating to the bottom of the PCB is pretty easy. Solder the negative (black) wire from the battery holder (you may want to shorten it so as to not have excess wire to tuck into the case) to VIN- of the booster module and the positive (red) wire to VIN+. To add an ON/OFF switch, connect the wire from the battery holder instead to the center terminal of the switch and a wire from one of the outside terminals of the switch to VIN+. Add some short pigtails of wire to the VOUT terminals.

Now set the output voltage of the boost module using the screw on the trim-pot (the square blue thing). Put in two AAA batteries and connect a volt-meter to the VOUT terminals. They say you should set the output voltage with a representative load on the module so if you can, connect a resistance of about 150 ohms across the VOUT terminals in order to pull about 30mA of current through the module. Set the output for 5 volts (I set mine for 5.08V). The nice thing about this module is that it really doesn't matter what its input voltage is (1.2V from rechargeables, 1.5 to 1.6V from fresh alkalines)... the module will give a steady 5V until the batteries as so dead that it completely shuts down. Use some large-diameter heat-shrink tubing to insulate the DC-DC module (wrapping with black electrical tape would work too).

Now use hot glue (non-conductive) to glue the battery holder to the bottom of the PCB using the RJ45 sockets as a location guide. The leads from the battery holder come out between pins of the ESP32 and nestle the DC-DC module between the rows of the ESP32 pins. Then solder the DC-DC module output wires to the leads from the top-side capacitor, You could use any other 5V/GND points if you mounted your capacitor on the bottom. Just be sure to observe the correct polarity. Here's a picture of what that looks like:



Note that if you got an ESP32 SHC with the utility LED assembled by me, I probably used a two-pin Molex connector, You will have to cut off the connector and solder those wires directly to the LED leads because there will longer be the depth required to accommodate the connector shell between the DC-DC module and the bottom of the case.

I have modified my case design to add an optional cutout to the bottom so that the battery holder can nest within that cutout when it is opened. The top of the battery holder is flush with the bottom of the case so there is nothing extra sticking out but the batteries remain easily accessible. In this case, I have used the optional ON/OFF switch, which is not included in the cutout so I made a small notch at the end of the holder where I hot-glued it to the end of the battery holder. This type of battery holder has flexible 'wings' that cradle the batteries to hold them in firmly without a cover.

And here are pictures of the finished unit, top and bottom.


George Cushing
 

Nice. The DC-DC booster is based on the MT3608 IC. Once the resistance to get your 5V is known you can use a couple of resistors for the voltage divider to eliminate the pot and get the circuit down to about a half in square. A switch between VIN and EN should handle on/off.

Mt3608.jpg


Dave Schwartz
 

Too much work, although it would be an option for integration on the PCB to create a native wSHC. The prefab module fits where it needs to just fine. Hard to beat the prefab module for price... <$0.99

In real world testing, I seem to be getting only ~5 hour life out of Ni-MH batteries. I don't think its the batteries fault... could it be that my $10 USB power monitor lied to me?

A shorter operating time is not a really big problem. They usually come in sets of 4 so just take both fully charged pairs with you.

Also, there has been no attempt at optimizing the code for low poser consumption to this point. Probably lots of fruit for that seeing as there are a number of power saving features and techniques available for the ESP32.

On 2021-11-07 11:37 a.m., George Cushing wrote:
Nice. The DC-DC booster is based on the MT3608 IC. Once the resistance to get your 5V is known you can use a couple of resistors for the voltage divider to eliminate the pot and get the circuit down to about a half in square. A switch between VIN and EN should handle on/off.

Mt3608.jpg


kevin
 

I havn't buit mine yet, bit if it isn't a stupid question is not eveything on the board 3.3 volts?  if you are connecting this power supply to the nodemcu 5v pin to power it it is dropping down to 3.3v via  a linear regulator so the 1.7 volts are going as heat. i.e the switching regulator is maybe 95% efficient but you are then throwing away 1/3 of its output.  could  you set your regulator to 3.3 v and connect to the 3.3v rail? personally i don't like the idea of "back feeding " a linear regulator but a lot of desingns do it.


kevin
 

Hi, another silly question , does it use Wifi or Bluetooth? i have a ESP D1 R32 board working ok over bluetooth but if i need Wifi I  belive i have to add an ESP8266 D1 min to it ? if it is just bluetooth will it be an alternative to the Android app on my phone, which would be really nice?
Thjanks fo putting up with me
Kevin


Dave Schwartz
 

The SHC is pretty much designed for 5V. Just easier to feed it with that.

DC-DC boost modules also work best if the output is a little farther above the input than the .1V that would be the case if you used fresh alkaline cells.

On 2021-11-07 2:21 p.m., kevin_kevin_kevin via groups.io wrote:
I havn't buit mine yet, bit if it isn't a stupid question is not eveything on the board 3.3 volts?  if you are connecting this power supply to the nodemcu 5v pin to power it it is dropping down to 3.3v via  a linear regulator so the 1.7 volts are going as heat. i.e the switching regulator is maybe 95% efficient but you are then throwing away 1/3 of its output.  could  you set your regulator to 3.3 v and connect to the 3.3v rail? personally i don't like the idea of "back feeding " a linear regulator but a lot of desingns do it.


Dave Schwartz
 

Wifi only for now. It uses the persistent command channel over port 9998 (not sure if that's going to change or become a parameter). The SWS doesn't support multiple connections over the same port so if you plan to use any other software that uses a persistent command channel you have to be aware of which ports they get allocated to and use one of the more recent versions of the SMS that offer persistent command channels on ports 9996, 9997 and 9997.

There is no Bluetooth version for now although doing that would probably be a power saving option.

On 2021-11-07 3:29 p.m., kevin_kevin_kevin via groups.io wrote:
Hi, another silly question , does it use Wifi or Bluetooth? i have a ESP D1 R32 board working ok over bluetooth but if i need Wifi I belive i have to add an ESP8266 D1 min to it ? if it is just bluetooth will it be an alternative to the Android app on my phone, which would be really nice?
Thjanks fo putting up with me
Kevin


kevin
 

Thanks for the quick replies, just ordered the oled so maybe next week i will have a wired handcontroller   :-)


Howard Dutton
 

On Sun, Nov 7, 2021 at 09:40 AM, Dave Schwartz wrote:
In real world testing, I seem to be getting only ~5 hour life out of Ni-MH batteries. I don't think its the batteries fault... could it be that my $10 USB power monitor lied to me?

A shorter operating time is not a really big problem. They usually come in sets of 4 so just take both fully charged pairs with you.
A possible optimization without my changing a single line of code is to set the ESP32 for something < 240Mhz in the Arduino IDE, like say 80Mhz; not sure it'll work but probably will.

This might be a more optimum setting for wired controllers also as it lessens the voltage drop and might stabilize power a little bit.


Howard Dutton
 

Also, note that the latest SmartHandController (main branch) now uses port 9996 as the default for WiFi.


Dave Schwartz
 

That was my thought exactly. I was just about to open the IDE to see if that was possible. After all, if overclocking increases power consumption, underclocking should decrease it.

On 2021-11-08 8:54 a.m., Howard Dutton wrote:
A possible optimization without my changing a single line of code is to set the ESP32 for something < 240Mhz in the Arduino IDE, like say 80Mhz; not sure it'll work but probably will.


Dave Schwartz
 

With the 80mHz option selected it appears to run well. A change I noticed, maybe due to other changes in the latest version, is that the startup sequence seems significantly faster. It used to take almost 10 seconds from power-on until the logo came up (and you got worried it wasn't going to work at all). Now its half that or less.

I'm not sure if it would make a difference but what change would be required to lower the data polling interval?

On 2021-11-08 9:34 a.m., Dave Schwartz wrote:
That was my thought exactly. I was just about to open the IDE to see if that was possible. After all, if overclocking increases power consumption, underclocking should decrease it.

On 2021-11-08 8:54 a.m., Howard Dutton wrote:
A possible optimization without my changing a single line of code is to set the ESP32 for something < 240Mhz in the Arduino IDE, like say 80Mhz; not sure it'll work but probably will.


Dave Schwartz
 

P.S. I had switched from using the ESP32 Dev Module to Node32s and the option to change the clock frequency doesn't exist there. Change back to ESP32 Dev Module and it does. I'm running the test at 80MHz (the lowest where it indicates WiFi/BT will operate).

On 2021-11-08 9:34 a.m., Dave Schwartz via groups.io wrote:
That was my thought exactly. I was just about to open the IDE to see if that was possible. After all, if overclocking increases power consumption, underclocking should decrease it.

On 2021-11-08 8:54 a.m., Howard Dutton wrote:
A possible optimization without my changing a single line of code is to set the ESP32 for something < 240Mhz in the Arduino IDE, like say 80Mhz; not sure it'll work but probably will.



Dave Schwartz
 

After the '1/3 CPU frequency test' I'll try tripling BACKGROUND_COMMAND_RATE. From what I think, this may slightly delay the responsiveness of icon changes but I don't think it will make much of a difference to the other data since that only seems to change with a granularity close to 1 second.


mil-cha@...
 

Hi,
I have just finished Battery power source in a bit different way. I used an old thin (only 5 mm) battery from my small tablet (or a smaller one from cellphone) that could be charged from the charger circuit  HW107 
Aliexpress Its input connected to a wall charger  (or a any powerbank in the field) to charge the battery and output to battery and to the input of the DC-DC converter (the same as from Dave). Now I only need a switch and to design new case.

Interesting is, that i have to set the output voltage of DC-DC booster below 5V (4.6 - 4.8V) otherwise the ESP32 is instabil 


Patrizio Boschi
 

I think that you may solder the +5v / GND of the HW107 to the power pins of the RJ11/ST4 port. So the SHC is charged when connected to the main onstep box.


Il giorno dom 14 nov 2021 alle ore 21:53 <mil-cha@...> ha scritto:
Hi,
I have just finished Battery power source in a bit different way. I used an old thin (only 5 mm) battery from my small tablet (or a smaller one from cellphone) that could be charged from the charger circuit  HW107 
Aliexpress Its input connected to a wall charger  (or a any powerbank in the field) to charge the battery and output to battery and to the input of the DC-DC converter (the same as from Dave). Now I only need a switch and to design new case.

Interesting is, that i have to set the output voltage of DC-DC booster below 5V (4.6 - 4.8V) otherwise the ESP32 is instabil 


mil-cha@...
 

Actually the only port I need is the micro USB on ESP32. The RJ 42 becomes due the WiFi obsolete. I have to make project for enclosure with the only one small hole for micro USB on ESP32


Patrizio Boschi
 

Indeed if the plan is to make the rj22 port obsolete. But I think it's a rather good fall back, and it could double as a charging port. Maybe it's possible to have both ports act as charge ports by adding one or two diodes?


P


Il lun 15 nov 2021, 10:31 <mil-cha@...> ha scritto:

Actually the only port I need is the micro USB on ESP32. The RJ 42 becomes due the WiFi obsolete. I have to make project for enclosure with the only one small hole for micro USB on ESP32


Drew 🔭📷🚴‍♂️
 

Here is a quick way to implement the WiFi connection with the SHC. These "credit card" power banks are widely available. I use one that claims 2500mAh. I have gotten 14 hours of connect time with it.


Dave Schwartz
 

I am leaving the RJ45 socket fully functional, but unconfigured, on mine for the backup reason although you would need to rebuild the software to use it. But why not have 2 - they're cheap!

Also... you would want the switch BEFORE the DC-DC module to eliminate its parasitic loss when the switch is off.

On 2021-11-15 6:27 a.m., Patrizio Boschi wrote:
Indeed if the plan is to make the rj22 port obsolete. But I think it's a rather good fall back, and it could double as a charging port. Maybe it's possible to have both ports act as charge ports by adding one or two diodes?


P

Il lun 15 nov 2021, 10:31 <mil-cha@...> ha scritto:

Actually the only port I need is the micro USB on ESP32. The RJ 42
becomes due the WiFi obsolete. I have to make project for
enclosure with the only one small hole for micro USB on ESP32