IceBurnHex
IceBurnHex

Reputation: 3

Is there a way to turn ESP32-WROOM-32D on a SparkFun Thing Plus into an IR Transmitter for a remote replacement on an old Benq Projector?

I'm still new to learning about Arduino, ESP32, and IR Transmission in general. So bare with me as I'm a bit uneducated with some of the terminology.

As the title states, I have a SparkFun Thing Plus module I'd like to try to turn into a replacement remote for an older Benq Projector. That way I can sent up Alexa commands for it and automate it blanking the screen, etc. I have managed to work my way to connecting it to WiFi, as well as using Alexa to turn on the built in blue LED (pin13). However, trying to get it to send to a transmitter I have (audiojack plug in, 3.3V plus signal wire) I've ran into it just not working. Could be my code, could be my lack of understanding of how it works, or maybe I'm just putting things on the wrong pins. I dont know at this point, I just know it compiles without errors.

Let me know what you think, maybe I'm just using the wrong type of device? Or maybe I'm missing something completely about making a transition for this. Thanks again in advance!

https://learn.sparkfun.com/tutorials/esp32-thing-plus-hookup-guide/all

#include <Arduino.h>
#define ESP32
#include <WiFi.h>
#include "fauxmoESP.h"
#include "login.h"
fauxmoESP fauxmo;
// -----------------------------------------------------------------------------
#define SERIAL_BAUDRATE     115200
#define LED_BLUE            13
#define ID_BLUE             "TEST_ON_LED"
#define IRSensor            5                 //NOT SURE HOW TO IMPLEMENT THIS
#define ID_IR               "IRSensor"        //NOT SURE HOW TO IMPLEMENT THIS
// -----------------------------------------------------------------------------
#include <IRremote.h>
IRsend irpower;
#define BLANK_CODE  0xCE01F
#define OK          0xCA857
#define RIGHT_ARROW 0xC708F
#define LEFT_ARROW  0xCB04F
#define UP_ARROW    0xCD02F
#define DOWN_ARROW  0xC30CF
#define BLANK       0xCE01F
#define RETURN      0xCA15E
#define POWER       0xC40BF
#define MENU        0xC20DF
#define AUTO        0xC10EF
#define SETTINGS    0xCF00F

// -----------------------------------------------------------------------------

void wifiSetup() {          //THIS SECTION WORKS
  WiFi.mode(WIFI_STA);
  Serial.printf("[WIFI] Connecting to %s ", WIFI_SSID);
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(100);
  }
  Serial.println();
  Serial.printf("[WIFI] STATION Mode, SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), 
  WiFi.localIP().toString().c_str());
}

void setup() { 

  Serial.begin(SERIAL_BAUDRATE);
  Serial.println();
  Serial.println();

  pinMode(LED_BLUE, OUTPUT);
  digitalWrite(LED_BLUE, LOW);

  // Wifi
  wifiSetup();

  fauxmo.createServer(true);
  fauxmo.setPort(80);

  fauxmo.enable(true);

  // Add virtual devices
  fauxmo.addDevice(ID_BLUE);
  fauxmo.addDevice(ID_IR);

  fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
      uint8_t len = 32;
      uint32_t datab = BLANK;

    Serial.printf("[MAIN] Device #%d (%s) state: %s value: %d\n", device_id, device_name, state ? "ON" : "OFF", value);

    if (strcmp(device_name, ID_BLUE) == 0) {
      digitalWrite(LED_BLUE, state ? HIGH : LOW);       //INDICATES IF ALEXA IS WORKING WITH COMMAND
    }
    if (strcmp(device_name, ID_IR) == 0) {
      irpower.sendNEC(datab,len);
    }
  });

}

void loop() {
  
  fauxmo.handle();

} ```

Upvotes: 0

Views: 198

Answers (1)

Adriano
Adriano

Reputation: 1892

The module is not able to transmit over IR, as it doesn't have a IR. Firstly, you need to buy a IR transmitter (https://www.sparkfun.com/products/18772 if you like sparkfun).

To drive this IR transmitter, you need to find the right frequence/pulse. Or, you can download the IR-remote Arduino library directly from your IDE:

https://github.com/Arduino-IRremote/Arduino-IRremote

This library is able to encode or decode the IR-signal.

Check the examples inside this library for more information.

Upvotes: 0

Related Questions