Friday, May 23, 2014

Arduino IR Blaster

My IR blaster is built on a LeoStick which is an arduino compatible USB stick. I must be a sucker for punishment because I thought it would be easy to make one of the many IR libraries work on here and control my Samsung TV.

There were two problems with my plan. First, the defacto IR libraries don't allow me to use the necessary IO pins and second, Samsung IR codes are not supported.

Rather than detail what when wrong, I will present my solutions.

The first problem arises because the LeoStick has a green LED attached to Digital IO pin 9 which is the default PWM Timer used by Ken Shirriff's IR library. The solution is an updated fork of this library Chris Young which implements more Timer chips and enables selecting Digital IO pin 5. Do to that, edit IRLibTimer.h and find the section with the heading 'it's probably Leonardo' (the LeoStick is apparently compatible with the Leonardo). Comment out the default #define and uncomment the IR_USE_TIMER3. (I wonder why we can't select this at run time?). Based on the IRLib manual, I also installed my IR LED with whatever resistors I had on hand (470 ohm I think).

So, thanks to the hard work of these guys, I have got my LED working. Now, to make it talk Samsung protocol.

There were a few snippits of code in various forums but I had to piece that together into the format for IRLib. I have only added sending as I already have a list of codes from SamyGO and LIRC. The only code I wanted to use is TV_POWER 0xE0E040BF because once the TV is on, I can talk to it via the network.

I have submitted my changes as a GitHub pull request. If they are not accepted in the upstream library you can find them here https://github.com/jnewbigin/IRLib

The final piece to the puzzle is making the IR code send when I want it to. To keep this generic, I made my sketch read a hexadecimal code from the serial port. When it receives a code it just send it, thus allowing control over the time and the code. This could probably be integrated with LIRC but I am just using a simple shell command
echo 0xE0E040BF > /dev/ttyACM0

So here is my sketch. There is not much error detection in the serial reading but what is the worst that can go wrong?

/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
 * Version 1.3   January 2014
 * Copyright 2014 by Chris Young http://cyborg5.com
 * Based on original example sketch for IRremote library
 * Version 0.11 September, 2009
 * Copyright 2009 Ken Shirriff
 * http://www.righto.com/
 *
 * Modified by John Newbigin to support Samsung and USB control May 2014
 */
#include <IRLib.h>

IRsend My_Sender;

void setup()
{
  Serial.begin(9600);
}

void p(char *fmt, ... ){
        char buf[128]; // resulting string limited to 128 chars
        va_list args;
        va_start (args, fmt );
        vsnprintf(buf, 128, fmt, args);
        va_end (args);
        Serial.print(buf);
}

// 0xE0E040BF = Power
void sendCode(unsigned long code)
{
   p("Sending SAMSUNG 0x%08lx\n", code);

  for (int i = 0; i < 3; i++)
  {
    My_Sender.send(SAMSUNG, code, 0);
    delay(30);
  }
}

unsigned long ir_code = 0;
void loop() {
  while(Serial.available() <= 0)
  {
    delay(10);
  }
  int incomingByte = Serial.read();

  int nibble = -1;
  if(incomingByte == 10)
  {
    p("Got newline\n");
    sendCode(ir_code);
    ir_code = 0;
  } 
  else if(incomingByte == 13)
  {
    // ignore
  }
  else if(incomingByte >= '0' && incomingByte <= '9')
  {
    nibble = incomingByte - '0';
    p("Got digit %d\n", nibble);
  }
  else if(incomingByte >= 'a' && incomingByte <= 'f')
  {
    nibble = incomingByte - 'a' + 10;
    p("Got hex digit %d\n", nibble);
  }
  else if(incomingByte >= 'A' && incomingByte <= 'F')
  {
    nibble = incomingByte - 'A' + 10;
    p("Got hex digit %d\n", nibble);
  }
  else if(incomingByte = 'x')
  {
    p("Starting number\n");
    ir_code = 0;
  }
  else
  {
    p("Got %d\n", incomingByte);
  }
 
  if(nibble >= 0)
  {
    ir_code<<= 4;
    ir_code+= nibble;
    p("Code is 0x%08lx\n", ir_code);
  }
}

