peros550 / esp-homekit-multiple-sensors

A firmware for ESP8266 based devices to be used as Homekit sensors and Thermostats.
MIT License
31 stars 7 forks source link

IR commands for AC control #2

Closed RavenSystem closed 5 years ago

RavenSystem commented 6 years ago

I am very interested in an IR system to receive a send commands like a remote. Maybe we can join efforts.

peros550 commented 5 years ago

Very happy to work with you. I'm kind of busy this period of time that's why didn't respond earlier. I'll let you know as soon as I have time again.

GPL71 commented 5 years ago

@peros550 any good news about IR transmitter? Thank you

peros550 commented 5 years ago

Yes, I've been testing it for the last a few months. The code works nice for the most part.
Allow me some time to to produce clean code and I'll get back to you with code examples and design of the IR circuit.

GPL71 commented 5 years ago

@peros550 WOW!!!!! very good news!!! Yes It would be interesting a wiki to get RAW Code, which IR TX and RX board too Thank you!!!

peros550 commented 5 years ago

@GPL71

better late than never, I found some time to put together the code that use Maxim's new library (esp-ir) in order to control my A/C. Checkout my latest commit with example: multiple_circuits_ac

Here are the first steps you need to take

1) Go here https://github.com/maximkulkin/esp-ir 2) Build the example raw_dumper on a esp8266 device like WemosD1 mini.

This program will help you capture IR commands from your original IR remote. You will need an Infrared Receiver (probably something like that). These modules have Vcc, Gnd and Data pins. You will connect the Data pin to GPIO 12 or D6.

3) As soon as you have the circuit ready and program "raw_dumper" loaded, you only need to point you original remote to the receiver and send commands. The program will capture the IR commands and will give your the raw code in the serial output. I had to do the same for all commands like Cool-16, Cool-16....Cool-30, and also for Heat-16...Heat-17...Heat-30 and one command for just Fan and of course the A/C Off command.

4) Having captured the raw codes, you now need to go into file ac_commands.c of my multiple_sensors_ac example and replace the codes you will find there with the codes you captured from your own remote.

5) build the physical circuit. I give you a link where I disucss with Maxim the part of the IR circuit. The design that you see there worked for me. You need of course to add the DHT22 , a motion sensor and a photodiode so that everything will work.

Multisensor_ac_schematic Multisensor_ac_breadboard

6) build the multi_sensor_ac

7) Let me know your feedback and any comments. Good luck

GPL71 commented 5 years ago

@peros550 thank you very much. My firend @curla92 is trying capture codes. At moment we have some little problem, but surely will do it.

Please what's the function of PIR in this circuit? Thank you

curla92 commented 5 years ago

Could you create only a firmware for ac controls? very thanks im ready to change your ir commands, i have the ir receiver.

curla92 commented 5 years ago

i tried your firmware. my ir transmitter doen't work, its led is always red and it doesn't send the command to the ir receiver. can you help me? i tried this on D5 GPIO14

peros550 commented 5 years ago

@GPL71 the circuit exposes a motion sensor through homekit. The PIR is used as a sensor to detect motion.

@curla92 What board are you using ? Perhaps a Wemos D1 mini? If you only need an AC accessory, it's not very hard to use the existing example and stripe out the irrelevant code.

curla92 commented 5 years ago

Perhaps

yes im using a wemos d1 mini.

peros550 commented 5 years ago

@curla92 Are you using a module with on board red & IR led like that?

Maybe if you used IR Led part and NPN transistor based on the Schematic above you would have more luck.

I know I wasn't too helpful but I can't figure out what's wrong.

curla92 commented 5 years ago

this is my ir. https://www.analysir.com/blog/product/sendir-advanced-infrared-emitter-module/

curla92 commented 5 years ago

the same ir works with ir firmware of kulkin

peros550 commented 5 years ago

So, using Kulkin’s IR library and examples , you captured RAW codes of your original remote and afterwards you were able to successfully transmit them through the Wemos , right ?

In this repo, I also use Kulkin’s IR library.

In order for you to activate the IR part, you need to activate the A/C accessory through Home app, I assume you did that right ?

Further troubleshoot I can think of, assuming positive answer to previous questions is to play with input voltage (Vcc ) of your module. Feed it with 3V3 or 5V and check if there is any jumper to control input voltage.

curla92 commented 5 years ago

So, using Kulkin’s IR library and examples , you captured RAW codes of your original remote and afterwards you were able to successfully transmit them through the Wemos , right ?

In this repo, I also use Kulkin’s IR library.

