Fixing a broken scroll switch


A while ago I felt I needed to upgrade my work mouse to a higher resolution one, since I am mousing all around doing designs across 3 screens. In a purchase of impulse, I ended up getting a wireless one for a good price, the 4000dpi Mpow Dragon Slayer gaming mouse. I was happy with it for the first 2 months: 2-3 weeks of life at max resolution using rechargeable batteries without lights and an excellent match for my hand. Then the scroll started working improperly, it would change direction every few steps.

Update: the thing does not work, again. I suspect it really is a bad encoder. I tried to replace it, but the size I got was incompatible so I ended up sending it to the dumpster. Not recommended.

Fixing it

I thought the problem was not mechanical – bad contact, but since I did not have a spare scroll switch anyway nor time to invest in looking for a replacement…i thought i could try an electronic fix: de-bouncing the switch, which I saw no trace of being implemented on the PCB in a brief search. Cheaper de-bouncing is normally done in firmware, without passives, however if insufficient, I can compensate in hardware.

Here is the guilty switch, the one with the red part

DSC_6580The solution: add 2 1nF capacitors across the switches. I figured this would give a good de-bounce time with what looks like internal pull up resistors (~10…100KΩ) from the microcontroller.

DSC_6581And the terrible soldering job

DSC_6581-2Then I put it back together


DSC_6586Of course, opening it meant removing the feet, which don’t stick back properly



All done, the rodent is happily and properly working. Time will tell if this will last long enough, I will update if it breaks again. I hope the engineers at Mpow can see this and fix this really great mouse. Also a more “business” model would be great. The fact that the problem shows up so soon and for so many people tells me it is a software problem – not enough debouching. It only works while the switch is perfect. I have used plenty of mice so far and never found this to be an issue ever, even for much cheaper products.

Cheap China

[This article is alive and being updated with things that I use].

This is a summary about my experience with cheap electronic modules from China. I have used quite a few throughout the years, so there will not be any long video explanation, but more of a summary. The article is a living creature, with new updates as I test more stuff.

Why buy this stuff?

It makes sense for large distributors to sell you parts at exponentially higher markup when bought in smaller quantities, since it takes comparable effort to collect, package and send you 1 or 100. But the home user is interested in small quantity and most of the time using things in a typical diy recipe. This makes a ready made module carrying, for example, a real time clock chip along with its passives and backup battery a lot more attractive than just a bare chip. Since these modules are made of components quite close to the factories, in Asia, and sold avoiding a lot of the middle-men, it makes sense they would be cheaper than a 1-off component from a distributor. However, the ingredients used are not really top notch.

Some general observation first

These modules are cheap, generally everything is under 20ish EUR, which is the mark for paying VAT in the EU, varying slightly by country. This tax usually attracts another fixed import processing fee which raises the price significantly. Unless you are into high quantity, it makes more sense to buy items over this threshold locally.

The most important thing to understand is that these things are mostly provided ‘as is’ with no guarantees, no matter what ebay/other website will try to convince you, because…

“It works” does not mean what you think it means. I have learned this while discussing LEDs with a distributor: it works means there is light coming out of the LED, that is it. Big companies will count LED lifetime until it drops to about 70% of initial brightness. Generally speaking, “it works” means the thing is doing something somewhat related to what it should do, with no guarantee of any performance or operating parameters. 

In general, you should assume that the parts on the modules might be fab rejects, clones or even something totally different pretending to be the real thing. Words like “genuine” or “original” are thrown in the tile to tell you they mean business.

With such a low value of the items, there’s no surprise that even though the seller would accept a return, paying for the return shipping is a no go. And they know that.

When you buy a lot of X quantity of parts, there are some that are crappy and even dead on arrival. It happened to me buying the NRF24L01+ modules, DC/DC converters, PIR sensors, even headers. I suppose they might do some testing on the 1 PCS sales, not on the lots.

Quality and functionality of some module will decrease over time and is not consistent among suppliers, as they find more ways to cut cost or make a clone of a clone of a clone, see the NRF24L01 below. This is the reason why I am not linking to places of purchase, you will not get the same thing anyway.

However, things are not all bad and these modules are worth it for some application. Think for example the NRF24L01, you probably don’t care that it is not compatible with genuine ones, and I don’t care that 1-2 of the 10 are not working, since I can buy 20 for the price I pay for 1 at a distributor. And hopefully, we will both never find out they break any radio compliance. But, I would not use them if I were to build something and sell it.

These types of devices are great for hobby and learning, especially the troubleshooting part. Or sometimes just exploring and getting to know the feeling of a device. So, if you proceed with the right expectations, good things can happen and great projects can come to life.

Here are the devices I have experimented with, but don’t take this information for granted. There are numerous suppliers and very high variability with all modules, not to mention some room for user error.


ESP8266. This is an absolutely great device and without access to a real good supply of these modules it is hard to say if the quality problem is with ESP8266 IC itself or the modules are  just using bad parts. The 1 of the 2 modules i got first from electrodragon is still working fine in the LED logger. But, overall 2 others have died, both coming from ebay. Another thing I have noticed is that the devices, even though specified up to 1.8V and with good supply and decoupling capacitors, seem to operate only down to about 2.6V.


NRF24L01 – 2 black ones DOA got while working on the Stockie project. 2 more died during experimenting from a batch of 10, without being stressed in some way. Another batch of 10 had 1 DOA. They are partially incompatible with genuine chips or “real” copies like the RFM75. But things get really bad after a while as they are trying to make them even cheaper than they are. A green version exists with an incompatible pinout which I did not test because of this. The high power version used as a central node coupled with low power versions on other nodes can give you quite some range.


Step up/down DC/DC converter, lot of 5, look at the great soldering job. The IC is far off the PCB, with only a bit of solder at the end of the metal tab. They are nowhere near capable of what they promise, de-rate 2-3X for continuous operation because of bad soldering, under performing IC, no heatsink and high ESR caps.


3mm LEDS: quite a bunch of them. Very inconsistent in brightness at the same current. Quite a few of them dead, maybe 3-5%, so I would not throw this in a project without giving it a try. A couple of them they died without any stress in some more long term assemblies. Stay away from them if you want to use them in anything more permanent, I know I do.


Bad led strips, bright and nice warm light, but getting dim fast as tested with the LED logger. I use these in a wardrobe, so no problem with lifetime there, as they run only minutes per day.


Ribbon cable that is so stinking of plastic smell even after letting it “out to dry in the sun” for a month. No picture,  i threw the thing away.


These breadboards are so terrible i threw them away. They are crooked and rusty. Nowhere near the quality of a regular breadboard.


These breadboards are OK, but quite small.


Ramps 1.4. Thought getting everything for a driver is cheaper separately but this thing came with such bad soldering I had to give up on it. There is not much on the board that could not function, just that all the connectors on the back were poorly soldered at an angle.


Component tester. The original one is an absolutely great device and was on my to build list for a long time, however not of relevant priority. The version i got is much nicer, as it comes with a graphic LCD that is more intuitive to use. Precision is not that great, judging from comparison with the multimeter, but that is not what I am looking for. It is good to know some simple things, like if those cheap 3mm LEDs are DOA or not or making sure you don’t have a old and dried capacitor. SMD component testing is rather impossible by placing the part on the board. Recommend it only as an aid to a good multimeter.


1.44” or 2.2” IL9341 LCDs use a controller chip for which you can find a driver on many platforms. Pretty bad in terms of colours and one of them fell apart, even though it is still working. The headers are compatible across sizes and the big ones support an awkwardly placed SD card slot on them, but I never used it. They are the best thing to get if you need a cheap colour LCD.



WS2812 LEDs are a pleasant surprise, as my LED logger is showing, they are good for long term lighting. However, they do come with some limits, as the strip copper is highly inadequate for carrying all the current with LEDs at max. The data input pint is also very sensitive, I have managed to break quire a few. I am using them on the kitchen counter along with a motion sensor and that is pretty much the only light i normally use. Being RGB LEDs, they increase the “saturation of vegetables”.


WS2812 ring I got for an indicator, which was fine. However I tried to use one for lighting and they are nowhere near capable of dissipating the heat of all LEDs at max brightness constantly.


RFM69 – at the moment it costs about as much as it does at distributors, if I purchase 25 minimum. There is clear difference in components and the ebay one appears to be soldered manually and poorly. I suspect they are factory rejects manually fixed. My sensors website folks seem to use them without issues and the one I got works so far. However, I will continue to purchase them through regular distributors.


Voltmeters – the ones with 3 wires are great, you can even hack the micro on them. Don’t know about long term life or stability. 2 wire ones I have not tested, but I suspect they are more limiting.


Buzzers – waaaaaaaaaaaaaay quieter than the same thing from a distributor. [If CAPS says I am SHOUTING, what do I use to talk quieter?]


Terminal blocks – at quantities of 10s to 100 similar to distributor price, but the ebay ones stink.


Headers and connectors – cheaper than distributors, specially in small quantities. Some stink, some don’t. The gold coating is almost missing and they are more prone to oxidation. Avoid in things that you would care to work over long time, I suspect they will rust.


Jumper wires. I have talked about this one before.


FT232 adapters. I guess you know how these work out. Cannot say why, but I prefer the CP2102 modules below.


CP2012 USB-serial adapters. Clones, all with same serial number – a pain to manage multiple in various USB ports. Occasionally lose connection, but SW like YAT reconnect automatically. Edit: apparently the serial number can be changed, but I have not tried it.


Touch sensor – not low power, but ok. Seems to work, no long term testing. Given the application, there should be a jumper to disconnect the LED, as it is burning more power than the chip. Thought it can work as sit sensor, while experimenting for Sit.Up, but the auto calibration means it does not detect a touch after a few seconds.


Micro USB breakout – no issues, but they could have used thicker lines for power. A version with integrated ESD on the data lines would be a lot better.


Step UP DC/DC converter Noisy and pretty incapable of operating at the specified power. Use 2-3X derating.


USB battery charger – no issues so far.


QFN/TQFP to DIP adapter – smart because it lets you add a capacitor or pull down resistor to every pin. Not great, since the pads are too wide and solder bridges are hard to avoid. Don’t forget to connect the ground plane to the ground separately.


