Since we’re so close to Thanksgiving, today I want to talk to you about turkeys.  Wild turkeys, that is, not the kind of turkeys we eat at Thanksgiving.  Did you know that the Pilgrims actually brought some turkeys with them on the boat?  Anyway, my interest in turkeys is just part of my interest in wildlife.  I’ve always been a city boy and I still get excited when I see things like deer and turkeys roaming around in the wild.  Snakes excite me too but not in a good way.


Unlike domesticated turkeys, wild turkeys are smart.  They are also very sociable.  They hang around in groups.  They play together.  And the older ones teach the younger ones everything they need to know about being a turkey.


When I lived in Iowa, I would drive by a small corn field on the way to church and every Fall there would be at least one bunch of turkeys grazing on corn that had fallen to the ground during the harvest.  In West Texas, though, the turkeys don’t have the luxury of corn fields.  I guess I don’t really know what they normally eat, but I do know that they like acorns.  I’ve seen a group of turkeys gathered around a tree eating acorns.  And when the supply of acorns runs low, one of the turkeys flies up into the tree and starts thrashing around to knock down more acorns.  See, I said they were pretty smart.  After awhile, the turkey will jump down from the tree to eat some acorns and another turkey will take its place in the tree.  It’s all part of living in community as turkeys.


So what do turkeys have to teach us about being a Christian?  Well, when Jesus founded the church, he basically told us to be like turkeys.  He didn’t say it exactly that way but he did expect us to be in community with one another.  He expected us to worship together.  He expected us to play together.  He expected us to teach each other how to be a Christian.  He expected us to take turns doing the work of “shaking the tree” so that everyone can get a share of the acorns.  And he expected us to be sociable enough that others would want to join our group.


Benjamin Franklin once wrote a letter to his daughter in which he compared the Bald Eagle and the turkey.  Basically, he said that the Bald Eagle looked good on the outside, but that it only cared about itself and was both a coward and a thief.  On the other hand, Ben praised the turkey for all of the things that I mentioned.  It’s like that for us as Christians too.  It doesn’t matter if you look more like a turkey than an eagle, it’s what’s inside that counts.  That’s what God sees in us and that’s what other people will experience through our actions.


There are lots of stories about people who overcame some bad things in life but the one that I know best is the story of my grandmother.  When grandma was born in 1905 her father was in charge of running a logging camp.  Her mother took care of all of the cooking for the camp as well as taking care of her own family.  Grandma loved school but, when she was still in High School, her father died.  Her mother had to take over the day to day business of the logging camp management and that meant that grandma, as the oldest child, had to quit school and take over the cooking and looking after her younger brothers and sisters.  Grandma eventually found her way back to school and, when in her 80’s, grandma dressed in a cap and gown and proudly marched up to get her diploma.  Every one of her kids and most of her grandkids were there to cheer her on.


Grandma got married and had children.  She lost her youngest daughter as a baby and then, when grandma was 94, she lost her oldest daughter who was my mother.  In between, grandma and grandpa made a modest living until grandpa died when grandma was 61.  In order to pay the bills grandma worked fulltime as a housekeeper at the local hospital.  Eventually she worked her way up to be a nurses aide but not before she lead a difficult fight to get the housecleaning workers organized into a union.  Grandma was in her 70’s when she retired from fulltime work at the hospital but she continued doing volunteer work there for another 20 years because she just liked helping people.


Grandma got a little slower with age but she was still very active and mentally sharp into her late 90’s.  She collected family stories and pictures and put them into a family history.  When I would visit her she would tell me wonderful stories about how life was lived long ago and the interesting characters who were my ancestors.  Unfortunately, all of that came to a sudden end when grandma had a stroke at age 98.  The stroke caused grandma to lose her ability to walk and to talk and even to swallow.  After being so active and helpful she ended up bedridden, with a feeding tube, and only able to make sounds that couldn’t be understood as words.  But grandma was still there inside of that broken body and people say that her face lit up with joy when her many friends threw her a 100th birthday party.  Grandma had another stroke a few months later and was finally released from her earthly prison.