In order for you to activate the IR part, you need to activate the A/C accessory through Home app, I assume you did that right ?

Further troubleshoot I can think of, assuming positive answer to previous questions is to play with input voltage (Vcc ) of your module. Feed it with 3V3 or 5V and check if there is any jumper to control input voltage.

i saved all ir codes with ir receiver thanks to kulkin's firmware. i have substituted them in ac_commands.c and added your firmware to homekit. I think that it's a voltage problem, i ll let you know after some check with 3.3 or 5v.

peros550 commented 5 years ago

@curla92 ok, sounds good but were you successful on transmitting your captured commands using Maxim's example code?

If no, there is one bug at Maxim's library that may haven't been fixed yet. Check this discussion for more info

curla92 commented 5 years ago

check this link video, so you can see the problem

https://www.dropbox.com/s/zoq8ylyi888fg1o/IMG_3072.MOV?dl=0

peros550 commented 5 years ago

good idea to send a video. Here are my comments:

a) I am not sure if the specific module shown in the video will do the job. I have used in the past a similar one but it didn't give strong light and my devices (A/C , TVs) could not detect the IR signal. It did the job but very unreliably. That's why I used the circuit in the previous messages. That module doesn't seem like the one posted before. Did you have same results with Analysir module?

b) In the video, it looks that you haven't connected the Vcc pin. Have you tried connecting 3.3V or 5V to that pin?

c) The flickering in the red led should be expected. Flickering happens when pulses are transmitted through the pin. It's very strange that LED remains ON before & after the IR transmission. If this is not caused due to bad voltage, then the first word that comes to my mind is "inversion". You either:

I would like to ask you if you had any success transmitting IR signals using solely Maxim's examples. I would also suggest to use the circuit I propose in my previous messages so that you can have reliable results.

curla92 commented 5 years ago

i have two ir transmitters and both give me the same problem. I tried 3.3 and 5v but the problem remains. I tried esp-homekit-ir from kulkins repository with stock ir codes and it works perfectly. i think it's a software problem because before to add it to homekit their led is off. It's remain on when only use AC in homekit.

curla92 commented 5 years ago

i have two ir transmitter and both give me the same problem. I tried 3.3 and 5v but the problem remains. I tried esp-homekit-ir from kulkins repository with stock ir codes and it works perfectly. i think it's a software problem because before to add it to homekit their led is off. It's remain on when only use AC in homekit.

your firmware is more easy than kulkin's firmware because you used raw ir method and it results fast and easy.

peros550 commented 5 years ago

i have two ir transmitters and both give me the same problem. I tried 3.3 and 5v but the problem remains. I tried esp-homekit-ir from kulkins repository with stock ir codes and it works perfectly. i think it's a software problem because before to add it to homekit their led is off. It's remain on when only use AC in homekit.

the code in this repo works very well for me. If the transmitting part of your circuit is successfully tested, then you need to make sure that raw_dumper works well for you.

On my initial testing I tried to capture IR signals from TVs. Those signals are shorter and easier to reproduce. Try with a TV remote first and then you try the A/C remote.

If you like you may post a few raw codes you have captured to try to test on my side here.

curla92 commented 5 years ago

ac_commands.txt

Hi, this is my complete list of ir commands like your. My file extension is bigger than your and during homekit coupling i have a memory error !!! HomeKit: [Client 4] Failed to dump SPR public key (code -2) How can i reduce my code?

peros550 commented 5 years ago

In regards to the pairing I also have some issue during homekit pairing. For me, it works if I do a reboot just after configuring the wifi. After that, it pairs.

I will check your A/C commands. By the way, what type and company is your A/C? Maybe I can find a similar to test in Greece.

curla92 commented 5 years ago

My ac is a fujitsu

curla92 commented 5 years ago

check this link video, so you can see the problem

https://www.dropbox.com/s/zoq8ylyi888fg1o/IMG_3072.MOV?dl=0

@maximkulkin

can you help me? do the same problem with 5v or 3.3v... very thanks

maximkulkin commented 5 years ago

@curla92 It's kind of hard to see on video, but I guess you're using pin D3, while you should be using D5. Also, I really recommend driving IR LED with a NPN transistor (see wiring diagram above).

curla92 commented 5 years ago

@curla92 It's kind of hard to see on video, but I guess you're using pin D3, while you should be using D5. Also, I really recommend driving IR LED with a NPN transistor (see wiring diagram above).

ok. im using d5. The same ir transmitter works with your esp ir thermostat example firmware. only with peros firm i have this problem. ill buy the transistor

curla92 commented 5 years ago

