Help with IRremote library | sending:
Hello. Firstly I apologise I am extremely new to arduino IDE. I am not sure if this is the right place to post my support request hopefully its okay.
My intention:
I wish to send just a single command over my IR diode, the sample code I find that comes with the library seems to just send on repeat which I am not sure how to stop firstly, I have managed to stop the sample code from interating by commenting that code out.
I have the remote codes using the IRremote library for receiving okay.
My issue:
I am not entirely sure where to put my send code, I have tried various places.
Code:
Due to limitations of thread character limit I've had to upload to github - https://raw.githubusercontent.com/HybridZach/HybridZach/refs/heads/main/SimpleSender_IR_C6.ino
The readme on the github which links to documentation here - https://dronebotworkshop.com/ir-remotes/#SimpleSender_Example_Code
With regards to where to change the command I am a bit lost.
The receiver gave me this for example for a UP button
So I assumed you change that line but it didn't work. I see the IR working (looking at it via a camera) so I've defined the pin correctly with the compile options, I'm just stuck on where to place the send code.
Thanks.
DroneBot Workshop
DroneBot Workshop
IR Remotes Revisited - 2023 | DroneBot Workshop
Learn to interface infrared remote controls with microcontrollers like Arduino and ESP32. Includes those tricky remotes as well!
71 Replies
there are many, many IR protocols in the world, you must use the one your receiving device expects. you "see" the IR with your cell phone, so likely the code being sent isn't what your receiver expects
No I know its NEC protocol I have the code from using the receiving demo code. I now want to apply that to the send demo code but I don't know where to replace it.
The receiving demo says this:
So where do I place the send with code in the send demo code?
What I meant by I see it in my phone camera is I must have the correct pin defined for the send pin as I see its sending IR signals fine
I just need to send the right command
currently you are sending
once a second
and you defined those variables up top
0x00 is the address, which doesn't match
NEC Address=0xE710
Yeah so I replaced that with
And the github says if unsure what number of repeats set to 3 as a start
My problem is the console shows that its not sending the correct command (I think?)
My output:
Am I replacing line 72 in my code linked above?
Sorry I send that before reading your other reply
So to change the command I change these?
try
that is "hard coded", not using the variables
Oh I see
Also how do I only send it once?
most IR codes want a repeat for reliability
Its just while I test the output so I don't spam the console every second
that's two different things, how many times the code is repeated, and how often you send results to the serial monitor
This is what I tried before I asked for help and my output says its sending the wrong command?
🤷♂️ wrong command for what?
Sorry for noobie let me try start again
I changed line 72 to what you put here
the github isn't showing line numbers, you could try pastebin.com
When I run the code the console says this
Sorry replying using my phone
if you use variable name those values would be used
(whatever names are defined)
Lemme give you the correct link one sec
ok, brb
GitHub
HybridZach/SimpleSender_IR_C6.ino at main · HybridZach/HybridZach
Config files for my GitHub profile. Contribute to HybridZach/HybridZach development by creating an account on GitHub.
I suck at CPP only good with python. Struggling to find where I change the sample code to run the command here
so as written it executes
yes, line 72
so you could hardcode address, command, repeats there
Sorry for the confusion that code I linked I replaced line 72 with
Sorry I know I'm trying to explain that what I linked you I changed that line with the above
ok, and what is complaining about that editied line?
So I change line 72 what about line 54 & 55
those lines set up the variables
The console output it saying (I think) that the wrong command is being sent
Address 0x00 command 0x34
what console? an ino script, a python script? how would the console know it's the wrong command?
The serial monitor in the ide
The code in the loop is meant to display the command it sent
i don't see any receive code or any lines that would send an error message
I suck at explaining 😅
all i can go by is the link you sent 😉
So in the loop it says in a comment Print current send values
//
comments are not compiled let alone executedNo lmao that's not what I meant
Ermm
this block?
Yeah
it's hardcoded, it'll always print that
I think I'm being dumb I thought it had variables to display but the first line is hard coded text
Ditto
yes
you could use variables...
How do I get it to display that its sent the correct code
Are variables in a text string defined with $?
I just want the console to show what command was sent
looking again
will print
sCommand
(in hexadecimal)
in C++ you should avoid "text strings", they are char arrays, an array of char
actersOkay lemme test some things and get back to you to see if I get the desired outcome. Thanks for helping such a noob lol
though in this case they are 16 bit unsigned integers (uint16_t)
C++ is very picky about data types 🙂
oh. potentially a problem, they are created as 8 bit integers... (uint8_t)
0xE710
is 16 bits
the original repository and examples are here https://github.com/Arduino-IRremote/Arduino-IRremoteYah I struggled to understand the examples/readme
So on line 54 it is setting up sCommand as the correct data type?
The example is 0x34 are you saying I need it to be 16?
Also running the code and holding the ir near what I want affected it doesn't work sadly
0x34 is only 8 bits, which might be ok for address, but data is 16 bits iirc
So what do I need to change that to
uint16_t
is an unsigned 16 bit integer, uint8_t
is an unsigned 8 bit integer
each character in a hex value is 4 bits (a nybble), 2 nybbles is a byte
16 bit is 2 bytes
0xE710 is 4 nybbles, 2 bytes, 16 bitsSo I need to change uinit8_t to 16?
Would you be able to edit my ino to send the command the receiver gave me so I can use that as an example to try understand it better perhaps?
do you have a device to control? I'd need to study the NEC (or whatever protocol) to know what you should be sending
Yeah my AC
It came with a remote and I sent the codes with the receive demo file which worked fine
I just can't figure out how to send what it gave me lol
I thought ir send and receiving would be simple 😅😭
This is a file I made with the various buttons I sent to the ir receiver with the IRremote ReceiveDemo
ac's use a different protocol, not NEC
https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/examples/SendLGAirConditionerDemo/SendLGAirConditionerDemo.ino as an example
Raw-Data=0xEA15E710 32 bits LSB first
Well the receive demo said it should spit out and decode what protocol it uses
Which gave me NEC
and it reports a 32 bit protocol
there is no "standard" way to send and receive IR
It says protocol=NEC
i'd read through https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file
there may be better tools to read your ACs remote
Haven't I already read the commands though I just need to send now?
the tool you're using may not truly understand what it's seeing
so it makes its best guess
might be simpler to start with a TV, they use more "standard" protocols
My whole goal is to control the AC though haha. I bought a IR send and receiver with an esp dev platform eventually I want to hook that up to home assistant to control my ac. I'm just using audino to decode the commands first because I thought I'd be simple. I guess I was mistaken lol
Can you help me try test the commands I got though?
"We love standards, that's why we have so many of them" 😉
https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#how-to-deal-with-protocols-not-supported-by-irremote
your goal is fine, but when setting out to design a Boeing 747, it's best to start with a Cessna 172, in other words, try to control a more standard thing first
I used this https://dronebotworkshop.com/ir-remotes/#SimpleReceiver_Example_Code to decode the commands and it spit out that it uses NEC
DroneBot Workshop
DroneBot Workshop
IR Remotes Revisited - 2023 | DroneBot Workshop
Learn to interface infrared remote controls with microcontrollers like Arduino and ESP32. Includes those tricky remotes as well!
This links to that
Why is it so complicated lmao oof
yes but ACs don't use NEC. think of protocols as languages, if i try to decode French but I only know German, the results may not be good
But the irremote readme says
If you have a device at hand which can generate the IR codes you want to work with (aka IR remote), it is recommended to receive the codes with the ReceiveDemo example, which will tell you on the serial output how to send them.
this concentrates on TV remotes https://dronebotworkshop.com/ir-remotes/
Doesn't that tell me what its using so are you saying its guessing its nec
it is listening for a more standard protocol, it hears Swahili so it takes its best guess
i'd google up "Decode AC remote", I myself have never used IRremote with an AC
The ac isn't a big named brand I'd doubt it to use something special
LOL
that makes it more likely it has a custom protocol
there are examples in the links above for LG air conditioners
https://github.com/Arduino-IRremote/Arduino-IRremote/tree/master/examples/SendLGAirConditionerDemo
Hmm this is way over my head then it seems
Thanks for the help anyways