Wednesday, 26 November 2014

Failure is always an option

As they say success comes through hard work. So I had these car FM transmitters laying around. I wanted to know, what made them tick. I ripped it wide open and started marking chip names down. With some logic I quickly determined the chip that was responsible for FM transmissions.

Name of the chip? – BK1085

So the implementation is simple enough. To my knowledge it’s just a one chip wonder. Audio comes in and it is modulated and spit out from the other side.

Datasheet is helpful. Every piece of information is available right there. The chip itself can be for example controlled over I2C. You can change the frequency, time out periods, mute etc.

So I started probing, first experiments went well. Then later I took the chip and placed it upside down, made some wrong connections and the magical smoke came out – blimey.

Then I took another FM transmitter and ripped that apart. It had the same chip but the package was different. So I soldered it out, made a little test/development board. Turned it on and nothing!

dev

Haven’t looked into that much anymore maybe in the future, when some inspiration strikes me. Also I ordered two transmitters so we will see where that leads us.

yt

Sunday, 20 July 2014

FM-RDS

RDS or Radio Data System is a very interesting thing. All of us have come across this in some point in life. RDS is a cool implementation. RDS shows radio stations name, frequency, song etc. A lot of car radios support this feature. So when you see “RAADIO 4” on your radio, it arrived there over RDS. It piggyback rides on the FM station at 57 KHz. So I wanted to learn more about it.

This is a typical FM stations baseband spectrum.

 

rdstext

 

 

Decoding RDS with some already made tools is somewhat simple. SDR Sharp has this feature built in. But rtl-sdr is not that sensitive receiving weak stations. So I started experimenting.

Firstly I hooked up my Panasonic car radio. It supports RDS. I listened to FM stations and it worked fairly well. Then for pure interest I connected the radio to my PC and fired up Spectrum Lab. And I was surprised it spit out the RDS data.

Then I thought what happens if I connect a Sony STR-232L to my PC. It’s a fairly old FM receiver. And yes, I was able to see RDS data. And I started using this as my main experimentation device because it is super sensitive. I was able to pick up quite far radio stations with it.

The most important thing is to sample at 192000Hz or you can not see the RDS stream.

I quickly found RDS Spy. You can even feed it directly with RDS data. The software works pretty well. It even decodes things that the car radio was not able to decode. It is even cooler to use the RDS Spy with my FM receiver. It’s an old analogue receiver but I am able to see RDS information on my computer screen.

RDS Spy and my FM receiver.

rdsparem

 

 

And I even was able to listen YLE YKSI from KO28XP. Here you can even see DARC.

To my knowledge nobody uses DARC in Estonia. More about DARC  HERE!

yledecoded

 

And YLEX.

ylex

 

Then I thought it would be super cool to actually send RDS data out myself. The simplest way to test this quickly was to record a radio station and then play it back to a transmitter. I tried with a car FM transmitter – that did not work. Then I tried the same with my FM transmitter bug that I had built couple of years back – That did not work.

So then I turned to my Raspberry Pi. The PiFM is a popular thing so maybe somebody has built RDS implementation into it? Yep.

And as you can see it works.

vlcsnap-2014-07-20-21h21m22s194

Now I need to buy this RDS+FM kit from Adafruit.

 

 

 

 

Monday, 14 July 2014

RTL_SDR Direct Sampling Mod

Listening to various radio signals is fun with vanilla rtl-sdr. The range is 22 MHz to 2200 MHz So that means there are pretty different things to listen to for a while. Couple of day’s back I wanted to listen medium and high frequency bands. Because radio waves in that spectrum travel a lot further than VHF and UHF signals. I know there are up converters that don’t cost very much and are easy to use. There are many other benefits using an up converter. But I wanted to do a direct sampling mod to one of my rtl-sdr. This so called “mod” is not very difficult. So I decided to try it out.

Source: 1 , 2 and 3

I should use a right ferrite for the job but I found this random one.



To the SDR I connected a 20M dipole.  So the rtl_sdr is not very good but the antenna makes somewhat up for it.



I’m using an old laptop as a server for the SDR. To add Direct Sampling mode in SDRSharp in TCP mode: LINK   And what do you know it works!

itworkslahe

Wednesday, 25 June 2014

Temperature Twitter Bot

