Friday, February 19, 2016

Infrared Transmitter Sensor Driver for Raspbery pi


37 sensor kit box is shipped with a Infrared Transmitter sensor. Alike Line Tracking Sensor, this one also a single pin sensor, turned on infrared while got ON / High on Signal port.

Hardware Description :
The IRT sensor circuit is very simple, just consist of a Infrared LED. The sensor got 3 physical PIN, and only Signal marked as S. Well, the middle on is for Volt [5v], and last one is for GND.
S is connected to GPIO – 2.



So, the wiring is like →

Wiring -
G – Ground [ rpi – 6]
V+ –  power [ rpi – 2]
S – control signal [rpi – 3 / GPIO – 2]

From the Line Tracking Driver post, here got different is, this sensor is await for client program to fill with High / Low to GPIO-2. So here things are like →

first set the gpio direction.
gpio_direction_output (gpio_irtr, 0);

Afterwards,
taking user_space buffer to kernel space, comparing the kernel space array, whether its High [1] or Low [0], and then gpio_set_value accordingly.

cp_cnt = copy_from_user (irtr_st, buffer, sizeof(irtr_st));



if (irtr_st[0] == '1'){

gpio_set_value (gpio_irtr, 1);

}

else if (irtr_st[0] == '0'){

gpio_set_value (gpio_irtr, 0);

}

All other stuff is almost / totally same like previous driver post.

A full source code will be found here.

Whether this IR sensor is function with the driver and client space program - cannot be justify through your blind eye, use your mobile camera in a dark room.

No comments:

Post a Comment