Friday, October 17, 2025

 Changing the I2C address of a SRF02 sensor

Unlike most other devices does the SRF02 not allow you to set it's address with jumpers on the hardware side. You need to send a specific sequence of values to it's register to set the new address.

I wrote a simple piece of C code to make this task easy for anyone with a Raspberry Pi. All you need is a C compiler and the wiringPi library.

Just compile the single C file, or use the CMake setup to get the tool and some sample utility and you are set to go.


The set_address application lets you change the i2c address of the sensor.

set_address <old address> <new address>

Where old address is the current I2C address of the sensor and new address is the desired address. Use 7-bit notation for both addresses. For example:

$ ./set_address 0x74 0x70

*** Changing SRF02' I2C address from 0x74 to 0x70

  Writing 0xa0 to register 0x00
  Writing 0xaa to register 0x00
  Writing 0xa5 to register 0x00
  Writing 0xe0 to register 0x00

*** Address change sequence complete

  Check if device reacts to new address 0x00
  -> The new device address is working

*** Address change was successful

The tool will

  • check if the sensor is accessible at the old address
  • reprogramm the address setting
  • check if the new address is reachable

Before you run the tool, make sure that the SRF02 is the only device on the I2C bus. THe reprogramming may fail otherwise.

Wednesday, October 15, 2025

 Carrera Haircutter .... - Battery repair

Another rechargeable device goes dead after only a few minutes of operation. This haircutter took from 100% to 10% battery less than 5 minutes.  Which may end up really bad is your in the middle of cutting your hair and then the cutter dies on you.


But I still refuse to trash a perfectly working device, jut because the battery doesn't want to recharge anymore. So the battery need to be replaced.

The device I have is a "Carrera Profi.Akku-Haarschneider Art. 96977 Modell 18233921" This brand has many similar devices. I expect the insides to be pretty similar. 

  


To open up the housing you need to first remove the clippers in the front. They come off easily, you probably dit this quite a few times for cleaning. 

Now two screws become visible. These need to be removed.

There is a thrid screw at the bottom side of the handle. Remove that one as well.



Now you can carefully open the case using a plectrum or spatula to prey the top and bottom part apart.


There are two small grips coming off as well. Put them to the side, we'll reattach them later.

As you can see, the battery is soldered to the PCB with two short flap like metal pieces.   Removing the old battery is probably the most difficult step.

I clipped the  gaps off the battery to get better access with the   soldering iron to the PCB. 









Then removed as much of the lead as possible and pulled the flaps out of their fittings while all was still hot and liquid. Make sure the holes in the PCB are free of lead, so the contacts of the new battery can slide through easily.

I did not fond a plug&play replacement battery for a reasonable price online. So I took one of these cheap RC batteries that come wiht USB chargers. You can get them as cheap as 6x for 10€.



When you carefully remove the outer skin, you'll get to the insides and see that this is a perfect fit for the old battery. You only need to clip the little connector for the cables away.












Now put the new battery in place. Make sure the Plus side faces to the motor. 



Once the battery is fixed and soldered you can start reassembling the hair-clipper again. 






Put the screws back in place and ... 






      ... "click" the grips back on after the case is tight.






Now all that is left to do is to recharge and enjoy the new battery life.

Saturday, October 11, 2025

SRF02 Ultrasonic Sensor with wiringPi

The
 SRF02 is a single transducer ultrasonic rangefinder frequently used in Aruino projects. I wanted to it to implement a simple, radar like distance sensor for a small robotic project.

Here are ready to use C functions to use the sensor on a Raspberry PI with the wiringPi GPIO access library. A basic usage example looks like this:

#include "SRF02.h"

#include <stdlib.h>
#include <stdio.h>

#define ADDR 0x70 // default address for SRF02

int main( int argc, char* argv[]) {
    int addr=ADDR;

    // allow device address as optional commandline parameter in hex notation
    if (argc==2) {
        sscanf(argv[1], "%x", &addr);
    }
    // initialize sensor‚
    int srf02Device = srf02Init(addr);
    if (srf02Device < 0) {
        fprintf( stderr, "ERROR: SRF02 not found at 0x%02x\n", addr);
        exit(1);
    }

    for ( ;; ) {
        // request distance in cm
        srf02Ping(srf02Device, SRF02_CENTIMETERS);
        
        // poll device until valid reading is returned, or timeout (100ms) expired
        int timeout=10; // 10*10ms -> break after 100ms
        int distance = -1;
        do {
            distance = srf02Read(srf02Device);
            delay(10);
            timeout--;
        } while (timeout > 0 && distance < 0);

        if (distance >= 0) {
            printf("Distance: % 4d cm (%d ms)\n", distance, (100-timeout*10));
        } else {
            printf("No valid reading returned after % 4d ms\n",  (100-timeout*10) );
        }
    }
}

