I’m a Technology Geek

Featured

I love technology. I’m a total geek when it comes to gadgets. Even if I wasn’t severely handicapped and dependent on technology to help me do everyday things I would still be the biggest, nerdiest, technology geek you ever saw.

In this blog I will share some stories about how I use technology and I will link to articles about the kinds of technology I like.

R.I.P. Pinoccio… It Was Fun While It Lasted

Pinoccio

Pinoccio Wi-Fi Development Board

I’m a tiny bit sad to report the death of Pinoccio. Note that the missing “H” is deliberate. I’m not talking about Pinocchio the beloved character from children’s literature. I’m talking about “Pinoccio” (without the “H”) open-source semi-Arduino-compatible hardware and software platform. Actually to say that I’m reporting it is a bit of yesterday’s news. It was actually reported here in a blog post on their website dated March 30, 2015. The reason I didn’t see that blog post right away is that I had pretty much given up on the system several months earlier.

Here’s a bit of history… In late 2012 or early 2013 I became aware of this Indiegogo campaign titled “Pinoccio – A Complete Ecosystem Building of the Internet of Things” It was a small 1″ x 2″ Arduino compatible board using a chip similar to the one used by the Arduino Mega. This variety had a built in mesh radio such as used by the X-Bee system. It had a built-in LiPo battery, an RGB LED, a temperature sensor and a Wi-Fi backpack. You could connect to one of the units called a Lead Scout via Wi-Fi and then it would communicate to the other units over mesh radio which were known as Field Scouts. I quickly signed up at the $149 support level which would get me a Lead Scout and a Field Scout. Although the units were a bit pricey, if you added up what it would cost to buy an Arduino Mega, battery, charger circuit, X-Bee radio, and Wi-Fi module it seemed like a bargain at the time. They were seeking $60,000 in funding and end up raising over $105,000. Put this in proper context note that this was several months before Spark Core appeared on Kickstarter. Note that Spark Core has recently rebranded as Particle.io.

Had Pinoccio made its original delivery date of July 2013 they would’ve beaten everyone to market and would’ve been a major player in the Internet of Things movement. There were plans for a smaller version without the battery and sensors that would’ve been easier to embed into production products. There were plans for a variety of backpacks or shields including the one I was most anxious to see… infrared LED and receiver. My goal was to use it to create an Internet capable IR remote. I wanted to create an inexpensive alternative to the RedEye IR Remote from ThinkFlood. And it was a good thing I was planning such because ThinkFlood was shutting down as seen here.

My Pinoccho boards upon arrival.

My Pinoccho boards upon arrival.

The folks from Pinoccio quickly learned the hard lessons of crowd sourced funding. Lesson number one is inevitably “If you’ve got a great idea it’s easier to raise money then it is to bring a product to market.” I won’t bother to recount the litany of things that caused multiple delays but the bottom line is that backers did not get their units until April 2014 a full 10 months past the initial estimated delivery. The reasons were the usual things: finding suppliers, finding someone to make the boards, setting up the business itself. It seemed that the main reason/excuse for delays was that “We want to get the software right.” Here is my blog post which gave my initial positive reaction to the devices when they finally arrived.

The software that we waited so long to finally get was indeed quite extensive. There was an Internet portal called hq.pinocc.io that allowed you to do many things without even writing any code. And it included an extensive script language that you could write small programs directly from the HQ application without having to use the Arduino IDE or do any C++ coding. They wanted you to be able to plug the thing in and do something with it right away. That ability is one of the key things that led to the success of the original Arduino. With a built in RGB LED and temperature sensor, you could do more than just blank the LED on pin 13 like you can with Arduino out-of-the-box.

However if you wanted to write your own applications, the learning curve at least for me was very steep. I had no experience in connecting devices to the web. I did know quite a bit of JavaScript programming, CSS, and DOM HTML programming which was useful. I had a little bit of experience with PHP however that did not apply in this case. What I did not have any idea how to do what is called “asynchronous communication” with Web servers.

I was taught as a programmer from day one that execution of a program started at the top of the main module and went step-by-step through the module sequentially unless modified by the if/then/else or some sort of loop structure. But asynchronous coding is something significantly different. You make a request to a Web server and within that request, you send it the code that you want to execute when it finishes the job. That seems simple enough. I figured it would call the code when it was ready and then move on to the next step. But it doesn’t work that way. You move on to the next step immediately after making the request and you have no idea when it’s going to complete that request and invoke your callback function. I would make a request from the server for a piece of information. My callback function would tell the server where to put that information in my program. Then I would try to display that information on the webpage. But it was never there. When I would insert debugging code to see why it wasn’t there, it was there. It reminded me of the paranoid poem about the little man on the stair.

“Last night I saw on the stair
The little man who wasn’t there.
He wasn’t there again today.
Oh how I wish he’d go away.”

I was being haunted by the returned data that wasn’t there :-)

What I didn’t understand was that this callback function wasn’t a normal subroutine where you call it, it executes, and when it returns you carry on. You have to carry on immediately after the request and you don’t know how long it’s going to take for the Web server to return your data. So you have to put something in the callback function that tells your main program “Hey he finally got what you asked for. You can use it now. It’s really here.”

When you are collecting several pieces of data in a row and you don’t want to proceed until you’ve got them all, the nested callback functions can get pretty hairy. It took me a long time to figure out what I was doing wrong. It also took a lot of patience on the part of the people from Pinoccio in their support forums to walk me through my inadequacies is particular area of programming. I owe them a tremendous debt of thanks. (Humorous note here… When I dictated the previous sentence using my dictation software, it misunderstood me and said “I/O them…”. How appropriate for a “.io” system). Anyway they were most gracious and patient with me.

I did my best to pay back their kindness. I blogged everything I could about the device. I showed it off on the Adafruit Google+ Hangout Show-and-Tell. I blogged about how to get around some SSL certificate problems that cropped up along the way. And I did my best to educate them in the hardware requirements necessary to make an infrared backpack for the Pinoccio system. And ultimately I did get a working Internet-of-Things infrared remote that I used to operate my TV and cable box.

My cable box is located in the living room but I have an HDMI cable that runs into my adjacent office so that I can watch the same thing my dad is watching and living room. I can get on a webpage in the office and control the cable box in the living room. I used it every day for several months and it was a real godsend. I succeeded in replacing my defunct and unsupported RedEye remote.

I included Pinoccio support in my next public release of my infrared library IRLib. I began cleaning up my asynchronous webpage code and preparing to publish it to share with the world everything I have learned so that the next novice who came along would have a clear and simple tutorial to follow I would not have to bother the people in the support forum to learn the things I have learned the hard way.

One of the things that bothered me about the entire system was that it was totally dependent upon the website hq.pinocc.io servers were maintained by the Pinoccio organization. On occasion, their server would crash and I would be stuck with a useless system. I asked them what do we do to remove that dependence. The old RedEye remote system was accessed directly to the local IP address of the device itself. It also included its own Web server in the device. In contrast the Pinoccio system required me to make my own webpage to control the device (as great as HQ was it wasn’t sufficient). That meant I had to install a Web server on my PC. I can only control the system from that PC unless I uploaded the webpage to cyborg5.com which I didn’t want to do. Setting up WampServer on my PC was much easier than I anticipated. That allowed me to host my controlling webpage with no problem.

Furthermore my webpage could not communicate with the device directly. It had to go through their servers. My controlling webpage went to a URL on their server and their server connected back to the device itself. The whole point of Pinoccio, for me at least, was to replace the defunct out of business RedEye Remote. What was I going to do if Pinoccio ever folded? They assured me that they were working on a system that would allow direct connections without going through their server system. And in the end they did so.. They developed a system where you could plug one Scout into a PC and have it communicate directly with the other Scouts using the mesh radio. You didn’t need the Wi-Fi at all. They called it a “Bridge Scout”. While that was of suited my purpose, still wouldn’t have given me all of the capabilities the device should have had. There supposedly is a way to set up one’s own server that would duplicate their part of the infrastructure. I believe them when they tell me that. However doing that myself would required another steep learning curve that I didn’t really feel like attempting. It would require more than I can get out of WampServer. It involved node.JS and a variety of other things that were beyond me.

Unfortunately somewhere along the way the device got a bit glitchy. There were constant software updates some of which I kept up with and some I did not. After not doing updates for several months, I finally decided to do an update in hopes of fixing the glitches. The end result was my device quit working altogether. I spent a couple of weeks presuming that the problem was an adverse interaction between my infrared code and their systems software. It involved going onto GitHub and figuring out which version of the software I had been using that was working somewhat well and then individually applying each and every update that had occurred over the period of several months. I finally found the patch that was causing my code to crash. In the end it was not an adverse reaction between my infrared code and their system. I was able to whittle it down to an example that did not include my IR code at all.

Somewhere in the midst of all this, I ended up “bricking” my lead scout. Somehow during a crash, the boot loader was overwritten. They talked me through a system wherein you could use one Scout as an ISP to restore the boot loader on a broken Scout. Initially that process did not work because I tried to do it with the Wi-Fi backpack still installed. Somewhere along the way while adding and removing the Wi-Fi backpack without disconnecting the power, I permanently damaged the Wi-Fi backpack. That meant that the so-called “Ecosystem for the Internet of Things” was no longer Internet capable. A replacement Wi-Fi backpack would cost $79. I was able to get the system running somewhat using the bridge Scout they described where you had to keep one unit plugged into a PC to communicate with another unit. However I had become frustrated with the whole thing and needed to get away from it for a while.

