chronos.chschmid.com

I use my TI chronos watch to control my bedroom light. This site contains information on how the whole thing evolved and how it works. To get a rough idea about the project you might want to watch the short video below.

Table of Contents

1. Introduction
    1.1 The Story Behind the Project
    1.2 The Hardware
2. Reverse Engineering the Communication
3. TI SmartRF Studio
4. Code Composer Studio: C Code
5. I want to hear from you!

1. Introduction

1.1 The Story Behind the Project

I installed a dimmer in my bedroom about a year ago. It comes with a remote control that allows you to switch the light on and off, as well as to dim the light. About two month ago ordered the TI chronos.

Hey wait a minute: They both operate at 868 MHz. So it should be possible to make the TI chronos control the dimmer. Well, the idea was born, now it was time to knuckle down ;)

1.2 The Hardware

This project combines

The TI chronos comes with a very detailed documentation and also Conrad even provides a schematics for the dimmer (Click links below).

The dimmer comes with a remote control which allows to switch light on and off. If the button on the remote is held down, instead of pressed just once, the brightness can be adjusted.

2. Reverse Engineering the Communication

The goal is to emulate the signals sent by the remote control with the TI chronos watch. Therefore the first step is to characterize the RF signal transmitted by the remote control. The problem can be tackle using two approaches. One can either try and understand the schematics provided above or one can perform measurements. The schematic has one flaw, that is it does not describe the RF module, so no information about the modulation scheme, packet format and so on.