PIR sensors – have quite a few large ones operate for a few years. As with other packs, from a pack of 10, 1 was DOA, one very insensitive. Small ones seem to do fine as well, but are less sensitive and you cannot adjust the sensitivity or time.


CSR8645 bluetooth module. Overheating from start, despite proper supply. Died in less than 1h.


Bluetooth device for my blue panda. Died after some 10s of hours of usage over the course of a couple of years.


HC-SR04 – ultrasonic sensor. Works as described, but only briefly tested on the Sit.Up project.


US-100 sonar, smarter than the HC-SR04 and can operate at lower voltage. No long term testing, just brief playing with Sit.UP!


Nokia LCD – refurbished parts from old phones, mine have bad contrast requiring adjustment, but great LCD for some LOW power displays. More flexible than the typical 16×2 LCDs.


Vibrator motor – used in Sit.Up. One of 5 DOA and pretty weak compared to what is found in modern smartphones.


25 EURO oscilloscope. Just amazing what you can get in terms of oscilloscope for such a low price. I got it out of curiosity, it is pretty impractical, but it is a lot better than no oscilloscope for a beginner.



A project out of frustration. A hardware solution to bad software…

[Project complete……but check in a few months for performance reporting]

Also available at

auto resetter electrobob


AutoResetRRR is a kind electronic frustration reducing device: it cuts the power periodically to devices that can go nuts (routers, net cams, servers), but it does give a heads up. If all is well, they can shut down safely and start back up. If not, the power cycle can fix a thing or two.

I have a raspberry pi time-lapse rig that sometimes hangs. And a few simple IP cameras also used for time lapse, all a bit inaccessible. And my modem/router that comes from the ISP gets the “slow internet syndrome” every now and then.

They should have good software, but they don’t. I cannot change the software in most devices to tell it to restart periodically, unlike my openwrt stuff. So I have fix this in HW by cutting the power with the AutoResetRRR.

Oh, and it allows devices like the RasPi to have a soft shut-down button like you expect from any PC.

What it is

A small devices that you place between the power adapter and your device. I works with most supplies from 5V to 35V, and can switch over 3A, so practically any device you might find in your home. From time to time, say once a day, it cuts the power to that device for a few seconds, forcing it to reboot. For devices that can use this, such as a raspberry pi, a separate pin can warn a little ahead of the coming restart and allow for safe shutdown.

As or the bells and whistles, especially for the raspberry pi, there is a possibility to shut down the power permanently by pulling a pin low.

Why it is not? Or the things I thought about before

A 555: because it’s difficult and requires bulky components for such low duty cycle, plus it is hard to get long durations or a pre warning.

A programmable of the shelf timer: it’s not possible to get a pre shutdown warning with it. Plus, I need quite a few of them, which makes my solution more cost effective.

ESP8266 based: mostly, too much current. A lot of the devices I have don’t have the margins to support the peak 250mA from their power supplies. Plus, so far quite a few of my ESPs have died after just months of operation.

Just a way to press the reset switch: it’s too much effort to get inside most devices.

A super complicated device with touch screen, configurations and bells and whistles: I want something simple that can have a high reliability and needs little time to design.

The proto

This is the first device I made on a bread board, but the PCBs are already mostly designed. So far the software is incomplete, but the reset time-out is working. The blue LED is the one that will blink, while the green one simulates the device.



Schematic and PCB

I finished the board and sent it to the fab. Schematic and PCB rendering below. Files are available at  GitHub along with the firmware and raspberry pi software. The usual 5V regulator with fool proof diode ensures a good 5V supply for the ATTiny13 micro, up to 35V input. There are no worries for powering the device from 5V directly, at the low current consumption it will get about 4V, enough for proper operation. But of course, you can totally skip the regulator in case of a 5V supply. A IRLL2705 logic level NMOS takes care of switching the load. And the brain is a small 1k of flash micro, the ATTiny13.

Your typical LED insures a nice blinky to tell you everything is working. The same output is going to intelligent loads like the Raspberry Pi: 2 minutes  before the reset the LED will stay constantly on, to tell it to shut down. The same pin is used bidirectionally: if the load will pull it to ground, that is a sign that it should be powered off soon, so the AutoResetRRR will cut the power after a delay.


auto resetter boardPCBs arrived

I made the PCBs at Elecrow, and due to the small size they sent quite a few extras. Time to get soldering




First one assembled

The first device skips the 5V regulator, as I am testing it with a raspberry pi. Everything is red, even the LED. I began to test it for the raspberrry pi as this needs the additional python software required to shut-down the pi safely. I am thinking to implement the functionality of a power button as well, will be a simple one, since the Pi does not have such functionality.

DSC_5624To contact the side ISP connector I use a home made PCB with a simple 90 degrees connector with pins slightly bent


And brief tests with the Pi, shutdown during the warning time works smoothly.



Parts are here and…

It appears I have accidentally ordered the wide version of the SO8 package for the tiny13. It has been 5 years 0 days since the last wrong part purchase. The pitch is the same, so I will probably get around this by bending them.

DSC_5640Mini assembly run

I have assembled 6 more devices, for a total of 8. Collecting the parts, assembling them and programming the 6 took slightly less than 1 hour, that is 10 minutes for each device. Not bad.