arduino_yunI ended up ordering an Arduino Yun from Adafruit.com. I immediately fell in love with the device. It consists of a powerful microprocessor running a minimal version of Linux and an Arduino Leonardo in one device. The communication between the Leonardo and the Linux was well defined and easy to use. The Linux portion did include its own Web server. You could also update the onboard Arduino sketch and the associated webpage using the latest Arduino IDE and do so wirelessly for Wi-Fi. That ability to update wirelessly was something that Pinoccio had promised from the beginning but never did fully implement at least from a users perspective. They did allow you to update system software wirelessly but not user programs at the Arduino level.

Although I did have the Pinoccio experience under my belt along with the experience of doing asynchronous callbacks to Web servers, setting up my IR remote on the Arduino Yun took me only a day and a half rather than the weeks and weeks of frustration that I had with Pinoccio. One of the things that was probably the nail in the coffin of Pinoccio for me personally was the fact that I could buy an Arduino Yun with its embedded Linux, Wi-Fi, Arduino Leonardo, and built-in Web server with no external infrastructure needed for about $75. That was four dollars less than the Wi-Fi backpack alone for Pinoccio.

With the success of modules like the CC3000, Particle a.k.a. Spark Core, and the amazing new and inexpensive ESP8266 there was no hope for Pinoccio. They might have salvaged it by ditching their own Wi-Fi backpack and making a backpack using the ESP8266.

My intent had been to take a break from Pinoccio after I got the other system up and running. I still felt like I owed them those tutorial blogs to help other Pinoccio users not have to go through the blood sweat and tears that I’ve been through. But I got distracted with other projects and never was able to do it. Now of course there is no more Pinoccio. Their servers are shutting down at the end of the month and anyone who hasn’t figured out how to launch their own server or who is content with using bridge mode is going to be out of luck.

Ironically my old RedEye Remote has in some ways outlasted the Pinoccio. Even ThinkFlood shut down over two years ago, you could still use their device as long as you didn’t need to update the software. I’ve been using mine as an Internet remote to control my bedroom TV and cable box in the same way I’m using the Arduino Yun for the living room. However I recently purchased a new TV in the bedroom and I cannot update the RedEye with the new codes. I had to order another Arduino Yun.

I had a bit of a scare because the Yun has been out of stock at Adafruit for a couple of months now. Fortunately I found one at my second favorite supplier SparkFun.com. I’m pretty sure that the shortage is a consequence of the trademark disputes between Arduino.cc and their previous hardware manufacturing company which has now rebranded itself as Arduino.org. Is my belief that Arduino.cc should and will win the dispute. And I’m absolutely ecstatic over the new announcement that Adafruit will become the US manufacturer for Arduino.cc. I’m confident that both Arduino and Adafruit will be around for a very long time.

In the end I think I’m going to miss Pinoccio. I was quite fond of the little fellow and a bit disappointed he never really achieved his full potential. I don’t regret any of it however. I learned a lot of useful programming. And I learned some lessons about crowd source funding. And it serves as a cautionary tale about Internet of Things systems that are too closely linked to their infrastructure. I think that as IoT continues to grow that’s going to be an important lesson for everyone.

Multitasking In Bed with TV And Laptop

In previous blog posts I’ve described how I am able to operate my TV, DVR/cable box, VCR, DVD player using a custom IR remote with just four buttons. The project has gone through several versions. Originally the buttons were connected to a standard TV remote which would send IR signals to an Arduino box on top of my TV. The Arduino has a small LCD screen with just two lines of 16 characters. By using the buttons like arrow keys I can scroll through symbols on the screen to select dozens of functions. The Arduino box then send IR signals back to the TV, cable box whatever. Here is how the original system looked… (You can click on any image in this blog to see it larger.)

Original "Remote-Controlled Remote-Control" System

Original “Remote-Controlled Remote-Control” System

Here is a close-up look at the menu box on top of the TV.

Arduino-based device with LCD menu sits atop my TV probably displaying an Adafruit "As Seen on Show & Tell" sticker.

Arduino-based device with LCD menu sits atop my TV probably displaying an Adafruit “As Seen on Show & Tell” sticker.

Click here for a previous blog post about that.

At one point I needed to add a call buzzer to the system that used RF signals that would reach all the way to my dad’s bedroom. Since I was adding an X-Bee radio system I decided I would use RF signals to avoid conflicting IR signals bouncing around the room. The buttons were then connected to an Arduino Micro with an X-Bee radio. It sends RF signals to the Arduino on top of the TV as well as to another Arduino in my dad’s room which has a buzzer in it. If I push single buttons, it scrolls the menus on the Arduino atop the TV. If I push multiple buttons it triggers an alarm that wakes up my dad. Here is how that updated RF system looked…

Communication between Arduino devices

Communication between Arduino devices

Click here for a previous blog post about the updated RF system with the call buzzer.

Unfortunately I seem to be spending more time in bed than I wish I was. My sinuses are mess which causes drainage and coughing spells and congestion in my lungs. The only thing I can do if he gets out of hand is to lie down so that I’m not fighting gravity trying to call things up. Once I’m in bed is such a hassle to give me put back together again that if I have such a spell in the evening I generally just don’t bother to get up again and spend the rest of the evening in bed.

I have a laptop computer that we would occasionally roll in on a bed tray so that I can get online or do other computer things while lying down. But we had to prop the laptop up on a stand so that I could see it. I had to stuff an extra pillow under my head. It was just a big hassle.

I mentioned that I had VCRs in my bedroom. You can see them in the photos above. The stack of devices on the dresser is the DVR on top of 2 VCR/DVD combos. I’m embarrassed to admit that considering how technologically advanced I claim to be. But I was using the VCR every day. I like to watch politics programs on MSNBC. Typically it’s “The Last Word with Lawrence O’Donnell” although I occasionally watch “The Rachel Maddow Show”. I severely miss having Keith Olbermann doing politics. Anyway I record Lawrence O’Donnell every day onto an eight hour tape and when it fills up I have my dad take it to my office where I watch it on a VCR there. (We used to call that “Nike networking”. Copy it to media, put on your Nikes, and walk it over to the other location.) I generally just have it on in the background while I’m doing other things. But how technologically backwards is that? Recording onto a VCR and then physically moving the tape to a different room. I was sorely ashamed. There had to be a better way.

Speaking of technologically backwards… Fortunately Bright House still has about 50 channels that are available as analog cable so it still possible to record them using a VCR. It beats paying extra for their whole house DVR service which comes at quite a premium.

wintv_productAnyway onto my alternative… I have a small USB device that is in NTSC/ATSC tuner that allows you to connect it to a cable or antenna and watch TV and/or record TV on your computer. It is a Hauppauge WinTV 950q. I thought perhaps I could connect it to a Raspberry Pi and record my programs and then use Wi-Fi to copy them to another Raspberry Pi in my office where I could watch them. Unfortunately without doing a lot of custom coding that I didn’t care to get into, the Raspberry Pi would not support analog recording. I could get it to record over the air ATSC digital broadcast but the Pi either wasn’t powerful enough for didn’t have the right drivers to make analog work. You have to be able to encode MPEG video on the fly. While the Raspberry Pi version 2.0 might be powerful enough, I didn’t really want to mess with it.

I did have in fact a superior alternative. I could use my laptop. You can easily record digital or analog using the USB tuner. What if I just got rid of the VCRs and set the laptop next to my bed. I could run an HDMI cable to my regular TV, put my dictation microphone on my pillow, and have complete access to a powerful PC on my TV screen and it could serve as a custom DVR as well.

The main problem is that the TV I have mounted on my wall only has one HDMI input and I needed 2. One for my cable box for watching TV and the other one for the laptop. Fortunately in my junk drawer I still had a RadioShack HDMI switch. I purchased it in about 2005 when I had my very first HDTV. My first HDTV only had one HDMI input because in those days HDMI was brand-new. I used it to switch back and forth between my cable box and my DVD which wasn’t even Blu-ray. The DVD player in those days had digital up conversion that made standard DVDs look almost HD. The RadioShack switcher would respond to an IR remote. You would simply hold down a learning button while sending it a signal. Then anytime it received that signal again it would switch to the appropriate input. So I would be able to easily switch back and forth between TV and laptop.

Here’s what it looks like now.
laptop_openBecause the cable box has lots of vents on top of it, we had to build a little shelf to raise the laptop up a couple of inches so that the box doesn’t overheat. I set things up on the laptop so that closing the lid does not put it in standby mode. 99% of the time I keep the lid closed and only use it through the HDMI on the TV. The USB TV tuner works just great. And then I had one other brainstorm…

my_wintvIn addition to a coaxial connection to which you can attach cable or antenna, the USB tuner also has a place to plug in an adapter with Red, White, Yellow RCA composite cables. By connecting them to the cable box I can then copy things from the cable box onto the TV tuner/laptop. That’s one of the nice things about the old VCR was that if I did record something on the cable box that I wanted to keep long-term, I could always make a low definition VCR recording of it for posterity. This would preserve that capability and add one other capability. There is a program that allows you to watch TV on your PC through the USB tuner. So if I’m using the laptop, I could put the TV program off in the corner of the screen and watch my cable box low definition through the component cables. Then on the rest of the screen I can log into Facebook, play games, write blogs whatever. It essentially made my laptop screen a-picture-in-picture capable TV with the TV in the small window and the laptop screen in the remaining area. Here is what it looks like on my laptop where I can watch TV and do other things at the same time.

pip

