Click here to Skip to main content
14,331,308 members

x10 Firecracker message format and a C++ class to use it

Rate this:
4.90 (10 votes)
Please Sign up or sign in to vote.
4.90 (10 votes)
6 May 2004
A C++ class to send commands to x10's firecracker unit.

Sample Image - x10Demo.jpg


The Firecracker(C) is a product by X10 industries. It is a matchbox sized unit that plugs into a serial port and transmits commands wirelessly one-way to a receiving unit that's plugged into an AC outlet, which then sends the same signal through the home's AC wiring to all other x10 control modules. There are several types of modules, the two main ones being a light controller and an appliance controller. This system can accommodate 16 house codes, with 16 controllers in each house code, for a total of 256 devices. The individual controllers can be set to a particular house and unit code by rotary switches. There are several different commands that can be sent out; On, Off, Dim, Brighten, All lights on, All lights off and All controllers off. The On and Off signals are sent to a house and unit code. This causes that controller to go into a listen mode after which it will respond to dim and brighten commands which aren't provided with a target. Each dim or brighten command causes about a 5% difference. The All lights on and All lights off are targeted to only a house code which would cause all light controllers (up to the max of 16) with that house code to respond appropriately. Finally, the All units off will turn off all light and appliance modules on that house code.


The Firecracker does not rely on normal serial communications, instead it is driven by the RTS & DTR signal lines which also provide its power. The command frame is pretty simple, consisting of only 5 bytes. Refer to table 4 for the message layout. A couple of tricky areas are initialization of the device and clocking out the signals to the RTS/DTR lines with appropriate delays between bits. Initializing the device is achieved by setting the RTS/DTR lines low for a short time and then bringing them both high with another delay before commencing a message. Sending out bits consists starting out with both lines high and setting DTR low for an on bit and setting RTS low for an off bit. In both cases, there must be a delay of at least 500 microseconds before setting that same line high again. This process continues until the entire 5 bytes are sent out. Table 1 lists the house codes. Notice that the house code is a bit different depending on which bank the target controller is on. Table 2 lists the byte to send to turn a controller either on or off. Note that controllers 9-16 have the same code as 1-8. Bit 2 of the house code is what ultimately decides which bank the command is for. Table 3 lists the all-on-off commands. These are sent in place of a code from table 2. Finally, table 4 shows the format of each message. The 2 header bytes and 1 footer byte are always the same.

Table 1 - House codes

CodeUnits 1 - 8Units 9 - 16

Note that the house code has bit 2 turned on when addressing units 9 - 16.

Table 2 - Unit codes and function

20x1000010000 0x1200010010
30x0800001000 0x0A00001010
40x1800011000 0x1A00011010
50x4001000000 0x4201000010
70x4801001000 0x4A01001010
100x1000010000 0x1200010010
110x0800001000 0x0A00001010
120x1800011000 0x1A00011010
130x4001000000 0x4201000010
150x4801001000 0x4A01001010

Note that the code for units 8 - 16 are the same. As explained in table 1, the house code indicates if we're addressing units 9 - 16.

Table 3 - Commands

All lights on0x9010010000
All lights off0xA010100000
All units off0x8010000000

Note that commands have bit 7 turned on.

Table 4 - Message format

HeaderHouse codeUnit code, Function / CommandFooter
0xD5,0xAA / 11010101,10101010Refer to table 1Refer to tables 2 and 30xAD / 10101101

Using the code

Just a handful of functions are needed to surface the functionality of the FireCracker. Open the COM port by calling Open() with desired COM port as a string as in "COM1". Demo projects for both VC6 and VS.NET are included.

  • void Open(LPCSTR pszComPort); // "COM1", "COM2", etc...
  • void Close(); // Releases the COM port
  • void TurnOn(char cHouseCode, int nUnitCode); // Turns on a unit. House code is the letter from A thru P
  • void TurnOff(char cHouseCode, int nUnitCode); // Turns of a unit
  • void Dim(); // Dims the last unit turned on by about 5%
  • void Brighten(); // Same as Dim() but brightens instead
  • void AllLightsOn(char cHouseCode); // Turns all lights on in a house code. Up to 16 controllers
  • void AllLightsOff(char cHouseCode); // Turns all lights off
  • void AllUnitsOff(char cHouseCode); // Turns all light and appliance controllers off


  • 5/7/2004 - Initial release.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

John Gonzalez
Software Developer
United States United States
No Biography provided

Comments and Discussions

GeneralA concise, bloat-free, reusable class. Stunning. Pin
CYLO1-Apr-08 14:10
memberCYLO1-Apr-08 14:10 
GeneralRe: A concise, bloat-free, reusable class. Stunning. Pin
John Gonzalez2-Apr-08 20:50
memberJohn Gonzalez2-Apr-08 20:50 
GeneralProgramming Pin
John LeBlanc29-Sep-04 14:05
memberJohn LeBlanc29-Sep-04 14:05 
QuestionWill it work with CM11A?? Pin
Kyle J7-Sep-04 14:25
memberKyle J7-Sep-04 14:25 
AnswerRe: Will it work with CM11A?? Pin
John Gonzalez11-Sep-04 13:48
memberJohn Gonzalez11-Sep-04 13:48 
QuestionQuestion n?? Pin
FlorianS2-Jun-04 4:00
memberFlorianS2-Jun-04 4:00 
AnswerRe: Question n?? Pin
John Gonzalez11-Sep-04 13:47
memberJohn Gonzalez11-Sep-04 13:47 
GeneralAwesome! Pin
Ravi Bhavnani16-May-04 6:23
professionalRavi Bhavnani16-May-04 6:23 
GeneralRemote control my PC via x10 CA19-Module Pin
ScruffR12-May-04 23:57
memberScruffR12-May-04 23:57 
GeneralRe: Remote control my PC via x10 CA19-Module Pin
MT9999919-May-05 3:13
memberMT9999919-May-05 3:13 
GeneralTheir interface sucks, thank you. Pin
frugalmail12-May-04 13:50
memberfrugalmail12-May-04 13:50 
GeneralRe: Their interface sucks, thank you. Pin
John Gonzalez12-May-04 13:58
memberJohn Gonzalez12-May-04 13:58 
QuestionWhat the... Pin
Snyp7-May-04 1:37
memberSnyp7-May-04 1:37 
AnswerRe: What the... Pin
Joel Lucsy7-May-04 2:40
memberJoel Lucsy7-May-04 2:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 6 May 2004


21 bookmarked