DSC_5659Notice the 2 ways to connect the power, supported by the PCB: using terminal blocks or DC jack. Of course, any combination of the 2 is possible. I prefer terminal blocks for all the devices that are out of warranty and I can cut the cord to as this allows for a more optimal placement, such as at the middle of the cable.


And finally, some tests with the most relevant type of device: the router. Disclaimer: this is not the router it will be used for, fortunately this can run OpenWrt.


Camera installation coming soon… and possibly a 3d printed case, although i have some project cases that fit the device nicely and that is a faster way to get things done.

Project is now complete: will report in a few months with the performance of the device!

Mini ikea molgan hack

Update exactly 7 months after initial post: I have used this on my night stand, for a little bit of instant light during the night. The thing is still working, but visibly dimmer, the batteries are just under 1V each, so mostly discharged. 7 months is a pretty good life time.

This does not deserve so much attention, but here it is. I got one of the Ikea Molgan motion sensor lights and thought it is too bright for the application. The light has 5 LEDs inside and the tipical BISS0001 pir IC.



They were bright enough to use a current limiting resistor for each LED(the right way to do it), so there are 2 solutions: increase the resistor for each LED, or just leave a single one ON. I took the lazy way out and cut the trace after the first resistor.


Ta daaaaaaa!


In case you are wondering, the original lamp burns almost 70µA while on standby and almost 100mA while the LEDs are on. This gives you about 1.6 years of standby and 10 hours of light or however you manage to combine it(about 6 months at 5 triggers of 30 seconds per day). With this change the light time is increased to 5X, so about 50 hours.



Too bad they used AAA batteries, AA would have been slightly larger, but with 2.5 times the life.

Digital Power Supply – Part 3: Concept comparison

Check out Part 1 and Part 2 of the project


A long time ago, around 12-13 years, I build one of the classical designs of a laboratory power supply and quickly started thinking about having a digitally controlled one. I got a prototype working in 2012, but made no progress after that, seemed my simple 7805 & LM317 was covering me for most part, so a total lack of motivation presented itself to finish the project. However, suddenly realizing I have wanted this thing build for more than 10 years got the gears working, it has to be finished!

New design

I have improved the previous design by going up for higher speed current sensor (INA225) and faster amplifiers, see Electrobob 2 below. Dropped the current mirrors, since there was no need for more than 30V output. Still, I was not satisfied with the speed. In search for the perfect recipe, I decided to analize the various concepts and make a short summary of performance and lessons learned.

The candidates

I have drawn simplified schematics to explain how each supply works. Some changes were made to the original schematics where needed to reduce the requirement of output capacitance to just 10uF. The results are simulation based, with the exception of Electrobob 1 and Electrobob 2 which were built and measured.

1. My previous design – Electrobob 1. It uses a single supply, no additional negative/floating rails. The positive rail current sensor allows for multiple channels to share a ground. It is designed to scale in voltage and current easily by using current mirrors to control the main transistor. Short circuit response is slowish because the used current amplifier(ZXCT1010) is rather slow. Therefore:

electrobob_1_schematic2. An improved design – Electrobob 2 – keeping the same features as before: went for a faster INA225 current amplifier. The current mirrors are missing, because the faster LM7332 can operate to over 30V. With these design changes and proper compensation, it is 10 times faster to respond to a short circuit compared to Electrobob 1.

electrobob_2_schematic3. The electronics lab design: uses a single secondary, but needs to generate a negative supply for the current op-amp to be able to drive the reference voltage down to 0V. The current shunt is located on the negative rail and both the current and voltage references need to use the output negative as reference, therefore all this current consumption(and the potential microcontroller) will be added to the load current. It is faster than Electrobob 1, but slower than Electrobob 2.

electronics_lab_schematic4. The most CLASSICAL design to make a great power supply, however it requires a symmetrical (Vpos, Vneg) isolated power supply apart from the main Vin. The ground reference is the positive output, and Vref and Iref need to be generated with respect to this one. It is found in a lot of designs and sold by a lot of companies. Provided Vpos/Vneg are clean (easy to do because of low power) it has very good rejection of Vin. Due to the extra supplies, it can have a low drop across the series transistor and can scale easily in voltage.

Classic_schematic5. The simplest design I can think of – SE simple – normally found in many regulators: uses current sensing on the negative rail, so this voltage is fed back in the voltage reference to compensate (R6-7). Vref and Iref are ground references, therefore it avoids extra current through the Shunt as with design 3. Speed depends largely on the speed of the op-amps used. The topology does not need any additional negative supply, provided that the op-amps output can reach ground.

SE_simple_schematic6. Same as 6, but using a PNP to get a low drop effect, just for comparison.

SE_PNP_schematic7. The classical LM317 regulator, along with a current sensor and comparator, to get it working in constant current mode as well. It requires a negative supply, as ADJ needs to be lowered to -1.25V in order to achieve 0V output in short circuit.



The table below measures performance with some simple tests. The simulation included secondary effects such as wire resistance and inductance, capacitor ESR, contact resistance, feedback and source resistance.

The load test is measured with the output set to 5V, a 1A load is connected and disconnected. The Drop voltage and Drop time are measured, when the load is connected. The opposite Peak voltage and Peak time are measured when the load is disconnected. Ideally the voltage should not drop or peak when the load changes, however in practice the peak and drop should be as small and short as possible. Output resistance was measured, but it is not relevant for comparison, it is within the mΩ range for all designs except LM317.

1A load peak and drop

The short circuit test shorts the output and measures the peak current and the time until it drops close to the expected current limit. The current should never peak above the preset limit, however this does not happen because of 2 reasons: the output capacitor will provide some current and the current control loop takes some time to kick in. Depending on the configuration and the type of output transistor, the peak current at short can be rather high.

short load peak and drop

The PSRR is measured by aplying an AC voltage an the input of the supply and measuring the output, over frequency, as in the example below

PSRR responseResults summary

The table shows the comparison of the discussed models and points out their strengths and weaknesses.The peak current indicates the peak through the pass transistor, while the load current is higher due to the output filter capacitor.


  1. When connecting/disconnecting 1A load.
  2. Is oscillating a bit, dampened in 10-15us
  3. Goes to zero and then comes back up
  4. Using TIP122, caused by high drive capability of LM7332. Can be reduced with extra R+NPN, IRLZ24 – about 60A
  5. Using IRLZ24 MOS, with TIP122, the drop/peak are higher, ~1.4V due to different gains at different currents (BE resistors), but peak currents are lower. Can be dangerous for the output circuit!
  6. compared to main supply input
  7. i don’t know why
  8. Requires separate secondary for +/-5..12V. However, cheap +/-5V 1W isolated DC/DC converters could solve this, like DET01L-05
  9. Using LM358, 5µs with TL3472
  10. Using LM358, 20µs with TL3472


Maybe it is time to revisit the idea of positive rail current sensor and go for a simpler, faster and cheaper approach, even though this might mean breaking the ground with the shunt.

A bit of history

Electrobob 1 was previously tested as V1, and with some updates it turned into V2 which never made it to the tests. Then I did some radical changes and it turned into V3, which was a failure, both as stability but also PCB design. Here it is below trying to split it in 2 boards. DSC_0459

DSC_0462Next came version V4, which is actually Electrobob 2, as presented above. I made a lots of progress with this one:. It fits in a 5×5 PCB without holes, which turned into a 5x7PCB with holes. I made a prototype with a screen and box, to be used with an external power adapter. It has some cool features like temperature protection, OVP and lots of software features.






Bad wires

Ready made jumper wires are popular for making prototypes and even using them permanently in projects. For me, these are some of the things that come from the various far away eBay sellers(or similar stores), as they are very cheap. The same cheap wires can be bought for more money from various local shops, who are reselling them.

However, recently I have bought a set from one of the big component suppliers, because I needed them in a day, not a month. This, of course, came with the penalty of paying about 4 times more for a set.

The difference in feel is huge: the expensive ones are much thinner and more flexible and seem to lack any bad plastic smells. Next, I measured the electrical resistance including the contact with a pin header, and the picture says it all. On the left, the cheap version is around 0.53Ω, while the good one is 0.09Ω, more than 5 times better. Or, to put it from my experience: I expected about 0.1Ω, which makes the cheap ones 5 times worse. 

bad_wires_drawingThis means you should pay attention whenever powering anything that draws a little more current. Using 2 of the bad wires for a power supply get you over 1Ω or resistance. I have experienced this with various modules, like motor controls or even radios such as the ESP8266 or the NRF24L01 with PA: drawing some 300mA causes about 0.3V drop on the power supply.

But it is not the absolute drop in the power supply that causes problems, it is the internal reset circuit that can cause a reset whenever the power supply suddenly drops by that much. This is why adding a large electrolytic capacitor near the device solves the problem.

What should you do? Depends on the application. The cheap ones are definitely adequate for most things and the price is better. However, the expensive wires will give you a lot less headaches.




Sitting for long periods has become more common in today’s jobs causing serious health issues. Unfortunately the plethora of activity trackers fail to address the issue: being rather active while sitting does not provide a good picture of the amount of time spent sitting.

Sit.Up is a simple device that attaches to the chair and alerts the user by vibration if sitting for too long while also tracking the sitting time. It aims to be easy to install and forget on any chair and work with any person. On top of that, it is very low cost and has months to years of battery life. With an optional WiFi connection, the data can be uploaded and you can track your sitting times.

This project is an entry for the Hack a day prize 2015 and is a work in progress. Stand by for updates and drop by to give a Skull for appreciation.

Check out the new project video

and the previous one

Let’s have a look at why sitting is bad for you, could not explain it better myself:

Project status

Version 2 of the project brings in new hardware and software features. Sitting is tracked, the data is uploaded and logged and the user is alerted of the prolonged sitting, while the web interface shows daily sitting time and real-time status.

I have greatly improved the self calibration of the device and currently testing the long term capabilities compared to previous operating time of a few days. By fixing some firmware issues, I have extended the battery life to more than 1 year with typical usage. The device has a dedicated box and PCB making it look more of a product than a prototype and minor details like multiple LEDs offer a better user experience. Still, there are minor software tweaks to fix and the project would greatly benefit from a new user interface, as I am planning to move from the open energy monitor to a dedicated platform.


System description

Under each chair there is a small module that monitors the status with the help of a capacitive sensor. When you sit down, a timer is started, counting how long you have been on the chair. After a while, a discreet vibration alerts you of the time spent on the chair as an invitation to take a short walk.

Ignore it for too long and the notifications get more insistent and even public, with the help of a buzzer. After all, not letting your chair buzz would be a public sign of trying to stay healthy.

The sensor connects to the internet and sends data to the server by using the local WiFi. The web interface allows the user to configure the alert times and track sitting. The web page contains instant status of the chair as well as statistics of the amount of daily sitting times.situp_system_3


All hardware in this project is Open Hardware. All software is licensed under GPLv3, for licencing see

Project LOG

21.09.2015 – Wrapping up V2

Hardware revision 2 is now complete, this includes a dedicated PCB for the circuit and a dedicated 3D printed box. I have made the new box black to merge better with office chairs, even though the box is not visible under the chair. Check you the newer V2, assembled



The documentation has been updated on GIT to include the newest hardware and firmware revisions.

Make sure to check out how simple it is to install the device, once it has been assembled:

and of course, a short testing. I had to alter the timings and disable the power saving to make the device more presentable.

13.09.2015 – New PCBs

The new Sit.Up! PCBs are here, a dedicated one just for this project. I added 3 LEDs, a footprint for the buzzer, transistor driver for strong vibration and a few other tweaks. Check it out:


06.09.2015 – 3D printed box with logo

I thought the project needs a custom box, nothing special. Since my 3D printer cannot print more than one colour, I had 2 alternatives to colour the embossed text on the box: markers and pause printing and swap filament. The double filament method makes it only possible to print the logo in a single colour, while colouring allows for multiple.

Here are the two box lids, side by side which one do you like better?


For the first option, I started with a white print, some markers and a bit of colouring, something i haven’t done in a while.


29.08.2015 – An Xmega mistake

Because of so many available pins and a higher current requirement of 80mA, I have connected the vibrator motor to 3 pins in parallel of the Xmega microcontroller. This is a good practice and saves adding an extra external switch, like a transistor in these cases. However, once I swapped the fresh alkaline batteries for some not so fresh rechargables, the vibrator was barely felt. Checking the datasheet shows that the Xmega pins are less capable than the old MEGAs, where my mind went for when I was considering that 3 pins are sufficient. So, time for the first design change: add transistor to switch off/on the vibrator. A NMOS is better than a NPN, since it includes a diode to protect against back EMF and does not need a base resistor, saving 2 components extra.

Xmega pin strength

10.08.2015 Wrapping things upall_complete 6-3

With the original capacitive sensor proven to be the best option, it was time to wrap up the project and build the final prototype device and code.

Software wise, a lot of features had to be added, most importantly the ability to alert the user when sitting for too long. The device alerts by vibration every 15 minutes, but once an hour has passed, it becomes more annoying. A web interface is in the works which allow configuration of parameters. Other updated include  better calibration, low power modes, vibrator patterns, LED blinks, buzzer sounds, LCD disable and a lot of clean-up.

Hardware wise, the module lost it’s LCD for debugging purposes and gained a vibrator motor, to discretely alert the user if sitting too much. Along with the batteries attached under the PCB, the whole thing is a lot more compact, practically invisible when mounted under a chair. The device is build around a general purpose board I have designed for the microcontroller, the complete schematic is available in the project documentation on GitHub.


DSC_4849Current measurement shows up at around 25μA while sleeping, mostly eaten by the EPS8266 module, the micro itself needs only 0.2μA. Make sure to cut the trace of the red power LED on the module, otherwise it will waste most of the power. In active measurement the current drawn is 4mA, going for an average of about 100μA,  should provide 2 years of stand by time. Of course, frequent sitting for long times drains the battery because of the vibrator motor and WiFi. Nevertheless, with typical usage I expect about 6 months from a pair of AAs.


Schematics for the device are simple, with plenty of pins to spare on the micro, there are no major issues. The buzzer and LED get a pin each, while the vibrator gets 3, to increase the current capability an elude a transistor. Optionally, there is an ESP8266 for data uploading and logging. The capacitive sensor itself only requires to connections to the outside: GND and Touch, no other components.

sit_upThe device, now installed looks much cleaner than before



Looking at some data from June, I can say I probably spent too many hours on my home chair, even after a day of office work

situp_june_data 2

12.07.2015 E-filed sensor

As my initial capacitive sensor using aluminium tape as electrodes proved successful, I looked into shrinking the size. Compared to measuring the capacitance, another method of detecting a conductive object like the human body around a sensor is by using the electric field method: 2 electrodes form a transmitter and receiver. When a conductive body comes between them, the amount of signal received changes. I have attempted to use a 75x100mm double sided PCB for this method, at first. In open air the detection distance can be even 20cm, but things change once this plate is placed under a chair: the sensor is very directional and there are ways to sit on the chair without being detected. Swapping the PCB for the original aluminium tape electrodes works better, but there is no point of implementing this method, as it requires extra parts. The system in this case consists of the microcontroller outputting a 1MHz signal on a pin serving connected to the transmitter electrode while the other electrode, the receiver, gets read out by the microcontroller’s ADC after passing through a simple detector.