Screen grab from my laptop shows me watching the news through the USB tuner while playing candy crush.

Here is an overview of how everything communicates together.

05_Dscn0426

IR and RF communication between my various devices.

I thought everything was going to work just great. All of the initial tests worked perfectly. But then I started having audio glitches. For some time, I had been having problems with audio not working between the TV and the cable box. You had to turn on the TV first and then turn on the cable box in order for the HDMI to sync up properly. However when I added the HDMI switch, for some reason it wouldn’t work properly. It probably had something to do with the HDMI switch being on all the time. Whenever it would glitch using direct connection, I could usually power things off and on and get them to re-sync but because I couldn’t completely powerdown the HDMI switch, I could not get it to work properly.

I didn’t really like using the HDMI switch and the TV was getting kind of old. So I just went over to Best Buy and picked up a new Samsung for the bedroom that had 2 HDMI inputs. Until then I had to watch TV using the USB tuner through the laptop. That was the only way I could get audio. But of course I also had to get another very long HDMI cable. While we were installing the second cable, my dad noticed that the original cable had gotten pinched beneath the bed wheels and had been damaged. That may have been the source of the audio problems to begin with. So it took another couple of days to get yet another cable which meant another couple of days of only watching low definition TV through the laptop.

Just as I got everything hooked up properly with the new TV, no HDMI switcher box, 2 brand-new cables, I hooked it all up and the HDMI on the cable box quit working altogether. I tried using different cables. Tried the old TV. Tried with or without the HDMI switch. Basically the cable box was fried. I could still get analog audio and video through the USB TV tuner and the laptop but HDMI audio was fried. I probably damaged the box by using the damaged cable. Something probably shorted out and ruined the cable box.

Unfortunately my DVR/cable box is in a permanent state of near overflow. Have you ever heard of the phrase “floating checks”? That’s where you write a check from one bank account to cover an overdraft in a different bank account and then you write a check from that bank account to cover the overdraft in the first one. Well, I practice a similar procedure “floating recordings”. When I run out of space on my DVR, I look at the movies I have recently recorded and look for another airing of that same movie a few days down the road. I then erase the movie, schedule it for re-recording as far in the future as I can, and then use the free space to record something today. I keep doing that over and over until the movie isn’t being shown anymore. Then I have no choice but to watch it or give up and delete it permanently. The bottom line is my DVR is always very, very full.

I know of no cable company that allows you to transfer recorded programs from one DVR to another. So when your box goes bad, you are screwed. I could still watch the programs in low definition. I could even copy them to tape on the VCR. But it would take me forever to catch up and in the meantime if I was ever going to get anywhere, I had to stop recording new programs.

I finally came up with a brainstorm. We would get a new replacement cable box and I would move the broken one to my office where I could either watch programs and/or copy them to the VCR in my office. New programs would be recorded on the new box so that the old one wouldn’t get any fuller. Eventually I would get caught up and turn in the box.

We already have two DVR’s. One of them in the living room and the one in my bedroom. The one in living room is a newer model that has more capacity but it still seems to fill up with ease. Both of the DVR’s are limited to 2 programs at once each. So you can record two programs simultaneously in the living room, two in the bedroom. But that’s it. You can watch recorded programs while recording 2 programs or you can record one and watch one. Even though we have a total of four streams between the two, it’s only two in the living room and two in the bedroom. Recording conflicts are a constant hassle both places.

Fortunately Bright House is now offering a premium DVR. It has 1 TB hard drive which is double the capacity of their previous big DVR and probably quadruple the capacity of the one I had in my bedroom. But the really great feature is allows you 6 streams of HD simultaneously. That means you can record five things at once and watch a sixth. After talking it over with dad, we agreed that a few more dollars a month for this DVR would be well worth the price. He went to Bright House headquarters and picks up a new enhanced DVR. We put it in the living room. We moved the living room DVR to my bedroom. And we moved my bedroom DVR to my office where I would watch down its content and/or record it to tape.

Before moving the damaged DVR to my office, I tried disconnecting the coaxial input cable to see if I could still watch recorded programs with the cable disconnected. I was able to do so successfully. So we moved everything to the office, connected it to the office TV and VCR and tried to turn it on. It wouldn’t work. It would not load the software without being connected to the cable. When I disconnected it and tested it in the office, I did not unplug the power so it didn’t lose its software. It would indeed work without being connected to cable but not after the power had been turned off and on. The problem is I don’t have cable in the office. The only other place I could get to it easily is in the kitchen at our bar between the kitchen and the family room.

So we disconnected everything, dug out one of my old VCRs that I had just put away, and reconnected everything in the kitchen. I then spent the next several days watching some programs while eating lunch at the bar in the kitchen and copying other programs to tape. It only took me about three or four days and 4 eight hour VHS tapes. Some movies I was able to “float” by erasing them from the old broken DVR and re-recording them on the new one as they were scheduled over the next several days.

Finally everything is working perfectly. I can use my laptop and watch TV easily in bed. We adore the new six stream DVR in the living room. You never have to worry about recording conflicts. Only one time in the past two or three weeks have we even come close to having five simultaneous recordings and we could have easily avoided that if we had dried. But the point is we didn’t have to juggle things. Five was enough. The large capacity drive is great as well although my theory is it doesn’t matter how big your hard drive is, eventually you’ll find a way to fill it up. Were only about 30% on this one and we have a ton of stuff recorded already. I don’t think we’re going to run out. If we do, shame on us.

One final modification to the whole system involved the mouse on the laptop. As I mentioned in other blogs, the voice control software I use Dragon NaturallySpeaking doesn’t work very well with the mouse. On my desktop computer I supplement the voice control by using an IR remote control mouse that I built using Arduino and sometimes a mouse control app on my android phone (formerly on my iPod touch).

While using the laptop in bed on the bed tray before we set up this system, the voice control program would occasionally hang up or I would have trouble using the mouse. On my desktop machine, if the voice control hangs up, I can get it going again using the mouse alternatives. But in bed I did not have those alternatives. Although wait a minute… I do have an IR remote. The Arduino box atop my TV is an IR remote. All I had to do was reprogram it to use the codes for my IR mouse device. I also took the opportunity to remove all of the software I had put in it for controlling the VCRs and DVD players that I no longer needed. You are a couple of images of the menu screen that shows the new mouse commands.
menus
The screen can only show 2 lines of text at once. You can scroll it up and down. The image on the left shows the first two lines of the mouse control section. The “M1” and “M2” at the start of the lines just tell me it’s the first and second line of the mouse control section. The arrows next to them move the mouse up, left, right, or diagonally. The “l” in the center means “left click”. If you look at the image on the right, you can see the sections for moving the mouse down and diagonally. Just to the right of all of the arrow commands you will see a capital “S”, “C”, and “A” which correspond to Shift, Control, and Alt. The “L” means “hold the down the left mouse button” and the “R” means hold down the right mouse button. Also “r” lowercase means simply click the right mouse button. The “f” and “s” make the mouse move faster or slower. The “u” and “d” options move the scroll wheel up and down. The “W” presses the Windows key. The “m” on row “M1” changes mode from mouse mode to keyboard mode. That makes all of the arrow selections control the arrow keys on a keyboard rather than mouse movement. The row labeled “Mt” is mostly TV commands. The “0”, “-“, and “+” control mute, volume down, and volume up. The “c” and “m” switch the HDMI switch to either “cable box” or “monitor for laptop”. The “>” symbol performs a Win+right arrow. Which will dock your currently open window to the edge of the screen. A command I use quite often.

08 IR mouse

Arduino Micro configured as IR mouse as used on this laptop and in my tutorial for Adafruit.

Although on my desktop PC I use this larger Arduino with a 20×4 character LCD screen, on my laptop I use this tiny Arduino Micro with just a couple of neopixels as indicators to tell me if I’m dragging the mouse or holding down the shift key or other functions. Unfortunately I can’t see those indicator lights the way I have things set up so I’m going to have to come up with an alternative to that. But I really have some ideas.

Prior to this new set up, the only time I ever used laptop in bed was if I had to lie down early from a coughing spell. However now that it was easy to get to, I’ve been using it more and more. When I initially lay down I have no trouble using the dictation software. I usually go to bed about 9:30 or 10 PM and watch TV. Then at about 11 PM I change into my pajamas and put on my CPAP respirator. It’s a mask that covers my nose and puts air pressure into my lungs to keep them inflated and prevent apnea. I typically watch more TV from 11 PM till about 12:30 AM or 1 AM with the CPAP on. However I had never used the laptop and the dictation software with the CPAP on before. It turns out that with the machine blowing air up your nose, one does not talk as plainly as one normally does. The dictation software doesn’t understand me nearly as well with the respirator on. Words such as “nine” come out as “dine” and “mike” comes out as “bike”. You can’t stop the air from rushing out of your mouth when you have the CPAP on and try to talk. So all of the soft sounds come out hard. That means being able to use the IR mouse is much more important when I have the CPAP on than normally.

Windows has a built in accessibility feature that pops up a keyboard window so that you can click on it with your mouse as if you were typing on a real keyboard. Most of the time I don’t need it. Late at night I’m either just browsing Facebook or crushing some candy. I don’t really need to do typing and the dictation software does work somewhat if needed.

Overall it’s been a real blessing to be able to continue to do productive work while in bed especially on those very frustrating days when I have to spend more time in bed then I want to spend there.