Twitter is an interesting thing. Share whatever you want, whenever you want. Twitter is cool and all but I don’t find much use for it until now.

I came across this project http://www.scottcutler.net/catpoop/catpoop.html as you can see pretty weird but the idea itself is cool - automated twitter posts.

I took my Raspberry Pi and installed necessary files.

For my project I wanted to tweet my temperature, humidity, and air pressure. The main magic is done by the RbPi. The Arduino is connected via USB cable, meaning we have serial connection. The python script on the RbPi reads the data from serial and then tweets it. And it is as simple as that.

I needed to install couple of extra packages for python: pyserial and Twython.

Couple of lines of python and done.

To get the necessary authorizations: LINK

My code
import sys
import serial
import os
import time
from twython import Twython
CONSUMER_KEY = 'SECRET'
CONSUMER_SECRET = 'SECRET'
ACCESS_KEY = 'SECRET'
ACCESS_SECRET = 'SECRET'

api = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
ser = serial.Serial('/dev/ttyUSB0',9600)
while True:
cmd = '/opt/vc/bin/vcgencmd measure_temp'
line = os.popen(cmd).readline().strip()
temp = line.split('=')[1].split("'")[0]
posttemp = ('CPU temperatuur on '+temp+' C. ')

vaartused = (ser.readline().strip()+' C. '+ser.readline().strip()+'%. '+ser.readline().strip()+' mBar. ')

api.update_status(status=posttemp+vaartused)


time.sleep(1800)

 

Thursday, 5 June 2014

Arduino Weather Box

Couple of nights ago I decided to mess with my Arduino. All of my sensors and displays had arrived so I decided to build something. All basically sensors that show different climate properties so I named it Weather Box – Go figure!

With Arduino it is as simple as the alphabet. Connect everything and then remember where you connected your things and of course you need the necessary Arduino libraries so your Arduino can talk to your sensors.

Alpha build/testing.



 

So what I have is Arduino Nano V3.0, BMP180 (pressure and temperature), Nokia 5110 display module and famous DHT11 (humidity and temperature sensor.)

So the idea was to display all of that information on that Nokia display.

 

So then I had an idea to make this into something permanent. For example make a case for it, making it portable. I had this case from some old project. For me it looked too bulky and weird. So using only the bottom half I decided to make a case.

 

[gallery ids="247,246,254,253,248,249,250,251,252"]

 

Everything in there is super crammed together but it works.

The 9v lead out of it is just for demonstration purposes. The case is so packed that it would not fit anything more.

DONE



 

Monday, 26 May 2014

Messing with 433MHz equipment

We all know and love wireless devices. For example wireless doorbells. They seem so cool yet mysterious. How do they work?

Wireless doorbells:

They come with a receiver and the transmitter that you stick near your front door. Simple! They are wireless, so they use ISM bands. Most commonly the 433 MHz range. So when you press your door bell button the bell rings. The transmitter sends data out and the doorbell responds via sound – Simple!

DECODING

This is the first time when I used GNU Radio. I knew that these doorbells probably send data out with AM/OOK modulation. That was confirmed later on.

I made a quick GNURadio program to decode and record necessary signals.

I connected the rtl-sdr, pressed execute and started smashing the doorbell button. And what do you know, it works.

This was the output.

uksekellhea

You can clearly see the repeating patterns.

Later on I created a different flow graph so could record these signals.

flowgraph

 

And then viewing them with Audacity.

ilustinaha

I used Audacity because it works better when trying to measure timings.

TRANSMITTING

Now comes the hard part. How to I send data out? These send and receive dongles for Arduino cost under 5 euros on EBay. But I wanted to build my own transmitter. No need for something powerful, it needs to work.

I found this schematic:

fwySK

When collecting parts if found a wireless motion detector.



 

You know these things typically in buildings. Only mine was wireless. And what do you know it sends data out at 433 MHz so I popped the cover off and seemed to hit jackpot. The transmitting unit is right there no need to build my own. The transmitter has a name – Jablotron TX-3. Quick search led to results:

7-2

Whipped out my multimeter and quickly found the pinout. Nothing special data, power and ground. Sometimes Mr. Murphy sleeps or something.

I strapped it to my Arduino Nano and started creating a code that transmits right doorbell data.



