Arduino Home Automation: Control Your TV, Air Conditioner, Fan, etc. with an Infrared Transmitter
Вставка
- Опубліковано 10 вер 2024
- In this video I show an easy and low-cost way to do some home automation. I setup an Arduino with an infrared receiver and transmitter, then use it to control my television and a tower fan. This setup can be used to control pretty much anything that has an infrared remote, even air conditioners.
I start by showing three different ways to wire up the circuit: breadboarding with a decoder and low-power LED, breadboarding with a decoder and high-power LED, and finally soldering together an Arduino shield for more permanent use.
Then I show how to code the Arduino sketch and test it out. After ensuring things are working correctly, I show how to keep the Arduino from resetting when you connect to its serial port, and then cover how to make batch files that send infrared commands to the microcontroller.
Finally I show how to use AutoHotKey to have your computer send those commands whenever you press a certain key on your keyboard.
The source code for the Arduino sketch is available here:
farrellf.com/ar...
This is the infrared LED and receiver that I used in the first part:
amzn.to/2lZ7pTy
For a higher-power LED:
amzn.to/2lZ6oLk
I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for me to earn fees by linking to Amazon.com and affiliated sites.
I haven't watched it all yet, but this is exactly what I'm looking for! Thank you, thank you, thank you! 🤗
Thanks for the kind feedback! Good luck with your projects. I still use this hardware almost every day :)
You are the Bob Ross of Arduino.
Great tutorial. Worked just right. One note, if using a Mega 2560 the LED should be connected to digital pin 9.
Thank You.
thank you
i can change pin 9 to another pin, how to change in code. Please
Hey , your channel is amazing. This is the third video I've watched today. Gem quality material on UA-cam. Love your work.
Thanks for the kind feedback.
Nice shorts.... excellent video and everything was very well explained which is much appreciated as most UA-cam tutorials leave out half of the steps.
Amazing presentation, wish you all success. it really helped me on my work. seriusly no one has done such a big tutorial on electronic over youtube. thank alot man!
One of the best tutorials on IR. Thanks A Lot!
Cool video!
Btw, you don't need to buy the stuff from China or Ebay, you can pick up the IR diode, resistor and receiver in any local electronics store, and it's probably even cheaper!
Best video for arduino i hve ever seen or i will watch.
Outstanding tutorial ! .... thank you for taking the time and sharing ..... SUBSCRIBED !
I am a new learner for Arduino projects this is an excellent explanation as I have been watching so many youtube videos for four months. Need a small help on a project if you can give, please.
Thanx man. Now I can do my home automation easy way !
VERY well done video. I just sat through the whole thing. DAMN. :D You've earned yourself a new sub.
this is well produced video, thanks man
Awesome project, thanks so much for sharing!
添加一個任意數字在RAW碼前端,造成遙控成功與失敗的區別,原因在於RAW碼是IR LED點亮與熄滅的間隔時間序列。
抓RAW檔的 library沒有刪除剛啟動LED的元素,造成點亮與熄滅的時機完全相反,所以,只要添加任一小數字在前方,即可修正。
甚至,可以去掉第一個元素,很可能也能工作
Awesome job. Thanks for sharing your work. Appreciate it
Very well explained video.
You can get much better range with standard IR LEDs by connecting them straight to a 5v rail and using a transistor on the arduino control pin to control the pulses. I do it this way and don't have to aim the device at all.
which transistor did you use?
i have 1 questions , where u define sender pin i.e in your video u marked pin 3 , but in coding i am unable to find that !!
Excellent presentation!!!!
Hello. I have applied the first scheme (with a normal IR-LED), but it is not working and the HEX number is longer than in the video. Could you please help me to fix it? Thanks
nice project, thanks
Need help please. I am building an arcade machine and would like to configure a few buttons to control the tv volume and on/off. I will be using an Ultimarc Ultimate I/O, having said that, how can I use the Arduino in my setup? Thanks
I have the atmega2560 and I didnt see anything blinking with my camera so I don't know what is wrong it works normally but I connect this to the pin 3 and didnt work can someone help me please
Hi again! I have a question, do you used a hardware pwm built in of the arduino or you used a software modulation for pwm? Can i migrate your sketch to a wemos d1 mini pro using the arduino ide? Because the wemos board doesn't have a hardware to manage the pwm signal, only thought software management thanks !
I'm looking to program an arduino to send a signal to Nvidia Shield tv to also control a mouse cursor. Have you tried this or seen it done anywhere? I'm not finding any results in my searches. I would prog. to receive from a tivo remote, then transmit signal same as my wireless keyboard with touchpad. Wondering how the mouse control would work.. can you hold the button for continuous movement? Would the touchpad send need different programming?
thanks a lot sir , u explained it very well
Thanks so much, i already make a project like that but i can't use a high power ir led 3w. Do you give me a extra tips? I make all like you say and use a mosfet HF4N60 wich Vgs(th) is min 2v and max 4v. I use a external power source 5v 1.5A. But instead of a arduino i use a wemos d1 mini pro that output logical is 3.3 v instead 5v there can be the problem?? Can you recomend me another mosfet that can work with 3.3v?? Thanks so much!!!
Good Job!
Man, I admire your skills!
Found your channel because of the telemetry an I can't stop watching your videos/tutorials... Keep up the good work, you are my new UA-cam hero :)
Some advises... can you make a future video on how to make this code run on esp8266-01 and have the commands sent wirelessly?
Can an USB capable arduino be connected to a keyboard and have each button mapped to a certain script?.. or maybe store them on an SD card... those w5100 SD/Lan shields...
Is there a way to embed a map (OpenStreetMap, or any other open source format) and have GPS coordinates visualized?
Thanks! I'm actually working on a short series of ESP8266 videos. I hope to have them done within a week or two. I plan to cover how to access a web page, how to host a web page, and how to use an ESP8266 to send telemetry wirelessly. That will be part of the next update for TelemetryViewer.
As for USB, I have not tried anything like that, so I don't know.
As for maps, I assume you want to do that with TelemetryViewer? I had not planned that, but it's a good idea. I'll look into it, but it may be a while before I have time to implement it.
Thank you for the heads up... hm... "heads up"... real time OBD car heads up.... just thinking.. :) :D
Looking forward for the new videos.
Hey man been wondering if it was possible to give commands through Alexa, I'm new to this whole Microcontroller thingie and I've trying to set up some form of Home automation for my parents before I go to college, please advise
Hello. Im trying to control my SAMSUNG AC with my Android via MIT App Inventor 2. Im using Arduino Uno, Bluetooth HC-05 and an IR Transmitter TSOP1136. Could you please help me with a code to decode my ac remote buttons?
Can i use a leonardo ver? Ive never played with Arduinos but i cant find anything to to send ir from my pc i ask because i was given a couple of mini leonardo style Arduino clones
So i have this setup and it receives the codes( much longer than yours my tv has 67 long) and when i try to send it just locks up my board
Like it , thanks
Can i controll the devices via a wifi shield and a mobile device? If so please make a video about it or explain it in the comments. THANKS!
amazing
keep it up!!!
Thanks
I've been having a problem where after reboots, the arduino usually doesn't work until I remove and then reinsert the USB cable. Sometimes I have to do this a couple times after a reboot. Running the mode command doesn't resolve it and I've cut the reset land as indicated. In Win10 under Devices and Printers and Device Manager it will say it's working properly and assigned to COM4, but it doesn't respond until I reseat the USB cable. I've tried assigning different ports, like COM3 & COM7, etc in Device Mgr and can get it to work but I still have this problem after most reboots. Otherwise it's working great. Any ideas on this problem related to reboots?
Weird. I've never had that problem and I'm not sure what would cause it.
I finally figured out the cause of my problem. I had a script in the windows startup folder "AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" that was sending a command to the Arduino. I guess it didn't like the timing of it or something. Anyway, problem solved by getting rid of the script and approaching what I was trying to do differently.
WHAT IS THE MAXIMUM DISTANCE, IT CAN WORK?
SIR THIS IS working for an window ac but incase of split acs it is not
can you help in this case
is it still not working?
Very good video with explanations. I am able to receive and send the codes to my Sony Tv ( same as in video). But for my AC it is only receiving codes. I can not send them back to the AC. Could you please help with that?
please did you manege to solve the AC problem ,, please help me
how to control MY AC plz give me any link or code in detail
great tutorial, thanks.
can you make one but using sms gateway please.
thanks a lot.
Awesome Project!
Where do I write the IR Data into the code to let the Arduino control things?
I just want to let my arduino turn on a TV (when a condition is reached, or a button on the Arduino is pressed)
I'm getting errors when I compile:
exit status 1
'IRsend' does not name a type
PC_To_IR:33: error: 'sender' was not declared in this scope
sender.sendRaw(durations, count, 40);
Any clues?
hey please share your whole code as i getting alot of errors. i will be very thankfull to you
Did you include the irremote.h header file?
do you still answer comments? i have a question for you
Hello, If usb port is disabled for mass storage devices will Adrunio work when connected with usb power ? and why after some time Adrunio goes offline when powered with usb. how to keep Adrunio online 24/7 from usb.
The Arduino Uno is just a USB UART, it does not use the Mass Storage protocol (as far as I know.) Not sure why your Arduino goes offline, mine does not do that.
please provide source code ..thank u
5:52
...you know, you know...
Are you an engineer or ... man.
how i disable reset button on arduino uno?
its turn on the tv but doesnt turn off the tv, anyone know how?
this is awsome man.. but i use same methode that you're in to, to my midea Air Conditioner But it not work can you explain a litlle bit? i've already tried everything but it not work at all. can you help me?
If it's not working I would try two things: 1. Check if the IR LED is emitting anything. A camera can see the IR, just aim your camera at it and try to send the command. 2. If the IR LED is emitting, use an oscilloscope on the real remote control, and on your IR LED, and see how the waveforms differ.
i've try the same IR LED to my TV, it works but not on my Air Conditioner. I has 100 count in raw code. and doesn't word. my tv remote only 63 and it work. does it matter?
i use ordinary IR LED
yess the waveform is different. how to fix it bro?
i tought the algorithm for the program is to sent exacly the same raw code as the remote sent
source code ...i was downloaded ..but it is empty
Same here :( … but anyhow great tutorials! well made!
which Transistor i can use ?
Most n-channel MOSFETs that can handle a drain current of at least 1 Amp should be fine.
Thanks
I don´t know why dont work :(
Wow
Is 120 ohm resistor ok or not?
If I can contact you
btw, the source code is empty.
re-upload it please.
Fixed it.
hey your code is note working see the error below and fix this..
Arduino: 1.8.3 (Windows Store 1.8.6.0) (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\sood\Documents\Arduino\sketch_jul10a\sketch_jul10a.ino: In function 'void loop()':
sketch_jul10a:24: error: invalid types 'unsigned int[int]' for array subscript
durations[i] = Serial.parseInt();
^
C:\Users\sood\Documents\Arduino\sketch_jul10a\sketch_jul10a.ino:27:42: warning: invalid conversion from 'unsigned int' to 'const unsigned int*' [-fpermissive]
sender.sendRaw(durations, count, 40);
^
In file included from C:\Users\sood\Documents\Arduino\sketch_jul10a\sketch_jul10a.ino:1:0:
C:\Users\sood\Documents\Arduino\libraries\IRremote/IRremote.h:260:9: note: initializing argument 1 of 'void IRsend::sendRaw(const unsigned int*, unsigned int, unsigned int)'
void sendRaw (const unsigned int buf[], unsigned int len, unsigned int hz) ;
^
sketch_jul10a:35: error: expected unqualified-id before '=' token
for (int = 1; i < results.rawlen; i++) {
^
sketch_jul10a:35: error: expected ';' before '=' token
sketch_jul10a:35: error: expected primary-expression before '=' token
sketch_jul10a:35: error: 'i' was not declared in this scope
for (int = 1; i < results.rawlen; i++) {
^
sketch_jul10a:35: error: expected ')' before ';' token
for (int = 1; i < results.rawlen; i++) {
^
sketch_jul10a:35: error: 'i' was not declared in this scope
for (int = 1; i < results.rawlen; i++) {
^
Multiple libraries were found for "IRremote.h"
Used: C:\Users\sood\Documents\Arduino\libraries\IRremote
Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.6.0_x64__mdqgnx93n4wtt\libraries\RobotIRremote
exit status 1
invalid types 'unsigned int[int]' for array subscript
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
AND WHOLE CODE IS :----------
#include
IRrecv receiver(2);
IRsend sender;
decode_results results;
long repetitions;
long count;
unsigned int durations(100);
void (*reset)(void) = 0;
void setup()
{
Serial.begin(9600);
receiver.enableIRIn(); // Start the receiver
}
void loop() {
if (Serial.available()) {
repetitions = Serial.parseInt();
count = Serial.parseInt();
for (int i = 0; i < count; i++)
durations[i] = Serial.parseInt();
for (int i = 0; i < repetitions; i++) {
sender.sendRaw(durations, count, 40);
delay(50);
}
reset();
}
if(receiver.decode(&results)) {
Serial.println(results.value, HEX);
Serial.print(results.rawlen - 1);
for (int = 1; i < results.rawlen; i++) {
unsigned int number = results.rawbuf[i] * USECPERTICK;
Serial.print(",");
Serial.print(number);
}
Serial.print("");
receiver.resume();
}
}
FIX THIS FRIEND AND LET ME KNOW.
THANKS