satb100Among the things I’ve worked on in bed is writing a tutorial for the Adafruit Learning System on how to create an IR controlled mouse using an Arduino Micro. That is the same device I’m using on the laptop for mouse control. Adafruit is where I purchase all of my electronic parts. They describe themselves as not being a store for selling electronics. Rather they are a tutorial website with a really big gift shop. When I showed off the project at a recent Adafruit Show-and-Tell video chat on Google+ they thought it was most interesting that I actually used the IR mouse to write a tutorial on how to create an IR mouse. Here is the video from that presentation.

Click here to see my IR mouse tutorial on the Adafruit Learning System. Also click here to see a previous tutorial I wrote for them about general use of infrared remotes with Arduino microcontrollers.

I Got Hacked by the Sun

Had a scary moment yesterday when I thought someone had hacked my computer.

I’m sitting here at the PC searching some website or doing Facebook or I forget what I was doing. Suddenly my mouse started going crazy. Begin jumping all over the screen wildly and I couldn’t control it.

I don’t ever really use an actual “mouse”. There is one connected to my computer in case somebody else needs to use it but I never touch the thing because of my disability. I actually have three different ways of controlling a virtual mouse. Most of what I do on my computer is dictate using voice recognition software called Dragon NaturallySpeaking. It has a variety of mouse commands such as “Move Mouse Up” or any other direction. You can also “Mouse Click” or “Mouse Double Click” or “Right Click” by simply saying those words with a pause before and after so that it knows that you’re not actually dictating. It also has commands for dragging the mouse which I bit difficult to use and you can move the mouse using a grid system that I won’t bother to describe here.

Additionally I have an Arduino Leonardo microcontroller configured as a USB mouse and keyboard emulator. It has IR receiver that lets me use my TV universal remote to send infrared signals and control the mouse that way. Details can be found here.

Also I have a special driver loaded on my PC the connects to an app on my android phone (my iPod touch prior to that). I can use my stick in my mouth to drag around on the app and click on buttons to control the mouse.

I desperately tried to shut down all the programs I was running to do a reboot but it was difficult to do with the mouse jumping all over the place. I couldn’t click on anything because the mouse was never in the position I wanted it to be in. None of my three methods of mouse control could override this erratic behavior.

Just as I was ready to close my last window, I happened to look over at my actual mouse lying on the desk. Except it wasn’t lying on the desk. It was lying on top of a bunch of junk piled on my desk. Most of them were cables clumped together in a tangled mess. Sunlight was pouring through my office window and reflecting off of the desktop, the cables, and other shiny objects lying in the pile. I finally figured out what the problem was.

I got hatched by the sun!

Although the original design for the computer mouse had a little rubber ball in the bottom of it that had to actually touch the surface of a table, all modern mice are optical mice. The original optical mice simply had an LED and a photosensor and could only be used on specially designed mousepads that had a herringbone pattern on them. But the latest optical mice actually have a tiny camera that focuses on the surface of whatever you are dragging it across. It can detect the movement of microscopic textures as the mouse moves and from that determine the direction in which you are moving the mouse. In this case the mouse wasn’t moving but the sunlight bouncing off of the table and other junk beneath the mouse was flickering and tricking it into thinking that it was being dragged across some surface. As I was attempting to close the last window and reboot, the sun went behind a cloud and the mouse stopped moving.

I had my dad come in the office end mouse firmly on the table. There’s been no further incidents of “hacking”.

So not only did I get hacked by the sun… The hacking was stopped by a cloud :-)

Zoomer Dino Controlled by Arduino IR Remote

satb100

One of the hottest toys this Christmas is the Zoomer Dino. It is a remote-controlled self balancing two wheel robot dinosaur with an infrared remote. I got one for my 10-year-old nephew for Christmas and after playing around with it I had to get one of my own. I have been thinking about building Arduino powered two wheel balancing robot from scratch but here was one that works right out of the box. I’m not sure if it has a gyro or accelerometer to keep it balanced. He rolls around on his own making noises including burps, farts, and laughs. You can also take over control with an infrared remote. The remote has a joystick and three pushbuttons. The joystick moves the head up, down, left, right. If you hold in the “run” button while moving the joystick he rolls around under your control rather than moving the head. There also is a button for “chomp” which makes his jaw chomp open and closed. Additionally there is a “angry” button which makes his eyes glow red and he thrashes around angrily.

Zoomer Dino and IR remote

Zoomer Dino and IR remote

As with my IR controlled to a helicopter before, I had to see if I could reverse engineer the protocol it was using for the remote control. It was one of the most challenging IR reverse engineering projects I’ve ever encountered. I finally had to go out and purchase one for myself because I had to wrap up the original one for my nephew.

I used my IRLib Arduino Library for decoding and encoding IR signals. Once you push a button to get things started, the remote puts out a continuous signal that is the neutral position of the joystick with no buttons pushed. I came up with a raw dump of the timing values using my IRrecvDump sample sketch. Here are the results.

 C++ |   |? 
01
Decoded Unknown(0): Value:0 (0 bits)
02
Raw samples(54): Gap:43480
03
  Head: m9250  s4750
04
0:m550 s650	1:m500 s650		 2:m550 s650	3:m550 s1800		 
05
4:m500 s650	5:m550 s650		 6:m550 s650	7:m550 s650		 
06
8:m550 s1750	9:m550 s650		 10:m550 s650	11:m550 s650		 
07
12:m550 s650	13:m500 s700		 14:m500 s650	15:m550 s650		 
08
 
09
16:m550 s1800	17:m500 s1800		 18:m550 s650	19:m550 s1750		 
10
20:m550 s1750	21:m550 s1800		 22:m500 s1800	23:m550 s650		 
11
24:m550 s650	25:m500
12
Extent=53300
13
Mark  min:500	 max:550
14
Space min:650	 max:1800

This is a quite typical set of signals used by many protocols. Only the timings and number of bits are unique. We have a header that consists of about 9200 mark and 4800 space followed by 25 data bits and a closing mark. The data marks run about 500 or 550. The data spaces are either about 650 or 1800. This variable spacing is the most common way to encode zeros and ones. We’ll call the short spaces ones and the long spaces as ones. I created a custom decoder object as follows.

 C++ |   |? 
01
 #include <IRLib.h>
02
#include <IRLibMatch.h>
03
 
04
class IRdecodeDINO: public virtual IRdecodeBase
05
{
06
public:
07
  bool decode(void); 
08
  void DumpResults(void);
09
};
10
#define DINO_HEAD_MARK   9200
11
#define DINO_HEAD_SPACE  4800
12
#define DINO_ZERO_MARK    500
13
#define DINO_ZERO_SPACE   650
14
#define DINO_ONE_MARK     500
15
#define DINO_ONE_SPACE   1800
16
#define DINO_SAMPLES 54
17
#define DINO_BITS 25
18
 
19
#define DINO (LAST_PROTOCOL+1)
20
void IRdecodeDINO::DumpResults(void) {
21
  Serial.print(F("Decoded DINO: Value:")); Serial.println(value, HEX);
22
};
23
bool IRdecodeDINO::decode(void) {
24
  IRLIB_ATTEMPT_MESSAGE(F("DINO"));
25
  if(!decodeGeneric(DINO_SAMPLES,DINO_HEAD_MARK, DINO_HEAD_SPACE,
26
    0, DINO_ZERO_MARK, DINO_ONE_SPACE, DINO_ZERO_SPACE)) return false;
27
  decode_type= static_cast<IRTYPES>DINO;
28
  return true;
29
};
30
 
31
IRdecodeDINO My_Decoder;
32
 
33
int RECV_PIN =11;
34
 
35
IRrecv My_Receiver(RECV_PIN);
36
long Previous;
37
 
38
void setup()
39
{
40
  Previous=0;
41
  Serial.begin(9600);while (! Serial);delay(1000);
42
  Serial.println(F("Send a code from your dino remote and we will decode it."));
43
  My_Receiver.enableIRIn(); // Start the receiver
44
}
45
void loop() {
46
    if (My_Receiver.GetResults(&My_Decoder)) {
47
    My_Decoder.decode();
48
    if(My_Decoder.decode_type == DINO) {
49
      if(My_Decoder.value!=Previous) My_Decoder.DumpResults();
50
      Previous= My_Decoder.value;
51
    }
52
    else Serial.println("Unknown");
53
    My_Receiver.resume(); 
54
  }
55
} 

Because the remote sends signals continuously, this routine only reports the initially received value and then anytime the value changes to something different. It outputs 6 hex digits but note that there are 25 data bits being received. I then plugged the hex values into an Excel spreadsheet, converted them to decimal, and then parsed out the individual bits to try to deduce a bit pattern. I tried leaving the joystick alone when pushing the 3 buttons individually. Then I tried moving the joystick full throw forward, backwards, left, and right. The results are shown in the table below. You may click the table image to enlarge it.

Table 1-Bit patterns from Dino remote.

Table 1-Bit patterns from Dino remote.

In all samples, the first three bits were always zero as was the last bit. It was pretty obvious that after the initial zero bits, there was a five bit field that was the left/right position of the joystick with the left position having a value of zero, the center as 16, and the right was 31. This was followed by another five bit field that was the forward/backwards joystick position with zero to the back, 16 in the center and 31 full forward. The next three bits were obviously the three buttons. There were eight additional bits that seem to have no rhyme or reason to them.

Here is a revised version of the receiving code that parses out the bits into their individual fields.

 C++ |   |? 
01
#include <IRLib.h>
02
#include <IRLibMatch.h>
03
 
