This is an Arduino sketch created in order to connect several devices and be able to retransmit IR signals among all devices using my ForoElectro.Net MQTT server.
You need one MQTT account: https://www.foroelectro.net/arduino/en/mqtt-doc
You can register it for free.
This library requires several libraries.
Libraries available on IDE Library Manager:
- uMessagesBrokerLib - https://github.com/Naguissa/uMessagesBrokerLib - Message broker
- uHexLib pulled by uMessagesBrokerLib - https://github.com/Naguissa/uHexLib - Hexadecimal encoding/decoding
- uEspConfigLib - https://github.com/Naguissa/uEspConfigLib - Configuration
- uEEPROMLib pulled by uEspConfigLib - https://github.com/Naguissa/uEEPROMLib - Suport for configuration on external EEPROM
- pubsubclient3 - https://github.com/hmueller01/pubsubclient3 - MQTT support
Libraries included in the sketch:
- IRremoteESP8266 - https://github.com/crankyoldgit/IRremoteESP8266 - Included because needs a fix in a PR still not merged: https://github.com/crankyoldgit/IRremoteESP8266/pull/2144/filessrc/
You can compile the sketch using Arduino IDE with ESP8266 or ESP32 support.
This sketch uses LittleFS in order to store configurations. You need to set a minimal SPIFFS space when uploading. It only needs few kbytes.
Configuration is not encrypted, so take it in mind.
Once uploaded it will be a new WiFi open network available, called IR-MQTT-AP.
Connect to that AP, navigate to http://192.168.4.1, set correct values and save.
After resetting itself it will be connected to your network.
If you enable debug functionality at configuration page you will see a lot of info, as its IP, via serial monitor. If debug is not enabled Serial will not be initialized, letting you use these pins (i.e.: in ESP8266 ESP01)
You need one IR emitter (940nm) and one IR receiver. Also, an generic NPN transistor (BC547, 2N3904 or A42 are good examples).
- IR receiver: https://www.foroelectro.net/arduino/link/receptor-decodificador-ir
- IR emitter: https://www.foroelectro.net/arduino/link/kit-emisor-ir-led
- Transistor (pack): https://www.foroelectro.net/arduino/link/lote-transistores-bjt
- Resistor, 10 to 100 Ohm (pack): https://www.foroelectro.net/arduino/link/lote-resistencias-1w
In order to IR emitter work correctly you need the NPN transistor as stated here: https://github.com/crankyoldgit/IRremoteESP8266/wiki#ir-sending
You can change several configurations using following variables on setup page (access ESP IP using same network, by default it's http://192.168.4.1 ):
-
wifi_mode - WiFi mode (C=Client, other=Access Point). By default it starts as AP
-
wifi_ssid - WiFi SSID. By default it's IR-MQTT-ESP
-
wifi_password - WiFi password. By default if's empty, no password
-
mqtt_server - Mqtt server address. By default it's foroelectro.net
-
mqtt_port - Mqtt server port. Byd efault it's 1883
-
clientName - Mqtt client name. It's used to skip resending own messages, each device has to have a different name. By default it's IrMqttEsp
-
ApiKey - ApiKey from https://www.foroelectro.net/arduino/en/mqtt-doc. Get one for free on https://www.foroelectro.net/arduino/en/mqtt-doc
-
email - Email corresponding to your ApiKey. Get one for free on https://www.foroelectro.net/arduino/en/mqtt-doc
-
topic - Subtopic where messages are directed; can be empty if you want. It's empty by default
-
kRecvPin - Pin number where IR demodulator is connected. By default it's 14 (D5 on a NodeMCU board)
-
kIrLed - Pin number where base of NPN transistor to IR emitter is connected. By dfault it's 4 (D2 on a NodeMCU board)
-
kMinLen - Signal minimal length. Default: 10
-
kTimeout - Milli-Seconds of no-more-data before we consider a message ended. By default it's 50
-
debugActive - Serial port debug (1=enabled, other=disabled). By default it's disabled.
- Naguissa
- https://www.foroelectro.net/proyectos-personales-f23/repetidores-de-infrarrojos-usando-esp-y-mqtt-t465.html
- https://www.naguissa.com
Any code contribution, report or comment are always welcome. Don't hesitate to use GitHub for that.
- You can sponsor this project using GitHub's Sponsor button: https://github.com/Naguissa/IR-MQTT-ESP
- You can make a donation via PayPal: https://paypal.me/foroelectro
Thanks for your support.
Contributors hall of fame: https://www.foroelectro.net/hall-of-fame-f32/contributors-contribuyentes-t271.html
