UPDATE: thanks for all the help guys, I managed to sort off run the transmitter and receiver and achieve communication. next is to be able to translate an image to binary representation whih i already have an idea and then trying to send it. thanks a lot again for everyone who helped
Hello guys. i am complete begginer with arduino and infrared communication an i would like to get some help.
my goal is to be able to send an image using simple IR transmitter connected to arduino nano and receiver the image and present it using simple IR receiver connected to another arduino nano.
I have been trying for a few days to establish reliable communication between the two and got to situation that when trying to send "hello" the message is received but the print is "F6360000".
I would like to get some help and guidence for what do you think I should do now, what functions will be best for transfering the image and why my current sketch doesnt fully works.
I am providing some links for the IR transmitter and receiver modules I have. the first 2 are my currently used ones but i can easilly use any from the list. in addition I am providing the sketches for transmitter and receiver I currently have.
#include <IRremote.h>
// Define the IR receiver pin
const int IR_PIN = 11;
// Define the IR receiver object
IRrecv irrecv(IR_PIN);
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
// Check if the IR receiver has received a signal
if (irrecv.decode()) {
// Print the HEX value of the button press
Serial.println(irrecv.decodedIRData.decodedRawData, HEX);
// Reset the IR receiver for the next signal
irrecv.resume();
}
}
transmitter sketch:
#include <IRremote.h>
// Define the IR transmitter pin
const int IR_PIN = 3;
// Define the IR transmitter object
IRsend irsend(IR_PIN);
void setup() {
Serial.begin(9600);
}
void loop() {
// Send the IR signal
irsend.sendNEC("Hello", 32);
delay(1000);
}
I know this post is long and exusting so I'm really thanking you in advance for any help.
please, please never ever again post pictures of text... Not only they are not readable nor usable directly for copy&paste but they use up lots of storage and internet bandwidth which contributes to polluting the planet.
β do your part and do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).
at the very minimum you should use double quotes for a string
irsend.sendNEC('Hello',32);
but would advise to read the documentation of irsend.sendNEC as it does not work that way
Your approach using the IR library for this, that is converting each character to an NEC remote code, may be wrong and will make a very clumsy communications channel.
Better would be to use the serial directly to energise an IR led, maybe via a transistor, possibly modulating a 38kHz carrier and, on the other side, a photo transistor (or maybe a special IR receiver balanced for data transmission e.g. Vishay TSDP34138 https://www.vishay.com/docs/82667/tsdp341.pdf ). A quick search for an example yields this (grim) video https://www.youtube.com/watch?v=TRbMfGUXVZo which at least demonstrate the principle. The referenced website causes a security warning in my browser so I don't recommend following the link.
I did use something very similar to program a schedule into a number of time switches over IR in an old project. Some solutions are appropriate only for short ranges.
First, thank you for your answer.
The problem is that i must use infrared communication and I cant purchase more components. I have 2 of a transmitter+receiver component that I sent which has Serial communication (TTL level) and other functions that I can send (i dont want to overwrite here).
what would you reccomend me to do and how to continue? I am honestly clueless
yes you are right, no need for 2 way communication. about the range and size of data, I dont have specific requirements just for the image to pass successfully so I am starting with short distance (20-100 cm for start) and small image/string for start and then increasing both while making progress
Are these images in the form of pictures (say JPEG files) ? How are you going to read this data into the Arduino for transmission and what are you going to do with it at the other end when you have received it ?
the idea is to be able to send bytes successfuly from the transmitter to the receiver. once I have that I can represend each pixel in the image on a certain way that will be sent to the receiver which will build the image based on the pixels it received
continuing my respond: in grayscale each pixel has a value 0-255 so the goal is that the transmitter will send each pixel color number for each pixel and the receiver will build the image based on that. currently i would like to succesffully send a message from the transmitter and decode it in the receiver and then i will be able to continue working about sending an image
I not sure, this codes are taken from the internet I just continued with the thing that kinda work. this code as i mentiened successfully receives a message from the transmitter but it cant decode it properly.
This Library either sends raw data that gets decoded or a two byte address and 1 byte command.
That could be leveraged for a (slow) encoding of each byte of the image. Some protocol around it would be needed like adding a start keyword, sending the length of the payload and possibly a crc
so based on your expirience do you see anything wrong with the code?
is it suitable for my IR receiver and transmitters specific models?
receiver: 38 khz, digital signal type
transmitter:
Port: Digital level
Modulation: Direct transmission No modulation
Type: Voltage Regulator
the code i sent in the first message, do you think that the way i send and receive the data is suitable for my components?
you are right about the string, corrected it in the code but it didnt helped a lot (just changed the output but it is still not hello unfortunatly). now updated here in the post