04
class IRdecodeDINO: public virtual IRdecodeBase
05
{
06
public:
07
  bool decode(void); 
08
  void ParseFields(void);
09
  void DumpResults(void);
10
  unsigned JoyX, JoyY, Parity;
11
  char Chomp, Angry, Run;
12
};
13
#define DINO_HEAD_MARK   9200
14
#define DINO_HEAD_SPACE  4800
15
#define DINO_ZERO_MARK    500
16
#define DINO_ZERO_SPACE   650
17
#define DINO_ONE_MARK     500
18
#define DINO_ONE_SPACE   1800
19
#define DINO_SAMPLES 54
20
#define DINO_BITS 25
21
 
22
#define DINO (LAST_PROTOCOL+1)
23
void IRdecodeDINO::ParseFields(void) {
24
  long Temp = value>>1; 
25
  Parity = Temp & 0x0ffL; Temp= Temp>>8;
26
  Run    = Temp & 0x1L;   Temp= Temp>>1;
27
  Angry  = Temp & 0x1L;   Temp= Temp>>1;
28
  Chomp  = Temp & 0x1L;   Temp= Temp>>1;
29
  JoyY   = Temp & 0x1fL;  Temp= Temp>>5;
30
  JoyX   = Temp & 0x1fL;
31
};
32
void IRdecodeDINO::DumpResults(void) {
33
  ParseFields();
34
  Serial.print(F("Decoded DINO: Value:")); Serial.print(value, HEX);
35
  Serial.print ("\tJX:"); Serial.print(JoyX,DEC);
36
  Serial.print ("\tJY:"); Serial.print(JoyY,DEC);
37
  Serial.print ("\tCh:"); Serial.print(Chomp,BIN);
38
  Serial.print (" Ag:"); Serial.print(Angry,BIN);
39
  Serial.print (" Run:"); Serial.print(Run,BIN);
40
  Serial.print (" Parity:"); Serial.println(Parity,HEX);
41
};
42
bool IRdecodeDINO::decode(void) {
43
  IRLIB_ATTEMPT_MESSAGE(F("DINO"));
44
  if(!decodeGeneric(DINO_SAMPLES,DINO_HEAD_MARK, DINO_HEAD_SPACE,
45
    0, DINO_ZERO_MARK, DINO_ONE_SPACE, DINO_ZERO_SPACE)) return false;
46
  decode_type= static_cast<IRTYPES>DINO;
47
  return true;
48
};
49
 
50
IRdecodeDINO My_Decoder;
51
 
52
int RECV_PIN =11;
53
 
54
IRrecv My_Receiver(RECV_PIN);
55
long Previous;
56
 
57
void setup()
58
{
59
  Previous=0;
60
  Serial.begin(9600);while (! Serial);delay(1000);
61
  Serial.println(F("Send a code from your dino remote and we will decode it."));
62
  My_Receiver.enableIRIn(); // Start the receiver
63
}
64
void loop() {
65
    if (My_Receiver.GetResults(&My_Decoder)) {
66
    My_Decoder.decode();
67
    if(My_Decoder.decode_type == DINO) {
68
      if(My_Decoder.value!=Previous) My_Decoder.DumpResults();
69
      Previous= My_Decoder.value;
70
    }
71
    else Serial.println("Unknown");
72
    My_Receiver.resume(); 
73
  }
74
} 

But what to do about those parity bits? I had to presume they were some sort of checksum or other data verification field. Normally when capturing and decoding IR signals I really don’t care what the data represents internally. I point a TV remote at my receiver circuit, capture the hex value, and then re-create that value using my IR transmitter. I could have just quit now and build an application on the Arduino that would transmit button pushes and fixed joystick positions but it would be nice to be able to use any joystick position that I wanted from 0- 31 in either X or Y directions in any combination. But to do that I needed to figure out how to compute those additional eight bits of data.

Most consumer-electronics protocols use a simple checksum of adding the previous data fields together. Sometimes you take the 1’s complement of the data and repeat it. Sometimes you use bitwise XOR to combine the fields. I spent three days playing around with various versions of my Excel spreadsheet analyzing lots of bit patterns captured from the remote and could not deduce the pattern. I asked a couple of online acquaintances if they had any suggestions but they’re only input was to try checksum, XOR etc. A cyclical redundancy check or CRC was another option but that would be hard to reverse engineer and they generally are not used for such short streams of data. Keep in mind were only talking about 13 bits of actual data if you don’t count the leading and trailing zeros or the eight check bits.

At one point I remembered there was something called a Hamming error correction code. I had learned about them in college in my CS 484 class with Dr. Judith Gersting over 25 years ago. I barely understood how they worked back then and I’ve not used them ever since so the chances of me being able to figure it out on my own were represented by the three initial zeros in the data stream :-) Dr. Judith Gersting was not my only mentor in college. Her husband Dr. John Gersting told us on the first day of programming class that he was not going to teach us programming. He was going to teach us to teach ourselves programming because the minute we walked out the door, everything would probably be obsolete anyway. He literally handed us a textbook that he wrote and told us to go teach ourselves the course. I guess I was going to have to do some Google searches and teach myself everything I needed to know about Hamming codes.

As it turns out there is no one single way to create an error detecting/correcting code. There are entire websites devoted to multitudinous ways and they all use notation that I didn’t understand. I did find one website from UMass linked here.

http://www.ecs.umass.edu/ece/koren/FaultTolerantSystems/simulator/Hamming/HammingCodes.html

One thing I have learned about Hamming codes was that they typically only add a vary few extra bits. Using the calculator linked above if I put in a 16-bit value it would only add five additional bits. I was getting eight additional bits on just 13 bits of data. But the one thing I did learn from that page was the way you calculate those extra parity bits. There is a matrix that tells you which of the data bits to add together to get each of the individual parity bits. I really had to do was figure out which data bits contributed to each parity bit. I had already noticed that if you push the “run button” which I have listed as “B0”, that parity bits P2,P1,P0 all inverted from their normal position. Similarly the “angry button” which is “B1” toggles parity bits P3,P2,P1. Similarly the “chomp button” labeled “B2” toggles P4,P3,P2.

So I made a new set of columns in the spreadsheet to compute the parity bits. I begin by saying…

 C++ |   |? 
1
2
P0=B0
3
P1=B0+B1
4
P2=B0+B1+B2
5
P3=B2+B1
6
P4=B2 

Additionally the center position of the joystick had only a single bit set, the highest order bit of the five bit field which was value 16. By comparing those to the joystick positions which were all of the way left or on the way back (which consisted of all zeros) I could figure out which parity bits changed based solely on X4 and Y4. Quite by chance I also found had captured samples with X positions of exactly 8, 4, and 2. So that told me which parity bits were based upon X3, X2, X1, and X0. As I updated the formulas for calculating each parity bit, I compared the computed results to actual capture values for every hex value I’d captured. I had a list of over 30 values that I had dumped from simply wiggling the joystick around. Eventually I was able to fill in the blanks and came up with the following formulas.

 C++ |   |? 
1
P0=X4+X0+Y4+Y3+B0
2
P1=X4+X1+Y3+B1+B0
3
P2=X4+X2+X0+Y3+B2+B1+B0
4
P3=X3+X1+Y4+Y0+B2+B1
5
P4=X4+X0+Y1+Y0+B2
6
P5=X3+X1+Y2+Y1+Y0
7
P6=X4+X2+Y3+Y2+Y1
8
P7=X3+Y4+Y3+Y2 

Comparing my computed results to all my captured results I was convinced I had completely deduced how the parity bits were calculated. When you put those results in a table as follows, there is a definite pattern to them. It looks a lot like the patterns that had been seeing on various websites.

Table 2-Parity calculation matrix.

Table 2-Parity calculation matrix.

Finally I was able to create a sending routine that allowed me to test all of this out. This is a somewhat stripped-down version of what I ultimately came up with. You upload the sketch, call up the serial monitor, and type various characters into the monitor. The sketch then interprets those as commands and sends the proper hex code to the IR transmitter.

 C++ |   |? 
01
 #include <IRLib.h>
02
#include <IRLibMatch.h>
03
 
04
class IRsendDINO: public virtual IRsendBase
05
{
06
public:
07
  void send(unsigned long data);
08
};
09
#define DINO_HEAD_MARK   9200
10
#define DINO_HEAD_SPACE  4800
11
#define DINO_ZERO_MARK    500
12
#define DINO_ZERO_SPACE   650
13
#define DINO_ONE_MARK     500
14
#define DINO_ONE_SPACE   1800
15
#define DINO_SAMPLES 54
16
#define DINO_BITS 25
17
 
18
#define DINO (LAST_PROTOCOL+1)
19
 
20
void IRsendDINO::send(unsigned long data) {
21
   sendGeneric(data,DINO_BITS,DINO_HEAD_MARK, DINO_HEAD_SPACE,
22
   DINO_ONE_MARK, DINO_ZERO_MARK,DINO_ONE_SPACE, DINO_ZERO_SPACE, 38, true, 0);
23
   delay(27);//Average gap was 26700 us
24
};
25
 
26
IRsendDINO My_Sender;
27
 
28
int RECV_PIN =11;
29
 
30
IRrecv My_Receiver(RECV_PIN);
31
char Mult, Normal, Chars;
32
#define COUNT 7
33
 
