วันเสาร์ที่ 11 กุมภาพันธ์ พ.ศ. 2560

nRF24L01 2.4 GHz Module Wireless

NRF24L01 Module Wireless 2.4GHz



This product is not recommended for new designs. Nordic recommends its drop-in compatible nRF24L01+ or for a System-on-Chip solution the Nordic nRF24LE1 or nRF24LU1+.

The nRF24L01 is a highly integrated, ultra low power (ULP) 2Mbps RF transceiver IC for the 2.4GHz ISM (Industrial, Scientific and Medical) band. With peak RX/TX currents lower than 14mA, a sub μA power down mode, advanced power management, and a 1.9 to 3.6V supply range, the nRF24L01 provides a true ULP solution enabling months to years of battery lifetime when running on coin cells or AA/AAA batteries. The Enhanced ShockBurst™ hardware protocol accelerator additionally offloads time critical protocol functions from the application microcontroller enabling the implementation of advanced and robust wireless connectivity with low cost 3rd-party microcontrollers.
The nRF24L01 integrates a complete 2.4GHz RF transceiver, RF synthesizer, and baseband logic including the Enhanced ShockBurst™ hardware protocol accelerator supporting a high-speed SPI interface for the application controller. No external loop filter, resonators, or VCO varactor diodes are required, only a low cost ±60ppm crystal, matching circuitry, and antenna.
The Nordic nRF24L01 is available in a compact 20-pin 4 x 4mm QFN package



http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01






Connect NRF24L01 to Arduino
  • Vcc    to  3.3V 
  • Gnd   to  Gnd
  • CSN   to 7
  • CE     to 8
  • MOSI to 11
  • SCK   to 13
  • MISO to 12

Source Code for TX

#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); // Channel have to the same

  transmitter.TXaddress("AAR"); // Create not over five both RX and TX the same

  transmitter.init();

}

String message;

void loop(){

  transmitter.txPL("How are you");  // Send message

  transmitter.send(FAST); // Send

  delay(1000);

}



Source code for RX


#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);  // The same both RX and TX

  receiver.RXaddress("AAR");  // The same both RX and TX

  receiver.init();

}

String message;

void loop(){ 

  if(receiver.available()){

    receiver.read(); // Command to read data

    receiver.rxPL(message); // Keep data in "message"

    Serial.println(message); // Print out to serial monitor

    message="";

  }

}

วันพฤหัสบดีที่ 2 กุมภาพันธ์ พ.ศ. 2560

GPS+Arduino+Google map

GY-NEO6MV2 Ublox NEO-6M GPS Module







Pin 

Vcc   >>>> 5Volt
GND >>>> GND
TX    >>>>  10
RX    >>>>  11




Product Description:
 Ublox NEO-6M GPS Module with EEPROM for MWC/AeroQuad with Antenna for Flight Control Aircraft 
 GPS modules NEO-6M, 3V-5V power supply Universal
Module with ceramic destined antenna, super signal
EEPROM power down to save the configuration parameters data
LED signal indicator
With data backup battery
The default baud rate: 9600
Mounting Hole 3mm 
Module size 23mm * 30mm 
Antenna size 12 * 12mm
Cable:20mm



Source Code

#include<SoftwareSerial.h>
SoftwareSerial GPSModule(10, 11); // TX, RX
int updates;
int failedUpdates;
int pos;
int stringplace = 0;

String timeUp;
String nmea[15];
String labels[12] {"Time: ", "Status: ", "Latitude: ", "Hemisphere: ", "Longitude: ", "Hemisphere: ", "Speed: ", "Track Angle: ", "Date: "};
void setup() {
Serial.begin(57600);
GPSModule.begin(9600);
}

void loop() {
Serial.flush();
GPSModule.flush();
while (GPSModule.available() > 0)
{
GPSModule.read();

}
if (GPSModule.find("$GPRMC,")) {
String tempMsg = GPSModule.readStringUntil('\n');
for (int i = 0; i < tempMsg.length(); i++) {
if (tempMsg.substring(i, i + 1) == ",") {
nmea[pos] = tempMsg.substring(stringplace, i);
stringplace = i + 1;
pos++;
}
if (i == tempMsg.length() - 1) {
nmea[pos] = tempMsg.substring(stringplace, i);
}
}
updates++;
nmea[2] = ConvertLat();
nmea[4] = ConvertLng();
for (int i = 0; i < 9; i++) {
Serial.print(labels[i]);
Serial.print(nmea[i]);
Serial.println("");
}

}
else {

failedUpdates++;

}
stringplace = 0;
pos = 0;
}

String ConvertLat() {
String posneg = "";
if (nmea[3] == "S") {
posneg = "-";
}
String latfirst;
float latsecond;
for (int i = 0; i < nmea[2].length(); i++) {
if (nmea[2].substring(i, i + 1) == ".") {
latfirst = nmea[2].substring(0, i - 2);
latsecond = nmea[2].substring(i - 2).toFloat();
}
}
latsecond = latsecond / 60;
String CalcLat = "";

char charVal[9];
dtostrf(latsecond, 4, 6, charVal);
for (int i = 0; i < sizeof(charVal); i++)
{
CalcLat += charVal[i];
}
latfirst += CalcLat.substring(1);
latfirst = posneg += latfirst;
return latfirst;
}

String ConvertLng() {
String posneg = "";
if (nmea[5] == "W") {
posneg = "-";
}

String lngfirst;
float lngsecond;
for (int i = 0; i < nmea[4].length(); i++) {
if (nmea[4].substring(i, i + 1) == ".") {
lngfirst = nmea[4].substring(0, i - 2);
//Serial.println(lngfirst);
lngsecond = nmea[4].substring(i - 2).toFloat();
//Serial.println(lngsecond);

}
}
lngsecond = lngsecond / 60;
String CalcLng = "";
char charVal[9];
dtostrf(lngsecond, 4, 6, charVal);
for (int i = 0; i < sizeof(charVal); i++)
{
CalcLng += charVal[i];
}
lngfirst += CalcLng.substring(1);
lngfirst = posneg += lngfirst;
return lngfirst;
}