DIY Automatic Power Switch for Wireless Mouse

DIY Automatic Power Switch for Wireless Mouse

EEWorld

Electronic News Sharp Interpretation

Technical Content Updated Daily

DIY Automatic Power Switch for Wireless Mouse

Wireless mice are very convenient, but the battery life is not very good. 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 it off after use, leading to waste. Although most mice have an automatic sleep function, it seems that the sleep effect is not ideal. I have tried several 2.4G wireless and Bluetooth mice, and they often have battery issues. I couldn’t find a suitable one, so I decided to modify one myself. Ideally, I want to use the mouse as soon as I pick it up, and have it automatically switch off after being put down for a while. This way, regardless of whether the mouse’s low-power function is good enough, it won’t drain the battery, making it worry-free to use. I just happened to have a spare Bluetooth mouse, so I got started on the modification.

DIY Automatic Power Switch for Wireless Mouse

This mouse is the most common public model mouse. It uses a 14500 lithium battery for power. Perhaps because of the small battery capacity and usually no power switch, it can typically be used for 7-15 days on a single charge (depending on usage frequency).DIY Automatic Power Switch for Wireless Mouse The mouse is easy to disassemble. After removing the battery, you can see the fixed screw. This mouse uses only one screw for fixation, and there are no screws under the mouse feet (some mice may have screws, while the last two mouse feet have screw pillars). After removing the screw, it’s easy to separate the top and bottom parts of the mouse and see the motherboard inside. Achieving the previous idea is not difficult; you only need a low-power microcontroller (most microcontrollers can do this), a touch button chip, and a P-MOS transistor. The touch button chip detects hand contact with the mouse; when the mouse is touched, it outputs a signal. The microcontroller detects this signal and controls the MOS transistor to turn on, supplying power to the mouse. When the signal disappears (the hand moves away), the power is cut off after a delay, automatically saving battery energy. Some microcontrollers support high current output pins (output current not less than 50mA), so the MOS can also be omitted. Once the basic plan is determined, the next step is to select suitable components. The voltage range of a lithium battery is 2.7-4.2V, so a microcontroller that supports 2.7-5V needs to be chosen; otherwise, an LDO must be added to prevent the voltage from exceeding the range. The MOS and touch chip also need to be selected with appropriate voltage ranges. These components are relatively easy to find, and I believe everyone has some familiar ones. However, the fun of DIY lies in using as few resources 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 that just meet the requirements:

  • ATTiny13V, an 8-pin AVR microcontroller

  • TTP223, a single touch sensor

  • SI2301, P-MOS

DIY Automatic Power Switch for Wireless MouseATTiny13V is an 8-pin microcontroller with a maximum clock frequency of 10M, 1KB flash, 64B RAM, and 64B EEPROM. Its power consumption in sleep mode is about 5uA (with watchdog enabled).DIY Automatic Power Switch for Wireless Mouse TTP223 is a chip in SOT23-6 packaging that supports various output methods and self-calibration. To make the program simple, a direct output method is used here, where low level is effective. Therefore, TOG needs to be grounded, and AHLB connected to VCC.DIY Automatic Power Switch for Wireless MouseSI2301 is a standard MOS that can be replaced with other similar models.

DIY Automatic Power Switch for Wireless Mouse I haven’t used AVR microcontrollers for several years, so I found my programmer, which I DIYed before using the AVRUSB method. I also dug out an old computer with XP installed because systems after Win7 cannot directly use AVRUSB.DIY Automatic Power Switch for Wireless Mouse DIY Automatic Power Switch for Wireless Mouse Since I don’t have (and don’t need) a simulator, I used Proteus for programming, simulation, and debugging. If the simulation runs normally, there generally won’t be big problems.DIY Automatic Power Switch for Wireless Mouse I haven’t used AVR for a long time and forgot some usages. Luckily, I had a general driver layer I wrote before, so I quickly completed the functionality without looking at the manual. I used one IO for touch detection and another IO for MOS control. The microcontroller sleeps most of the time and wakes up via WDG. The power consumption during sleep should be below 20uA. I didn’t realize it before, but now I increasingly feel that a good HAL is very important.

#define F_CPU 4800000L

#include <inttypes.h>

#include <avr/io.h>

#include <avr/interrupt.h>

#include <avr/sleep.h>

#include <util/delay.h>

#include “uhd.h”

#define V_OUT B, 3

#define T_IN1 B, 4

void init()

{

IO_dir(V_OUT, IO_OUTPUT);

IO_set(V_OUT);

//IO_pullup(T_IN1, PULLUP_ENABLE);

IO_dir(T_IN1, IO_INPUT);

WDT_sleep(40);

}

uint8_t cnt = 0;

uint8_t mode = 0;

int main()

{

init();

while (1)

{

WDT_sleep(8);

if(IO_in(T_IN1) == 0)

{

IO_clr(V_OUT);

mode = 1;

cnt = 60;

}

else

{

if(mode)

{

cnt–;

if(cnt == 0)

{

mode = 0;

IO_set(V_OUT);

}

}

}

}

return 0;

}

Download the program to the microcontroller first, then solder the signal line, and it’s done. A long wire was used as the touch sensor and fixed to the underside of the top cover.DIY Automatic Power Switch for Wireless MouseDIY Automatic Power Switch for Wireless Mouse After installing the battery and running, the effect was good, and the sensitivity was high. However, I found that the delay time for shutting off the power was a bit short; the program was designed for 5 seconds, but sometimes when I picked something up, the power turned off. In the future, it might be better to change it to 10-30 seconds.Postscript:

  • After the first installation and running, I found a problem: the TTP223 output could not pull to 0V, only 2.8V. Upon checking, I found that I had enabled the pull-up resistor for the IO, and after disabling it, it was normal.

  • To better prevent interference, multiple touch signals could be used for control; only when multiple signals are valid at the same time would the power turn on, resulting in better performance.

  • For a mouse powered by a single AA battery, since the voltage range is 0.9-1.5V, the components above cannot be used. Therefore, it is necessary to select suitable components or use a boost method.

For the complete Proteus8 program, please click to read the original text to download.

Recommended Reading

Content | Understanding Five Common Internal Noises

Content | How to Characterize Noise in Operational Amplifier Circuits?

Content | EMC Design Experience in the Early Stages of Electronic Product Design

Content | An In-Depth Analysis of CAN Communication on STM32

Content | DC Motor Drive Circuit and Design Experience Sharing

Content | A Compilation of Circuit Diagrams Every Electronic Engineer Must Master

Content | A Single Article to Help You Understand the Difference Between DC-DC and LDO

Content | FreeRTOS Learning Notes – Software Structure of FreeRTOS

Content | Classic Operational Amplifier Circuit Analysis

DIY Automatic Power Switch for Wireless Mouse

The following WeChat public accounts belong to

EEWorld (www.eeworld.com.cn)

Welcome to follow by long pressing the QR code!

DIY Automatic Power Switch for Wireless Mouse

EEWorld Subscription Account: Electronic Engineering World

DIY Automatic Power Switch for Wireless Mouse

EEWorld Service Account: Electronic Engineering World Welfare Society

Leave a Comment