Thus I went with the measurements first. A session at the spectrum analyzer and a 10 GS/s oscilloscope soon showed the commands are sent using OOK (On/Off shift keying) at a carrier frequency of 868.35 MHz. The signal that goes into the RF module simply turns an SAW oscillator on and off. The chip that is used to generate the transmit data is a HT12E encoder (http://www.holtek.com/english/docum/consumer/2_12e.htm). As long as the button is pressed the encoder generates a signal that is repeated periodically. The following figures show the signal as measured with an oscilloscope.

It turned out that a minimum of 6 code cycles are required for the dimmer to switch the light on and off. If more code cycles are transmitted the brightness starts to change.

The exact code generated by the encoder is hardwired into the remote control by soldering, as can be seen below (click to enlarge).

The last four bits are always zero but the first eight bits are set by soldering at the encoder’s pins. The encoder prepends a zero and then generates a stream of three bits for every single input bit (a total of 3+8*3+4*3=39 bits) which are then transmitted by the TX module (see oscilloscope plots above and, which matches the code of the remote in the photo). I now even have two dimmers in my apartment, no measurements were required for the second dimmer, as the code can be read from the soldering.

Click here to download a zip file that contains measurement data and MATLAB code to extract the data to be sent by the TI chronos. Simply run “runDataExtraction.m”. “runEncodeData.m” will produce the hex code for a given solder mask.

3. TI SmartRF Studio

Now it is time to test the code obtained from 2. Reverse Engineering the Communication with the TI chronos to see weather it works or not. I just connected the chronos to the computer via the debug interface and started TI SmartRF Studio (http://focus.ti.com/docs/toolsw/folders/print/smartrftm-studio.html)

First I used the “Packet TX” mode, after adjusting all the required RF settings suddenly, like magic, the light turned on and off. In a next step I tried the “RF Device Commands” mode. This is a little bit trickier, you have to set all the strobes yourself. At first it did not work as I never used the FSCAL strob, but then I found the following routine to be working:

1. Initialize register settings: Press “Pkt TX” button
2. Set the RF parameters to your requirements, in my case (click to enlarge):

SmartRF Studio 7

3. Write TX FIFO (Write data to TX FIFO)
4. SCAL Strobe (Calibrate PLL)
5. STX Strobe (Transmit the command)

Tada, the light goes on or off every time STX strobe is set. After the first run, you can skip 1 and 2, just loop 3-4. Now it was time to export the register settings for the C code to be implemented in 4. Code Composer Studio: C Code, so I enabled the register view and used the “Register Export” feature. Which format works best for you depends on how you write your C program.

4. Code Composer Studio: C Code

What can I say, here’s the complete source code: download source code.

First of all, what are the changes from a user point of view: Compared to the original software there’s not much of a change, only two things: The primary first (L1) and second line (L2) modules (the ones that show the time and the date) loose their secondary view mode. So the up and down keys will no longer show the seconds or the year. But come on: Who needs to know what year it is, or the exact second. Instead these buttons will cause the two codes for my two dimmers to be transmitted.

Now to the code point of view: The two new files are cSLight.c and cSLight.c. Actually they implement another L2 mode. But I did not activate it, as modifying the buttons for the two main L1 and L2 modes seemed a better idea. Besides the obvious things needed to implement the L2 mode and to modify the main L2 and L2 modes I changed the Strobe function in rf1a.c. I don’t know if it is actually needed, but I found more recent CC430 rf1a code on the TI website, which actually seemed more reasonable – so I replaced the function that comes with the chronos.

Well. That’s all for now, just one more thing:

5. I want to hear from you!

Please let me know what you think about it, just use the comment box below! And check back later for more information.

46 thoughts on “chronos.chschmid.com

  1. Marius

    Hello! very interesting your project. I want to do the same project in my house. Can you put the C code from CCS, or send it to me on email. Thanks in advance

    Reply
  2. Xorsio

    Cool! Just what I was looking for! Thank for you description of you work. Are you willing share the source code? Have place an order for a chronos now!

    Reply
  3. Fabio

    Hi,
    i think the idea of your project is great. could you please send me the source code per mail. It doesn’t work with your code yet.

    Thanks

    Reply
  4. israel

    very interesting your project. I want to do the same project in my house. Can you put the C code from CCS, or send it to me on email. Thanks in advance

    Reply
  5. George Mouzourakis

    Thats an excellent job well done.I am trying the same thing with my chronos watch but even though i do have my x10 receiver code i cant set up the right registers about the sync bit.Can you please Upload an image about the RF settings?Thank you very much.

    Reply
    1. Christian M. Schmid (Post author)

      Sorry for the delay, a SmartRF Studio 7 screenshot is posted above now. The exact hex register settings can be found in “cSLight.c”, which is part of the source code

      Reply
    1. Christian M. Schmid (Post author)

      Sorry for the delay, a SmartRF Studio 7 screenshot is posted above now. The exact hex register settings can be found in “cSLight.c”, which is part of the source code.

      Reply
  6. Christophe C.

    this is great project.
    Thanks for sharing.
    I’m about to receive my chronos and to start programming as well … so all examples are welcome. Your’s is very interresting ! (and’s got a good approach).
    Rgds !

    Reply
    1. Christian M. Schmid (Post author)

      You can of course have two chronos watches or more that act as remote controls. It’s like with TV remote controls, however if both try to send a command things will get messy. Is that what you mean by paring with each other?

      Reply
    1. Christian M. Schmid (Post author)

      Sure! It is totally possible that two watches communicate with each other! You can either do it the hard way (= your own protocol) or you can do it using Ti’s protocol, or some zigbee stack, or …

      Reply
  7. Fischbeck

    Good morning :D
    Dear Mr. Schmid,
    in Part 2 you wrote: …I now even have two dimmers in my apartment, no measurements were required for the second dimmer, as the code can be read from the soldering.

    Now my question:
    Is it a hex-value, a bit-value or a decimal value which is on the soldering?

    for example your bitcode in sample 1. Is there a decimal Code like 80953053769 on the soldering-board or a hex Code like 12D92D9249 ?

    Greetings Mr. Fischbeck

    Reply
    1. Christian M. Schmid (Post author)

      I have added additional information on how to extract the code from the remote PCB soldering. Hope you enjoy playing around with your chronos!

      Greetings Christian

      Reply
      1. Fischbeck

        Thank you very much :) If I had read the documentation for the HT12E better, than I had seen this info earlier :)

        greetings Fischbeck

        Reply
  8. CSK

    Hey Awesome work!!
    so far the best chronos reverse engineering stuff.

    i really dont like the idea of having an intermediate “PC” in projects, ur idea of watch talking to devices directly is what i was looking for. infact before buying the watch i assumed this could be done very easily.

    i bought a 433 MHz as in India i get a lot of RF transmitters and recievers using that RF range. but i am lost as its not so easy for me to understand the Rf communication ez430 is using, just wish if experts like you can write some library for easily sending RF commands using ez430 {prefrebly 433Mhz} :)

    btw thanks again cool idea :)

    Reply
    1. CSK

      Also can you please suggest what changes should i make in RF parameters for my watch 433 Mhz
      {to replicate a 433MHz RF transmitter with HT12E encoder}

      Reply
      1. Christian M. Schmid (Post author)

        Enlarge the TI SmartRF Studio screen shot above, make sure all settings in the “RF parameter” area are the same as in the screen shot (apart from the base frequency, which is somewhere around 433 MHz for you, depending on the RF module)

        That should give you the correct seetings for the emulating an HT12E encoder with a 433 MHz ASK/OOK RF module.

        Reply
    2. Christian M. Schmid (Post author)

      Thanks for your comment.
      I think that “writing some library for easy RF” is neither a good idea nor necessary. To be frank, with the integrated MSP430 + transceiver + the TI’s RF studio + the source code it is as easy as it gets

      The thing is the transceiver is so highly configurable that you can do almost everything that is using 868 or 433 MHz in your case. Because of the many parameters that you can choose the library approach, you would need a really really large library to cover all possible cases of use (ASK, PSK, packet mode, zigbee, …)

      Using TI’s SmartRF Studio for testing and for generating the register settings + using the C libraries that come with the watch works fine.

      Reply
      1. CSK

        Thank you for replying.. after researching on various datasheets / RF studio realized that really what you have provided should actually suffice all the needs. :)

        btw there is another discovery i have made to add more trouble to my chronos research life.. i had actually replaced all HT12E encoders i used few years ago for “complete home automation project via bluetooth / sms” with HT640 as it has 8 bit data unlike ht12e which has only 4 bit data.

        so it all starts again… wish i had an oscilloscope.. by looking at the ht12E and ht640 datasheets i have figured out what data i should send, but modulation frequency is the tricky part, as there is no formula provided for “fosc” based on resistor used and i dont have an oscilloscope :)

        so either i ll have to replicate standard values of resistor / VDD as mentioned in HT640 datasheet or i need to switch back to low data bits HT12E currently sticking on to HT640 lets see..

        just in case if u manage to have a look at HT640 datasheet and have spare time to discuss please drop a mail :)

        btw based on ht12E datasheet findings:
        i think the pcb soldered values you provided are inverted or am i missing something here..

        SYN == first bit always 1 for sync purpose
        ADD == Adddress bits 12 for HT12E
        DAT == Data bits 4 for HT12E
        001 001 011 011 001 001 011 011 001 001 001 001 001 (from oscilloscope data)
        SYN ADD ADD ADD ADD ADD ADD ADD ADD DAT DAT DAT DAT (HT12E datasheet)
        1 1 0 0 1 1 0 0 1 1 1 1 1 actual values (HT12E datasheet)
        0 0 1 1 0 0 1 1 0 0 0 0 0 Christian

        Reply
        1. CSK

          firstly sorry to flood your blog with my comments :) ur the only person who can save me :)
          hey based on the graph in datasheet of the decoder HT648L i figured out Fosc == 200kHz for resistor i had used earlier 150kOhm, also there is a frequency division happening internally Fosc / 33 and 1 address/data bit uses 3 cycles of Fosc / 33
          now i have data but i really donot know how to proceed further… as it looks quite different from HT12E.. :( so i think now i have to determine how can i replicate the modulation frequency using acuurate number of bits /cycles to represent data :)

          Reply
          1. CSK

            hello again… okay i think i am too close to what i want just that… i am missing just one key… i just wanted to know how you arrived[calculated] the Data Rate 1.599312 kBaud and what was the Resistor (Rosc) used in the HT12E / Decoder.

  9. Eginhard

    In case I don’t have access to a spectrum analyzer, can I do such measurements with the Chronos’ hardware? Does SmartRF studio allow me to read the incoming singnals from the USB RF unit?

    Reply
    1. Christian M. Schmid (Post author)

      This is a very interesting question! I don’t think that the SmartRF studio will help you to achieve what you need. – With the SmartRF studio you have to adjust the settings, it won’t find the settings for you.

      But implementing your own rudimentary “Spectrum Analyzer” might be possible … as well as laborious.

      Reply
  10. peter

    hi,

    all I can say is Wow! that’s a great tutorial.
    I was also trying to control my intertechno rf switches and thanks to this page I was able to power on/off the switch using the smartrf studio software via the chronos watch.
    my only gripe atm is that the radio sends a preable (something like b100001000) and what looks like a 14-16bit crc hash after my sequence even if I enabled the ‘no preamble/sync’ mode in PacketTX. looks like it’s time to dig deep into a datasheet.

    also, you should mention in this page that a spectrum analyzer, an extremely fast osciloscope and matlab are nice but not really needed. since the radio switch that you try to control already has a nice demodulator that one can poke with any cheap scope. then one only has to compare the signal the factory remote generates with the signal from the chronos.

    thanks again,
    peter

    Reply
    1. Christian M. Schmid (Post author)

      Hi Peter,

      Thank you for your comment! You are absolutely right, you could also do it without using the fancy equipment I was using.

      Just throw in some assumptions about the modulation format (no header, no CRC, OOK) and you could even do the measurements with your computer audio port ;)

      Regarding your problem with the preamble / sync: You’re on the right track! I studied the datasheet too and I had to manually edit some of the register settings, some of which you see on the right side of the TI SmartRF Studio screenshot. Too bad I don’t remember which ones I changed manually.

      Thanks again and good luck and lots of fun with your TI Chronos Project!
      Best regards,
      Christian

      Reply
      1. Peter

        Hi,

        for the record, the two settings that have to be changed are PKTCTRL0 = 0 (to disable CRC) and MDMCFG2 = 0x30 (to disable preamble). these two tend to change back to defaults even if you look funny to the smartrf studio. which would explain why the screenshot on this page is also out-of-sync compared to your rf settings from the source code :)

        cheers,
        peter

        Reply
        1. Christian M. Schmid (Post author)

          Glad to hear you found it – great job!

          The source code is of course the real thing and the settings there are the ones you should trust, I bet I set the changes like you suggested ;)

          Thanks again and best regards!
          Christian.

          Reply
        2. Peter

          hi,

          the first proof-of-concept code is available at https://github.com/rodan/openchronos-rfsw

          it’s based on openchronos and can be compiled with the open-source mspgcc linux toolchain, since ccs was too much for me.
          this might help others that try to set up the chronos watch with the Intertechno RF switches.
          once I’ll understand how to properly use the menu system and more than 1 button per page I’ll implement device number and on/off command selection.

          thanks again for the great tutorial ;)
          peter

          Reply
  11. Sab

    Hi! I need to do a mini project using msp430. Could you suggest something simple but useful I could do with this microcontroller?

    Reply
    1. Christian M. Schmid (Post author)

      Thank you for your comment! There are a lot of useful things that you could do. It mainly depends on how you define useful ;) Some ideas are listed here: http://processors.wiki.ti.com/index.php/Category:Microcontroller_Projects_-_MSP430

      Also browsing youtube will give you an idea of what people have done using uCs. One project that I would love to do if I had the time would be to build a clock like this: http://blog.makezine.com/2010/11/04/another-excellent-diy-wordclock-bui/

      Good luck and lots of fun with our project!

      Reply
  12. Nicola

    Nice project!

    Today my eZ430 Chronos (868MHz) arrived. And i have to say, it’s a great “toy” :D . C-Code and the µC are totaly new for me. In the past i played succesfully with Atmels ATMEGAs, ATTINYs and BASCOM AVR. Now i have to arrange with C . My target is, to use an 868 MHz receiver and feed the data into a mikrocontroller. Did you have any experince with general 868 MHz receivers and the eZ430 Chronos, except the Conrad module?

    Thanks for sharing your work with us!

    Reply
    1. nadohha

      Hi Nicola,

      I thought I might share my experiences with communicating with RF receivers and the Chronos watch. I have use the RF Link Receiver – 4800bps (434MHz) sold by sparkfun. It is exceptional easy to setup and use, only requiring a couple of connections (power, ground, data and antenna). Unfortunately sparkfun they do not sell an 868MHz version, however there are other equivalents modules out there that work in the exactly same manner, for example the AM-RRQ3-868.

      Getting data into a microprocessor is pretty handy, you simple connect the RX pin of your receiver to some GPIO pin of the micro controller, write some code (interrupt driven perhaps) to buffer the incoming data. One thing to be aware of is that the RF receivers output will float when no signal is present, it will not simply stay low as you might expect. It is constantly picking up electromagnetic noise, so keep that in mind when attempting to read data into the micro controller. There are a couple of solutions to this, you could implement a low pass filter and then transmit your data at a relatively slow rate. Or you could pull the RX line low for a long period of time (1ms) to indicate data is being sent. Your micro controller could then simply wait until its input pin is dragged low and stays low for 1ms. When this condition is met, it will then start buffer then next N bytes.

      Hope that helps

      Reply
  13. nadohha

    Hi Christian,

    When attempting to get my Chronos watch to open my gate your website was more useful than any other resource. My biggest issue as I imagine most peoples will be was figuring out how to configure the CC1101 radio and how to write a simple byte to it. Thank you for pointing me towards the TI SmartRF studio, it was invaluable. As was your example code at implementing the resulting register values.

    Two things still tripped me up and took awhile to figure out, so I want to mention them here for the benefit of others.

    1) The packet length is hardcoded in the RF registry dumped by TI SmartRF studio, see PKTLEN. Make sure this matches the length of your byte array.
    2) Although working correctly and sending the correct codes, my Chronos watch kept randomly resetting itself while transmit. I realised that the radio config was set to 10db TX power. 10db seems to drain to much power to quickly, causing the watch to reset itself. To fix this issue, make sure you set your TX power at 0db. This is set in the paTable0 register.

    Note that in Christians code this is set using the line: unsigned char cSLpaTable[2]={0x00,0xC3}; //0 dBm
    This is fine for 868Mhz, however at 434Mhz it is incorrect. Instead, it should be cSLpaTable[2]={0x00,0x50};

    Reply
  14. Nutella

    Hi Christian,
    I would like to use your source code for controlling the ceiling/table lamp etc.
    May i know how can i connect the table lamp to code composer studio?

    Reply
    1. Christian M. Schmid (Post author)

      I had measured the signals with an oscilloscope and used Matlab for the graphical representation of the signals.

      Reply
  15. Pingback: Holiday Project: Philips Hue Goes System Tray | Christian M. Schmid

Leave a Reply

Your email address will not be published. Required fields are marked *