DIY Automatic Control Power Switch for Mouse

Wireless mice are very convenient, but the batteries are not very durable. Even rechargeable batteries need to be charged. Many mice come with a power switch to save battery energy, but it’s easy to forget to turn off the switch after use, leading to waste.

Although most mice have an automatic sleep function, the effect of sleep doesn’t seem ideal. I have tried several 2.4G wireless and Bluetooth mice, and have often been troubled by battery issues without finding a suitable one, so I thought about modifying one myself.

Ideally, the mouse should be usable as soon as you pick it up, and automatically turn off power after being placed down for a while. This way, regardless of whether the mouse’s low power consumption function is good enough, it won’t drain the battery, making it more worry-free to use. I happened to have a spare Bluetooth mouse, so I got to work on modifying it.

DIY Automatic Control Power Switch for Mouse

This mouse is the most common public mold mouse. It is powered by a 14550 lithium battery, and possibly due to the small battery capacity and usually not having a power switch, it can typically be used for 7-15 days on a single charge (depending on usage frequency).

DIY Automatic Control Power Switch for Mouse

The mouse is easy to disassemble. After removing the battery, you can see the fixed screws. This mouse is secured by only one screw, and there are no screws under the mouse pads (some mice may have screws at the back under the pads). After removing the screw, it is easy to separate the upper and lower parts of the mouse and see the mainboard inside.

To achieve the earlier idea, it’s actually not difficult. You only need a low-power microcontroller (most microcontrollers nowadays can do this), a touch button chip, and a P-MOS transistor. The touch button chip detects when a hand touches the mouse, and when the mouse is touched, it outputs a signal. Once the microcontroller detects this signal, it controls the MOS transistor to turn on and supply power to the mouse; when the signal disappears (the hand is removed), it cuts off the power after a delay, thus automatically saving battery energy. Some microcontrollers support high current output pins (output current not less than 50mA), in which case the MOS transistor can be omitted.

Having determined the basic plan, the next step is to select the appropriate components. A lithium battery’s voltage range is 2.7-4.2V, so you need to choose a microcontroller that supports 2.7-5V, otherwise, an LDO is needed to prevent the voltage from exceeding the range. The MOS and touch chip also need to be selected according to the appropriate voltage range. These components are relatively easy to find, and I believe everyone has some familiar ones. However, the fun of DIY lies in trying to use as few costs and existing items as possible, rather than spending a lot of money to buy a ready-made one. So I rummaged through my junk box and found the following components, which just meet the requirements:

  • ATTiny13V, an 8-pin AVR microcontroller
  • TTP223, a single touch sensor
  • SI2301, P-MOS

DIY Automatic Control Power Switch for Mouse

ATTiny13V is an 8-pin microcontroller with a maximum clock frequency of 10M, 1KB flash, 64B RAM, and 64B EEPROM. The power consumption in sleep mode is about 5uA (with the watchdog enabled).

DIY Automatic Control Power Switch for Mouse

TTP223 is a chip in SOT23-6 package that supports multiple output modes and self-calibration. To keep the program simple, I used the direct output mode here, which is active low. Therefore, TOG needs to be grounded, and AHLB connected to VCC.

DIY Automatic Control Power Switch for Mouse

SI2301 is just a regular MOS, and other similar models can be used.

DIY Automatic Control Power Switch for Mouse

I haven’t used AVR microcontrollers for many years, so I found my programmer, which I DIYed back then, using the AVRUSB method. I also found an old computer with XP installed because systems after Windows 7 cannot directly use AVRUSB.

DIY Automatic Control Power Switch for Mouse

DIY Automatic Control Power Switch for Mouse

Since I didn’t have (and didn’t need) a simulator, I used Proteus for the program. In Proteus, you can simulate, write code, run simulations, and set breakpoints. If the simulation results are normal, there usually aren’t any big issues.

DIY Automatic Control Power Switch for Mouse

I hadn’t used AVR for a long time, and I had forgotten some usages. Fortunately, I have a general driver layer I wrote before, and I was able to complete the functionality quickly without looking at the manual. I used one IO for touch detection and another for MOS control. The microcontroller usually sleeps, waking up through WDG timing, and the power consumption in sleep mode should be less than 20uA. I didn’t feel this deeply before, but now I increasingly realize how important a good HAL is.

  1. #define F_CPU 4800000L

  2. #include <inttypes.h>

  3. #include <avr/io.h>

  4. #include <avr/interrupt.h>

  5. #include <avr/sleep.h>

  6. #include <util/delay.h>

  7. #include “uhd.h”

  8. #define V_OUT B, 3

  9. #define T_IN1 B, 4

  10. void init()

  11. {

  12. IO_dir(V_OUT, IO_OUTPUT);

  13. IO_set(V_OUT);

  14. //IO_pullup(T_IN1, PULLUP_ENABLE);

  15. IO_dir(T_IN1, IO_INPUT);

  16. WDT_sleep(40);

  17. }

  18. uint8_t cnt = 0;

  19. uint8_t mode = 0;

  20. int main()

  21. {

  22. init();

  23. while (1)

  24. {

  25. WDT_sleep(8);

  26. if(IO_in(T_IN1) == 0)

  27. {

  28. IO_clr(V_OUT);

  29. mode = 1;

  30. cnt = 60;

  31. }

  32. else

  33. {

  34. if(mode)

  35. {

  36. cnt–;

  37. if(cnt == 0)

  38. {

  39. mode = 0;

  40. IO_set(V_OUT);

  41. }

  42. }

  43. }

  44. }

  45. return 0;

  46. }

Download the program to the microcontroller, then solder the signal wires, and you’re done. A long wire was used for touch sensing and fixed under the upper cover.

DIY Automatic Control Power Switch for Mouse DIY Automatic Control Power Switch for Mouse

After installing the battery and running it, the effect is good, and the sensitivity is also very high. However, during use, I found that the delay time for turning off the power is a bit short; the program is designed for 5 seconds, and sometimes when I pick something up, the power turns off. It might be better to change it to 10-30 seconds in the future.

Postscript:

  • After the first installation and running, I found an issue where the TTP223 output could not be pulled to 0V, only to 2.8V. Upon checking, I found that the pull-up resistor for the IO was enabled in the program, and after disabling the pull-up, it worked normally.
  • To better prevent interference, multiple touch signals can be used for control. The power should only be turned on when multiple signals are simultaneously valid; this will yield better results.
  • For mice powered by a single AA battery, since the voltage range is 0.9-1.5V, the above components cannot be used. Therefore, appropriate components need to be selected, or a boost method must be used.

Recommended Reading

DIY Automatic Control Power Switch for Mouse
Targeting autonomous vehicles, the US is challenging China again!
Facts about the chip war
China Semiconductor Industry Association speaks out: A series of restrictions by the US government in recent years is regrettable
Is LiDAR becoming just a “showy technique” in the assisted driving field?

DIY Automatic Control Power Switch for Mouse

Reply with any content you want to search for in the public account, such as keywords, technical terms, bug codes, etc., and you can easily get professional technical content feedback related to it. Go try it!
If you want to see our articles regularly, you can go to our homepage, click the three dots in the upper right corner of the screen, and click “Set as Favorite”.

DIY Automatic Control Power Switch for Mouse

Scan to follow us
DIY Automatic Control Power Switch for Mouse
DIY Automatic Control Power Switch for Mouse
DIY Automatic Control Power Switch for Mouse

Leave a Comment