34
void SendMultiple(unsigned long Data, char Count) {
35
  for(char i=0;i<(Count);i++) {My_Sender.send(Data);};
36
};
37
void setup()
38
{
39
  Serial.begin(9600);;delay(2000);while (! Serial);delay(2000);
40
  Serial.println(F("Enter one of the following letters A,C,U,D,L,R,F,B,<,>,N,0"));
41
  Normal=1;
42
};
43
void loop() {
44
  char Cmd;
45
  if (Serial.available()>0) {
46
      switch (Cmd) {
47
          case 'A': SendMultiple(0x2105a0, 9); break;      //anger
48
          case 'C': SendMultiple(0x201984, 6); break;      //chomp
49
          case 'U': SendMultiple(0x21f162, COUNT); break;  //head up
50
          case 'D': SendMultiple(0x2000ae, COUNT); break;  //head down
51
          case 'L': SendMultiple(0x010112, COUNT); break;  //head left 
52
          case 'R': SendMultiple(0x3f003a, COUNT); break;  //head right
53
          case 'F': SendMultiple(0x21f36c, COUNT); break;  //forward 
54
          case 'B': SendMultiple(0x2002a0, COUNT); break;  //backwards 
55
          case '<': SendMultiple(0x01031c, 5); break;  //spin left 
56
          case '>': SendMultiple(0x3f0234, 5); break;  //spin right
57
          case 'N': Normal=1; break; //send neutral commands
58
          case '0': Normal=0; break;//send wiggle commands
59
      }
60
  } else {//if no serial data then send either normal play mode or sit still
61
    if(Normal) {
62
       //Un-comment next line to have Dino do normal behavior.
63
//      My_Sender.send(0x2101bc);  //Comment out to turn off continuous transmission
64
    } else { //wiggle slightly in an attempt to set still
65
      My_Sender.send(0x21132c);
66
      My_Sender.send(0x20f27e);
67
    }
68
  }
69
} 

The actual remote sends continuous streams of data even when you aren’t doing anything. If you don’t touch any buttons or move the joystick for about one minute it eventually shuts down. If you are not pushing a button and the joystick is in the neutral position, the dinosaur engages in various preprogrammed behaviors. I needed a way to get him to sit still while I’m typing in the next string of letters. If you select “Normal” mode. It doesn’t send any signals. If you press a “0” it continuously sends a tiny forward and backwards code which basically has him sit in one place. He wiggles a tiny bit and make some noises but he doesn’t go off on his own. Then when you type other letters he goes in the direction you want him to. You can look at the “switch statement” to see which characters perform which functions. I send multiple transmissions of each code. The default number of signals is defined in COUNT so it was easy to change the default. I have a more advanced version of the sketch which causes him to move at various speeds, shake his head repeatedly, travel in zigzag motions etc. I also added commands to make him go forward and right or forward and left simultaneously. That way he doesn’t spin in place, he turns in a broad curve. In the demo video below I use that feature to make him travel in an oval-shaped pattern.

Know that all of the driving patterns I put him through in the video below could be done with the actual remote. You’ll have to trust me that they were created using an Arduino and my software.

My ultimate goal is to port my code to my pinoccio board which includes Wi-Fi and mesh radio. That way I can control him through a webpage similar to this. I will end up with an “Internet of things” remote control dinosaur. The pinoccio has a LiPo battery and is very small. I might just velcro it with an IR LED to the back of the dinosaur and not worry about maintaining a line of sight from my transmitter. I will post more details when and if I ever get that working.

Here is where I demonstrated the project on the Adafruit weekly Show-and-Tell on Google Plus Hangouts.

IRLib Updated to Version 1.5

We are pleased to announce that IRLib has been updated to version 1.5. IRLib is a library for Arduino-based microcontrollers that allows for the receiving, decoding, and sending of infrared signals. These new changes are a step forward in making the library less hardware platform dependent so that it can be more easily used by a variety of microcontrollers. These changes include…

  • New bit-bang option for PWM output frequency setting. Now can use any output pin with no hardware timers. Note:bit-bang output not as accurate as timer-based frequency selection.
  • Major rewrite of IRLibTimer.h to facilitate bit-bang. Separated hardware timer selection and specification into sending and receiving sections in order to implement bit-bang.
  • New IRfrequency class for detecting input frequencies. Previously was a stand-alone special sketch but now is a class including a DumpResults method.
  • New IRfreq and IRrecvDumpFreq illustrate simultaneous detection of frequency and pattern with both an IR learner and IR receiver is connected.
  • New #define USE_IRRECV define can be commented out to completely remove the interrupt driven IRrecv receiver class from the library. This resolves ISR conflicts with other libraries such as Tone() when not using IRrecv class.
  • New #define USE_DUMP define can be commented out to disable DumpResults methods. Saves code space when these methods are not needed.
  • Revised user manuals to document new features and correct previous documentation problems.

Note: The included user manual update is not yet available on the website at http://tech.cyborg5.com/irlib/docs/ but it will be updated shortly. New user manual is available with the library itself as a Microsoft Word .docx file as well as PDF and EPUB versions.
This library is available on GitHub at . For more information on this library see http://tech.cyborg5.com/irlib/

Resolving SSL Certificate Problems

I’ve been working with the new Pinoccio microcontroller Arduino-like platform for creating internet-of-things devices. One of the many ways you can access devices through a webpage called their headquarters. It is available at hq.pinocc.io and requires a special plug-in for Google Chrome. I had been having great success with the device and suddenly two days ago the webpage quick loading. At first I thought their server was down but eventually realized that I could login using other in my home but not the one that I had been using. It was the classic “why is this thing not like the others?” problem.

The folks at pinocc.Io were tied up in a maker fair and working on other issues and were not able to help me right away. So I did some exploring on my own.

I finally figured out that it was a problem with SSL certificates on a piece of JavaScript. I only figured that out by typing in the URL the JavaScript itself instead of the URL of the webpage. That gave me the following…
hq_problem2
Note you can click on any of these images for larger versions.

I clicked on the “MORE” and got the following information.
hq_problem3

That told me that the certificate had been revoked and it told me who had issued the certificate but that still tell me very much. The first problem was figuring out where in Google Chrome SSL certificates were handled. Several Google searches later I determined that chrome uses Windows computers default settings. You can get to it in Google Chrome’s settings under the section “proxy settings”. (Gee no wonder it didn’t jump right out at me!) You can also access SSL certificate information from Internet Explorer under Tools… Internet options… content tab. I tried clicking on the “clear SSL state” hoping that it would flush everything out and recheck the certificates. That didn’t help. I clicked on the “Certificates” button but couldn’t find anything related to the certificate issuer “Gandhi Standard SSL, CA” that I had gotten from that more detailed error message.

I browsed around the certificate section in Internet Options but could not find anything under any of the tabs regarding that provider. Then I noticed that where you type the URL there is a little green padlock icon that somehow was beckoning me to do a right-click on it.
SSL 4

When I did I got the following…
SSL2
The initial tab talks about permissions but I clicked on the Connection tab. Then I clicked on the Certificate Information link. Which gave me this…
SSL3
The details tab was interesting but didn’t really tell me much so I tried the “Certification Path” tab and got the following
SSL1
This gave me some other places to look. I started the top with USERTrust and found it under “Trusted Route Certification Authorities” here…
SSL 5
However it would not allow me to remove it. However under “Intermediate Certification Authorities” I found an entry that it would allow me to remove.
SSL 6
After clicking on the “Remove” button and closing everything out, I was able to go back into Google Chrome, access the website, and it loaded perfectly. It apparently went and got a fresh copy of the certificate. Now everything is working fine.

The folks at Pinocc.io later explained “We recently added a load balancer which was still configured with the pre
heartbleed ssl cert we revoked. This has been fixed.”

So if anyone is out there reading this whether they are using Pinocc.io or not and you are having SSL Certification problems perhaps the steps I’ve shown you will help.

Pinoccio Internet of Things IR Remote Demo

satb100Here is a YouTube video demonstrating how I created an internet of infrared remote using the new Pinoccio platform. The Pinoccio is an Arduino compatible board based on the ATmega256RFR2 chip. It uses a Wi-Fi backpacked and built-in 802.15.4 mesh radio.

As mentioned in the video I have not yet released my source code for the Pinoccio port of my IRLib but I will do so very soon. The source code is now available on GitHub here. Read more about Pinoccio (and yes it really is spelled without an “h”) at https://pinocc.io. And my IRLib at http://tech.cyborg5.com/irlib/

Update: I also did a live demonstration of this project on the Adafruit Industries Google+ Hangout weekly Show-and-Tell which you can see here…

At some point I will post an extensive tutorial on this project.

Pinoccio Wireless Arduino Compatible Board: First Impressions

My Pinocchio boards arrived today in the mail. By the way I’m going to continue to call them Pinocchio rather than it to spelling Pinoccio simply because it’s easier to dictate using my voice control software wherein I do not need to go back and delete the “h” each time I type the word. For an explanation of the name you can see their FAQ here.

This board started out as a crowdsource funded project on indiegogo.com. It was billed as “A Complete Eco-System for Building the Internet of Things”. It consists of an ATmega256RFr2 microprocessor, a USB interface, a temperature sensor, an RGB LED, and a LiPo battery. The mesh radio built into the chip is a 2.4 GHz transceiver supposedly capable of ZigBee and IEEE 802.15.4 transmission although I’ve not yet seen anything about how to communicate with X-Bee or ZigBee modules from other manufacturers.

The package I ordered as part of my funding sent me two modules, one of them with a Wi-Fi shield or backpack as they call them. They call the boards “Scouts” so the one with the Wi-Fi shield is the “Lead Scout” and those without Wi-Fi are called “Field Scouts”. As a milestone perk I also got a prototyping shield and a small USB cable for charging and configuring. Here are some photos of the devices as shipped. (Click the images for larger view.)

