Arduino Wireless Communication - 01

Hasistranger

Well-known member
  • Oct 21, 2010
    13,426
    7,103
    113
    Western Province, SL
    my-journal-view.vercel.app
    ඔන්න මචන්ලා අද මම කියල දෙන්න යන්නේ arduino වල තියෙන වැදගත් module එකක් ගැන.ඒක තමයි NRF24L01 කියන RF Transceiver එක.මේ module එක අපි යොදාගන්නේ wireless communication සදහායි.මේ module එක ගොඩක් වැදගත් වෙන්නේ පහත සදහන් කරුණු කීපය නිසයි.


    • මිලෙන් අඩු වීම.
    • RF Links වලට වැඩිය ගුණාත්මක භාවයෙන් ඉහල වීම.
    • අඩු බලයකින් ක්‍රියාත්මක වීම.
    • එක module එකකට connections කීපයක් ඇති කරගන්න පුළුවන්.
    • මේ module දෙකක් අතර ඇති කරගන්නේ pipeline connection එකක් නිසා data නිවැරදිව ඒක module එකක සිට අනිත් module එකට transmit කිරීමට හැකිවීම.

    ඒ වගේම තමයි මේ එක module එකකින් Transmitting සහ Receiving කියන කාර්යයන් දෙකම ඉටු කරන නිසා මේ වර්ගයේ module වලට අපි කියනවා Transceivers කියල.ඒ නිසා අපිට මේ module දෙකක් ගත්තහම අපිට අපිට communication units දෙකක් හදාගන්න පුළුවන් , වගේම ඒ unit දෙකම transmitter & receiver විදිහට ක්‍රියාත්මක කරවන්න පුළුවන්.

    දැන් බලමු මේ module එකේ pin out වෙන විදිහ කොහොමද කියල.


    NRF24L01.jpg



    මේ උඩ තියෙන chart එකෙන් අපිට බලාගන්න පුළුවන් මේ module එකේ pin out වෙන විදිහ.මේ module එකේ pins 8ක් තිබ්බත් අපි පාවිච්චි කරන්නේ 7ක් විතරයි. ඒ 7නුත් 5ක් විතර තමයි අපිට arduino බෝඩ් එකත් එක්ක connect කරන්නේ.එක පැත්තකින් මේක පොඩ්ඩක් අවාසි සහගතයි. මොකද arduino බෝඩ් එකේ පින් 5ක්ම මේකට වෙන් වෙන නිසා අපිට ඉතුරු වෙන්නේ.පින් 7ක් විතරයි.

    හරි අපි දැන් බලමු කොහොමද මේ module එක වැඩ කරන හැටි.එකට අපි මුලින්ම පහල විදිහට Transmitter එකක් සහ Receiver එකක් හදාගමු.අපිට මේ වැඩේට ඕන කරනවා පහල දේවල්,



    දැන් අපි බලමු කොහොමද සර්කිට් දෙක හදන්නේ කියල.අපි පහල පින්තුරයේ විදිහට සර්කිට් දෙක හදාගමු.


    16lbtph.jpg



    Transmitter එකයි Receiver එකයි දෙකටම තියෙන්නේ එකම පරිපතයයි.Arduino Program එකෙන් තමයි
    Transmitter & Receiver කියල වෙන් වෙන්නේ.අපි දැන් බලමු මේකේ connections දෙන්නේ කොහොමද කියල.[FONT=&quot]

    [/FONT]

    • [FONT=&quot]NRF24L01 Transceiver එකේ [/FONT][FONT=&quot]+VIN[/FONT][FONT=&quot] පින් එක Arduino එකේ 3.3V පින් එකට සම්බන්ධ කරන්න.[/FONT]
    • [FONT=&quot][FONT=&quot]NRF24L01 Transceiver[/FONT] එකේ [/FONT][FONT=&quot][FONT=&quot][FONT=&quot]GND [/FONT][/FONT][/FONT][FONT=&quot] පින් එක [/FONT][FONT=&quot]GND එකට connect කරන්න.[/FONT]
    • [FONT=&quot][FONT=&quot]NRF24L01 Transceiver[/FONT] එකේ MISO[/FONT][FONT=&quot] පින් එක [/FONT][FONT=&quot]Arduino[/FONT][FONT=&quot] බෝඩ් එකේ [/FONT][FONT=&quot][FONT=&quot]D12 pin එකට[/FONT] connect කරන්න.[/FONT]
    • [FONT=&quot][FONT=&quot]NRF24L01 Transceiver[/FONT] එකේ SCK[/FONT][FONT=&quot] පින් එක [/FONT][FONT=&quot]Arduino[/FONT][FONT=&quot] බෝඩ් එකේ [/FONT][FONT=&quot][FONT=&quot]D13 pin එකට[/FONT] connect කරන්න.[/FONT]
    • [FONT=&quot][FONT=&quot]NRF24L01 Transceiver[/FONT] එකේ CE[/FONT][FONT=&quot] පින් එක [/FONT][FONT=&quot]Arduino[/FONT][FONT=&quot] බෝඩ් එකේ [/FONT][FONT=&quot][FONT=&quot]D9 pin එකට[/FONT] connect කරන්න.[/FONT]
    • [FONT=&quot][FONT=&quot]NRF24L01 Transceiver[/FONT] එකේ MOSI[/FONT][FONT=&quot] පින් එක [/FONT][FONT=&quot]Arduino[/FONT][FONT=&quot] බෝඩ් එකේ [/FONT][FONT=&quot][FONT=&quot]D11 pin එකට[/FONT] connect කරන්න.[/FONT]
    • [FONT=&quot][FONT=&quot]NRF24L01 Transceiver[/FONT] එකේ CSN[/FONT][FONT=&quot] පින් එක [/FONT][FONT=&quot]Arduino[/FONT][FONT=&quot] බෝඩ් එකේ [/FONT][FONT=&quot][FONT=&quot]D10 pin එකට[/FONT] connect කරන්න.[/FONT]
    • [FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot] Aruino Board [/FONT][/FONT][/FONT][/FONT][/FONT][FONT=&quot]එකේ VIN[/FONT][FONT=&quot] පින් එක 5V ධන අග්‍රයක් සම්බන්ධ කරන්න.[/FONT]
    • [FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot]Aruino Board [/FONT][/FONT][/FONT][/FONT][/FONT][FONT=&quot]එකේ [/FONT][/FONT][FONT=&quot][FONT=&quot][FONT=&quot]GND pin එක[/FONT][/FONT][/FONT][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot] 5V ඍන අග්‍රයක් සම්බන්ධ කරන්න.[/FONT][/FONT][/FONT][/FONT]
    [FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot]

    හරි අපි දැන් බලමු Arduino program එක කොහොමද කියල.අපිට මේ module එක ක්‍රියාත්මක කරගන්න උපයෝගී කරගන්නවා
    [/FONT]
    [/FONT]
    [/FONT]
    [/FONT]
    [FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot][FONT=&quot]Arduino Library එකක්.එක පහල ලින්ක් එකෙන් download කරගන්න .ඊට පස්සේ එක Arduino Library Folder එකට extra[FONT=&quot]ct කරගන්න.[/FONT]

    [FONT=&quot]NRF24L01 Library
    [/FONT]
    [/FONT]
    [/FONT]
    [/FONT]
    [/FONT]
    [/FONT]
    [/FONT]
    [/FONT]
    [/FONT]
    [FONT=&quot]
    [/FONT]
     

    Hasistranger

    Well-known member
  • Oct 21, 2010
    13,426
    7,103
    113
    Western Province, SL
    my-journal-view.vercel.app

    [FONT=&quot]හරි දැන් බලමු [/FONT][FONT=&quot]code [/FONT][FONT=&quot]දෙක .මුලින්ම මම දාන්නම් [/FONT][FONT=&quot]transmitter [/FONT][FONT=&quot]එකේ [/FONT][FONT=&quot]code [/FONT][FONT=&quot]එක.[/FONT]
    [FONT=&quot]

    Transmitter


    [/FONT]
    #include <SPI.h>
    #include <nRF24L01.h>
    #include <RF24.h>

    RF24 radio(9,10);

    constbyte rxAddr[6] = "00001";

    voidsetup
    (){

    [FONT=&quot]
    [/FONT]Serial.begin(9600);
    radio.
    begin();
    radio.setRetries(15, 15);
    radio.openWritingPipe(rxAddr);
    radio.stopListening();

    }

    voidloop(){

    constchar text[] = "Hello World";
    radio.
    write(&text, sizeof(text));[FONT=&quot]
    [/FONT]Serial.println("Sent:");
    Serial.println(text);
    Serial.println();
    delay
    (1000);

    }
    [FONT=&quot]
    [/FONT]
    [FONT=&quot]

    [/FONT]
    [FONT=&quot]
    [/FONT][FONT=&quot]Receiver

    [/FONT]

    #include <
    SPI.h>
    #include <nRF24L01.h>
    #include <RF24.h>

    RF24 radio(9,10);
    constbyte rxAddr[6] = "00001";

    voidsetup(){

    while
    (!Serial);
    Serial
    .begin(9600);
    radio.
    begin();
    radio.openReadingPipe(0, rxAddr);
    radio.startListening();

    }


    voidloop
    (){

    if
    (radio.available()) {

    char text[32] = {0};
    radio.
    read(&text, sizeof(text));
    Serial.println(text);
    }
    }
    [FONT=&quot]
    [/FONT]
    [FONT=&quot]



    [/FONT]
    [FONT=&quot]මෙතැනදී [/FONT][FONT=&quot],

    [/FONT]
    RF24 radio(9,10);
    [FONT=&quot]
    [/FONT]
    [FONT=&quot]මේ කොටසේදී කියන්නේ[/FONT][FONT=&quot] module [/FONT][FONT=&quot]එක [/FONT][FONT=&quot]Data Transmit & Receive [/FONT][FONT=&quot]කරන්නේ[/FONT][FONT=&quot] 9 [/FONT][FONT=&quot]සහ[/FONT][FONT=&quot]10[/FONT][FONT=&quot] ([/FONT][FONT=&quot]CE[/FONT][FONT=&quot],[/FONT][FONT=&quot]CSN[/FONT][FONT=&quot]) [/FONT][FONT=&quot]කියන පින් දෙකෙන් කියල.මේ පින් දේකට අපිට[/FONT][FONT=&quot]D2 [/FONT][FONT=&quot]සිට[/FONT][FONT=&quot]D10[/FONT][FONT=&quot]වෙනකන් ඕනෑම පින් දෙකක් දෙන්න පුළුවන්.[/FONT][FONT=&quot]

    [/FONT]
    constbyte rxAddr[6] = "00001";
    [FONT=&quot]
    [/FONT]
    [FONT=&quot]
    [/FONT][FONT=&quot]මේ කොටසේදී කියන්නේ මේ [/FONT][FONT=&quot]module [/FONT][FONT=&quot]එක [/FONT][FONT=&quot]access [/FONT][FONT=&quot]කරන්න පුළුවන් මේ [/FONT][FONT=&quot]address [/FONT][FONT=&quot]එකෙන් [/FONT][FONT=&quot], [/FONT][FONT=&quot]ඒ කියනේ [/FONT][FONT=&quot]module [/FONT][FONT=&quot]දෙක අතර [/FONT][FONT=&quot]data pipeline [/FONT][FONT=&quot]එකේ [/FONT][FONT=&quot]address [/FONT][FONT=&quot]එක.මෙතැනදී [/FONT][FONT=&quot]transmitter [/FONT][FONT=&quot]සහ [/FONT][FONT=&quot]receiver [/FONT][FONT=&quot]කියන දෙකේම [/FONT][FONT=&quot]pipeline address [/FONT][FONT=&quot]එක සමාන වෙන්න ඕනේ.[/FONT][FONT=&quot]


    [/FONT]
    [FONT=&quot]හරි දැන් අපි උඩ තියෙන පින්තුරයේ විදිහට සර්කිට් දෙක හදාගත්තනම්[/FONT][FONT=&quot], [/FONT][FONT=&quot]එක [/FONT][FONT=&quot]unit [/FONT][FONT=&quot]එකකට [/FONT][FONT=&quot]transmitter code [/FONT][FONT=&quot]එක [/FONT][FONT=&quot]upload [/FONT][FONT=&quot]කරන්න [/FONT][FONT=&quot], [/FONT][FONT=&quot]අනිත් [/FONT][FONT=&quot]unit [/FONT][FONT=&quot]එකට [/FONT][FONT=&quot]receiver code [/FONT][FONT=&quot]එක [/FONT][FONT=&quot]upload [/FONT][FONT=&quot]කරන්න. ඊට පස්සේ [/FONT][FONT=&quot]unit [/FONT][FONT=&quot]දෙකම [/FONT][FONT=&quot]power up [/FONT][FONT=&quot]කරලා [/FONT][FONT=&quot]unit [/FONT][FONT=&quot]දෙකේම [/FONT][FONT=&quot]serial monitor [/FONT][FONT=&quot]දෙක [/FONT][FONT=&quot]open [/FONT][FONT=&quot]කරන්න.[/FONT][FONT=&quot]

    [/FONT]
    [FONT=&quot]එතකොට අපිට බලාගන්න පුළුවන්[/FONT][FONT=&quot] transmitter unit [/FONT][FONT=&quot]එකෙන්[/FONT][FONT=&quot] receiver unit [/FONT][FONT=&quot]එකට "[/FONT][FONT=&quot]Hello World" [/FONT][FONT=&quot]කියන [/FONT][FONT=&quot]message [/FONT][FONT=&quot]එක [/FONT][FONT=&quot]transmit [/FONT][FONT=&quot]කරනවා.[/FONT][FONT=&quot]

    [/FONT]
    [FONT=&quot]මම හිතනවා ඔයාලට මේකෙන් යම් දැනුමක් ලැබෙන්න ඇති කියල.එහෙනම්[/FONT][FONT=&quot]තවත් අලුත් ත්‍රෙඩ් එකක් ගෙන බලාපොරොත්තුවෙන් මම නවතින්නම්.[/FONT][FONT=&quot]

    [/FONT]
    [FONT=&quot]මගේ කලින් ත්‍රෙඩ්.[/FONT][FONT=&quot]

    [/FONT]
    [FONT=&quot]
    [/FONT][FONT=&quot][FONT=&quot]ගෙදර විදුලිය ඉතිරි කරගමු[/FONT]

    [/FONT]
    [FONT=&quot]Arduino Shift Registers

    Wireless Home Automation System ( Arduino + ESP8622 + Java )

    [/FONT]
    [FONT=&quot]RGB L.E.D + Arduino with Acrylic Table Deco



    [/FONT][FONT=&quot]
    [/FONT]
    [FONT=&quot]මගේ බ්ලොග් එකට ගියානම් ඔයාලට ගොඩක් දේවල් ඉගෙන ගන්න පුළුවන්.[/FONT][FONT=&quot]

    [FONT=&quot]මගේ බ්ලොග් එකට[/FONT]


    [/FONT]
     
    Last edited:

    lag8777

    Well-known member
  • Sep 16, 2008
    5,254
    516
    113
    machan mata podi help ekak one. aththama kiwwoth mata neme ape maamata. night rider tale lamp eke C walin liyau program ekak thiyanwada? mata ahanna kiwwa widiya tamai oka :D
     

    Ysa Karu

    Well-known member
  • May 29, 2014
    20,433
    1
    10,680
    113
    පට්ට වැඩක් මචන්.දිගටම කරගෙන යමු...:cool::cool::cool: