ความรู้แน่น ฟรีสำหรับชุมชน ArduinoAll ที่นี่เท่านั้น

ฟรีและดีที่สุด คอร์สอบรม Arduino + NodeMCU
ทำเพื่อแบ่งปัน ห้ามนำไปจำหน่าย หรือเก็บเงินค่าเรียน
  !!!


  


AllNewStep รับประกันคุณภาพทุกชิ้น วันจันทร์-ศุกร์แจ้งชำระสินค้าก่อน 14.00 จัดส่งทันทีวันนี้ค่ะ

กรุงเทพ /ภาคกลาง ได้พรุ่งนี้


*** สินค้าทุกชิ้น ถ้าสามารถทำรายการสั่งซื้อได้ แสดงว่ามีครบทุกรายการค่ะ *** 

พิมพ์ค้นหาบทความ หัวข้อกระทู้ และสินค้าในเว็บ AllNewStep ได้ที่นี่
QUOTE 

NRF24L01 ปรับความเร็วการส่งข้อมูลอย่างไรครับ

Keem Coe

ผมสั่ง NRF24L01 PA LNA  มาคู่นึง และ arduino atmega8 ทดสอบตามโค้ดที่ได้แนะนำในบทความแล้วทำงานได้ดีครับ (ขอบคุณสำหรับโค้ดตัวอย่างด้วยครับ) ผมอยากถามเพิ่มเติมดังนี้ครับ
- ไลบรารี่ที่ให้มาสามารถกำหนดความเร็วในการส่งได้มั้ยครับ เพราะจากข้อมูลในดาต้าชีตถ้าส่งที่ความเร็วตำสุดสามารถส่งได้ไกลสุดใช่มั้ยครับ

- สามารถรับและส่งข้อมูลพร้อมๆกันเลยได้มั้ยครับ เช่น A ส่งข้อมูลไป B ได้รับก็ตอบ ACK กลับมาเพื่อยืนยันข้อมูลและไม่ทราบว่ามันรับส่งกันแบบ half duplex หรือ full duplex ครับ พอจะมีข้อมูลมั้ยครับ

....ตัวนี้ผมจะทำเป็นตัวแปลงข้อมูล serial (uart) แล้วส่งแบบไร้สายไป อีกฝั่งก็รับแล้วส่งต่อออกไปเป็น serial uart อ่ะครับ

ขอบคุณครับ

QUOTE 
ความคิดเห็นที่ #81
Satn

พอจะมีวิธีแก้ไมครับ ผมลองทำทุกทางที่พอจะทำได้แล้ว ไม่สามารถแก้ได้เลยครับ

QUOTE 
ความคิดเห็นที่ #82
เจ้าของร้าน

ต่อแบบไหนครับ ขอรายละเอียดการต่อด้วยครับ

QUOTE 
ความคิดเห็นที่ #83
Satn

ต่อตามที่เพจสอนเลยครับ

QUOTE 
ความคิดเห็นที่ #84
Satn

นี้คือรูปครับ เวลากดเช็ค

http://www.mx7.com/view2/ztzEAZ23lGnkV0Jn

QUOTE 
ความคิดเห็นที่ #85
เจ้าของร้าน

คอมไพล์ผ่านปกตินะครับ ลองเช็คไลบารี หรือเปลี่ยนมาใช้ Arduino IDE เวอร์ชัน 1.6.9

QUOTE 
ความคิดเห็นที่ #86
พรเทพ

อยากถามว่าผมใช้บอร์ดstm32f103cพอลองเขียนโค้ดตรงsetbitorderไม่ขึ้นอักษรสีส้มอะคับต้องแก้ยังไงดี

QUOTE 
ความคิดเห็นที่ #87
พรเทพ

ผมอยากรู้ว่าถ้าจะต่อกับบอร์ดstm32f103c8ต้องต่อกับportไหนบ้างคับ

QUOTE 
ความคิดเห็นที่ #88
เจ้าของร้าน

ใครยังไม่ได้ ลองตัวนี้ดูครับ ต่อวงจรเหมือนกัน เครดิสคุณ guspice

รับและสงใน file เดียวกัน

อ้างอิง http://shanes.net/another-nrf24l01-sketch-string-sendreceive/

 