In regards to the pairing I also have some issue during homekit pairing. For me, it works if I do a reboot just after configuring the wifi. After that, it pairs.

I will check your A/C commands. By the way, what type and company is your A/C? Maybe I can find a similar to test in Greece.

i found the problem... when i use a long raw complete my ir transmitter bricks while use a raw code like this:

  3291, -1611,
  443,  -370,   425,  -421,   421, -1185,   424,  -422,
  421, -1185,   425,  -421,   421,  -370,   424,  -392,
  448, -1188,   423, -1214,   444,  -372,   422,  -395,
  447,  -397,   420, -1186,   449, -1185,   424,  -423,
  419,  -375,   441,  -372,   423,  -422,   420,  -372,
  444,  -370,   424,  -422,   420,  -372,   421,  -393,
  424,  -421,   421,  -371,   422,  -392,   449,  -398,
  420, -1185,   450,  -396,   421,  -370,   422,  -423,

it works perfectly... now i want to know the reason of this bug

peros550 commented 5 years ago

Perhaps if @maximkulkin has time, could have a look on this issue. I still haven't tried your commands yet.

GPL71 commented 5 years ago

@peros550 the follow is the code related to switch ON about my A/C How much of that code do I need copy and replace? I have used Maxim Kulkin raw dumper Thank you

Decodedpacket (size = 233): 3618 , -698 ,
328 , -343 , 907 ,-1316 , 381 ,-1349 , 389 , -534 , 360 , -571 , 354 , -515 , 389 ,-1340 , 469 , -428 , 385 , -598 , 357 ,-1346 , 382 ,-1348 , 389 , -534 , 361 ,-1376 , 473 , -424 , 389 , -507 , 387 ,-1342 ,
386 ,-1405 , 383 , -540 , 354 ,-1349 , 389 ,-1341 , 386 , -572 , 363 , -533 , 362 ,-1340 , 387 , -536 ,
358 , -600 , 355 ,-1347 , 442 , -455 , 388 , -508 , 386 , -545 , 380 , -515 , 390 , -533 , 361 , -508 ,
386 , -571 , 384 , -538 , 357 , -513 , 381 , -514 , 390 , -541 , 384 , -512 , 382 , -514 , 381 , -514 ,
390 , -567 , 388 , -508 , 386 , -510 , 385 ,-1343 , 384 , -575 , 360 , -536 , 359 ,-1343 , 384 , -539 ,
355 , -602 , 364 ,-1339 , 388 ,-1342 , 386 , -537 , 357 , -574 , 361 , -508 , 386 , -510 , 384 , -512 ,
382 , -601 , 355 ,-1347 , 390 ,-1340 , 388 ,-1342 , 385 , -574 , 361 , -535 , 360 , -509 , 385 , -511 ,
383 , -600 , 355 , -515 , 389 , -506 , 389 , -507 , 387 , -544 , 381 , -515 , 389 , -506 , 389 , -507 ,
387 , -597 , 358 , -511 , 383 , -513 , 381 , -514 , 391 , -540 , 384 , -539 , 356 , -513 , 381 , -514 ,
390 , -594 , 361 , -508 , 387 , -536 , 358 , -511 , 383 , -548 , 387 , -535 , 359 , -510 , 385 , -511 ,
383 , -600 , 355 , -541 , 363 , -506 , 389 , -507 , 387 , -570 , 355 , -541 , 363 , -506 , 388 , -508 ,
386 , -598 , 357 , -538 , 357 , -513 , 381 , -514 , 390 , -541 , 384 , -512 , 382 , -514 , 381 , -541 ,
363 , -594 , 361 ,-1341 , 387 ,-1343 , 384 , -539 , 355 , -576 , 359 , -537 , 357 , -512 , 381 , -560 ,
466 ,-21190 , 870 , -440 , 597

peros550 commented 5 years ago

@GPL71 you need the whole code, otherwise it does not work.

BUT as mentioned in one of my previous messages, there is a bug in the library that probably hasn't been fixed yet. Hopefully there is a workaround. and you need to check this discussion for more info

Basically every value higher than 9999 or lower than -9999 will make the system IR part fail.

In your code you captured -21190 which is not good. As a workaround, this must be replaced by -9999, -9999, -1192.

Try it and let us know.

curla92 commented 5 years ago

hi peros. i want to tell that now the firmware works. thanks for the help

peros550 commented 5 years ago

Just for the record and if you don’t mind, what was the issue?

royfocker19 commented 5 years ago

Hi Peros, is it possible to add dry and only fan option to the modes?