Easier said than done in my case. I found like libraries dedicating to 433 transmitting but they did now work in my case because I wasn’t able to change timings or anything. So I started poking more and more. I put together some code from multiple places. So couple of hours later I was ready to test this out. This is my first Arduino project.

With Audacity I was able to measure timings. So I used all the gathered data and started writing it into a code. Uploaded it to my Arduino and the doorbell started ringing! Magic

Code source: HERE.

I also tried mimicking weather sensor data. Recorded the transmission. Analyzed it and then played it back. And Bob’s your uncle!

This applies to large amount of devices.

 

And here is a video:
Sorry for the shaky footage did not plan to upload this.

[youtube http://www.youtube.com/watch?v=F3qmHGu1rWo]

 

 

 

Wednesday, 16 April 2014

Weather data website

My first blog post was about reading data from weather sensors. I used the rtl_433 package. I did not have a conclusion. I got it to work. I did not capture any rtl_433 compatible sensors near me. I had an idea to run a webserver that’s displays a temperature captured with a SDR.

I reinstalled my homemade antenna. It’s a dipole antenna for CB frequencies. It’s and pretty wide range antenna so it captures all kinds of frequencies pretty well. Had some fun with it. I was scanning through the 430~ region and noticed that this antenna picks those frequencies pretty well. I remembered all the rtl_433 fun and tried it again.

Installed the rtl_433. It did not take long when it started decoding supported weather probes. At first I picked up only one but we’ll get back on that later.

temp

As you can see it also sends other fun data.

When I launched my command “rtl_433 –p 35 2>rtl433test.txt”

The “–p 35” flag deals with the frequency correction because rtl-sdrs are not perfect. I used  kalibrate-rtl to calibrate. It found out that my rtl-sdr error is 35 ppm.

It outputted everything in the text file.

PYTHON

Now I needed something to extract the necessary info from the text file. I used python to do the job. Little Google search lead to results and also used what I have studied lately.  It is HERE I know this thing is not very efficient. Probably there is a better way to solve my problem, but that’s the thing I made and it works. It imports the 433test.txt, searches for the terms „humidity” and “temp”. Then it prints the whole line where the term is present. Instead of printing the line it saves it into an html file. Had problems with it saving into txt and then presenting them in the website. So I used html because it is just almost plain text.  It gets the info from 433test.txt, outputs the necessary values to “temp.html” and “niiskus.html” and then waits for 60 seconds.

HTML page:

I used the power of Google and some free tools to craft that webpage.  The most important things are of course the temperature and humidity. The other stuff I added because of fun. Also I presented the path it takes to present that information. The page automatically refreshes after 60 seconds so you don’t have to refresh it manually.

Server:

Domain part was simple, registered a free domain called kukktemp.tk – go figure. Used its free DNS feature and pointed the DNS to my home IP.

I needed something to run this webserver on. I picked up my Raspberry Pi and installed apache2 on it. I did not need any MySQL or other stuff. I only needed the webserver. I configured the apache server and other parts.

Port forwarded the Pi and VOILA the Pi is available to the internet. I also forwarded the SSH.

I ran the commands and it started working surprising or that’s what I thought.

PROBLEMS:

I started noticing that sometimes it reports the temperature as 0 degrees. I found out that some kind of transmitter, that is picked up by the rtl_433 but it is glitches so it only shows 0 degrees. Enough to mess with my data. I had to thoughts how to solve this problem. ONE. Edit the python script or TWO edit the rtl_433 files.  With python script it would glitch when the sensor reports 0 degrees legimately so I moved to editing the rtl_433 files.

I noticed that, that phantom sensors is using a different protocol than the one that sends good data. So again I downloaded the rtl_433 from github and started poking at it.

When I removed the whole protocol it stated screaming because it does not find the references it needs. So then I looked for the part where it actually prints the data to the screen. I found the protocol I needed and deleted the lines where I normally prints the temperature. Also then I noticed I was able to do  even more that deleting  lines.  I saw that I was able to edit everything. Next time when I make a new revision, I probably would make new keywords and stuff so the python would have an easier time picking it up. We’ll see. It has running strong for the past days. I have no intensions to pull the plug. Let’s see where this thing leads us.

kukktemposx

KUKKTEMP.TK

 

EDIT 20.04.2014

Added a line in the rtl_433 files so it would also print the time and date for further logging and data collection.

kell

 

EDIT > 26.04.2014

I have noticed over a week that the website does not work after a while. The problem: that file what python need to process gets really long. I mean line 100k lines, then it does not work anymore. So I modified the code so at the beginning it would make a backup and then with that backup when it’s done reading data it cleans it. So every time it has only couple of lines to process. Let’s see how long that works! You can see the change HERE

EDIT > 3.05.2014

Made an Android application that basically serves the same purpose as the website itself. Only now it is much simpler to check the data out.

Couple of days ago I added the log to the website. It scrolls automatically to the end. It sounds simple but it pretty difficult to get working.

Here’s a screenshot:

kukktempapk

Kukktemp.apk

 

The website has ran almost two weeks I think. A lot of data has been gathered.

EDIT: 10.06.2014

It has ended. Everything is HERE.

Monday, 24 March 2014

WRT54GL SD card mod.

I have had lots of fun with the WRT54G series routers. I have installed custom firmware on every single of them. I have had at least five of these routers only 3 work at this point in time. The others have died in all kinds of ways – water, stupidity, etc.

So last summer I stumbled across this: http://www.dd-wrt.com/wiki/index.php/Linksys_WRT54G-TM_SD/MMC_mod

I thought it is the coolest thing ever. Let’s do this!

I did not have a spare SD card so I had to improvise. I dug up some old boxes and found an old floppy connector. It matched the SD card perfectly, making it the perfect adapter. And now the easy part: It was documented pretty well, so I only had to follow couple of steps. Mainly soldering the right SD card pins to the right GPIO leads.

Everything went well. Got it working. It ran a super tiny web server, because you know everything is cooler with a web server. When visiting the website it displayed the routers temperature, load and etc. It ran couple of html widgets. It doesn’t work at the time because I need the SD card.

Couple of pictures:

23022013124-1024x768 23022013126

Atari Punk Console

I just had to test out the Fritzinger magic. I only had 555 chips laying around, so with little bit of fun with google, I found this :

 

atari_punk_console_schem_556

 

 

Some information:  http://en.wikipedia.org/wiki/Atari_Punk_Console

Basically it is a super simple project. I needed something to test the Fritzing out. So I created this:

 

schem

And thanks to that, it auto created this(I had to fix couple of things):

 

 

And then of course it is etching time!

I use the laser printer method

 

IMG_6610

IMG_6611 IMG_6612

 

Iron(III)chloride in action!

IMG_6616

IMG_6619

IMG_6625

 

 

 

IMG_6627

 

Done!

2014-03-21 14.00.20

2014-03-21 14.00.09

 

You might ask why those IC’s are on the wrong side of the PCB. Answer - I rushed and forgot to mirror the print. You learn something every day! But I managed to get it working.

[audio mp3="http://kukk.tk/blog/wp-content/uploads/2014/03/Untitled.mp3"][/audio]

It is powered by USB - 5v.

Monday, 17 February 2014

Bought a server.

Today was an interesting day. At the end of the day I purchased a server. It is called PRIMERGY RX220 and it is made by Fujitsu-Siemens. It has two Opteron 265’s at 1.8 GHz and 1 GB of ram. It is not the fastest server in the world in fact it is quite old it is 8 years old. But for my intensions I think it is powerful enough. The only thing that bothers me is that it supports max only 500 GB hard drives. I haven’t checked any bios updates, so maybe they have updated it. Hopefully it runs Windows Server 2012 R2 well enough because I got a free key from Dreamspark. If it doesn’t run well I probably install Ubuntu server or something lightweight like that. The main idea right now is to run it as webserver for this website – I think. I know that Elion’s update speed is like 1 Mbps but it beats my current hosting. If my dual wan thingy works maybe even maybe 2 Mbps but that is a stretch. Also idea - run it as file server.
It hasn’t arrived yet via mail, so I don’t even know if it works, so it is too early to make plans.
Ooh and I also got it for 7 euros so that made it clear why I bought it.

Wednesday, 12 February 2014

Raspberry Pi FM trasmitter

So I was browsing reddit and came across THIS.


It was so cool, I had to try this out. So I took my Raspberry Pi and hooked it up. When it booted up I was able to run the following commands over SSH.



mkdir radio
cd raadio
wget http://omattos.com/pifm.tar.gz
tar –xvf pifm.tar.gz

And that’s it. Now you need to connect a wire to Pi’s 4 GPIO pin. I just connected a random wire. For maximum performance use 20cm wire or dedicated antenna.


To test it out I typed:


sudo ./pifm sound.wav 100

Tuned my radio to 100 MHz and tadaa – Star Wars theme was rolling in.


When the file ends or you cancel it, it stops but the modulation stays on. To get rid of it you need to restart your Pi or run this script I made.


stop For example save it as "stop.py". And run it.


sudo python stop.py

And it should stop.


As you can see the 100 stands for the frequency. For more flags read THIS. Now it even supports stereo.


You can replace the "sound.wav" with other music file. PiFm currently only supports 16 bit 22050Hz mono .wav files. To do this you need to put your file into the pifm directory or type in the full directory where the file is located.


If you want to transmit .mp3 files you need to install a package.


I tried this out and it worked great!


If you want to transmit your voice live you need to use USB webcam or microphone because Raspberry does not have a dedicated mic input.


I have a Logitech webcam with mic and used this command to pipe my mic output to PiFm



Worked great!


Now when that was done I wanted to push Pi into its limits and see how far it would transmit.


With the wire it was simple : it basically covered entire house.


Put what happens if I use a bigger antenna? Let’s find out!


antennid


So the HAM shack is in the attic so I climbed there, hooked everything up and port forwarded Pi’s SSH.


I quickly made this ghetto adapter.


2014-02-12-18.44.42


Before I went away I snapped a picture because it looked cool:


2014-02-08-16.52.37


I grabbed a IC-T8E and started pedaling. I turned the radio on. Took out my phone and SSH'd into the Raspberry that was sitting in the attic. Inserted the commands and boom IT WORKS!


[youtube http://www.youtube.com/watch?v=z7yesNNWZJQ?rel=0]

When I arrived I climbed on my roof and tried again. Still worked with the stock antenna. It was low on signal but I was still able to listen it. The range was whopping 2km. That blew my mind. Probably I was violating like thousands of FCC and TJA rules when I transmitted in the FM frequencies – I have nothing else to say then “Sorry”.


The next day I drove on the top of the trash mountain and started the experiment again. The stock antenna did not pick up anything but when I tried with my Yagi antenna it worked. I did not test it much because it was freezing there. Before I left I snapped a pic:


2014-02-09-15.15.46


Anyway without any amplification the Raspberry Pi transmitter is pretty powerful with a good antenna. That ended my experiment.


I’m looking forward to send other modulations than WFM. AM would be super cool. That means I can record what my doorbell button sends out – record that with my SDR and then whenever I need replay that and my door would ring. Think about the possibilities!


Tuesday, 11 February 2014

Reading data from 433Mhz temperature probes.

As the title stated, I had a idea to capture data from those magical things! These thing wirelessly send data between the sensor and the station.

 

yhst-37697109791737_2268_384347716

I had one of these probes laying around and I thought I should at least try to capture something from it. I did not have the base station only the probe.

Sounds cool on paper! The first thing I tried to do was actually capture a sample.  I booted into my Ubuntu and launched Gqrx. With my SDR I was able to tune into the 433 MHz region. Those probes usually work around that frequency.

So I captured this around 433.900Mhz AM

This is what that region looks like:

gqrx430

So then I started searching and I found this: https://github.com/merbanan/rtl_433

Went to my linux machine and typed into the terminal (the readme commands did not work for me) :http://pastebin.com/embed_iframe.php?i=0YQ8jDjg

So when that was done I figured how to use that thing.

Everything is super simple when that part is done. So I was able to run this:

rtl_433 –a  - this outputs all it's magic into the terminal but we want a way to have all that in a simple txt file. The default frequency is 433.92 MHz.

So I entered this:

rtl_433 –a 2 > 433test.txt

This command dumped everything at /home/kukk/433test.txt

So I captured one transmission. This was the output:

http://pastebin.com/embed_iframe.php?i=11KP9Mp3

It also transmits humidity. Working that out is not as simple as temperature. Also it sends out other data that I don’t know anything about.

I had an idea to run this on my Raspberry Pi.  When it is running the python extracts the temperatures and presents it on my website.

With SDR it is cool to read multiple probes and maybe then average it.