/*

  nRF Serial Chat

 

  Date : 22 Aug 2013

  Author : Stanley Seow

  e-mail : stanleyseow@gmail.com

  Version : 0.90

  Desc :

  I worte this simple interactive serial chat over nRF that can be used for both sender

  and receiver as I swapped the TX & RX addr during read/write operation.

 

  It read input from Serial Monitor and display the output to the other side

  Serial Monitor or 16x2 LCD (if available)... like a simple chat program.

 

  Max payload is 32 bytes for radio but the serialEvent will chopped the entire buffer

  for next payload to be sent out sequentially.

 

*/

 

 

#include

#include "nRF24L01.h"

#include "RF24.h"

#include "printf.h"

 

/* 1 - GND

  2 - VCC 3.3V ONLY!!!

  3 - CE to Arduino pin 9

  4 - CSN to Arduino pin 10

  5 - SCK to Arduino pin 13

  6 - MOSI to Arduino pin 11

  7 - MISO to Arduino pin 12

  8 - NA

  This sketch receives and sent strings from nrf24

  and prints them out via serial.

*/

int msg[1]; //Holding your sent message

#define CE_PIN 8

#define CSN_PIN 7

RF24 radio(CE_PIN, CSN_PIN);

// Radio pipe addresses for the 2 nodes to communicate.

const uint64_t pipe = 0xE8E8F0F0E1LL;

 

String theMessage = ""; //Received Message

String inputString = ""; //Hold incoming Message from Serial

 

void setup(void) {

  Serial.begin(9600);

  while (!Serial) {} //Needed for Leonardo

  radio.begin(); //Start the radio

  radio.setRetries(15, 15); // optionally, increase the delay between retries & # of retries

  radio.setPayloadSize(8);// optionally, reduce the payload size.

  radio.openWritingPipe(pipe);

  radio.openReadingPipe(1, pipe);

  radio.startListening();

}

 

void loop(void) {

  if (radio.available()) { //Wait for incoming message from radio

    receiveText(); //Call funtion to receive message

  }

}

 

void receiveText() {

  radio.read(msg, 1); //Read radio 1 char at a time

  char theChar = msg[0]; //Stor it in theChar

  if (msg[0] != 2) { //If you get \n char then

    theMessage.concat(theChar); //link all together

  }

  else { //If done then

    Serial.println(theMessage); //Print to serial

    theMessage = ""; //Clear Message

  }

}

//This is same as EXAMPLE CODE it just works this better. NO ERRORS

void serialEvent() { //if something happens in serial do this

  while (Serial.available()) { //Do till you get all from serial

    char inChar = (char)Serial.read(); // get the new byte:

    delay(3); //*****I add this else you get broken messages******

    inputString += inChar;// add it to the inputString:

  }

  sentText(); //Call function to sent message to other radio

}

 

void sentText() {

  radio.stopListening(); // First, stop listening so we can talk.

  // String theMessage = inputString; //

  int messageSize = inputString.length(); //Calculate String length

  for (int i = 0; i < messageSize; i++) { //Sending 1 char at a time to other radio

    int charToSend[1]; //Hold the char to be send

    charToSend[0] = inputString.charAt(i); //First char stored

    bool ok = radio.write(charToSend, 1); //Sent char

    if (ok) //This is not needed but will make you feel better

      Serial.println("OK...");

    else

      Serial.println("ERROR...");

  }

  msg[0] = 2; //send the 'terminate string' value...

  radio.write(msg, 1);

  inputString = ""; // clear the string

  radio.startListening(); // Now, continue listening

}

QUOTE 
ความคิดเห็นที่ #89
combo

//นำ code คุณ คุณ Keem COE มาแก้ไขครับ  ให้ตัวรับส่งสัญญาณ "A" กลับมาบอกตัวส่ง

//เพื่อบอกให้ตัวส่งทราบว่าได้รับแล้ว

//################ code ตัวส่ง ###################

///////----- ตัวส่ง (ที่เป็นตัวรับด้วย) 

#include <SPI.h>

#include <nRF24L01p.h>

 

nRF24L01p transmitter(7,8);//CSN,CE

 

