Forum: Mikrocontroller und Digitale Elektronik Chinesische USB/nRF24L01 Adpapter


von Tim  . (cpldcpu)


Lesenswert?

Hat jemand mit diesen Modulen Erfahrung? Sieht nach einer einfachen 
Möglichkeit aus, von einem PC mit einem nRF24L01 zu kommunizieren.

http://www.aliexpress.com/item/2-pcs-WIFI-USB-Interface-2-4G-Wireless-Serial-Communication-Module-Compatible-with-NRF24L01P/1715882767.html

: Bearbeitet durch User
von Mike J. (linuxmint_user)


Lesenswert?

Tim    schrieb:
> Hat jemand mit diesen Modulen Erfahrung? Sieht nach einer
> einfachen
> Möglichkeit aus, von einem PC mit einem nRF24L01 zu kommunizieren.

Findet man bei eBay unter:
150Mbps Mini USB WiFi Wireless Lan Network Card Adapter 802.11n/g/b


Also ich habe die gleiche Version, aber nicht  mit PCB-Antenne, sondern 
mit einer SMA-Buchse und Stabantenne.

Das sind eigentlich normale W-Lan Sticks, ich weiß nicht ob man damit 
mit dem nRF24L01+ Daten übertragen kann.

Ich habe verschiedene nRF24L01+ in Gebrauch und steuere sie indirekt an.
PC -> USB/UART-Konverter -> AVR -[SPI]-> nRF24L01+

Wenn du mir beschreibst wie ich ein entsprechendes Datenpaket 
zusammenbaue und es dann über den W-Lan-Stick verschicke dann würde ich 
es versuchen, aber ich bezweifle dass man da wirklich etwas machen kann.

von Tim  . (cpldcpu)


Lesenswert?

>Wireless Serial Communication Module Compatible with NRF24L01P

Im Titel steht, dass die Sticks nRF24L01-kompatibel sind. Ich vermute 
dass es kein WLAN-Stick ist. Eventuell wird das gleiche Gehäuse 
verwendet?

von Mike (Gast)


Lesenswert?

Tim    schrieb:
> Ich vermute dass es kein WLAN-Stick ist.
Da steht aber auch WiFi was dem Funkstandard für WLAN entsprechen würde.

von Sebastian W. (wangnick)


Lesenswert?

Tim    schrieb:
>>Wireless Serial Communication Module Compatible with NRF24L01P
>
> Im Titel steht, dass die Sticks nRF24L01-kompatibel sind. Ich vermute
> dass es kein WLAN-Stick ist. Eventuell wird das gleiche Gehäuse
> verwendet?

Sehr interessant. Da steht nämlich auch:
1. The USB wireless device, PC is recognized as the serial device 
(please install our Serial Driver).
2. Sending end can easily set the baud rate, in order to prevent the 
receiver-side processing, however, the sender sends a packet preferably 
every 5 ms delay.
3. Just need an AT command, such as AT + SET = 40270102030405.
Instructions explain:
40 representatives 0X40 refers to the physical frequency number, based 
on the increase in 2400MHZ can set a total of 126 0X40MHZ.
27 representatives SETUP register used to set the baud rate transmit 
power and receive
0102030405 physical address on behalf of five software
4. Modules when no data is sent automatically enters the receiving state
5. The module operates in a dynamic packet format.

Ich hab mal eine Anfrage nach der vollständigen Dokumentation an den 
Lieferanten gestellt ...

LG. Sebastian

: Bearbeitet durch User
von Tim  . (cpldcpu)


Lesenswert?


von Tim  . (cpldcpu)


Angehängte Dateien:

Lesenswert?

Sind inzwischen angekommen. Es handelt sich um USB-Stecker mit BK2433. 
Das ist ein SOC mit 8051 und nRF24L01-Clone. Die Firmware emuliert eine 
serielle Schnittstelle und nutzt die eingebauen Windows-Treiber. Es wird 
nur ein Treiberdefinitionsfile benötigt (ini).

Ich habe eine geänderte .ini Datei angehängt, die das Dongle mit einem 
englischen Namen registriert.

Das Dongle registriert sich als eine Serielle Schnittstelle mit 115200 
baud und leitet die Daten transparent über 2.4Ghz weiter. Wenn man einen 
no-nonsense Drahtlosen Terminalzugang braucht, ist das eine einfache 
Lösung. Sogar noch stressfreier als die Bluetooth-Dongles.

Das Ändern der Frequenz (AT+SET?) habe ich leider nicht hinbekommen. 
Evtl. muss man dafür noch einen Escape-Code senden.

von Klaudyu (Gast)


