Embedded devices

atmega328

    Transceiver nRF24L01: The Olimex nRF24L01 module is a 2.4GHz transceiver module developed by Olimex and based on the nRF24L01 IC from Nordic Semiconductor

    Server code Using the Mirf library for nRF24L01.

    							#include 
    							#include 
    							#include 
    							#include 
    
    							void setup(){
    							  Serial.begin(9600);
    							  Mirf.init();
    							  Mirf.setRADDR((byte *)"MAS863"); 
    							  Mirf.payload = sizeof(unsigned long);
    							  Mirf.config();
    							  Serial.println("Listening..."); 
    							}
    
    							void loop(){
    							  
    							  byte data[Mirf.payload];
    							   
    							  if(!Mirf.isSending() && Mirf.dataReady()){
    								Serial.println("Got packet");
    								 
    								Mirf.getData(data);
    								Mirf.setTADDR((byte *)"clie1");
    								
    								Mirf.send(data);
    								Serial.println("Reply sent.");
    							  }
    							}
    						

    Client code Using the Mirf library for nRF24L01.

    							#include 
    							#include 
    							#include 
    							#include 
    
    							void setup(){
    							  Serial.begin(9600);
    							  Mirf.cePin = 7;
    							  Mirf.csnPin = 8;
    							 
    							  Mirf.setRADDR((byte *)"MAS863");
    							  Mirf.payload = sizeof(unsigned long);
    							  Mirf.config();
    							  Serial.println("Beginning ... "); 
    							}
    
    							void loop(){
    							  unsigned long time = millis();
    							  
    							  Mirf.setTADDR((byte *)"serv1");
    							  
    							  Mirf.send((byte *)&time);
    							  
    							  while(Mirf.isSending()){
    							  }
    							  Serial.println("Finished sending");
    							  delay(10);
    							  while(!Mirf.dataReady()){
    								//Serial.println("Waiting");
    								if ( ( millis() - time ) > 1000 ) {
    								  Serial.println("Timeout on response from server!");
    								  return;
    								}
    							  }
    							  
    							  Mirf.getData((byte *) &time);
    							  
    							  Serial.print("Ping: ");
    							  Serial.println((millis() - time));
    							  
    							  delay(1000);
    							} 
    						

    Follow up on Project 4: Electronics Production: second stage Amp circuit