void setup(){

  delay(150);

  Serial.begin(115200);

  SPI.begin();

  SPI.setBitOrder(MSBFIRST);

  transmitter.channel(90); // ตั้งช่องความถี่ให้ตรงกัน

  transmitter.TXaddress("MRK1"); // ตั้งชื่อตำแหน่งให้ตรงกัน ชื่อตั้งได้สูงสุด 5 ตัวอักษร

  transmitter.RXaddress("MRK2"); //address สำหรับรับข้อมูลกลับ

  //transmitter.dataRate(250);

  transmitter.init();

}

 

char  message[32];

 

String data_receiv;

 

int len;

 

void loop(){

 

  if(len=Serial.available()>0)

   {

     Serial.readBytes(message,len);

     String str(message);

     Serial.println(len);

     delay(500);

     Serial.println(message);

     delay(500);

     Serial.println(str);

     delay(500);

     transmitter.txPL(str);  // ค่าที่ต้องการส่ง

     transmitter.send(FAST); // สั่งให้ส่งออกไป

   }

 

   if(transmitter.available())  //ถ้าหากมีสัญญาณเข้ามาจะเข้าเงื่อนไขนี้

  {

    transmitter.read(); // สั่งให้เริ่มอ่าน

    transmitter.rxPL(data_receiv); // สั่งใหอ่านเก็บไว้ที่ตัวแปร

    Serial.print("data_receiv = "); //serial monitor ที่ตัวส่ง data_receiv = A

    Serial.println(data_receiv);    //โดยที่ค่า A คือค่าที่กำหนดไว้ที่ตัวรับ ให้ส่งกลับ

    data_receiv="";

  }

  }

 

 //################### code ตัวรับ #########################

//ทุกครั้งที่มีข้อความเข้าอะไรก็ได้  จะส่ง "A" กลับไปบอกตัวส่งทุกครั้ง

/////------------- โค้ดตัวรับที่เป็นตัวส่งด้วย

#include <SPI.h>

#include <nRF24L01p.h>

 

nRF24L01p receiver(7,8);//CSN,CE

 

void setup(){

  delay(150);

  Serial.begin(115200);

  SPI.begin();

  SPI.setBitOrder(MSBFIRST);

  receiver.channel(90);  // ตั้งช่องความถี่ให้ตรงกัน

  receiver.RXaddress("MRK1");  // ตั้งชื่อตำแห่นงให้ตรงกัน ชื่อตั้งได้สูงสุด 5 ตัวอักษร

  receiver.TXaddress("MRK2");  // address สำหรับส่งข้อมูลกลับ

  //receiver.dataRate(250);

  receiver.init();

 }

 

char  message[32];

 

String data_receiv;

 

int len;

 

void loop(){ 

 

  if(len=Serial.available()>0)

   {

     Serial.readBytes(message,len);

     String str(message);

     receiver.txPL(str);  // ค่าที่ต้องการส่ง

     receiver.send(FAST); // สั่งให้ส่งออกไป

   }

 

  if(receiver.available())  //เมื่อมีสัญญาณเข้ามา

  {

    receiver.read(); // สั่งให้เริ่มอ่าน

    receiver.rxPL(data_receiv); // สั่งใหอ่านเก็บไว้ที่ตัวแปร

    Serial.print(data_receiv);

    receiver.txPL("A");  // ตัวรับจะส่งคำว่า ok ให้ตัวส่ง  เพื่อบอกทราบว่าได้รับแล้ว

                          // ok จะขึ้นที่ serial monitor ที่ตัวส่ง

    receiver.send(FAST); // สั่งให้ส่งออกไปแบบเร็ว

    data_receiv="";      //เคลียร์ค่า data_receiv เพื่อรับค่าใหม่

      }

}

QUOTE 
ความคิดเห็นที่ #90
เจ้าของร้าน

ขอบคุณที่ช่วยแชร์ครับ : )

แสดงความคิดเห็นที่ 81-90 จากทั้งหมด 154 ความคิดเห็น
ขาย ARDUINO
คุณภาพ อันดับ 1

ได้รับรางวัลร้านยอดเยี่ยม
ตั้งแต่ปี 2558
ขาย Arduino
วีดีโอสอน Arduino

สอน esp8266

สอน Arduino IoT
สอน Arduino แบบเร็ว

สอน NodeMCU

อุปกรณ์ Arduino

MEMBER ZONE

พูดคุย-สอบถาม