Lesenswert?

Hello, I don't speak German, but this is the only link I found yesterday 
about those modules. It helped me, to find and dig the source, so I'll 
post here my findings. This is a program I used to make them work with 
arduino mega 2560 with RF24 library. I've included the comments in the 
source, it should be easy to understand. I have no previous experience 
before yesterday with these modules, so the things might be improved. 
This program is an echo program, and should work out of the box.
To setup the Arduino and the nrf module I used the info here: 
(http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo) with the 
modification that CE pin goes to 48 and not 9
Hope you'll find it useful.



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

RF24 radio(48,53); // CE pin and CSN pin

unsigned char ch;

void setup(void)
{
  Serial.begin(57600); //the usb dongle works by default at 1Mbit, so 
this can be any speed
  radio.begin();

  //wi-fi channel (frequency) and the address and the speed
  // those are the default values, can be modified by user
  //
  // To modify them send the following text to the terminal on which the 
usb dongle is: AT+SET=xxyyabcdefghij
  // xx is the channel
  // yy is the RF_SETUP REGISTER on nRF24l01 (on dongle there is BK2423, 
but works almost the same)
  //        It sets the dB power level and the speed (default value 0x07 
= 1Mhz, 0dB (maximum value));
  // ijghefcdab - the port (note that is in the reverse byte order)
  // all values are in hexadecimal
  // Example: to change to the default values use: AT+SET=28073443101001
  //
  radio.setChannel(0x28); //default value when the usb wifi dongle is 
plugged (can be changed by user)
  radio.openReadingPipe(1,0x0110104334LL); //default value when the usb 
wifi dongle is plugged (can be changed by user)
  radio.openWritingPipe(0x0110104334LL);
  radio.setDataRate(RF24_1MBPS);

  //setPayload,enabledynamic,setcrc.
  //These are hardcoded the same on usb wifi dongle.
  //Cannot be changed by the user
  radio.setPayloadSize(32);
  radio.enableDynamicPayloads();
  radio.setCRCLength(RF24_CRC_16);

  radio.startListening();
  radio.printDetails(); //print the configuration
}

void loop(void)
{
    if ( radio.available() )
    {
      radio.read( &ch, 1 );
      Serial.print((char)ch);
      radio.stopListening();
      //delay(5);
      radio.write(&ch,1);
      radio.startListening(); //flush the rx buffer
    }

}

von Tim  . (cpldcpu)


Lesenswert?

Klaudyu schrieb:
> Hello, I don't speak German, but this is the only link I found yesterday
> about those modules.

Thank you very much! This is very useful indeed.

Did you ever manage to change the channel by using the AT commands?

von Klaudyu (Gast)


Lesenswert?

Tim wrote:
>Did you ever manage to change the channel by using the AT commands?

Yes, you just send the ASCII string to the device, it will automatically 
intercept and configure the device (ex: "AT+SET=11073535353535" , where 
3535353535 is the address, 11 is the channel - no quotes)
I used both TeraTerm and RealTerm, they both give the same result.
I've put the example on how to change in the comments of the program.

von mahmood (Gast)


Lesenswert?

Hello dear friend

I am using the following code.
But I could not establish a connection between the module NRF24l01+ and 
the USB device.

If you could help me.
Thank you

1
#ifndef __nRF24L01+_H
2
    #define __nRF24L01+_H
3
4
    #include <mega32.h>
5
    #include <nRF24L01+.h>
6
    #include <stdio.h>
7
    #include <delay.h>
8
    // SPI functions
9
    #include <spi.h>
10
11
12
    #define CE PORTB.3
13
    #define CSN PORTB.4
14
15
    /* Instruction Mnemonics */
16
    #define R_REGISTER 0x00
17
    #define W_REGISTER 0x20
18
    #define REGISTER_MASK 0x1F
19
    #define ACTIVATE 0x50
20
    #define R_RX_PL_WID 0x60
21
    #define R_RX_PAYLOAD 0x61
22
    #define W_TX_PAYLOAD 0xA0
23
    #define W_ACK_PAYLOAD 0xA8
24
    #define FLUSH_TX 0xE1
25
    #define FLUSH_RX 0xE2
26
    #define REUSE_TX_PL 0xE3
27
    #define NOP 0xFF
28
29
30
    /* Memory Map */
31
    #define CONFIG 0x00
32
    #define EN_AA 0x01
33
    #define EN_RXADDR 0x02
34
    #define SETUP_AW 0x03
35
    #define SETUP_RETR 0x04
36
    #define RF_CH 0x05
37
    #define RF_SETUP 0x06
