nRF24L01 & PIC18F4220

 
- page last modified, August 2012-  (página en castellano)



circuit for a varity of sensors
18F4220 & nRF24L01 18F2420 & FT232 serial to USB converter

Behind this project is the idea to have a small battery powered circuit of the size of only 5,2mm * 4,2mm capable to plug in a varieties of sensors, like accelerometer, gyro-meter, compass, temperature, etc., depending of the actual needs and sending the captured data wireless to the computer.

The wireless data transfer is done using the nRF24L01 from Nordic. Attached, at the download- link at the bottom of this page is the code written in C for SourceBoost. I made sure that the code is nearly ANSI compatible so, with view modification one can use other compiler platforms to use the code.

enlarge the electronic schematics of the circuit
punkt_yellow.jpg



The Nordic nRF24L01 costs 3,50E/unit compared to the xBee ZNet 2,5 of 45E/unit. The very small size and the costs made me do the effort to write the code. The first prototype unit I made with the nRF24L01 incorporated on the PCB of the main unit. (Photo DSCN0352_E_Web).

As the battery acts like a shield of the circuits with this design I reached only a very small wireless rage of some meters, not enough to use the circuit for live performances. This is the reason that finally I bought a breakout board from Sparkfun and re-designed the circuit with the incorporated breakout board.





18F4220 & nRF24L01

Photo of the protoptype version with a Nordic nRF24L01 incorporated. The battery acts like a shield for the radio waves, this is why it can't be used for live performances.

(schematics General_Nordic_V1)


enlarge the electrical schematics of "General_Nordic_V1"
punkt_yellow.jpg

 

 
receiver/transmitter
18F2420, FT232 transmisor/receptor, PIC18F2420 & FT232

enlarge the electronical schematics "18F2420_nRF24L01"
escquema 18F2420_nRF24L01
enlarge the electronical schematics "Nordic_Receiver"
punkt_yellow.jpg



manage incomming data with SuperCollider
// first part creates 6 sliders.
(
var win= Window("ACCELOMETER", Rect(100, 100, 590, 420));
var sld0= Slider(win, Rect(20, 10, 50, 400));
var sld1= Slider(win, Rect(115, 10, 50, 400));
var sld2= Slider(win, Rect(215, 10, 50, 400));
var sld3= Slider(win, Rect(315, 10, 50, 400));
var sld4= Slider(win, Rect(415, 10, 50, 400));
var sld5= Slider(win, Rect(515, 10, 50, 400));

~action_gui= {|chan, val|
    switch(chan,
        0, {{sld0.value = val/1023}.defer}, // z (RA0) OLD version x, RA2
        1, {{sld1.value = val/1023}.defer}, // y (RA1)
        2, {{sld2.value = val/1023}.defer},  // x (RA2) OLD version z, RA0
       
        3, {{sld3.value = val/1023}.defer}, //
        4, {{sld4.value = val/1023}.defer}, //
        5, {{sld5.value = val/1023}.defer}  //
    );
};
win.front;
)

SerialPort.listDevices // command to evaluate the USB port.

// The next section is:
// Incomming data with packages of 3bytes. 1.byte header 0x00, 2nd byte
// hi data-byte, 3thd byte low data-byte. The 2nd byte incorporates also the
// 6 address bites (64 addresses max)

(
var port= SerialPort("/dev/ttyUSB0", 57600); //edit port here
Routine({
    var byte, loByte, hiByte, val, valsl, chan, index= 0;
    inf.do{
          while({(byte= port.read).isNil}, {}); //wait for serial
          //byte.postln;        //debug
          if(index==0 and:{byte==0},
          {
          index= 1;
           }, {
            if(index==1, {
            hiByte= byte;
            index= 2;
                },
              {
            if(index==2, {
            loByte= byte;
                       
            //("received: hi:"+hiByte+" lo:"+loByte).postln;
            chan= (hiByte&2r11111100)>>2; // mask 2 lower data-bites
            val= ((hiByte&2r00000011)<<8)|loByte;
            //("chan:"+chan+"val:"+val).postln;
            ~action_gui.value(chan, val);
            ~action_synth.value(chan, val);
                           
            index= 0;
            });
        });
        });
    };
}).play;
CmdPeriod.doOnce({port.close});
)
code written by Fredrik Olofsson


NORDIC wireless nRF24L01 from Martin Hug on Vimeo.




 

links related to this page. Opens new window (only IE)

 

 
download the files download the files associated with the project