Saturday, February 18, 2023

Low cost yet effective sleep monitoring. Tests for sleep apnea etc issues.

From teenage i suffered a strange problem my first part of my whole sleep used to be nightmarish, or less relaxing. If i slept 6 hrs starting 1-2 hrs are mostly bad.

After many years of suffering one reason i found time gap between dinner and sleep. If gap is very high i.e. 6+ hours then sleep was much better. Every person has different body and has different weak and strong parts in body. From teenage my gut was not great and from that time this problem started. I ate lots of sugar in childhood, i abused meal timing very much, not eating for long and this type of behavior led to poor digestive health. But later i tried to fix almost every bad routine like sleeping late night to eating on time.

Today (2023) we have powerful technology at hand at low cost. Using which we can monitor some factors effecting sleep. I read about sleep apnea and thought i could be suffering this problem at some level for some reason. So i decided to test my sleep.

I tried smart watches to monitor sleep but they are definitely not good for serious sleep monitoring. The reasons are inaccurate sensors, high polling time of sensor data etc. Smart watches poll sensor data at high time gap. For example pulse is checked every 1-5  minutes and spo2 is checked every 10-30 minutes. What if spo2 was low during 2 consecutive polls? For this reason i shifted to oximeter.

I found many oximeters which could monitor the pulse and oxygen every second. This is far far ahead of smart watches. Some oximeters are Beurer PO 80, Miditive MPO-04. Many oximeters have Bluetooth which can log sensor data to phone.

Software for Bluetooth based oximeter have very bad rating on stores due to various issues like Bluetooth disconnected, data not logged after some time etc. Beurer oximeter has complaints of outdated pc software and data loss after saving sleep data to pc. Means the data was erased after download into pc. The cost of this oximeter is high and considering the limitations and lack of software support this oximeter doesn't fit for cost and features.

Then a very low budget solution was available to me which is M-170 oximeter. This is mass produced in China and rebranded by many companies. I got it at Rs900 i.e. ~USD11. In bulk it can even cost $2.

Here are some links for this oximeter -








This oximeter is just rebranded and has unique feature of maximum 8 hours of recording. The recording is split into 15 minutes parts. 4 hours of sleep is split into 16 pages. It can be used to monitor 15 minutes or even lesser data but should be for non sleep tests only. I will recommend to buy any cheaper oximeter from any brand because all are same. The model must be M-170 with 8 hours recording. There are some models which look same but don't offer recording. Old models had RR (respiratory rate) feature. Updated models have ODI (oxygen desaturation index).


Below are images of oximeter i took after my 4 hours sleep recording. I slept more but removed the oximeter.


My spo2 went down to 93 but that time i was awake after a sleep of 1.5hrs. The oximeter was loose and my left hand was pressed and blood flow went down. I learned many critical things by using it. Many false readings can happen due to many reasons. Like oximeter is loose, blood flow reduced to the hand, battery is not full, fingers are not clean and clear, fingers are rough, skin is very hard, very dark pigments etc. Its important to ensure these kind of things are not causing bad values in oximeter.

The graph is generated between minimum and maximum values read by oximeter. If minimum is 90 and max is 99 then the graph shows how values have chaned between these two. This makes it easier to analyze values despite low resolution screen of device and almost less visible data.

Page 1/16 means the first 15 minutes of sleep. Each page is 15 minutes of sleep. Total 16 pages means 4hrs of sleep data. Maths 15 minute page X 16 pages = 240 minutes of data. Even if total pages are different and don't match with 15min/page then it can be calculated using same maths. The low spo2 was caused by myself which i fixed and slept again. I will record more and then make any conclusion. It will help me monitor my sleep after different routine of day. What i ate, when i slept etc to remove activities that harm my sleep.

This monitor can also be used to check spo2 and pulse during physical activities e.g. 30 minute walk. But oximeter must not be loose and sweat etc things can also affect the reading. ODI value must be counted for sleep tests only. And sleep must be standard not a little nap.

Special note: Last recording of this oximeter doesn't erase even after removing batteries.

I hope this will help into your sleep monitoring. 

Monday, February 13, 2023

DIY making OTG with power supply for Fire Stick.

This article will help make these -






This has been tested on Fire TV stick 3rd generation 2021. It has only one USB micro port and that's for plugging its own 5v 1A adapter. There are already many cables available in market but making it is so simple that those who cannot buy new cable for any reason can make it.

Items required:
- OTG micro cable or OTG adapter.
- USB cable to tear and join with otg.

Pic 1


Picture 1 shows an OTG cable and a usb cable. The usb cable can be a usb charging cable or data cable.

As shown in pic 1 carefully cut the otg cable to take out 4 wires. The RED is +ve, BLACK is -ve. Do not cut the white, green wires. USB data will transfer from those wires NOT usb power. The red and black wires will provide power to both fire stick and usb device. Now join the power supply wires of usb cable to otg cable as shown in pic 2.

Pic 2


Now test all wires they should not short with other wire colors. In case your usb has different colors then you must check the +ve & -ve wires using multimeter or other method. Now pack the wires with tape etc as shown in pic 3.


The micro port connects to fire stick and white usb male goes to adapter and female usb port can be used to plug pen drive, gamepad, wireless dongle etc.

Warning: do not connect high power devices like external hard disk to otg. The fire stick adapter only supplies 5 watt of power and any device having high requirements will shutdown whole setup. For connecting high power devices use higher power adapter.

Note: This otg may cause the fire stick to suddenly reboot from "Loading..." Screen. Even if this happens try again it can work or try to change adpaters.

One thing i have noticed this setup sometimes works sometimes fire stick reboots from loading screen. But it works when i use fire stick adapter. This might be due to power supply difference. Fire stick says only connect 5 volt 1 Ampere adapter. For this reason we should make a setup which supplies 5w power to fire stick and higher power to usb device via external supply. Like only connecting data wires of otg to usb device and different power wires to fire stick and different power wires to usb female port or simply provide high Ampere from adapter but use small current restriction circuit to allow 1A to go to fire stick. This is not needed but i am not sure what causes reboots. Once fire stick boots to UI then it doesn't reboots.

I have tested this cable with wireless keyboard & mouse dongles, pendrive, external hard disk, ps2 to usb gamepad adapter.


Fire stick issue with some gamepads:
When i connect ps2 gamepad using ps2 to usb adapter it handles button 1 & 2 for shortcut. Button 1 for launching custom app and button 2 to Bluetooth devices list. This makes the gamepad useless. This means any input which has button 1 & button 2 unique IDs will behave same ways and cannot be used. Will always launch shortcut apps. This can be solved but i am simply using BT gamepads. This issue doesn't happen with XInput and Direct Input gamepads.