Everything I Got

Everything I Got


Topside view: Lead Scout with Wi-Fi on top. Field Scout below.

Topside view: Lead Scout with Wi-Fi on top. Field Scout below.


Bottom view showing battery.

Bottom view showing battery.


The units use a micro USB cable. The first one I tried was a mini USB with an adapter on it. The adapter was too large because it got in the way of the Wi-Fi shield. I finally found a cable in my pile of cables. I wanted to be able to plug in both of them at once but as it turns out that may be a bad idea.

There was a card included that says to get started I should open a chrome browser and go to hq.pinocc.io and download their chrome app. I thought about browsing around the website and reading a bunch of documentation but one of the things the designers have said is that it ought to be easy to get started. They spent a lot of time working on the software and the front end for this thing rather than just creating the hardware and sending them out. In fact the original deadline for shipping was last July and here is the following April. So I thought I would give it the acid test and play dumb and see what I can find.

The app loaded just fine and I got a screen that told me to click to add a Scout control panel. They call the control panel “HQ” The first thing it said I had to do was to downloading Windows driver and install it. They tell you to plug in the device first and then it would tell me that no driver was available. Then it suggested I go to Device Manager via Control Panel in Windows and then I would find the device under “Ports (COM & LPT)”. It was not there it was under “Other devices” which is no big deal. I downloaded the driver and unzipped it into a folder. I would’ve preferred a self extracting installer but that was no big deal. When I tried to install the driver, Windows for bid me because it was not signed. No mention of that fact in any of their documentation so minus a few points for that problem as well. This was a Windows 8.1 64 bit machine. I had had trouble loading Arduino drivers on my laptop for the same reason and I found a website that explains how to permanently turn off that feature. I don’t know why I had not had the similar problem with Arduino drivers on my desktop Windows 8.1 PC. If you are interested… here is the website that tells you how to do it. That went relatively well.

Then I went to the process of configuring the lead scout. It took me several attempts and some email exchanges with their technical support people. Eventually it did start working but I’m not really sure what we did to fix it. It seemed to me that the steps they outline history followed in an exact precise manner.

Scouts in a mesh are configured together in something called a “troop”. So the first thing you have to do is give it a troop name. I chose “The Collective” (as an homage to Star Trek’s Borg). Then you name your lead Scout. I chose “Picard”. It then searches for Wi-Fi signals and asks you which Wi-Fi it should try to connect to. You are the Wi-Fi from the list and enter your password. There’s also a manual option if it cannot detect your Wi-Fi. When you completed that a screen pops up telling you that it succeeded adding your lead Scout to the Scout HQ. It then tells you to unplug the device so that it will reset and reconnect to your Wi-Fi. After that you click on the button that says “Done”. Apparently they are very picky about the order. You cannot click done until you’ve unplug the device and give it time to reset. Even then I had difficulty getting it to work right. In the end the only reliable way I could configure it was to unplug it and turn its power switch off and on. Then wait a few seconds before clicking done. Oh by the way when you first plug it in, the HQ searches for it and tells you that he could not find the device and that you probably forgot to turn it on. But it doesn’t tell you where the switch is. It’s not obvious. Anyway after unplugging, cycling the power switch, waiting a few seconds, and then clicking the done button it seemed to work okay.

You go to the same process for the field Scout although it does not prompt you for Wi-Fi information since it doesn’t have Wi-Fi.

The HQ app gives you the ability to turn on the RGB LED and change colors. It tells you the percent your battery is charged any gives you the temperature from the temperature sensor. I took my field Scout outside to see what the outside temperature was. Unfortunately it was raining so we had to put it in a plastic bag when sitting it out on the back porch. I don’t know how accurate the temperature was but it did change to a reasonable value. There are also controls for configuring the several I/O pins. There’s also a command line for sending for sending script commands. Here are some screen grabs showing the two scouts.

HQ control panel for the lead scout "Picard"

HQ control panel for the lead scout “Picard”


HQ control panel for field scout "Seven-of-Nine"

HQ control panel for field scout “Seven-of-Nine”

There are variety of script commands that you can use on the command line. Here is a link to the reference page.

The next thing I tried to do was use the Arduino IDE. You have to download a beta version because the current IDE does not support that chip. Again is a zip file rather than an installer. I already had the current production Arduino IDE installed on this machine. I took a chance and just copied the new files over the old ones. Apparently that was not the right thing to do because when I tried to compile an example sketch I get a “compiler error” with no error message whatsoever. I will probably go back and uninstall original Arduino IDE and delete all the files and try to reinstall the beta version from scratch. But that’s a task for tomorrow.

It’s going to be a steep learning curve to do anything really useful with this. Of course my ultimate goal is to port my IRLib and use it to make an “Internet-of-Things” infrared remote. Let’s going to take lots of time with data sheets and schematics. It looks like as powerful system but are not a long way to go in order to get it to do what I wanted to do.

Revised Remote-Controlled Remote-Control with Call Button

Imagine yourself being a severely disabled person lying in bed at night and needing assistance. It might be that you’re uncomfortable and need to roll over. Sometimes it’s just something annoying like a bug crawling across your arm. Other times it’s more serious such as a severe coughing spell, nausea, or potentially even a heart attack. A couple of months ago I woke up in the middle of the night with chest pains. I was 99% sure it was just a muscle cramp. I had had my back brace on a little bit crooked that day and I was pretty sure it was just the aftermath of that. But I wasn’t really sure that it was not a heart attack. I tried calling my dad who sleeps in his bedroom which is pretty far from my room. As both of us have gotten older, my lungs are weaker and his hearing is worse. I can usually yell and wake him up in 10 or 15 minutes. However some nights he sleeps very soundly and it’s not unusual for me to lie in bed awake for an hour or even two until he gets into a lighter sleep cycle and can hear me.

As I was lying there in bed wondering if I needed to be calling 911 or if I just needed a rubdown with some BenGay, I wished that I had some sort of a call buzzer that would alert him that I needed something. Years ago I had a call buzzer that we built out of parts from RadioShack. It was part of their home security line of products. There was an emergency call button that you would wire into their control boxes and that control box could in turn be hooked into an auto dialer. We really didn’t need a button to call 911. We just wired in a loud buzzer. We had one for me and one for my grandmother. The radio on the button was strong enough that she could trigger hers in her home next door and it would buzz here.

In 1990 my grandmother passed away and I was using the buzzer myself less and less. We ended up putting it away somewhere because it wasn’t as critical for me and typically if dad didn’t hear me my mom did. In recent years I’ve looked for that gadget all over the house. I’ve looked through closets and junk boxes and junk drawers and cannot find it. RadioShack no longer makes the kind of gadget that we used. Their newer home security systems do not seem to have something similar. I guess they expect you to buy some commercial home security system that is monitored. You know the famous “I’ve fallen and I can’t get up” type of gadget.

So anyway I’m lying there thinking it would be really nice if I had a button in my hand that would trigger a buzzer to wake up my dad. But wait… I did have the button in my hand. I had four of them in fact. Unfortunately all they would do would be to turn on my TV. No buzzers attached.

In previous articles I’ve talked about my “Remote-Controlled Remote-Control” project that I use to control my TV, cable box and DVD players while in my bed.

Sitting in my wheelchair I have no problems pushing buttons on a remote. I use a wooden stick in my mouth.

Sitting in my wheelchair I have no problems pushing buttons on a remote. I use a wooden stick in my mouth.

When sitting up in my wheelchair, I poke at the buttons of a traditional universal remote by using wooden stick in my mouth. But when I’m in bed, I don’t have sufficient dexterity to handle a bunch of buttons.
Arduino-based device with LCD menu sits atop my TV probably displaying an Adafruit "As Seen on Show & Tell" sticker.

Arduino-based device with LCD menu sits atop my TV probably displaying an Adafruit “As Seen on Show & Tell” sticker.

Instead I have a system that uses a set of micro switches, universal remote, and the special electronic gadget that I built that sits on top of my TV. That gadget is based on an Arduino microcontroller. It has an LCD screen and an infrared receiver and transmitter. Below is a diagram of how down the original system worked. I have a set of four micro switches that I hold in my hand. They can be seen lying on the bed connected by wire to universal remote that is sitting on top my cable box. I would push the micro switch causing the universal remote to send an IR signal to the Arduino box on top of my TV. After selecting an item off of the menu the Arduino box would then send an IR signal back to the cable box. Note you can click on any of the images in this blog to see a larger version.
Original "Remote-Controlled Remote-Control" System

Original “Remote-Controlled Remote-Control” System

What I needed was an additional function to ring a buzzer. The problem is that infrared IR signals are just ordinary beams of light that happen to be of such a frequency below what the human eye can see. While it is possible to bounce the IR signals off of a shiny object or a light-colored wall, there’s no way that the signal was going to reach all the way to my dad’s room. That means we needed some sort of radio RF signal.
X-Bee Series 1 Radio

X-Bee Series 1 Radio


My microswitches were wired directly into a traditional universal remote. The box on top of my TV was designed by me and built by my dad and it was based on the Arduino series of microcontrollers. Lots of types of gadgets have been designed for use with these controllers. The most popular RF module is called an X-Bee radio.

I thought about adding an X-Bee to the Arduino on top of my TV, however to trigger it I would need to select that option from the LCD menu. However sometimes I sleep on my side and I could not see the menu. That meant that the X-Bee would have to somehow be connected to the microswitches directly. I concluded that I could build another Arduino gadget to replace the universal remote. The microswitches would wire into the new transmitter Arduino. It would send the IR signals to my set-top Arduino just like the remote did. But it would also have an X-Bee module that was sent RF signals to my dad’s room.