10.07.2015 – Dedicated proximity sensor – A failure!

I have done some brief experimenting with dedicated proximity sensors, specially the MTCH101: better sensitivity, but comes with  2 nice “features”. First, it is designed for momentarily proximity, so after a while it will compensate the person and think there is actually nothing there. Second, it seems to get stuck in “detected” mode quite often, even the datasheet mentions a “Stuck Release Mechanism” as a feature! So, no good.


14.06.2015 Wifi Enabled Data logging and display chair

After the first successful tests using capacitive sensors I implemented the thing in the chair. Here are the modules as size comparison. The new module can sit on top of 2 AA batteries and will not require more than 2 wires leaving from it.



Due to the nature of the capacitive sensor, having an ISP/serial cable connected to the PC influences the measurement. In order to develop the software I connected an LCD and in the end I thought it should stay on the chair for a while.

There are 2 electrodes made of aluminium tape: the one towards the back is the ground and the one towards the front is the sense. The capacitance is measured between the two and when a person sits, it increases. I could not find any normal sitting position on the chair which does no detect the person. Here is the whole thing assembled.



And of course, some data logging on the LCD:


11.06.2015 Welcome capacitive

For the last 2 days I have experimented with capacitive sensing using the method described in Atmel’s Qtouch ADC guide: charge division between external capacitor and internal sample and hold. Things are a little bit trickier that with buttons: normally a capacitive sensor drifts, therefore it needs to be constantly adjusted. For a button it is not an issue, as you expect it to be not pressed most of the time. So, you just compare the current readout with some average over the past and you are done. For the Sit.Up sensor it needs to be able to detect a “button press” for longer periods of time, so the button methods don’t work. I believe I solved this problem differently, but more on that later.

The new sensor can be a lot smaller than before, this new board sits on top of 2 AA batteries, and will be hidden under the chair anyway.




09.06.2015 Optical does not work

Today I was checking the proximity sensors based on optical reflection, specially the VCNL4020 which can do 20cm and which I have in my parts box. Or the SI1146. It turns out that even though these would allow for a smaller sensor, they have more limited range than the ultrasonic distance sensor. Then, it hit me: capacitive! A simple wire placed under the chair can measure capacitance which should change depending on whether somebody is sitting or not.

Note: i am not looking at making a chair with built in sensor, rather a sensor as a simple to use add-on.

03.06.2015 New ultrasonic sensor and some data

It’s becoming obvious that ultrasonic sensors are not the best way to tell if somebody is using a chair. I have failed to make another one work with a different model of a chair, which means they will not work everywhere. Apart from that, they are very bulky, coupled with 3AA(A) batteries will have to create a reasonably large sensor. Time to think of alternatives.

I have just received the new US-100 ultrasonic sensors from ebay. As they operate from 3V, a 3.3V supply can be common to the microcontroller and WiFi. Current consumption is also lower, I am measuring 1.8mA vs 7.5mA with the older sensor, 4 times less, this should improve overall power consumption.

DSC_3999I have set up an emoncms panel to watch over the data. Unfortunately it takes a precise level of zoom for the first graph to look this great: the visualizer decimates the data and then interpolates the remaining points linearly, which usually causes it to draw diagonal lines between some sitting and non sitting event. However, here is a section that looks great:

emoncms_data_2On Saturday, 30th may I left something on the chair by accident, which caused it to record a lot more hours. Human and non human distinction would be great for new types of sensors.

25.05.2015 First experiments with chair version

The chair version will work with any user and should be as low cost as possible so that it will be installed on a high scale on any possible chair. Alternatively, if the chairs are dedicated per person they may provide insight on time spend on each chair, like at work, at home or in the car.

I started doing some experiments with an ultrasonic distance sensor. As it turns out, it is not the ideal thing to use: this particular version requires 5V and quie a lot of power, but it will do for the time being, as proof of concept.

The circuit is build around an XMEGA32E5 one some header board, with an attached ESP8266 and your tipical HC-SR04 ultrasonic ranging module, nothing special. It is not optimised for power consumption in any way so it will burn a charge of batteries in 3-4 days. For now, it simply uploads the data to emoncms on my website, similar to Led logger V3.




As it turns out, putting the sensor on the top of the chair is not a good idea: some fabrics seem to be pretty bad at reflecting ultrasounds and crouching does not detect the person.


Next up, i mount this sensor between the seat and back of the chair. It is a delicate position, as a bit higher or lower will cause the sensor to pick up the cushions as obstacles. However this seems to work a lot better, usable with all the types of pants that i have. (well a long wool sweater will still break the thing).

DSC_3983 DSC_3993

Conclusion on ultrasonic: might work, delicate to place, large. The high voltage and high power consumption may be managed to get decent battery life.

Active probe


While working on the capacitive sensor for the Sit.Up project I stumbled about a common problem: connecting an oscilloscope or the Analog Discovery to the capacitance measuring pin disturbs the whole measurement. This happens because the load presented by the Analog Discovery or your typical oscilloscope: about 1MOhm || 24pF. Most importantly, the 1MΩ was discharging the sense capacitor. To make it work, I needed something with much smaller capacitance and much much larger resistance.


The solution is rather simple: build a simple active probe. Since I was not interested in going beyond +/-5V signals, a simple CMOS rail to rail opamp was sufficient. My parts collection complied and provided the MCP6H92 which has a much better input configuration  10TOhm || 6pF, not perfect, but a great improvement.


active probe




Have you ever needed to look at what is going on on a serial port and not have a PC/smartphone around because the location was a bit inaccessible? I did not need this until now, but now I do, so I was looking for a solution. After building this, I think that it would be a good addition to the modified programmer.

This is a quick and dirty solution, i scavenged of the build of the ESP8266 test rig which uses the XMEGA header board. It’s using a IL9341 driven 2.2″ 320×240 LCD connected over SPI on PORTC (see code for exact details). I used a rather small font(10×16) to be able to show a reasonable amount of text, 20 lines and 24 characters per line. The LCD is used in portrait mode, since it only supports hardware driven scroll on the vertical and I did not want to spend time with more complicated code to copy memory.  Even the hardware scrolling functions were missing from the ASF driver implementation for Xmega. Without hardware scroll feature, there would be a lot of time wasted moving data around the memory, and getting a reasonably fast response would require a lot of SW optimization.

Two hardware UARTs are used to monitor a bidirectional serial port communication between 2 devices, the one on PORTC and the one on PORTE. This allows the micro to know from where to where the data is going and display both in different colors, white or green, color matched to the input wires.

Since it needs to be portable, it is powered by 3xAA batteries. Current consumption is under 50mA, so that should be over 50 hours of operation. Additionally the micro supply is brought out, so it can be powered by the external circuit or provide power to it.

Here are a few pictures of the build and a video of booting up a router:






Quiet 3D printer


I have recently purchased a 3D printer, mostly because  I was interested in learning about 3D printing, and of course, because I wanted one. Between buying a ready to print one and sourcing all parts individually, I went for a complete kit. I though getting a kit that needs assembly would allow me to learn more about it and I would enjoy assembling it. So, I went for a prusa i3 steel, because i wanted something capable of both ABS and PLA from the start and should have reasonable endurance.

The Noizzzz

Clearly, the thing is noisy, without any tuning it was constantly over 70dB, peaking at 75dB for some motions. Since I keep it next to my computer desk where I spent most of the time, I am troubled by it. So i made some changes to try and reduce the audible noise. For noise measurements I have used my smartphone with Audio Tool app and an IMM-6 calibrated microphone placed about 1m from the printer.

1. Support. Place the printer on something as rigid and heavy as possible. I found that tables are not that great, but a drawer set works better.

2. Decouple from the support, in order to minimize vibration transmission. Apart from a layer of foam, I used 4 furniture support feet placed under the Y carriage, which means that now the 3d printer touches the ground in less and smaller points than before. This helped a lot.


3. Play with printing speed. As a mechanical system, the whole printer is prone to have certain resonant frequencies and it turned out that the default 50mm/s speed was the loudest possible.

Speed 1

4. Change the motor drivers. The biggest change I have managed to make in terms of noise was to swap the original A4988 X and Y drivers with DRV8825. While these produce a high pitch wine, the mechanical noise is strongly reduced, i managed to get about 8-10dB.


5. Fix the power supply fan. The most annoying thing about it is that it cycles ON/OFF, not continuously variable according to the temperature. Of course  this is acceptable for an industrial power supply, but not for home use. I could have replaced the control with a variable speed one, but there is not much to gain here either: the fan is small and placed in a closed space. The solution i settled for was to replace it with a 9cm fan, the largest I found in my parts collection. After cutting out the previous guard, I mounted the fan as far away from the case as my screws allowed and sealed the area around with duck tape. This is to allow the air to flow easier and keep the fan blades away from the big aluminum plate which would cause noise. Of course, no fan is complete without a red guard on top, with a bit of scaling. I left the original control in place, but I added a 50 ohm resistor as well, to keep the fan turning at lower speed. My goal is for the original thermostat that puts the fan at full power to never trigger. Some tests have shown that this performs as desired, even the outside of the power supply stays cooler then before. This is clearly beneficial and should increase the life span of what is not such a great quality power supply. Check below for the build pictures below.

What is inside the typical not so high quality, 360W, 12V LED power supply:


For thermal regulation, the power supply uses a simple mechanical thermostat placed inside the filter inductor, which switches the fan on at 45°C and switches it off at 33°C. Since the printer does not draw much power, the fan cycles ON and OFF, which is not that great for all the components, since they keep cycling between the 2 temperatures.


I have removed the original fan and cu the grill to improve airflow as much as possible. The fan is placed at about 1cm further away from the case to reduce noise.




Tape is used to seal the gap


I connected an extra wire to the positive supply of the fan to be brought outside in order to add a resistor to keep the fan at idle speed.


Ending with some experiments for idle speed


Of course, no fan installation is complete without a red grill


Note: The E3D fan is small and it’s quite noisy, if the printer does not print. Otherwise there is no difference in noise with or without it, so there is no need to replace this one with something larger.

1,771 views since Nov 2016