For this week I will use bluetooth technology through the HC-05 modules for wireless communication between two devices.
Serial communication is used for the exchange of information between the microcontrollers and a computer or other devices. All microcontroller have at least one serial port that allows communication in a direct way or also gives the possibility of connecting wireless communication modules such as Bluetooth, ZigBee, LiFi and others.
Bluetooth is a technology that defines the IEEE 802.15.1 standard for the transmission of voice and data between different devices through an omnidirectional radiofrequency link. It is designed especially for low consumption devices with a low coverage range especially for personal networks
Bluetooth operates in the ISM frequency band of 2.4 GHz using the technique of frequency hopping FHSS which consists in dividing its frequency band into several channels of length of 1Mhz and performing 1600 jumps per second in a pseudo-random way
"WI-FI is one of the most widely used wireless wave communication technologies nowadays, also called WLAN (Wireless LAN, wireless network) or IEEE 802.11 standard. WI-FI is not an abbreviation of Wireless Fidelity, it is simply a commercial name "
This technology is used mainly in the implementation of local area networks and allows ranges of up to 100 meters in open environments and up to 30 meters in closed environments, in addition there are different versions of the IEEE 802.11 standard.
ZigBee is an open standard for low power radio communications known under the IEEE 802.15.4 standard for wireless personal area networks. It includes a robust and reliable network protocol, low consumption and cost, with security services and an application layer that guarantees interoperability between devices. ZigBee works at a data rate of 250 Kbps over the free 2.4 GHz band, although it also supports the 868 and 900 MHz bands
One of the most outstanding features of ZigBee technology is its meshed network support. Meshed networks allow several nodes to interconnect with each other. Connections between nodes are dynamically updated and optimized using sophisticated integrated routing tables. Meshed networks are decentralized; each node is able to discover the network by itself. In addition, when a node leaves the network, the mesh topology allows the other nodes to reconfigure the routes according to the new structure of the network. The possibilities of a mesh topology and ad-hoc routing provide greater stability and adaptation to unpredictable conditions or drop links and nodes
For this assignment I have decided to use the electronic circuit designed in week OUTPUT DEVICES week, To the circuit we have adapted a bluetooth module HC-05 to be configured as a slave, to be able to connect through a mobile application designed in app inventor from which we will send the message
The module HC-05 is a device whose function is to send and receive data wirelessly, the main feature of this element is that it can be configured as a slave or as a master, which allows to connect directly with a cellular mobile device or electronic tablet. also allows to connect with other bluetooth modules, it is also ideal for short distance interconnections and is compatible with all microcontrollers.
To configure the module use an FTDI cable and hyperterminal software
Now the device is ready to connect from the mobile application, below is the application designed to send data to the microcontroller through bluetooth
#include
char dato;
int cont;
SoftwareSerial mySerial(A0, A1); // RX, TX
void setup() {
mySerial.begin(9600);
mySerial.println("Hello, world?");
pinMode(6, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() { // run over and over
if (mySerial.available()) {
dato=mySerial.read();
if(dato=='A'){
if(cont<=5){
cont++;
}
}
if(dato=='B'){
if(cont>1){
cont--;
}
}
}
if (cont==1) {
digitalWrite(5, 0);
digitalWrite(6, 0);
digitalWrite(4, 0);
digitalWrite(3, 0);
digitalWrite(2, 0);
} else {
if (cont==2) {
digitalWrite(5, 1);
digitalWrite(6, 0);
digitalWrite(4, 0);
digitalWrite(3, 0);
digitalWrite(2, 0);
}
else {
if (cont==3) {
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(4, 0);
digitalWrite(3, 0);
digitalWrite(2, 0);
}
else {
if (cont==4) {
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(4, 1);
digitalWrite(3, 0);
digitalWrite(2, 0);
}
else {
if (cont==5) {
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(4, 1);
digitalWrite(3, 1);
digitalWrite(2, 0);
}
else {
if (cont==6) {
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(4, 1);
digitalWrite(3, 1);
digitalWrite(2, 1);
}
}
}
}
}
}
}
For this assignment I designed and built a network using the circuit of the week of OUTPUTS and the circuit designed in the week of INTERFACES and APPLICATIONS, I am going to have them communicate with each other by means of a wireless communication.
#include
SoftwareSerial mySerial(2, 3); // RX, TX
char a;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() { // run over and over
if (Serial.available()) {
a=Serial.read();
if(a=='A'){
Serial.println('A');
mySerial.println('A');
}
if(a=='B'){
Serial.println('B');
mySerial.println('B');
}
}
}
#include < SoftwareSerial.h>
char dato;
int cont;
SoftwareSerial mySerial(A0, A1); // RX, TX
void setup() {
mySerial.begin(9600);
mySerial.println("Hello, world?");
pinMode(6, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() { // run over and over
if (mySerial.available()) {
dato=mySerial.read();
if(dato=='A'){
if(cont<=5){
cont++;
}
}
if(dato=='B'){
if(cont>1){
cont--;
}
}
}
if (cont==1) {
digitalWrite(5, 0);
digitalWrite(6, 0);
digitalWrite(4, 0);
digitalWrite(3, 0);
digitalWrite(2, 0);
} else {
if (cont==2) {
digitalWrite(5, 1);
digitalWrite(6, 0);
digitalWrite(4, 0);
digitalWrite(3, 0);
digitalWrite(2, 0);
}
else {
if (cont==3) {
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(4, 0);
digitalWrite(3, 0);
digitalWrite(2, 0);
}
else {
if (cont==4) {
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(4, 1);
digitalWrite(3, 0);
digitalWrite(2, 0);
}
else {
if (cont==5) {
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(4, 1);
digitalWrite(3, 1);
digitalWrite(2, 0);
}
else {
if (cont==6) {
digitalWrite(5, 1);
digitalWrite(6, 1);
digitalWrite(4, 1);
digitalWrite(3, 1);
digitalWrite(2, 1);
}
}
}
}
}
}
}
In this assignment I did not have any considerable problems