38
    #define STATUS 0x07
39
    #define OBSERVE_TX 0x08
40
    #define CD 0x09
41
    #define RX_ADDR_P0 0x0A
42
    #define RX_ADDR_P1 0x0B
43
    #define RX_ADDR_P2 0x0C
44
    #define RX_ADDR_P3 0x0D
45
    #define RX_ADDR_P4 0x0E
46
    #define RX_ADDR_P5 0x0F
47
    #define TX_ADDR 0x10
48
    #define RX_PW_P0 0x11
49
    #define RX_PW_P1 0x12
50
    #define RX_PW_P2 0x13
51
    #define RX_PW_P3 0x14
52
    #define RX_PW_P4 0x15
53
    #define RX_PW_P5 0x16
54
    #define FIFO_STATUS 0x17
55
    #define DYNPD 0x1C
56
    #define FEATURE 0x1D
57
58
59
60
61
    #pragma used+
62
    /* library function prototypes */
63
64
    flash unsigned char Base_Addrs[5]={0x00,0x01,0x03,0x07,0x00};
65
    unsigned char Temp_Addrs[5]={0x00,0x01,0x03,0x07,0x00};
66
    unsigned char payload[33];
67
    unsigned char Command_Reg = 0,Status_Reg = 0,State = 0;
68
    char Opr_Mode;
69
    bit send_actived = 0;
70
71
72
    void Set_Reg(unsigned char ins)
73
    {
74
    int i;
75
    CSN = 0;
76
    Status_Reg=spi(ins);
77
    switch(ins & 0xE0)
78
    {
79
    case 0x00:
80
    {
81
    if((ins & 0x1F)==0x0A || (ins & 0x1F)==0x0B || (ins & 0x1F)==0x10)
82
    {
83
    for(i=4;i>=0;i--)
84
    {
85
    Temp_Addrs[i]=spi(NOP);
86
    }
87
    }
88
    else
89
    {
90
    Command_Reg=spi(NOP);
91
    }
92
    break;
93
    }
94
    case W_REGISTER:
95
    {
96
    if((ins & 0x1F)==0x0A || (ins & 0x1F)==0x0B || (ins & 0x1F)==0x10)
97
    {
98
    for(i=4;i>=0;i--)
99
    {
100
    spi(Base_Addrs[i]);
101
    }
102
    }
103
    else
104
    {
105
    spi(Command_Reg);
106
    }
107
    break;
108
    }
109
    case R_RX_PL_WID:
110
    {
111
    if((ins & 0x01)==1)
112
    {
113
    i=payload[0];
114
    while(i!=0)
115
    {
116
    payload[i]=spi(NOP);
117
    i--;
118
    }
119
    }
120
    else
121
    {
122
    Command_Reg=spi(NOP);
123
    }
124
    break;
125
    }
126
    case W_TX_PAYLOAD:
127
    {
128
    i=payload[0];
129
    while(i!=0)
130
    {
131
    spi(payload[i]);
132
    i--;
133
    }
134
    break;
135
    }
136
137
    }
138
    CSN=1;
139
    delay_us(10);
140
    }
141
142
143
144
145
    // External Interrupt 2 service routine
146
    interrupt [EXT_INT2] void ext_int2_isr(void)
147
    {
148
    // Place your code here
149
    if(Opr_Mode==0)
150
    {
151
    Set_Reg(NOP);
152
    if(Status_Reg & W_REGISTER)
153
    {
154
    State = 2;
155
    Set_Reg(FIFO_STATUS);
156
    if((Command_Reg & 0x01)==0)
157
    {
158
    Set_Reg(R_RX_PL_WID);
159
    if(Command_Reg<=32)
160
    {
161
    payload[0]=Command_Reg;
162
    Set_Reg(R_RX_PAYLOAD);
163
    State = 3;
164
    }
165
    else
166
    Set_Reg(FLUSH_RX);
167
    }
168
    }
169
    else
170
    {
171
    State = 4;
172
    }
173
    }
174
    else
175
    {
176
    Set_Reg(R_RX_PL_WID);
177
    if(Command_Reg>32)
178
    {
179
    Set_Reg(FLUSH_RX);
180
    }
181
    else
182
    {
183
    payload[0]=Command_Reg;
184
    Set_Reg(R_RX_PAYLOAD);
185
    State = 1;
186
    }
187
    }
188
    Command_Reg = 0x7E;
189
    Set_Reg(0x27);
190
    Set_Reg(FLUSH_TX);
191
    }
192
193
194
195
196
197
    void Send_Data(char num , char *data)
198
    {
199
    int counter = 0;
200
201
    payload[0] = num;
202
203
    for(counter=0;counter<num;counter++)
204
    payload[counter+1] = *(data+counter);
205
206
    if(send_actived)
207
    {
208
    send_actived = 0;
209
    if((Temp_Addrs[4]==Base_Addrs[4]) && (Temp_Addrs[3]==Base_Addrs[3]) && (Temp_Addrs[2]==Base_Addrs[2]) && (Temp_Addrs[1]==Base_Addrs[1]) && (Temp_Addrs[0]==Base_Addrs[0]))
210
    {
211
    Set_Reg(FLUSH_TX);
212
    Set_Reg(W_TX_PAYLOAD);
213
    delay_ms(10);
214
    CE = 1;
215
    delay_us(20);
216
    CE = 0;
217
    delay_ms(10);
218
    }
219
    else
220
    State = 5;
221
    }
222
223
    if(State!=0)
224
    {
225
    send_actived=1; //faal sazi ersal mojadad
226
    State=0;
227
    }
228
    }
229
230
231
232
    void nRF_Config(char mode)
233
    {
234
    // Port B initialization
235
    // Func7=Out Func6=In Func5=Out Func4=Out Func3=In Func2=In Func1=In Func0=In
236
    // State7=0 State6=T State5=0 State4=0 State3=T State2=T State1=T State0=T
237
    PORTB=0x00;
238
    DDRB=0xB0;
239
240
    CSN = 1;
241
    CE = 0;
242
243
244
    // External Interrupt(s) initialization
245
    // INT0: Off
246
    // INT1: Off
247
    // INT2: On
248
    // INT2 Mode: Falling Edge
249
    GICR|=0x20;
250
    MCUCR=0x00;
251
    MCUCSR=0x00;
252
    GIFR=0x20;
253
254
255
    // SPI initialization
256
    // SPI Type: Master
257
    // SPI Clock Rate: 2000.000 kHz
258
    // SPI Clock Phase: Cycle Start
259
    // SPI Clock Polarity: Low
260
    // SPI Data Order: MSB First
261
    SPCR=0x50;
262
    SPSR=0x00;
263
264
265
    #asm("sei")
266
267
    delay_ms(110);
268
269
    Opr_Mode = mode;
270
271
    Command_Reg = 0x01;
272
    Set_Reg(0x21);
273
274
    Command_Reg = 0x01;
275
    Set_Reg(0x22);
276
277
    Command_Reg = 0x03;
278
    Set_Reg(0x23);
279
280
    Command_Reg = 0x2f;
281
    Set_Reg(0x24);
282
283
    Command_Reg = 0x01;
284
    Set_Reg(0x25);
285
286
    Command_Reg = 0x06;
287
    Set_Reg(0x26);
288
289
    Set_Reg(0x2A);
290
291
    Set_Reg(0x30);
292
293
    Command_Reg = 0x01;
294
    Set_Reg(0x3C);
295
296
    Command_Reg = 0x07;
297
    Set_Reg(0x3D);
298
299
    if(mode==0)
300
    {
301
    Command_Reg = 0x4E;
302
    Set_Reg(W_REGISTER);
303
    delay_ms(100);
304
    send_actived = 1;
305
    }
306
    else
307
    {
308
    Command_Reg = 0x3F;
309
    Set_Reg(W_REGISTER);
310
    delay_ms(5);
311
    CE = 1;
312
    }
313
    }
314
315
316
    #pragma used-
317
318
319
    //#pragma library nRF24L01+.lib
320
321
322
    #endif

von Fredi N. (fredek)


Angehängte Dateien:

Lesenswert?

Meine 2 cent:

Ich habe den stick mit einen Arduino Uno und nrf24l1+ getestet.

Mit diesen Programm:
https://github.com/maniacbug/RF24/blob/master/examples/pingpair_dyn/pingpair_dyn.pde

Es klappt ohne Probleme.
Den stick muss man mit: AT+SET=4C07E1F0F0F0F0 umstellen.
Bitte beachten dass es nur mit Großbuchstaben klappt.
4C ist die Default Frequenz vom nrf driver.
Die Adresse muss in umgekehrter Reihenfolge eingegeben werden.

Gruss Fredi

von cody (Gast)


Lesenswert?

Und was bedeutet bei AT+SET=4C07E1F0F0F0F0 die 07?

Ich versuche gerade diesen Chinesen-Stick mit einem NRF24L01+ zu 
verbinden, aber dieser empfängt nur kaputte Zeichen und es geht auch nur 
in eine Richtung.

Gibt es noch weitere AT-Befehle? Oder eine Doku?

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.