Wednesday, 1 March 2017

Sleep tracker for baby

Aim: Track baby's sleep using images from baby monitor.

Camera: D-Link DCS-825L
   Example image 17.5 kb, 640x352 pixels, 96x96dpi, 24bit.




Method, use the change in image filesize as a proxy for baby movement:
  • Capture image using wget from local network 192.168.1.2/image/jpeg.cgi
  • Crop the image using mogrify (imagemagick) to remove date and time from image.
  • An artefact of the above makes night-vision jpeg images in greyscale (and keeps lighted images in colour); we'll see later that this is useful metadata.
  • Repeat as often as possible (e.g. every second); although maybe it is possible to overload the camera.
  • Write to file with columns: Year, Month, Day, Hour, Minute, Seconds, FileSize, Greyscale

Analysis
  • The jpeg filesize varies from 0 to about 130 bytes from second to second, even with no movement.
  • Baby movements gives up to 400 bytes of variation.
  • Adult movement gives many hundreds or thousands of bytes of filesize changes.
  • We can cut off the awake-time evening and morning data when the night-vision was off (this is presumably when an adult was in the room putting the baby to sleep and collecting the baby in the morning).
  • Each morning plot (using octave) the night's movements:
    • Sleep was from 9pm until 7am, with help from parents around 04:30 to 05:00 (plus baby's own movements around 10pm, midnight, 2am, 4am):




Useful link:
  • D-Link forum: http://forums.dlink.com/index.php?board=427.0

Monday, 16 January 2017

Automated capture of radio communications

PART 2
(see also earlier blog post about this)

Aim: to log lake temperature

Method: similar to before, but with new device.

Device:
 * "SODIAL(R) New Wireless Digital Floating Swimming Pool Thermometer Bath Spa Temperature" bought from Amazon
 * Example result for 13.0degC was 01011000 01111010 00010010 10011111 10101111 00110011 1

Other notes on message:
 - there's a 'calibration' set of 8 before the main message
 - Then a long time at "1"
 - Then a long time at zero
 - Then main message
 - The start of each bit jumps from 0 to 1
 - After each bit there is a jump from 1 to 0
 - The 0 "on" is longer than the 1 "on"
 - The bits seem to be of different widths for "1" and "0"


Decoding:
  * Calibrated from 4 temperatures between 3 and 31degC. A linear relationship found between temperature and bits 15-24 (T = mx + c, where T is temperature (degC), m=0.1, c=-40, and x is the message in bits 15-24).

In Linux or Windows (or even Raspberry Pi):
    rtl_sdr -s 1e6 -n 3.2e7 -f 433.85e6 -g 40 output.dat
This should create a 32-second data sample at 433.85 MHz with a gain of 40dB and save the file to "output.dat".


In Octave:
  fid = fopen('output.dat','rb'); 
  y = fread(fid,'uint8=>double'); 
  y = y-127.5; 
  y = y(1:2:end) + i*y(2:2:end); 
  plot(abs(y));

Then many lines of Octave code to interpret and clean signal,
and then writes result to data log file with each row as follows: Year,Month,Day,Hour,Minute,Temperature(degC)



Helpful websites included:
  • http://electronics.stackexchange.com/questions/145714/what-encoding-is-used-in-this-signal
  • http://sdr.osmocom.org/trac/wiki/rtl-sdr
  • http://aaronscher.com/wireless_com_SDR/RTL_SDR_AM_spectrum_demod.html 

Wednesday, 4 January 2017

Moisture indoors

In Finland in winter, the indoor air is normally so dry that it causes problems with cracking/itchy skin. Ideal indoor moisture should be 30-50% relative humidity (NB. too high RH causes damp/mould), but easily indoor RH can get down to 10% in cold spells in Finland.

I have bought a sonic humidifier that has a 1 litre capacity and takes about a day to emit this moisture into the air. I want to know roughly how much effect this might have.

I'm going to ignore effects of sources/sinks/storage like showers/cooking/washing/ventilation.

If we imagine a starting point of 20C and 25% RH, then this is about 4 g/m^3.


Now let's imagine instantaneously and evenly adding all that 1 litre (1000 g) of water into the air in my flat (72 m^2 and about 3m tall, so volume of about 216m^3). This would be adding 1000/216 = 4.6 g/m^3.

So we would be roughly doubling the moisture content, and the RH would increase to about 50%. This would be a great result.

Future blog update...estimate the effect of time on this scenario by looking at the rate at which the humidifier works and the rate of ventilation in/out of the flat...

Sunday, 25 September 2016

Obtaining and deciphering radio messages


Aim: to obtain and decipher radio messages from household devices.

Test device: Clas Ohlson (WS2015) temperature sensor - typical household 433MHz device.

Receiver: USB dongle (e.g. hsy® USB 2.0 Digital-DVB-T-DAB FM RTL2832U FC0013B SDR TV Radio Receiver-Stick) on a Windows laptop.

Data study and capture: SDR# (SDR sharp), 8bit wave file made of a couple of seconds and filesize of a few megabytes.

Understanding the data: each clock-cycle has a level shift (0/1). Logic1 has a level shift within a clock cycle, whilst logic0 does not. Bits 21-35 are temperature (scaled as +50 x 128). Useful website was http://ala-paavola.fi/jaakko/doku.php?id=wt450h

Data processing: done 'myself' in Octave -- the key command was wavread('FILENAME.wav'). But also some 'debouncing' was done to infill the many dropped "1" values. Plus all of the 6 messages were taken (2 channels, 3 messages per channel) after some synchronizing.

Hardware:
  
Software, SDR#:

Software, Octave:
Each minute 3 near-identical 36-bit messages sent:
  
Example, zoom in on first 5 bits of first message (notice the many 'dropped' "1" values): 
 
After tidying and then converting the binary message to a normal (decimal) value the result is found: 
 



See also Part 2





Tuesday, 13 September 2016

Winter wonderland

All winters are cold and snowy in Finland, but some much more than others.

Weather station at Helsinki Airport in Vantaa.
"Cold days" are with maximum temperature below 0C.
"Snow days" are simply days with at least some snow on the ground.
Winters are shown such that e.g. "2010" on the graph means the winter of 2009/10 (e.g. November 2009 --  April 2010).

Source: Finnish Meteorological Institute.

Summer days

I had the impression that this year had lovely summery weather. it did, and I enjoyed it lots. But apparently it was only about the same as the long-term (30-yr) average (of about 50 days per year), and even this year was cooler than some of the recent warmer summers that Helsinki's had in the last decade or so.
Weather station at Helsinki Airport in Vantaa.
"BBQ days" are with maximum temperature above 18C, at least 4 hours of sunshine and no rain.
"Hot days" are with maximum temperature above 25C.

Source: Finnish Meteorological Institute.

Tuesday, 5 July 2016

It doesn't rain as often as we think.

It doesn't rain on me very often going to work. I wanted to know how often it happens...


It's dry a lot of the time: for 88% of all 10-min periods and 81% of all 1-hour periods. Although the statistics for 24-hours looks less good - only 37% of days are completely dry.

My bike-ride to work is 5 minutes each way. So there's an 88% chance of being dry each day when I go to work - i.e. it'll rain on me on about only 2-3 days per month. 

I also looked at Helsinki (Vantaa) airport 1985-2015 for a few more things PER YEAR: 
  • 52 BBQ days (Tmax>18C, sun>4hrs, rain=0) 
  • 17 hot days (Tmax>25C) 
  • 85 gloomy days (sun=0, rain>0) 
  • 70 cold days (Tmax<0)