Project in progress

You can turn on the TV at ANY TIME. © CC BY-NC

You can turn on the TV at ANY TIME.

  • 1,418 views
  • 0 comments
  • 11 respects

Components and supplies

Ardgen mega
Arduino Mega 2560 & Genuino Mega 2560
×1
Wizwiki 7500
WIZnet WIZwiki-W7500
×1
Arduino Ethernet shield
×1
IR receiver & transceiver sensor
×1

Necessary tools and machines

mbed
mbed compiler

About this project


IoT era.

Many things can be controlled remotely. Bluetooth or WiFi is used to these. But I am making is too difficult and expensive. I can more easily access the IR remote module in the surrounding.

So, I decided to use the Infrared remote.

IR Gateway!

Step 1: Parts for making it


1. Remote controller.

I use the remote controller a feature of the smartphone

2. IR Receiver

Arduino + Ethernet Shield + IR Recive Sensor (It contained in Total Sensor Board)

3. IR Transceiver

WIZwiki W7500(mbed platform) + IR Transceive Sensor(It connected with Seeed studio's interface board)

Step 2: Flow

You can turn on the TV at everywhere.

1. Press the power button on the remote control.

2. Arduino + IR receiver reads the IR value. (ex, 0x20 0xDF 0x10 0xEF)

3. Arduino + ethernet shield is transmitted to the server in a specified format.

(NEC, 0010 0000 1101 1111 0001 0000 1110 1111)

4. WIZwiki-W7500 TCP server receives a fixed format.

(NEC, 0010 0000 1101 1111 0001 0000 1110 1111)

5. Binary Format Conversion

0000 0100 1111 1011 0000 1000 1111 0111

6. And it transmits the IR data. Because Bits are stored in reverse order.

Final HEX values: 0x04 0xFB 0x08 0xF7

Step 3: Can my TV get the same value via direct and indirect path?

I tested that my TV can receive the same values from different paths.

So, I used Arduino + IR receive sensor. Then uploaded demo firmware (IRrecvDemo - Arduino example source code) author: Ken Shirriff's IRremote library(http://arcfn.com)

I tested that IRrcvDemo program has received the same.

1. Direct path.

When I used my IR remote controller, IRrcvDemo program received 0x20 0xDF 0x10 0xEF when Power button pressed.

2. Indirect path.

When I used the IR library in mbed(https://developer.mbed.org/users/shintamainjp/code...

I sent 0x20 0xDF 0x10 0xEF, IRrcvDemo program received 0x04 0xFB 0x08 0xF7..

In both cases, IRrcvDemo program received a differnet value.

I fell into chaos.

So, I had checked Binary code.

0x20 0xDF 0x10 0xEF ==> 0010 0000 1101 1111 0001 0000 1110 1111

0x04 0xFB 0x08 0xF7 ==> 0000 0100 1111 1011 0000 1000 1111 0111

!!! An array of bits had been opposed.

So, I tried to make bits to inverse in mbed & Transceiver

Step 4: When TCP Client sent specific Packet to TCP SERVER & IR TRANSCEIVER

I sent the specific Packet like "NEC,00100000110111110001000011101111".(Protocol,Bit string)

W7500(TCP SERVER&IR TRANSCEIVER) can receive the right packet and send the reversed IR code.

So, IRrcvDemo program received the right data that I want.

Step 5: When I use the IR Remote controller


How to send specific Packet that I want.

I want to send sepcific packet like "NEC,00100000110111110001000011101111" when I pressed the Power button on my remote controller.

When I Press the power button on my remote controller, Arduino+Ethernet Shield+IR receiver can receive the data like "0x20 0xDF 0x10 0xEF".

So, I had to change to the specific format. (NEC,00100000110111110001000011101111)

Then that packet send to the TCP Server.

Step 6: Finally, When I press the Power, Could my TV be received correctly?


When I press the power,

TCP Server can receive the right packet(NEC,00100000110111110001000011101111)

AND send the reverse packet(0x04 0xFB 0x08 0xF7)

......

My RECEIVER(IRrcvDemo program) can receive the same data as a Direct path.

Step 7: Result.


WOW, my TV received same data in two cases.

Receiver side Source code included in this article.

And IR transceiver side Source code included in mbed repository.

(https://developer.mbed.org/users/jehoon/code/IR_Gateway/)


Schematics

WIZwiki-W7500.png
Wizwiki w7500
sche1.PNG
Sche1

Code

IR_receiver.inoPlain text
//Sending ir codes over ethernet
//This sketch accept IR from an IR sensor connected to Pin 6 and sends over IP
// parts of the code for storing ir in to buffer is from  Ken Shirriff's ir recorder http://arcfn.com
//
//                       THIS ONE PICKS IR FROM A REMOTE
//
#include <IRremote.h>
#include <SPI.h>
#include <Ethernet.h>
 

int RECV_PIN = 6;
IRrecv irrecv(RECV_PIN);
decode_results results;
 
// Network settings 
byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //MAC
byte gateway[] = { 192,168,29,1 };// Gateway
byte ip[] = { 192,168,29,190 };  //ip if dhcp fails 
 
// IP of the Target arduino with ir emitter
IPAddress server(192,168,29,150);  
EthernetClient client;

char rawCodes[RAWBUF]; // The durations if raw
int codeLen; // The length of the code
//Get the infrared codes from remote

void storeCode(decode_results *results) {
//  NEC,00100000110111110001000011101111\n
  int count = results->rawlen;
  int j = 0;
  Serial.println("Received code");
  codeLen = results->rawlen - 1;
    for (int i = 3; i <= codeLen; i++) {
      if (i % 2) {
        Serial.print("");
      } 
      else {
        // Space
         if(results->rawbuf[i] > 25)
             rawCodes[j++] = '1';
          else
             rawCodes[j++] ='0';
      }
   }
    codeLen = j;
}

 
void setup()
{
  // For debug
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  // Start ethernet
  Ethernet.begin(mac, ip, gateway);
  Serial.println("Initialised");
}

//sending the raw IR code over the ether net

void sendIR(decode_results *results)
{
    char tmp[50] = {'\0'};
    int n=0;
    // Send over HTTP
    if (client.connect(server, 5000))
    {
      Serial.println("connected");
 
       if (results->decode_type == UNKNOWN) {
         n = strlen("UNKNOWN,");
        strcpy(tmp,"UNKNOWN,");
      } 
      else if (results->decode_type == NEC) {
        n = strlen("NEC,");
        strcpy(tmp,"NEC,");
      } 
      else if (results->decode_type == SONY) {
        n = strlen("SONY,");
        strcpy(tmp,"SONY,");
      } 
      
      for (int i = n; i < codeLen+n; i++) {
        tmp[i] = rawCodes[i-n];
      }
     Serial.println(tmp);
     client.print(tmp);
     client.stop();
    } 
  
}
 

void loop()
{
  if (irrecv.decode(&results))
  {
    Serial.println(results.value, HEX);
    storeCode(&results);
    sendIR(&results);
    irrecv.resume(); // Receive the next value
  }
 
}

Comments

Similar projects you might like

Pac-Man LED Pixel Panel Costume

Project tutorial by Ben Muller

  • 4,150 views
  • 3 comments
  • 73 respects

LoRa Gateway for DeviceHive

Project tutorial by DeviceHive IoT team

  • 980 views
  • 2 comments
  • 16 respects

SmartWay

Project tutorial by Universum

  • 142 views
  • 0 comments
  • 4 respects

Raspberry Pi and Arduino Laptop

Project tutorial by Dante Roumega

  • 17,305 views
  • 6 comments
  • 42 respects

IoT Bird Feeder with Sigfox and Tweeter

Project showcase by Gaël Porté

  • 289 views
  • 0 comments
  • 4 respects

Arduino-Based Automatic Guitar Tuner

Project tutorial by Ben Overzat

  • 2,650 views
  • 0 comments
  • 10 respects
Add projectSign up / Login