The X-Bee does have some digital input/output pins to which I could connect a buzzer directly. However I wasn’t really sure if it was going to be a buzzer perhaps something that would turn on a light or perhaps trigger an intercom. Since I wasn’t completely familiar with the capabilities of X-Bee and I do know a lot about Arduino I decided that the receiver in my dad’s room would also be an Arduino with an X-Bee connected to it.

Adafruit X-Bee Adapter

Adafruit X-Bee Adapter

I went to my favorite electronics supplier Adafruit.com and ordered the following gadgets (2 each) an Arduino micro, an X-Bee adapter that makes it easy to connect a 3 volt X-Bee to a 5 volt Arduino, an X-Bee Series 1 radio module, a USB cable, a 5 volt USB power supply. I already had parts to make an IR transmitter. The only other item I needed was some prototyping boards and a 5 volt buzzer.

I had no previous experience with X-Bee. It’s a pretty powerful system that allows you to create a network mesh of transmitters and receivers. You can configure them as a master controller which can control either end nodes or routers. The routers can talk to the master controller and to end points. I had several online tutorials and an e-book that many of them talked about the newer X-Bee series 2 devices and I was using the older and slightly less expensive series 1. It was a pretty steep learning curve until I finally found an article that explains how to set up the simplest possible X-Bee network. Here is the link…

http://jeffskinnerbox.wordpress.com/2013/03/20/the-simplest-xbee-network/

06 hayes_smartmodemThe author explains that X-Bee is really just an ordinary serial modem. In fact the firmware recognizes escape sequences and text commands that are based on an old system used by Hayes Smart Modems. I remember the days when I had an old Hayes Smart Modem 300 sitting on top of my S-100 bus-based computer back in the early 1980s. By the way that “300” wasn’t just a model number… It meant that it communicated at 300 baud. That is approximately 300 bits per second. Today’s Internet traffic is not measured in hundreds of bits per second rather in megabits per second. That shows you how old this system is. Typically an X-Bee radio communicate that 9600 baud.

FTDI USB cable and X-Bee Radio with Adapter

FTDI USB cable and X-Bee Radio with Adapter

Anyway you simply connect them to a USB port using an FTDI or an Arduino. Then you use a serial communication program to type text into the radio. Using the Hayes protocol you type “+++” with a pause before and after to get it into command mode. Then you type text commands beginning with the letters “AT” to configure various parameters. Once it is configured, anything that you type into one X-Bee gets transmitted and appears on the other radio. It’s like a little 2 man chat room.

There is a more advanced mode called API mode that allows you to send packets of digital data. But for my purposes all I needed to do was send one character of data that would be interpreted as “Ring the buzzer”.

I first prototyped everything on a breadboard to get it working. Then I had dad solder it all together neatly on a prototype board. Here is a photo of the receiver device that goes in my dad’s room. It consists of an Arduino Micro, an X-Bee radio sitting in the 5 V adapter board, and a buzzer.

Receiver module with buzzer

Receiver module with buzzer


Here is a photo of the transmitter device that sits on top of cable box. It shows the sets of 4 micro switches next to it. The small board on top is an IR transmitter consisting of three transistors and 2 IR LEDs.
Transmitter with IR emitters and microswitches

Transmitter with IR emitters and microswitches


Here is an illustration of how the system worked using the Arduino transmitter with X-Bee radio and IR transmitter in place of the universal remote.
Communication between Arduino devices

Communication between Arduino devices


I spent several days tinkering with the timing of the system. I had to deal with de-bouncing the micro switches. I also had to deal with conflicts between the IR signals going back and forth between the two boxes. The signal going from the transmitter to the box on top of the TV show by the green arrow would interfere with the signal going from the LCD menu box back to the cable box shown with the blue arrow. The Ghostbusters were right “Don’t cross the streams!”. The original universal remote had been configured to only send a signal once even if you held down the button. I wanted to be able to hold the button to send repeat signals so that it would be easier to scroll through the on-screen channel guide for example. But as the transmitter box with send a second signal, the LCD box would be trying to talk to the cable box and it would get confused.

One of the problems was that the transmitter was too intense. Those double LEDs each with their own driving transistor were putting out too much power. IR receivers have something called an automatic gain control or AGC. They automatically adjust to the amount of infrared light coming in. My ultrabright transmitter was bouncing off of the TV and other objects in the room and temporarily “blinding” the AGC on the IR receiver of the cable box. I ended up putting a piece of tape over one of the LEDs and that helped my timing issues a little bit. While I was able to get it working as well as the old system, I still couldn’t get the timing right to be able to hold the buttons for a continuous stream of pulses for scrolling through on-screen menus.

On the other hand the call buzzer worked pretty well. The first couple of nights that I tried it, my dad was able to hear the buzzer and come and roll me over or do whatever else I needed. I programmed the transmitter Arduino to only trigger the buzzer if I held down 2 buttons simultaneously for a duration of five seconds or more. That way I wouldn’t accidentally set off the buzzer while trying to change channels or do some other function on the TV. Also it meant that I did not need to add any additional buttons.

Completed buzzer with cone.

Completed buzzer with cone.

However a few nights later, dad was in a deeper sleep than he had been during the initial tests and did not hear the buzzer. I was going to go looking for a new buzzer that was perhaps louder. I had also considered adding a relay to the receiving Arduino that would perhaps turn on a lamp in his bedroom. But my dad had a better idea. He noticed that the sound coming from the buzzer was a bit directional. Since he is a retired sheet metal worker he naturally thinks of solutions that involve making things out of metal so that is what he did. He created a little metal cone that he fitted atop the buzzer using a little plumbing elbow. Here is a photo of the modified device and the little plastic box that he used for an enclosure. So far this modified device is working really well.
X-Bee mounted atop LCD menu box

X-Bee mounted atop LCD menu box

I still was not happy with my timing problems on the transmitter. I realized that I could avoid the IR interference if I added an X-Bee to the LCD box on top of my TV. Then we would have an RF signal going from my transmitter box to the LCD box and it would not interfere with the IR signal going from the LCD box to my cable box and DVD etc. I ordered another X-Bee and X-Bee adapter from Adafruit and it arrived in few days. We mounted it on top of the LCD box and wired it into the Arduino inside. Here’s what it looks like now.

We cut away the IR transmitter board from the transmitter Arduino and removed it. We then mounted the device in a plastic box. The boxes we were using were boxes that originally contained a deck of cards. It turns out they are just the right size for the Adafruit half-size prototyping board.

Completed transmitter with IR board removed

Completed transmitter with IR board removed


Completed transmitter painted black and sitting atop cable box

Completed transmitter painted black and sitting atop cable box

I eventually painted my box completely black because I didn’t like all the blinking LEDs lighting up my room at night. There is a green power LED and a red transmit LED on the X-Bee adapter and there is a bright blue power LED on the Arduino Micro.

Here is an illustration of how the new system works.

Communication between boxes in final version

Communication between boxes in final version

The X-Bee on the transmitter box sends RF signals to my dad’s bedroom and to the LCD box on top of the TV. That signal is shown by the magenta arrows. The LCD box then transmits IR signal back to the cable box shown in blue arrows. There is of course no interference between IR and RF so I don’t have to build in the special delays. I can pump the buttons as quickly as I want to or hold the button in and let the software pump the signal for me at whatever rate I want. It works wonderfully.

I mentioned earlier that X-Bee was capable of creating complicated networks with master controllers, routers, and in points. Was a bit worried I was going to have to learn how to do all that once I had added the third radio. As it turns out the simple system of everyone-talks-to-everyone works just as well with more than two radios. Therefore the same RF signal in the same data goes from the transmitter box to my dad’s receiver buzzer and to my LCD box. The data I am sending is just a single text character. If it sends a “^” character then the buzzer goes off. If it sends a “U”, “D”, “L”, “R”, or “S” character than it tells the menu box to move the cursor up, down, left, right, or select. Actually I do not have an up microswitch in the system. It’s easier to get by with just 4 buttons. The menu wraps around and sue if I need to go up, I just go down several steps.

satb100The whole thing is working really well. I demonstrated my original “remote-controlled remote-control” on the weekly Adafruit Show-and-Tell videoconference on Google+ Hangouts over a year ago when I first created it. Here is a link to that blog entry which contains the video demonstration. A few weeks ago I also demonstrated on the Show-and-Tell the initial X-Bee system that did not include the third radio. Below is the YouTube video of that Show-and-Tell.
Part of the segment begins about 8:30 into the video. I will probably do a follow-up demonstration of three radio system.

Here’s a list of the parts used with links to Adafruit.com

IRLib Now Supports U-Verse

IRLib Version 1.4 is now available on GitHub at https://github.com/cyborg5/IRLib/. It includes minor upgrades to the debugging macros, a new system for decoding based on absolute tolerance in microseconds rather than a percentage tolerance. Also included is a new example sketch which implements the Phillips RCMM Protocol. The 32-bit version of that protocol is used by AT&T U-Verse cable boxes. Note that there are some unusual timing requirements in this protocol. The decoding routine works best when used with the IRrecvLoop or IRrecvPCI receivers. The sending of IR codes however should work well.

Details about these changes in the unusual decoding requirements of this protocol will be included in an upcoming documentation on how to implement new protocols for this library. That documentation should be available in a few weeks.