I read somewhere recently that life can only promise us pain so it’s up to us to create the joy.  When I think about that I’m reminded of grandma.  She endured what life threw at her and still managed to thrive and to be someone that made people feel good.  The Bible also tells us that we are certain to have suffering in our lives.  And, unfortunately, good people sometimes suffer more than bad people because life is not fair.  But the Bible also tells us that we can take joy and comfort in a life lived in Jesus.  And we can take joy and comfort in knowing that there is a better world after this one.  I know that grandma believed that.  And I think that’s what got her through the last year and a half of her life.

One Parade Too Late

He remembers watching the faces on T.V. as the tears began a salty cascade down their cheeks.  He cried as they cried, their impending separation ripping through more than twenty years of psychic dust and debris to lay open the feelings of a 19-year-old kid.  The feelings that came as he turned away from the girl he loved and marched across the tarmac toward the plane that would deliver him into the military and the uncertainty that surrounded the Viet Nam war.

He also remembers the faces on T.V. as they returned to an overwhelming display of yellow ribbons, smartly flapping flags, and old-fashioned victory parades.  Some of them reveled in the triumph of the moment, and some flushed with embarrassment, but all were thankful to be home.  The Gulf war was over and they were all treated as heroes.  And he cried again.

The year is 1971.  The 19-year-old kid is now 22 and he is sitting in the squadron commander’s office.  Quietly, but with a slight waver in his voice, he explains why his roommate has wandered off toward the ridge that overlooks the base.  A few months later the young man heads home before reporting for his next assignment.  Disappointment sets in when his young wife does not meet his plane.  It grows as he unlocks the door to her empty apartment.  It turns to crushing despair when he wakes the next morning and finds that he is still alone in bed.

This is one fragment of the era covered by what PBS describes as the “10,000-day War”.  It was a war that recorded tens of thousands of American names in black granite and altered the lives of so many others.  Those who answered the call of their country in the face of political divisions.  Those who, at worst, were reviled for their efforts and who, at best, were ignored.  Years later they shared, vicariously, in the celebration bestowed on the Gulf War veterans.  Ultimately, however, they realized that, for them, it was one parade too late.

Etekcity Wireless Socket Hacks


There are a zillion RF remote controlled outlets available but one of the most popular appears to be those from Etekcity.  I was able to pick up, at regular price, a set of five and two remote controls for less than $30 on Amazon.  I wasn’t sure what I was going to do with them but I figured it was a prime opportunity to do some hacking.

One thing to keep in mind is that these are only controllable with the included remote, and not via the internet.  But we will fix that.  Also, they are normally off when plugged in and go back to that state if power is lost.  I don’t know about you, but I have some applications where I want the outlet to be normally on instead.  We will fix that as well.  Just keep in mind that these hacks require some knowledge of electronics and basic soldering skills.

Making Normally On Outlets

Changing one of these outlets from normally off to normally on would seem to be a simple task because they use a pretty standard relay which should have pins for both states.  As it turns out the relay may or may not have the normally on pin, but it is not accessible on the circuit board.  That complicates our task but it’s probably a smart safety move by the manufacturer.  What that means, then, is that we need to find a way to reverse the on/off logic.



LED Replaced

There are two pieces to reversing the logic.  The first is to change the polarity of the LED.  The solder pads for the LED are shown in the first picture.  Once the LED is removed, we need to make two cuts to the circuit traces as shown in the second picture.  The right hand cut separates the LED solder pad from ground.  We do that so that after the LED is reversed, we can solder that pad to +5 volts.  The left hand cut separates the base of the relay driver transistor from the 4700 ohm resistor.  That will allow the second logic polarity reversal to be installed.  Double check with an ohmmeter to make sure that the cuts are successful.  In the third picture we have reinstalled the LED with the anode now connected to the cut pad and to +5 volts.  The leads were just long enough on my unit so that I could bend it over to the +5 volt output of the 78L05 voltage regulator.

Transistor Added

