Do you also want to make a drone that goes 1.8km.... make a car that goes 1.8km.... Then you can use the
HC-12 Module. (Image 2)
As soon as HC-12 is mentioned, Bluetooth comes to mind..... 1.8km from Bluetooth?? It can't be done. This module is not Bluetooth, devices that work with Bluetooth work with a frequency in the GHz range. But HC-12 uses frequencies in the MHz range.
This HC-12 is a Half-Duplex Wireless Serial Communication Module. This module works in the 433.4 - 473.0 MHz range. HC-12 is capable of communicating at a distance of about 1.8 km. But it is not from the spring antenna that comes with this module. This default spring antenna can communicate at a distance of 600 - 700 m. If the transmission is carried out at a distance of about 1.8 km, an external antenna has to be used.
This HC-12 Module is designed with STM85003F3 Microcontroller and Si4463 Transceiver. Let's see what this is.
Si4463 Transceiver :-
The opportunity for wireless communication between the two modules is provided by this transceiver. The maximum transmit power here is 20dBm (100mW). Receive Sensitive is -129dBm. 2 64 byte Rx and Tx FIFO memories are included in this chip.
STM85003F3 Microcontroller :-
It is an 8 bit Microcontroller and contains an 8KB Flash Memory and a 128 bytes EEPROM. This microcontroller is programmed to connect another HC-12 module through Si4463 Transceiver through UART communication.
There are 5 pins in this HC-12 module. (Figure 3)
VCC Pin - To provide power to the module.
GND - To provide ground connection.
RXD Pin - To provide the required input to the module.
TXD Pin - To output data from the module.
SET Pin - To change the configuration of the module.
Now let's see how to use this HC-12 Module with Arduino. Even though the module is mentioned, one module is not enough for us to do this work. 2 HC-12 Modules are required for communication. The first thing we need to do is,
1) HC-12 Module × 2
2) Arduino board × 2
3) 100 uf Capacitors × 2
4) Jumper Wires
Now set up the devices as shown in Figure 4 and upload the following code. The same code should be uploaded for both Arduino boards.
(Special:- 2 Arduino boards should be connected to 2 computers.)
#include <SoftwareSerial.h>
const byte HC12RxdPin = 11;
const byte HC12TxdPin = 10;
SoftwareSerial HC12(10, 11);
void setup() {
Serial.begin(9600);
HC12.begin(9600);
}
void loop() {
if (HC12.available()) {
Serial.write(HC12.read());
}
if (Serial.available()) {
HC12.write(Serial.read());
}
}
Here, connect the RX pin of the HC-12 module to the 11th pin of the Arduino, and the TX pin to the 10th pin of the Arduino.
This code prints whatever is typed on the Serial Monitor of one computer in the Serial Monitor of the other computer.
Now let's see how to turn on and off an LED using 2 HC-12 Modules and a Push Button. This allows you to control the LED from a distance of 1.8 km. In addition to the aforementioned devices,
5) 4 Pin Push Button × 1
6) LED × 1
7) 220 Ohms Resistor × 1
😎 10 K Resistor × 1
Now set up the devices as shown in Figure 5 and upload the following 2 codes. The first cord is used for the Arduino Board which is connected to the remote i.e. Push Button and the second cord is used for the Receiver.
Code For Remort :-
#include <SoftwareSerial.h>
const byte HC12RxdPin=11;
const byte HC12TxdPin=10;
SoftwareSerial HC12(10,11);
int button=2;
boolean old=LOW;
boolean news=LOW;
boolean ledstate=LOW;
void setup() {
Serial.begin(9600);
HC12.begin(9600);
pinMode(button,INPUT);
}
void loop() {
news=digitalRead(button);
if(news!=old){
if(news==HIGH){
if(ledstate==LOW){
HC12.write('1');
ledstate=HIGH;
}
else{
HC12.write('0');
ledstate=LOW;
}
}
old=news;
}
}
Here the 2nd Pin of the Arduino is connected to the Push Button.
Here, when the Push Button is pressed once, the value 1 is written to the HC-12 Module, and when the Push Button is pressed again, the value 0 is written to the Module.
Code for Receiver :-
/*
#include <SoftwareSerial.h>
const byte HC12RxdPin = 11;
const byte HC12TxdPin = 10;
SoftwareSerial HC12(10, 11);
int led = 6;
int state = 0;
void setup() {
Serial.begin(9600);
HC12.begin(9600);
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}
void loop() {
if (HC12.available() > 0) {
state = HC12.read();
}
if (state == '1') {
digitalWrite(led, HIGH);
state = 0;
} else if (state == '0') {
digitalWrite(led, LOW);
state = 0;
}
delay(10);
}
Here the LED on pin 6 of the Arduino One is connected. Here, the values written to the module in the previously mentioned code are read. Here, if the value 1 is read, the LED will turn on, and if the value 0 is read, the LED will turn off.
A drone that works in a 1.8km range using these 2 HC-12 modules... and everyone has been making a toy car that can be controlled by a mobile phone... now you can make a car that can travel 1800m.
0 Comments