IoT Remote
Project Overview
With the increasing market of "smart" devices, more technologies than ever are able to be interacted with using the internet. In the wake of this expansion, certain legacy devices which can only be interacted with through IR technology are beginning to fall behind. The IoT remote will bridge the two connection methods, allowing an internet connection to control the passing of IR signals.
Hardware Devices Used
Wiring
mbed | IR LED |
---|---|
p21 | CTL |
p13 | GND |
VU | VCC |
mbed | IR Receiver |
---|---|
GND | GND |
p14 | OUT |
VU | VCC |
mbed | Pi |
---|---|
p28 | GPIO 22 |
Functionality
The IoT remote reads in an IR signal from a remote control. After a brief delay to confirm the data has finished sending, the IoT remote will store the signal's data. Once this data has been saved, the web server running on the Raspberry PI can be used to toggle I/O pins. If a control pin moves high, all of the data stored from each button press is retransmitted from the IR transmitter.
Demo Video
Code
Demo Code Usage
The program below allows the user to see the data received and eventually retransmitted from the IR devices. The PC serial connection is required in order to display the ASCII representation of the IR codes.
Pi Server
The following link was used to set up the remote server on the Pi. * https://tutorials-raspberrypi.com/setup-raspberry-pi-node-js-webserver-control-gpios/
Import programIR_Demo
Receives IR signals and stores them. Retransmits when a signal is received from the Pi server
#include "mbed.h" #include <vector> Serial pc(USBTX, USBRX); // tx, rx Serial device(p13, p14); // tx, rx DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalIn outCheck(p29); Timer t; PwmOut IRLED(p21); struct arrContainer { uint8_t buffer[20]; }; //IR send and receive demo //LED1 and LED2 indicate TX/RX activity //Character typed in PC terminal application sent out and returned back using IR transmitter and receiver int main() { //IR Transmit code IRLED.period(1.0/38000.0); IRLED = 0.5; //Drive IR LED data pin with 38Khz PWM Carrier //Drive IR LED gnd pin with serial TX device.baud(2400); vector<arrContainer> inputs; inputs.push_back(arrContainer()); int currInput = 0; int currLocation = 0; myled1 = 0.0; bool irInput = false; bool shouldPrint = true; t.start(); uint8_t temp; while(1) { //IR Receive code if(device.readable()) { if (temp = device.getc() && shouldPrint) { if (currLocation < 20) { inputs[currInput].buffer[currLocation++] = temp; } else { pc.printf("Full"); } if (shouldPrint) pc.putc(temp); t.reset(); irInput = true; } } // If more than 4 seconds has passed since receiving // a signal, store the data and await next input. if ((t.read() > 4) && irInput) { currInput++; inputs.push_back(arrContainer()); currLocation = 0; pc.printf(" Confirmed! \n\r"); irInput = false; } // If more than 8 seconds has passed resend the data // and output to terminal if (t.read() > 8 && outCheck) { for (int i = 0; i < currInput; i++) { for (int j = 0; j < 20; ++ j) { device.putc(inputs[i].buffer[j]); if (device.readable()) pc.putc(device.getc()); } } irInput = false; shouldPrint = false; wait(5); } } }
Please log in to post comments.