Fab Academy 2015

Fab Academy

How to Make Almost Anything...


Networking and Communications

Weekly Assignment

This week assignment consists in design and build a wired &/or wireless network connecting at least two processors. In my case I will make a one-way communication by radio (433Mhz) using a specific module for this.

Radio module (433MHz)

For this assignment I'm going to use a module for wireless communication running at 433MHz, this is a really cheap radio module very easy to configure and work with it.These modules can be bought easily all over the world, if you're interested, you can buy here.

433MHz Receiver Transmitter

These modules can achieve emission up to 90 meters in open areas, without antenna just have a range of a few meters and with the antenna I've made, I could get about 30 meters range in a closed place (with walls).

Transmitter

433MHz Transmitter

Receiver

433MHz Receiver

Assembly diagram

The assembly diagram is very simple, I have a transmitter module controlled by a microcontroller (FabKit) emitting a signal depending on whether it is pressed or not certain buttons and the emitted signal is picked up by a receiver module controlled by a microcontroller Extreduino which is on an power shield. When the receiving plate receives the correct signal activates the elements connected to it.

Mounting Diagram

Montaje

Device programming

The program consists of a transmitter that sends a signal when a button is pressed and a receiver which is waiting the button pressing information. Communication is unidirectional and in this case there are only two devices, so I have not added device address, This example can be made more complex besides sending information pulsed button, sending the device address.

Transmitter

The program waits for a button is pressed, depending on the button pressed the transmitter will send a 1 (if the button 1 is pressed) or 2 (if the 2 button is pressed).

		/*
		FabAcademy 2015
		Weekly Assignment: Networking and Communications (29/04/2015)
		Wireless communication via an RF module (433MHz)
		Transmitter
		*/
		
		#include VirtualWire.h

		int button1=6;
		int button2=7;

		int button1State=0;
		int button2State=0;


		void setup()
		{
		  vw_setup(2000); //Set the baud rate (bit per second)
		  vw_set_tx_pin(12);  //Transmission pin
		  pinMode(button1,INPUT);
		  pinMode(button2,INPUT);
		  
		}

		void loop()
		{
		  button1State=digitalRead(button1);
		  button2State=digitalRead(button2);
		  
		  if (button1State==HIGH){
			  send("1"); //"send" function for sending data
			  delay(500);
			
		  }
		  if (button2State==HIGH){
			  send("2"); //"send" function for sending data
			  delay(500);
		  }
		}

		void send (char *message)
		{
		  vw_send((uint8_t *)message, strlen(message));
		  vw_wait_tx(); //Wait until the entire message has been sent
		} 
		

Receiver

Awaits receipt of a data and if it matches a valid value on or off the device.

		/*
		FabAcademy 2015
		Weekly Assignment: Networking and Communications (29/04/2015)
		Wireless communication via an RF module (433MHz)
		Transmitter
		*/
		
		#include VirtualWire.h
		
		byte message[VW_MAX_MESSAGE_LEN]; //Buffer to store the input data
		byte messageLength = VW_MAX_MESSAGE_LEN; //Message size

		int led1=10;
		int led2=9;

		boolean stateLed1=false;
		boolean stateLed2=false;


		void setup()
		{
		  Serial.begin(9600);
		  Serial.println("El dispositivo esta listo");
		  vw_set_rx_pin(12);
		  vw_setup(2000); //Set the baud rate (bit per second)
		  vw_rx_start(); //Initializes the reception
		  pinMode(led1,OUTPUT);
		  pinMode(led2,OUTPUT);

		}

		void loop()
		{
		  if (vw_get_message(message, &messageLength))
		  {
			Serial.print("Received: ");
			for (int i = 0; i < messageLength; i++)
			{
			  Serial.write(message[i]);
					if(message[i]=='1'){
				Serial.write("el unooo");
				stateLed1=~stateLed1;
				digitalWrite(led1,stateLed1);
			  }
			 if(message[i]=='2'){
				Serial.write("el dooos");
				stateLed2=~stateLed2;
				digitalWrite(led2, stateLed2);
			  }
			}
			Serial.println();
		  }
		} 
		

Testing communication

Source Files