The fourth picture shows the method used to reverse the logic for driving the relay.  I used a common 2N3904 NPN transistor (an equivalent would be ok) as an inverter.  The emitter is soldered to ground, the base is soldered to the on-board 4700 ohm resistor, and the collector is soldered to the base of the relay driver transistor.  In order to ensure that the relay driver transistor is normally switched on, I had to add a 4700 ohm resistor from its base to +5 volts.  Now, when the logic output is high, it will turn on the new transistor which will turn off the relay driver transistor.

Remote x-wired

If you want to take an extra step you can cross-wire the appropriate buttons in the remote so that the left button will turn on the modified outlet and the right button turn in off.  Basically you need to cut the circuit traces that go to the switch contacts that are closest to the middle of the board and then add jumper wires as shown in the picture

Internet Control

There are two methods possible for controlling the RF outlets from the Internet.  Both require the use of a cheap module like the ESP8266.  One method would be to wire into one of the remote controls and use a microcontroller to simulate the button presses.  The other less messy method is to use a microcontroller to take the place of the remote control.  That is what is described here.  The microcontroller will receive commands via the ESP8266, translate them into the proper RF bit pattern, and then send that bit pattern to an RF transmitter.  It sounds complicated but the only hard part is figuring out what the proper control codes are for your set of RF outlets.

There are many posts online that use an RF receiver and the audio input to a PC to figure out the codes.  I have the luxury of having a decent oscilloscope so it is easy for me to capture them.  I also have an RF sniffer circuit (detailed in one of my other electronics projects on my website) that allows me to capture RF transmissions using a terminal program on my PC.


The frequency for communicating with the RF outlets is 433.92-MHz and the commands are comprised of a long sync bit, 24 data bits, and 1 stop bit.  The data encoding method used is On-Off-Keying (OOK) which means that data bits are differentiated by the on/off times.  There are no requirements in OOK for number of bits or period length.  That’s why there are so many variations out there for different devices.  I have seen that first hand by decoding security sensors and weather sensors.  The waveform looks similar to what is shown in the picture here.


PIC WiFi Interface2

The schematic shown here is almost identical to the one I used in the one of the earlier Wi-Fi projects listed on my website.  The main difference is that the final version doesn’t have the USB interface but does have an interface to an RF transmitter module.  The transmitter module I used is labeled FS1000A and transmits at 433.92-MHz.  I have not tried other models of RF transmitters but most should work as long as they have similar characteristics.  The RF module is run from the +5 volt input and readily accepts the 3.3-volt logic level for the serial data bit stream from the PIC.

Some ESP8266 modules have their own 3.3 volt regulator onboard so the input to it would be 5 volts.  I have included a 3.3 volt regulator in my schematic for the PIC and it can also be used for the ESP module if it doesn’t have its own voltage regulator.  This allows the PIC and the ESP to communicate at the same logic levels without the need for converters.

You could simplify the ESP hardware by using the ESP-01 module and the adapter (shown here).  The adapter takes +5 volts and has an onboard 3.3 volt regulator.  If you go this route I also recommend that you buy the USB interface that is specifically made for the ESP-01.  It will make the setup of the ESP-01 much easier.


The software listing is available below.  It is an extension of the software I wrote for a previous Wi-Fi project.  I chose that because I wanted to have the status response from the PIC displayed as simple graphics instead of text.  I also added code to output the single-pin serial bit stream to the RF transmitter.  Like the earlier version, I used HTML commands to draw circles that represent the status of each of the five remote switches.  Red=off, green=on, and white=unknown.  The important thing to remember is that there is no feedback from the remote switches themselves so the software can only maintain the status of the last command sent for each switch.  That means that every time there is a power up of the controller hardware the switch statuses are all unknown.  That’s it for this post.  Check out my other electronics projects at: http://www.boomerrules.com

ESP8266 RF Socket Controller

No Country for an Old Man

Strife in politics is nothing new but the division in this day and age has grown so hardened that there appears to be no common ground for compromise.  Terms that used to convey philosophical leanings have now taken on the status of derision and expletives.  I’m talking about words like “Conservative”, and “Liberal”.  We have become so polarized that it has literally become a “my team versus your team” mentality with no handshakes after each contest.  Worse yet is the fact that each side continues to push for more and more ideological purity, thus terms like “RINO”.