61 comments:

  1. Thank you for your sharing. Thanks to this article I can learn more things. Expand your knowledge and abilities. Actually the article is very practical gmail login

    ReplyDelete
  2. great post. i like it. feeling great when reading your post

    Mutilate A Doll 2

    ReplyDelete
  3. Very helpful advice in this particular post! It’s the little changes that make the largest changes. Thanks for sharing!
    vex 3

    ReplyDelete
  4. Really i am getting inspired and i hope you will be awesome activity you have! but i want to learn this i am using Mass Texting and i have to get many learn and received activities messages you must to check it’s very helpful service and this is really informative blog well sharing more and keep it up your success

    ReplyDelete
  5. I think this webpage is a standout amongst the best I have seen so far on the web. You examine probably the most recent technique on split testing in a compelling way. The article is talked about in a brilliant way and I am happy that it has helped me to such an extent. Now every things are colorful because colorful thing always attract user and Color is also a key element in custom logo design and plays an important role in brand identification. design colorful and meaningful logos by world best designers.

    ReplyDelete
  6. This was an awesome article! If you want to know the History and Facts of Tarot Cards, please refer yourtarotlife.com.

    ReplyDelete

  7. I like your article very much, thanks for sharing the good information we have read.
    hotmail login email
    gmail sign up

    ReplyDelete
  8. Along these lines, you are an administration worker AND a Linux nerd. Join the club. best cleaning companies in dubai It is conceivable to utilize your savvy card to get to DOD CAC Card empowered destinations.

    ReplyDelete
  9. Spectrum Internet offers amazing deals on its service, no matter what speed you require. According to speedtest.net, they deliver the fastest internet in the US. Plus, they delivery these internet speeds at affordable prices along with providers all across the US which you can search based on your location.

    ReplyDelete
  10. Speedily this excellent website may possibly without doubt always be well-known amidst virtually all blogs folks, to the thoughtful articles or blog posts or maybe testimonials. VIn number

    ReplyDelete
  11. I really treasure your piece of work, Great post. Oscar Awards 2020

    ReplyDelete
  12. I simply wanted to thank you a lot more for your amazing website you have developed here. allegheny county real estate It can be full of useful tips for those who are actually interested in this specific subject, primarily this very post.

    ReplyDelete
  13. You know your projects stand out of the herd. There is something special about them. Room addition

    ReplyDelete
  14. Sometimes it is on top of that an awesome posting garage repair

    ReplyDelete
  15. I liked your blog and the detailing you have provided about IR blaster, Can I share it on Geek Squad tech support

    ReplyDelete
  16. I would love to use some experts of this for a report I am doing I hope that would be okay. Eyal Nachum

    ReplyDelete
  17. Our team of trusted dissertation writers works on your task with thorough concentration. This results in the completion of work even before the deadline.
    someone write my essay for me | dissertation writing services

    ReplyDelete
  18. The next time I learn a weblog, I hope that it doesnt disappoint me as much as this one. hazard perception test qld practice

    ReplyDelete
  19. It is really an extraordinary and obliging piece of data. Federal Pacific panel

    ReplyDelete
  20. Speedily this excellent website may possibly without doubt always be well-known amidst virtually all blogs folks, to the thoughtful articles or blog posts or maybe testimonials. Albagora

    ReplyDelete
  21. Great post! I like your blog because of its content which is very helpful to many. federalprocessingregistry.com

    ReplyDelete
  22. I have perused every one of the remarks and proposals posted by the guests for this article are very fine Skip hire bristol

    ReplyDelete
  23. ITach WiFi devices provide a new level of control flexibility, for ... compatibility with control-based computer software

    click

    ReplyDelete
  24. I am very happy to read this. Appreciate your sharing play gem swap 2

    ReplyDelete
  25. I am usually to blogging and i genuinely appreciate your content regularly. mp3juices

    ReplyDelete
  26. Thank you very much for this great post.satta king

    ReplyDelete
  27. https://medium.com/@sadik8877/watch-joker-full-2020-streaming-online-7024315dfbd6
    https://medium.com/@sadik8877/watch-joker-2020-full-online-free-streaming-da82fab37755
    https://medium.com/@sadik8877/putlockers-hd-watch-joker-2019-online-full-for-free-15da8ef3d519
    https://medium.com/@sesbikel2/123movies-watch-joker-2020-hd-full-movie-online-free-32ecd293196b
    https://medium.com/@sesbikel2/hd-joker-2020-4k-full-movie-watch-online-download-38e629a8a482
    https://medium.com/@sesbikel2/download-and-watch-joker-full-movie-hd-2020-e4e76ff53063

    ReplyDelete
  28. Good Subway Surfers download. I think I may be a little to late to vote though.

    ReplyDelete
  29. https://wrestlemanianfo.com/wwe Wrestlemania 2020

    ReplyDelete
  30. Your opinion is great, it is exactly what I think. If we go in that direction, everything will become much more perfect potty racers 4

    ReplyDelete
  31. IR Transmitter and Receiver Using Arduino: Tv ir remote uses InfraRed NEC Protocol for communication between infraRed remote and Tv itself.

    click on here

    ReplyDelete
  32. This post is good enough to get someone to understand this great thing, and I'm sure people will appreciate these interesting things play

    ReplyDelete
  33. It seems like the major phone manufacturers are moving away from built in IR blasters so I'm looking for a way to future-proof my "dumb" devices that don't currently integrate with my IoT infrastructure. I have a mesh-networked smart home, but I need to find a physical remote to turn on my TV? There has to be a better way.
    about us

    ReplyDelete
  34. ABC Assignment Help is an ethical place where students can get Chinese Assignment Help services at the best price. Our professional academic experts consistently help students in assignment which is free of plagiarism.
    Chinese Assignment Help

    ReplyDelete
  35. hp printer won't print black can happen due to multiple reasons such as dry or empty black ink cartridge, Printed clogging, or software related issues. For early diagnosis, you should always check and verify if you are the ink cartridges are full and not empty. The next step should be to confirm for the Clean printhead; your HP printer is equipped with an automatic printhead cleaning tool, which can be run through Control Panel. There might also be a chance of a blocked nozzle, and it can be cleaned with the help of a cotton swab. Additionally, you should always ensure to use the genuine ink cartridges and routine maintenance of your printers. I hope you will now get rid of the HP printer won’t print black

    ReplyDelete
  36. On a regular basis, many users are using canon printer for the excellent printing services. Users prefer canon printers for their personal or official usages. It is certain that user can face minor or major technical issues while printing procedure. If your canon printer is not printing the documents, you can get connected with live printer experts to get full technical support to sort out canon printer not printing issue immediately. Our canon printer troubleshooting team is highly skilled and rich experienced to recognize the major reasons of canon printer not printing and apply the best technical resolutions to resolve this error within a few seconds.
    canon printer troubleshooting

    ReplyDelete
  37. When QuickBooks desktop is unable to launch properly, QuickBooks Error 80029c4a arises which signifies the some of the necessary files are either missing or corrupt. QuickBooks Error 80029c4a signifies that the dynamic link library file got corrupted somehow. Sometimes this also indicates that your system might be at risk to the virus. You better check your antivirus and firewall configuration to rule out that possibility. If the process seems complicated to you and you need assistance. We are happy to help you with this simple process. Our technical support team can resolve this issue within a few minutes. Get in touch today!

    ReplyDelete
  38. Assignment Help Hong Kong is the best option to complete academic papers without any stress. If you don’t want to degrade your academic performance, make sure to connect with the professional service provider of assignment writing help.
    Assignment Help Online
    Online Assignment Help

    ReplyDelete
  39. I am applying my technical skills to resolve this technical problem, but I am facing a lot of problems. Hence, it has become a critical situation for me. I don’t have complete technical knowledge to find out the major reasons of this technical error. So I look for the permanent resolutions to resolve AOL Gold Icon not responding problem as soon as possible.

    ReplyDelete
  40. McAfee is one of the best and powerful antivirus software, if you’re finding for an antivirus program for your computer system. You can install, and activate McAfee antivirus software at mcafee.com/activate. This antivirus program provides the safe and secure online browsing and safeguards all your important and valuable data. If you get stuck to install McAfee antivirus software, you can take specialized help from our certified antivirus experts.

    ReplyDelete
  41. MkvPoker Adalah Situs Judi Poker Terbaik Dengan Taruhan Uang Asli Yang Menjaminkan Kemenangan Yang Tinggi

    Wa : +855 9637 31855

    ReplyDelete
  42. Select the option of Assignment Help when you don’t want to take the stress of writing your assignments or homework. This option allows you to get experts’ assistance for composing your academic papers even in adverse conditions. You can take the online help of academic writers at any time using these kinds of services. If you can’t pay attention to homework writing or don’t have enough time, this option will help you a lot. Handle everything for composing your papers even in adverse conditions via online academic writing services.

    ReplyDelete
  43. A great post including its information and I positively bookmark to this site because here I always get an amazing knowledge as I expect. Thanks for this to share with us.
    Need My Assignment Help
    Best Homework Help Online

    ReplyDelete
  44. Thanks a lot for your work and time you've spent preparing this article. I want to useful too, and recommend you service search for plagiarism at https://plagiarismsearch.com/. Try it, I think it will be helpful for you.

    ReplyDelete
  45. I want to buy PEB structural sheets for my green housing unit. I want to construct my housing building with the help of to quality Pre Engineered Buildings solutions. I have small budget for buying PEB sheets for my housing unit. I want to decrease my construction cost and time. I also want to use the lightweight structures for my accommodation unit. So I am looking for a reliable supplier of PEB sheets for my house. I don’t have ideas about the reliable supplier of PEB sheets. So anyone can suggest a reliable supplier of Pre engineering buildings for my housing unit.

    ReplyDelete
  46. Je sais que l'habitude naturelle des gens est de se pencher ou de se pencher sur la chaise, de sorte qu'ils ressentent généralement des maux de dos. Je pense que cette posture vient dans ma séance régulière. Alors maintenant, je souffre de maux de dos. Sur de longues périodes, une mauvaise posture assise peut endommager les structures de la colonne vertébrale et aggraver les problèmes de dos. Donc, je veux supprimer complètement mon mal de dos. Je veux donc acheter des chaises de classe mondiale pour ma séance officielle, afin que je puisse m'asseoir confortablement sur ma chaise. Je souhaite acheter des fauteuils contre les maux de dos à Toulouse. Je ne connais pas le distributeur de Fauteuils à Toulouse, donc je cherche l'aide de quelqu'un. Ainsi, n'importe qui peut partager un nom réputé de distributeur Armchair dès que possible.

    ReplyDelete
  47. Using dissertation help services, students can complete their work and submit their projects on time. Students who have no ideas on how to start their thesis, they can search for our services and access the option of online dissertation help. For more information, make sure to visit the website of the service provider.
    For More Relevant Information Visit here-
    dissertation Help service
    dissertation writing help
    dissertation Help online

    ReplyDelete
  48. Get the assistance of experts 24x7 using the option of online coursework help. With this option, you don’t have to wait for a specific time or make your submission delay because of any reason. It is good to have the services of academic writers whenever you have doubts to make effective assignment submission. So, buy coursework help now and make your submission on time.
    Read More:- coursework help
    coursework help online

    ReplyDelete
  49. Use Java Programming Help if you have less knowledge of coding and programming language. If you find tough to compose your Java papers before the due dates, get expert's help using the option of online Java programming services.
    Java Assignment Help
    java homework help
    Java Programmer Help
    Java Help

    ReplyDelete
  50. Place an order for Assignment Help  in Singapore so you can connect with professional writers. Pay a good amount to buy the services of online assignment help even in Singapore.

    ReplyDelete
  51. The Ascent is an industry leader for Alternative Investment Fund Administrator, which provides funds solutions as per the client's specific needs. As a fund administrator, we can perform various sets of activities, including fund accounting, NAV calculations, etc. Industry experts lead our team with rich experience in funds structure, venture capital funds, funds of funds, and sophisticated real estate funds.

    ReplyDelete
  52. The Quickbooks refresher tool helps you to diagnose and rectify the errors in QuickBooks application. However, now the intuit company has discontinued the refresher tool's operations and merged it with the QuickBooks tool hub. To download this tool, you can simply visit the intuits website and click download in front of the QuickBooks tool hub and then install it. To use the QuickBooks refresher tool, you can launch the newly downloaded program on your computer and then click the tool and click quick fix my program. This way, you can also troubleshoot various sorts of errors in your QuickBooks program.

    ReplyDelete
  53. Your efforts and dedication helps to enhance your academic performance. You need to put your time and effort when it comes to writing flawless assignment in Hong Kong as well. How will you manage your time when you have to write various assignments? What if you don’t find enough time to collect information regarding your research work? If you are facing these kinds of problems, then you need to use experts’ assistance. For that, use online assignment help and improve your academic performance. We all know that time plays a crucial role and it becomes more important when you are composing academic papers. If you receive Assignment help online service at the correct time even in Hong Kong, you may create a huge change in your approach and reap the best outcomes.

    ReplyDelete
  54. Australian Assignment Help provides law writing services in Australia to students and Student Life Saviour provides assignment help Ireland services to students.

    ReplyDelete
  55. Assignment Help services uncover various modes to get writing assistance for different subjects. Place your order for academic writing services and grab the hands of professionals at a reasonable price even in Australia.
    Assignment Help Australia
    Online Assignment Help
    Assignment Help Online

    ReplyDelete
  56. This post is good enough to make somebody understand this amazing thing, and I’m sure everyone will appreciate this interesting things.
    MindFlex Home Tuition

    ReplyDelete