This lets the sensor send a ping and poll it untils the sensor readings are available:

$ ./sonarping 0x70
Distance:   14 cm (20 ms)
Distance:  258 cm (30 ms)
Distance:  213 cm (30 ms)
Distance:  213 cm (10 ms)
Distance:  259 cm (30 ms)
Distance:  258 cm (30 ms)
Distance:  258 cm (30 ms)
Distance:  256 cm (10 ms)
Distance:   16 cm (10 ms)
Distance:   14 cm (10 ms)
Distance:  258 cm (10 ms)
Distance:   14 cm (10 ms)

You see the measured distance and the time it took the sensor to return a value.

Thursday, October 9, 2025

Beboncool Q44 Wireless Switch Pro Controller Battery Replacement

If your controller is like mine, then the battery life will drastically decrease after a few years of usage. I bought a couple of these controllers three years ago. In the beginning recharging was needed only after 10+ hours of gaming. Now battery life was down to about 30 minutes. Other than that, they are working just fine. Joysticks and buttons are still OK and it would be a waste to trash then, just because of a bad battery.








Time to open up the controller up and check how to replace the battery. It actually was a fairly easy job to do and I like to share a step step guide for you to do it yourself. 



Getting prepared

All you need is

  • A small phillipps screwdriver to open the case and remove the upped PCB. 
  • A small spatula or plectron to remove the colored handles. If nothing else is at hand, a small screwdriver may do the job as well.
  • A 3.7V LIPO battery of the right dimensions, with a JST connector. See below for details.
  • Some padded, double sided tape to fix the battery to the PCB.
  • About 30 minutes of time.
The dimensions of the original battery are roughly 20 x 40 x 8 mm. I did not find one of the same size, so I used a slightly lager, but thinner one (24 x 38 x 5,6 mm). There is enough space in the casing to allow for some variation of the size.

The capacity of the replacement I picked is 500mAh, which is a significant improvement over the original battery. It now lasts even longer than when they were new before a recharge is required.

It is important to make sure that the polarity is correct at the JST connector. If plus (red) and minus (black) are flipped, you risk to brick the controller. So please double check when you order the battery (both options are available) and check once again before you plug the new battery into the controller PCB. Compare the connector with the old battery, both need to look the same.





Open the Controller

The grips clip onto the controller. Use 
a spatula or a plectron to prey them open.





Next you can loosen the eight screws holding  the backside of the controller












Next you can remove the backside and see the bottom PCB and the motors driving the weights used for vibration. 

In my case I also saw some corrosion of the PCB. There must have been moisture inside at some point of time.








Remove the bottom PCB and the old battery


The bottom PCB is held in place by four screws. Remove them.

There is a cable connecting the two PCBs. Carefully "fold" the PCB away, so you can see the battery. There is no need to disconnect the cabling. 












Now unplug the battery and carefully lift it from the PCB. It's attached with some double sided padded tape. 

There are electronic components below. Be sure not to scratch them or to break any of the connections.








If possible clean the remains of the tape. It'll give the new battery some more space to fit in.

Plug in the new battery and do a first check



Time to reassure the correct polarity of the new battery. Compare the connectors. The red and black cables need to match up.


When everything is correct, you can plug the new battery into the socket on the PCB and fix the battery on the with some adhesive padded tape.

If the new battery has not the exact same size as the original one (like in my case), you should make sure that it doesn't block any of the screw-holes or the joystick mechanics.  



If you like you can flip the controller around and press the home button. The red LEDs in the middle should start blinking.  The new battery works!











Putting it back together

Almost done!

When the battery is fixed in place, you can to put the bottom PCB back. Make sure the joysticks are in they sockets and move freely. There should be no cables, no glue or even the battery in contact with any moving part of the buttons or the joysticks. It everthing is OK, put the four screws back in.

 




At this point you can test the full functionality of the controller before you put the backside and the grips back in place.

Just be careful not to get hit by the vibrating weights.







Next put the back cover in place, make sure it sits tight and that there are no gaps - they may indicate pinched wires. Eight screws to fix it.













The last steep is to "click" the grips back on and charge the controller.

Congratulations! 

You replaced the battery and the controller is ready for some more years of entertainment...