Some of us may think we have an open mind to other political stripes so let me provide a little test.  I will list the attributes of two individuals and you can decide how to categorize them.  The first is a white male in his late 60’s.  He is a military veteran, having served during the time of the Viet Nam war but not in the war.  He is most comfortable in jeans, tee shirts, and cheap sneakers, all purchased at Wal-Mart.  He owns several guns, mostly of the handgun variety.  He thinks there should be some limits on abortion.  He has always worked to live within his means and believes that the government should too.  He attends church on a regular basis.

The second individual is also a white male in his late 60’s.  He went to high school and college in Southern California during the 1960’s and 1970’s.  He holds three degrees in all – Psychology, Sociology, and Computer Science.  He was opposed to the Viet Nam war.  He believes that a woman should have the right to an abortion.  He believes that those who have much should help those who don’t.  He believes that there should be better screenings for gun ownership.  He thinks that those who believe that the Universe came about exactly as it is stated in the Bible are intentionally ignorant of scientific facts.

So, what do you think?  Number 1 sure sounds like a “Conservative” and number 2 sure sounds like a “Liberal”, don’t they?  At this point, however, many of you may suspect that this is a trick and you would be right.  Both descriptions fit the same individual.  Before you write this individual off as some sort of Schizophrenic oddity let me assure you that he is a happily married (47 years), middle-class individual who is well within the norms of sanity.  I should know because he is me.

So what is the point of this exercise?  Simply to show that there are many individuals who don’t fit the constricting molds that have become the new world views of “Conservative” and “Liberal”.  Moderates of both parties are an endangered species and any hint at compromise is seen as a betrayal of one’s political tribe.  I wrote a letter to the editor one time in which I decried the language of a local party boss who berated those of his own party who were not “pure enough”.  He also filled his commentary with plenty of invective for those of the other party and peppered it with lots of usage of the terms “Conservative” and “Liberal”.  A big part of my argument was that the use of labels in general was a lazy way to avoid making the effort to see other points of view.  In some ways it harkens back to what Sociologists like Erving Goffman called “Labeling Theory”.  The danger here is not only do we too easily reject those who do not fit the label but we also too easily help in the very creation of our own enemies.

So what is an old moderate to do?  Well, first and foremost is to not stoop to the levels of mudslinging that are so common today.  Second is to call BS when alternative facts are espoused by anybody of any political stripe.  But to do so requires that you have the actual facts at hand as proof.  It may not (and probably won’t) change the mind of the person or persons touting the alternative facts but it’s still somewhat comforting to know what the truth is.  Third is to stand up for people who need a voice or a hand.  There are those who get disenfranchised from not only the political process but from society as well.  I have worked hard for what I have but I know many people who have worked hard and have very little.  As someone who tries to follow the example of Christ I know that I should do what I can with what I have to help people who need it.  But I can’t help everyone and sometimes that breaks my heart.  I’m not saying you have to be a Christian or even believe in God to be part of the solution.  Your motivations may be different than mine and your resources may be different than mine but the results will be the same – someone who needs it will be helped.  Last is to vote.  For about ten years my wife and I lived in a state where our votes almost always went opposite of the majority.  But we voted anyway because we view voting as not just a right but a responsibility.  Besides, I always say that if you don’t vote then you have thrown away your right to complain about the results.

The United States is the greatest nation in the history of the world in terms of wealth, opportunity, and personal freedoms.  To have been born here is a stroke of fate for which I am eternally grateful.  The fact that I feel like an outcast from both political parties does not change that perspective.  But I hope, and pray, that I will live long enough to see reason and civility return to our political process.  Maybe then there will once again be a country for this old man.

I2C 4-Digit LED Interface

In an earlier project I detailed an I2C (two-wire) interface to the common 1602 LCD.  Recently I found a cheap 4-digit LED module that uses a pseudo I2C interface.  I don’t have a particular need for it but I went ahead and added one to a parts order I made.  If you know a little about I2C you know that it is a serial interface where the controlling circuit provides the clock and controls the direction of the single data line.  Usually you can hang several I2C modules on the same pair of line (e.g.: clock module and display module) because each module has a unique address.  I said this LED module has a “pseudo I2C” interface because it does not have an address.  That means that it needs to be the only device using the data line.

