nRF24L01+ Module Documentation

nRF24L01+

Library

Arduino Library Download
Copy to ‘Libraries’ folder within your main Arduino folder.

Pins:

MISO -> 12
MOSI -> 11
SCK -> 13

Configurable:

CE -> 8
CSN -> 7

Properties:

byte cePin
CE Pin controls RX / TX, default 8.

byte csnPin
CSN Pin (Chip select not), default 7.

byte channel
RF Channel 0 – 127 or 0 – 84 in the US, default 0.

byte payload
Size in bytes, default 16, max 32.
Note: channel and payload must be the same for all nodes.

Methods:

void init(void)
Initialize the module, set the pin modes for the configurable pins and initialize the SPI module.
Example:
Mirf.csnPin = 9;
Mirf.cePin = 7;
Mirf.init();
void setRADDR(byte *addr)
Set the receiving address. Addresses are 5 bytes long.
Example:
Mirf.setRADDR((byte *)"addr1");
void setTADDR(byte *addr)
Set the sending address.
Example:
Mirf.setTADDR((byte *)"addr1");
void config(void)
Set channel and payload width. Power up in RX mode and flush RX fifo.
Example:
Mirf.payload = 32;
Mirf.channel = 2;
Mirf.config();
bool dataReady(void)
Is there data ready to be received?.
Example:
if(Mirf.dataReady()){
//Get the data to play with.
}
void getData(byte *data)
Get the received data. 'data' should be an array of bytes Mirf.payload long.
Example:
byte data[Mirf.payload]
Mirf.getData(data);
void send(byte *data)
Send data. 'data' should be Mirf.payload bytes long.
bool isSending(void)
Return true if still trying to send. If the chip is still in transmit mode then this method will return the chip to receive mode.
Example:
Mirf.send(data);
while(Mirf.isSending()){
//Wait.
}
//Chip is now in receive mode.
NB: Lots more information is available from the status registers regarding acknowledgement or failure status. See Mirf.cpp:218.
bool rxFifoEmpty(void)
Is the RX Fifo Empty.
bool txFifoEmpty(void)
Is the TX Fifo Empty.
byte getStatus(void)
Return the status register.
void powerUpRx(void)
Power up chip and set to receive mode. Also clear sending interrupts.
void powerUpTx(void)
Power up tx mode.
Exa

Examples

See examples folder in zip file.
Arduino Library Download

Building A Thermostat Using Arduino

This gives an excellent description of the technique. I’ve still yet to determine the switching current, which I’d like to before I build a potentially hazardous item. End goal of this project? Constructing a ‘Nest’-like learning thermostat. Mostly just to predict when I’ll come stomping in from the cold, and adjust the temperature appropriately an hour or two ahead of schedule.

Keeps it toasty.

Teensy (The once and future king) Model 3.0

ImageThis thing is epic embodied. Go ahead and contact Mr. Teensy Himself on Twitter and tell him how appreciative you are. Because it won’t be long before these things are everywhere. With an ARM Cortex-M4 processor and an independent IC for the bootloader, it’s quite resilient to bricking (necessary for me!) native USB, what else is to be expected from PJRC

Oh yeah, and fully working Arduino bootloader and libraries for everyone who doesn’t want to program in C/C++. This is going to be big. Paul claims they easily overclock to 96MHz, and combined with a 32-bit processor, that’s a lot of computing power. Not to mention the 32bit analogWrite() (billions of levels of precision) and 13bit analogRead() (65536 levels of read, or down to a 134uV precision per level. Compare that to a Arduinos’ precision of 19mV, or 4.2mV for the Mega with the 1v1 voltage reference.

So…basically stoked. Get it here for the next day or so.

P.S. Of course, the Kickstarter for this thing was fufilled basically instantly. I mean, we all have the Teensy 2.0, right?

Galago, a ARM Cortex-M3 development board with a real time debugger!

http://www.kickstarter.com/projects/kuy/galago-make-things-better

ImageWhat a great find for $19. Half the price of a Arduino (from radio shack, at least, I go with the chinese knockoffs for $17) and orders of magnitude more capability. Too great to pass up, I swung for one. Here’s the bad news, unless they sell $30k worth, they don’t get any of the funding. And, there’s only 17 days to go. Hopefully they can pull this one out of their ass, get funded and give PJRC and their new Teensy 3.0 a run for their money.

Arduino on the attiny in 15 minutes

It’s actually fairly easy, you must do precisely this. First, you will need to download the one of the files listed below, depending on which model attiny you’d like to use (I’d suggest installing them all, so it will be easy to change between microprocessors as the situation warrants.) For the example case, I will be using the attiny85, so, I will refer to the attiny45_85.zip file.

First, make sure the Arduino program is *not* currently running, if so, shut it down. Open your arduino folder (arduino_022, or whatever you’ve named it) and create a folder inside your sketchbook folder called hardware (if it does not already exist.) Extract the zip file, and copy the folder within to your newly created hardware folder. The arduino IDE is now prepared to program your attiny. If you have a stand alone ISP, skip down to the ‘my first ardutiny program’ below. Otherwise, you need to configure your arduino (or compatable) to program your bare attiny.

Fortunately, the arduino IDE comes with a sketch built in to handle this task. Connect your arduino, start up the IDE, and select the ‘Arduino ISP’ sketch from the examples menu. Upload the sketch to the arduino, and now were ready to wire this bad boy up.

image

The picture above shows my setup. Basically, you need to connect the attiny to power and ground, connect three of its pins (5, 6, and 7) to three of your arduino’s pins (11, 12, and 13) respectively. Connect the attiny pin 1 to the arduino’s pin 10; this will allow your attiny to be automatically reset as you program the microcontroller. *If you’re using a teensy or other ‘arduino-compatable’ your pins will be different. If you can’t work it out, feel free to contact me in the comments.*

ardutiny programming
Now, were ready to program. Select ‘attiny85 (w/ Arduino as ISP)’, open up the blink sketch from the examples, and hit program (likely some errors will pop up, ignore these, and carry on). Take a LED, and connect it as shown above, and watch it light up!

This allows the attiny to support the best arduino functions such as digitalWrite(), digitalRead(), analogRead(), analogWrite() this is our PWM! More on this in tomorrow’s article. It also is hip with the time based functionality, such as millis() and pulseIn() another very useful function to be covered this week!

Give your thanks to these folks, if they’re still listening, MIT HLT Lab, and Alessandro Saporretti. Questions, comments and hopefully plenty of b**ching in the comments below, por favor.

files
attiny84
attiny45/85.zip
the avr motherlode

Blog at WordPress.com.

%d bloggers like this: