Uploaded by Adrian Morlanes

Chat-Application-Using-Mesh-Radios

advertisement
technology
workshop
craft
home
food
play
outside
costumes
Chat Application Using Mesh Radios
by Idiotware on December 27, 2016
Table of Contents
Chat Application Using Mesh Radios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Intro: Chat Application Using Mesh Radios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
Step 1: Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
Step 2: Working . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
Step 3: Setup NRF Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
Step 4: Connect OLED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
Step 5: Connect Buzzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
Step 6: Upload the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
Step 7: Sender Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
Step 8: Receiver Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
http://www.instructables.com/id/Chat-Application-Using-Mesh-Radios/
Intro: Chat Application Using Mesh Radios
In this project, I am going to demonstrate how you can send and receive messages wirelessly, with the help of two idIoTware shields. No internet no worries we have
some crazy idea to make a chat room that can work till few miles with the external antenna. There are many places where you can not get network. What we have done
is create the large range chat room for 6 peoples.All this is possible with an Arduino, idIoTware shield and the Wireless module nRF24L01.
This Arduino Chat Room uses nRF24L01 to set up a low-cost Chat Room in your local area.You can extend the chat coverage by using nrf24l01 radio module with an
external antenna.
Step 1: Requirements
Arduino UNO & Genuino UNO × 2
idIoTware Shield × 2 (https://goo.gl/D2EOdO)
NRF24L01 NRF24L01+ Wireless Module × 2
0.96" I2C oled display × 2
Generic Jumper (0.1") × 2
USB-A to B Cable × 2
9V 1A Switching Wall Power Supply × 2
Arduino IDE Installed on a computer
http://www.instructables.com/id/Chat-Application-Using-Mesh-Radios/
Step 2: Working
In this example, we are using NRF24L01 radio module and Arduino to communicate to the other Arduino and Nrf24L01 radio module using the serial monitor.
Here we are creating a local mesh between two radio modules(Nrf24L01). The two sets of Arduino and nRF24L01 are connected together to establish a wireless Serial
communication link so that they could talk to each other. The nRF24L01 are half duplex transceiver modules, hence they can send and receive data. The data is sent
from the user using Arduino Serial monitor, by typing on his keyboard, and this data can be received and displayed on the receivers OLED display, which is on the
Idiotware shield, and vice- a verse. This project is limited to just adding two members to the Chat room, But the nRF24L01 has capability to handle 6 connections, and so
there could be a maximum of 6 members in our chat room, each talking or chatting with each other. This chat room coverage could be upto 100 meters depending upon
the nRF24L01 Modules range.
Step 3: Setup NRF Module
Connect the NRF module to NRF24L01 header
Step 4: Connect OLED
Connect i2c OLED on the headers above the touchpad
Step 5: Connect Buzzer
Connect the BUZ pin to the center pin on SEL13 pin header, effectively connecting the Buzzer to the A1 pin.
Step 6: Upload the Code
Upload the code from Arduino ide and start chatting with friends in neighbourhood.Use the Serial monitor of arduino ide to send message.
No more connecting things on breadboard and messy wiring. With the idIoTware shield the sky's the limit.
http://www.instructables.com/id/Chat-Application-Using-Mesh-Radios/
Step 7: Sender Code
/*
In this example we are using NRF24L01 radio and Arduino to communicate with other Arduino and NRF24L01 using Serial Monitor. Here we are creating a local mesh
between two radios(NRF24L01) using and .
*/
#include #include #include #include "U8glib.h" // // Hardware configuration /
/ Set up nRF24L01 radio on SPI bus plus pins 9 & 10
RF24 radio(7,8);
// Network uses that radio RF24Network network(radio);
// Address of our node const uint16_t this_node = 0;
// Address of the other node const uint16_t other_node = 1;
boolean send_message = false; char messageToSend[32] = "";
int melody[]= {2000,2000,2000,2000}; // note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 8,8,8,8 };
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0); // I2C / TWI
String inputString = ""; // a string to hold incoming data boolean stringComplete = false; // whether the string is complete
void setup(void) { u8g.setFont(u8g_font_unifont); Serial.begin(57600); Serial.println("NRF24L01 MESSENGER"); SPI.begin(); radio.begin(); network.begin(/*channel*/ 90,
/*node address*/ this_node); u8g.firstPage(); do { u8g.setPrintPos(0, 10); u8g.print("Organizer " ); u8g.setPrintPos(45, 10); // u8g.print(this_node); } while( u8g.nextPage()
); }
void loop() { // Pump the network regularly network.update(); if (stringComplete) // if there is typed message on serial monitor ready to send { inputString.replace("\r","");
inputString.replace("\n",""); RF24NetworkHeader header1(/*to node*/ other_node); boolean message = network.write(header1, inputString.c_str(), 32); // send message to
other user if (message) { Serial.print("Organizer: "); // print message on serial monitor Serial.println( inputString); send_message = false; } else Serial.println("could not
write....\n"); // if it is failed to send message prompt error stringComplete=false; inputString=""; } //// Is there anything ready for us? while (network.available() ) { // If so,
grab it and print it out RF24NetworkHeader header; char messageToRecieve[32] = ""; boolean recieve = false; while (!recieve) { recieve = network.read(header,
messageToRecieve ,32); Serial.print("Organizer: "); // print recived data on serial monitor Serial.println(messageToRecieve); for(int thisNote = 0; thisNote < 4; thisNote++)
{ // to calculate the note duration, take one second divided by the note type. //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. int noteDuration =
1000/noteDurations[thisNote]; tone(A1, melody[thisNote],noteDuration); // to distinguish the notes, set a minimum time between them. // the note's duration + 30% seems
to work well: int pauseBetweenNotes = noteDuration * 1.60; delay(pauseBetweenNotes); // stop the tone playing: noTone(8); } u8g.firstPage(); do { u8g.drawStr(0,10,
"participant :"); u8g.setPrintPos(0, 30); u8g.print(messageToRecieve); } while( u8g.nextPage() ); } } } void serialEvent() { while (Serial.available()) { // get the new byte:
char inChar = (char)Serial.read(); // add it to the inputString: inputString += inChar; // if the incoming character is a newline, set a flag // so the main loop can do
something about it: if (inChar == '\n') { stringComplete = true; } } }
Step 8: Receiver Code
/*
In this example we are using NRF24L01 radio and Arduino to communicate with other Arduino and NRF24L01 using Serial Monitor. Here we are creating a local mesh
between two radios(NRF24L01) using and .
*/
#include #include #include #include "U8glib.h" // // Hardware configuration /
/ Set up nRF24L01 radio on SPI bus plus pins 9 & 10
RF24 radio(7,8);
// Network uses that radio RF24Network network(radio);
// Address of our node const uint16_t this_node = 1;
// Address of the other node const uint16_t other_node = 0;
boolean send_message = false; char messageToSend[32] = ""; //
int melody[]= {2000,2000,2000,2000}; // note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 8,8,8,8 };
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0); // I2C / TWI
String inputString = ""; // a string to hold incoming data boolean stringComplete = false; // whether the string is complete
void setup(void) { u8g.setFont(u8g_font_unifont); Serial.begin(57600); Serial.println("NRF24L01 MESSENGER"); SPI.begin(); radio.begin(); network.begin(/*channel*/ 90,
/*node address*/ this_node); u8g.firstPage(); do { u8g.setPrintPos(0, 10); u8g.print("Participant " ); u8g.setPrintPos(45, 10); // u8g.print(this_node); } while(
u8g.nextPage() ); }
void loop() { // Pump the network regularly network.update(); if (stringComplete) // if there is typed message on serial monitor ready to send { inputString.replace("\r","");
inputString.replace("\n",""); RF24NetworkHeader header1(/*to node*/ other_node); boolean message = network.write(header1, inputString.c_str(), 32); // send message to
other user if (message) { Serial.print("Participant: "); // print message on serial monitor Serial.println(inputString); send_message = false; } else Serial.println("could not
write....\n"); // if it is failed to send message prompt error stringComplete=false; inputString=""; } // Is there anything ready for us? while (network.available() ) { // If so, grab
it and print it out RF24NetworkHeader header; char messageToRecieve[32] = ""; boolean recieve = false; while (!recieve) { recieve = network.read(header,
messageToRecieve , 32 ); Serial.print("Participant: "); // print recived data on okserial monitor Serial.println(messageToRecieve); for(int thisNote = 0; thisNote < 4;
thisNote++) { // to calculate the note duration, take one second divided by the note type. //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. int noteDuration =
1000/noteDurations[thisNote]; tone(A1, melody[thisNote],noteDuration); // to distinguish the notes, set a minimum time between them. // the note's duration + 30% seems
to work well: int pauseBetweenNotes = noteDuration * 1.60; delay(pauseBetweenNotes); // stop the tone playing: noTone(8); } u8g.firstPage(); do { u8g.drawStr(0,10,
http://www.instructables.com/id/Chat-Application-Using-Mesh-Radios/
"Organizer : "); u8g.setPrintPos(0, 30); u8g.print(messageToRecieve); } while( u8g.nextPage() ); } } } void serialEvent() { while (Serial.available()) { // get the new byte:
char inChar = (char)Serial.read(); // add it to the inputString: inputString += inChar; // if the incoming character is a newline, set a flag // so the main loop can do
something about it: if (inChar == '\n') { stringComplete = true; } } }
Related Instructables
Spreading
Information with
Intel Edison by
JoaoL6
Sup!
Community
Storytelling
Experience IoT
Kiosk by aniden
Chatting Using
'evive' and
ESP8266 by
evivetoolkit
The Winkel
Board by RishiH
Arduino Internet Simple Arduino
Of Things (IoT)
Wireless Mesh
Using NiceRf
by Dr_Acula
LoRa1276 by
Absolutelyautomation
Advertisements
Comments
1 comments
Add Comment
Swansong says:
Intresting idea :) I'd like to se a video of it working!
http://www.instructables.com/id/Chat-Application-Using-Mesh-Radios/
Dec 28, 2016. 8:44 AM REPLY
Download