LED I2C Module

TM1637 Module

The module I have is similar to the one shown here.  It is typically listed as part number TM1637.  You can find a variety of information on the web but I had a hard time finding all of the details I needed.  I also looked at some existing code (Python and C) which can often be a dangerous thing to do.  The one critical thing I determined from the code was that the data bits sent to the LED module need to be LSB first.  That differed from the approach for the other I2C projects I have done.  Another idiosyncrasy that I noted is that the addresses for the digits go from left to right (starting with address C0).  That means that data must be written from most significant digit to least significant digit if using the auto increment addressing mode.  In fixed addressing mode you would just pick the appropriate digit and write directly to it.

I2C Communications

I2C communications are accomplished by using just two wires: one for data (SDA) and one for a clock (SCL).  The data line is defined as being bidirectional so there needs to be a “master” device on the bus to control things.  The clock rate is limited by the slowest device on the bus and controlled by the master device.  Basically it sets a data bit and then toggles the clock line.  At the end of each byte transfer the master reverses the direction of the data line and then clocks in the acknowledgement bit from the slave device.

There are three basic commands for the LED module.  One controls the on/off and brightness of the display, one controls the address of the digit to write, and one controls the addressing mode (fixed or auto increment).  Usually an application will just load all four digits each time so the auto increment mode is normally used and the address set to the first (left-most) digit.


LED I2C Interface

The connections to the PIC are pretty simple with only two I/O pins being used.  That leaves four other pins on our little 12F683 for getting sensor data.  This same connection can be used with the 16F688 if we want more I/O pins.  The module already has the required pull up resistors on the SDA and SCL lines.


The software link is listed below.  While it is targeted for the 12F683, it is easily ported to bigger versions of the PIC like the pin compatible 16F688 that I use for a lot of my projects.  Some of the newer PICs also have a hardware I2C interface so most of the related software routines would be greatly reduced or eliminated.

The I2C routines are the same as those I wrote for the LCD project but a lot of the other LCD-specific code was not needed for the LED module.  I added a lookup table that converts single packed ASCII characters to the required LED segments.  I also added a second test routine that shows how you can make non-ASCII displays by turning on the right segments.  The data bit associations for the segments are shown in the header of the software source code.  The eighth bit in the segment bytes is reserved for turning on the colon that resides between digits 2 and 3 on the module.  In my tests it appeared that all four characters had to include a 1 in the eighth bit in order for the colon to light.

I added a line of code to the end of the “i2cwaitack”routine to try and recover if the slave does not acknowledge the data transfer.  If the slave fails to acknowledge a transfer then the software will be reset by enabling the Watch Dog Timer (WDT).  Newer PIC chips have a software reset command that can be used instead.  An alternative for some I2C applications would be to simply make a call to “i2cstop” and then continue where the code left off.  That’s it for this post.  Check out my other electronics projects at boomerrules.com.


Intruder Alert

In an earlier post on my website I detailed a PIC microcontroller project that allowed me to capture information about a variety of RF security system sensors I have.  In this post I have taken the information I collected for a cheap 433-MHz motion detector I bought on ebay and turned it into a usable circuit.  In addition to the PIC, I use an RF receiver module and a solid state voice recorder/player.  All of the parts, including the motion detector, cost less than $15 total so you can have some cheap fun with this project.



The motion detector module I used looks like the picture above.  It uses a 12 volt battery and has an extendable whip antenna.  The RF signal it puts out is strong enough that I didn’t even have to add an antenna to my RF receiver board for use in my house.  I used a sensor logger circuit (detailed in another project on my website) to determine the sync and bit times for the sensor as well as the actual data bytes.  The sensor outputs 24 bits (3 bytes) of data and each sensor has a different pattern.  There is also one stop bit.  The sync time turned out to be 10ms and the bit times were about 320us and 970us.  I verified this with a second sensor and also by capturing the RF receiver output on my oscilloscope.  There are many examples online that detail how to capture this information using a PC audio card.

RXB6 Front

The RF receiver module I prefer is a super heterodyne receiver called the RXB6.  It has much better range than the cheaper receivers that commonly get paired with an RF transmitter module.  In fact, when I was trying to buy a few extra RF transmitters I ended up buying them with the cheap receivers for less than 60 cents a set from a USA seller.  I’ve kept the bad receivers for now but will likely never use them.

ISD1820 Module

The sound recorder/player module is commonly listed as ISD1820.  That’s actually the chip part number but it’s also the module designation.  The particular version I bought is shown in the picture but pretty much all of them work the same.  It’s convenient to have the push buttons on the module so you can do the recording and verify the playback before embedding it into your circuit.  These modules are typically set up for a maximum of 10 seconds of recording but the manual shows how to modify them for shorter or longer times.  The maximum time is 20 seconds but the tradeoff is lower quality.  It’s probably not a problem for simple voice messages.  I was pleasantly surprised at the clarity of the recording.

Motion Detector

The schematic is shown above.  The sound modules are often advertised as being able to run on 5 volts but the recommended range for the chip is 2.7-4.5 volts.  Just to be safe I’ve added a cheap 3.3 volt regulator (LM1117) to drive the sound module.  That also means that the play trigger from the PIC needs to be reduced in voltage so a simple resistor voltage divider is used.  The resistor values are not critical.  Just try to get the ratio of values to about 2:3.


There are some defines in the first part of the software that may need adjustment for your application.  There are defines for the sync time (in milliseconds) and the 0/1 bit times.  The bit times are actually for the OFF part of each bit because that is how the software does the measurement.  The bit times are not in milliseconds but are the expected count for the upper half of Timer1.  Each count in TMR1H represents 128 microseconds based on the 8-MHz clock frequency of the PIC.  This simplification works because the shorter bit time will always exceed 256 microseconds but never exceed 384 microseconds.  Likewise, the longer bit time will always exceed 896 microseconds but never exceed 1024 microseconds.  Again, this is based on measurements I made for my sensors.  Yours may be different.  Another set of defines is included to represent the byte values transmitted by the sensor.  These will be different for your sensor.

The software uses the 16-bit Timer1 to measure the sensor bit durations by counting only during the low level part of each bit.  That meant that I needed to use the T1G (Timer1 Gate) input of the PIC.  I also wanted to check on the pulse counts when they completed so I used the INT (external interrupt) input and set it to trigger on a rising edge.  Each bit (including the stop bit) always starts with a rising edge.  The bit value (0/1) is determined by the duration of the high part of each bit but we actually measure the low part because we also want to measure the low level time between data messages for the sync.

The interrupt handler is triggered by the rising edge of each bit.  At that point the upper half of Timer1 is read.  If the Synced flag is not yet set, then the software determines if we have measured a sync pulse.  The math is easy because all we do is round up (add 4) and then right shift three times (divide by 8).  That gives us the integer number of milliseconds.  If the value matches our required sync time then the Synced flag gets set.  That allows us to skip directly to the bit measurement part of the code for subsequent interrupts.  If a bit time matches, then it is packed into RF_Byte and the Bit_Found flag gets set.  If a bit time doesn’t match then everything previously collected is discarded and we wait for a new sync pulse.

After the return from an interrupt, the main part of the software checks the Bit_Found flag to determine if it needs to take action.  If a complete byte has been received then the software checks the value against the expected value for the sensor.  That is done by calling a simple lookup table with the indices for the table being the variable Byte_Count.  If a byte doesn’t match, then everything is discarded and we wait for a new sync pulse.  If all three bytes have been received and match, then the software sends a high-level pulse to trigger the sound module.  An Alarm LED is also turned on and remains on until power is cycled.  The reason I added that is to facilitate testing and as an event memory.  That way I can position the sensor and receiver at different locations and verify successful operation without having to use a second person to listen for the sound.  I can also test sensor locations to make sure that heater/cooler air flow or one of our cats doesn’t cause a false trigger.  That’s it for this project.  be sure to check out my other projects on my website: boomerrules.com

Motion Detector