Another way to transmit data over the radio channel

This article is based on this one. To repeat the success of the existing Baofeng uv-5r, a Quansheng uv-k5 was purchased, and then another uv-k5, because the uv-5r took a long time to activate the VOX function. The case is very interesting, but it is difficult to use in practice due to the low transmission speed. An attempt to get rid of this drawback is described below.

Disclaimer
The tutorial describes how to transmit data via radio, so before you start playing pranks, familiarize yourself with the legal framework of the state in which you plan to play pranks.

The author hopes that the article will be read by people who understand the topics covered in the article and will provide constructive criticism.

Introduction

For the experiment, you will need two laptops, two microcontrollers and two radio modules, for example, Ebyte E22. In fact, Raspberry Pi and special modules from Waveshare for them will do. And in general, it is not necessary to use LoRa, you can also use the usual FSK on CC1101. In general, anything that comes to hand will do. At the first stage, to check how the network protocol is configured, the microcontrollers will be connected to each other simply by wires via UART.

The idea is to initialize the AX.25 network protocol via UART, and then you can use any device with a UART on board to transmit data. And the connection will be limited only by the radio channel. For Ebyte E22, the maximum transmission speed is 62500 baud. But at this speed, information will be transmitted with losses. For CC1101 or RF4463F30 modules, the transmission speed can be set to 500 kbps! But you shouldn't expect miracles in the transmission range.

Note from the author
The author of this article chose the Ebyte E22 for several reasons. The most important of them is the range at which it was possible to establish a good low-speed connection. With a power of 30 dBm at a speed of 4800 baud, stable communication was at a distance of 110 km! With reservations, of course. In the experiment, direct visibility between the antennas of the modules was ensured. Without direct visibility, such results cannot be expected.

Setting up AX.25 on Linux

Install programs:

sudo apt-get install libax25 ax25-apps ax25-tools

Create an executable file kiss.sh with the following content:

sudo nano kiss.sh

#!/bin/sh
# start ax25 on ttyS0 using port defined in /etc/ax25/axports
/usr/sbin/kissattach -m 254 /dev/ttyACM0 ax0 10.10.10.1
sleep 1
# listen for various incoming connects like PMS, node, etc.
# (MUST first be configured in /etc/ax25/ax25d.conf)
/usr/sbin/ax25d
sleep 1
# listen for stations heard
/usr/sbin/mheardd
#end of script  

Please note that the usb-to-com converter may be on a different port (not ttyACM0). You can list it with the command ls /dev and choose something like /dev/ttyACM0.

Hidden text
Fig 1. The screenshot shows the list before usb-to-com is connected

Fig 1. The screenshot shows the list before usb-to-com is connected

  Fig. 2. The screenshot shows the list after connecting usb-to-com

Fig. 2. The screenshot shows the list after connecting usb-to-com

Make kiss.sh file executable:

sudo chmod a+x kiss.sh

Edit the file /etc/ax25/axports:

sudo nano /etc/ax25/axports

# /etc/ax25/axports

# The format of this file is:
#
# name callsign speed paclen window description
ax0 ABCDEF 115200 254 1 LoRa<br>
#replace ABCDEF with your 6 letter callsign

You need to do the same steps for the second computer, but specify a different IP address and call sign (line 6 in the file /etc/ax25/axports.On the first computer the call sign is ABCDEF. Then on the second computer you can use FEDCBA, for example).

Intermediate experiment

To check that everything works correctly, you can assemble a simple experimental setup. It is suggested to use two laptops, each of which has its own Arduino UNO debug board connected. Reset of each of the debug boards should be connected to GND, so that you can safely use the USB-to-COM converter. Debug boards should be connected via serial interfaces. Pay attention to the inclusion of RX of the first board in TX of the second and TX of the first board in RX of the second board. The boards should be connected via “ground”.

/*

 UNO 1               UNO 2 
---------------------------
                           
 0 RX -------------- 1 TX  
                           
 1 TX -------------- 0 RX  
                           
 GND  -------------- GND                         
                           
 */

Run the kiss.sh script with root privileges:

sudo ./kiss.sh

Now you can ping computers, connect via SSH, transfer files using SCP. And much more that only a network connection of computers is capable of.

Hidden text
Fig. 3. Simple stand for testing network connection

Fig. 3. Simple stand for testing network connection

Note from the author
The photo shows connected cc1101 on debug boards, they are not involved in this experiment. If you look closely, you can see that Arduino UNO are connected Reset to GND.

Interim results

At this stage, it was possible to connect computers over a network via USB-to-COM converters. There is two-way access from one computer to another at a speed that allows working through a terminal (What else do you need to be happy?).

Of course, you can leave everything as is, but the length of the serial port connection leaves much to be desired. Then a solution suggests itself that will allow buffering the data coming into the serial port and transmitting it via a radio channel. Then it's a little more complicated, but more interesting!

Preparing the radio channel for data transmission

In the following experiment, we will use ESP32-S3 microcontrollers on YD-ESP32-23 debug boards and two Ebyte E22-400T33D modules. As an IDE, we will use VS code with PlatformIO (Arduino framework). For ease of use with Ebyte E22, you can use the author's tested library (or you can not use it if you are bored).

Note from the author
If you study the information from
repositoriesyou may find that you don't have to limit yourself to the ESP32 microcontroller. The examples include implementations for Arduino UNO and other debug boards. And in other repositories of the author of this wonderful library, there is an implementation for other Ebyte modules, such as E32 or E220. And a lot of other useful information!

The program for the microcontroller consists of two parts: working with the serial port and working with Ebyte. To receive data from the serial port, you can use the source code:

while(Serial.available()>0){
  // get the new byte:
  char inChar = (char)Serial.read();
  // add it to the inputString:
  inputString += inChar;
  // set a flag so the main loop can do something about it:
  stringComplete = true; 
}

// when a newline arrives:
if(stringComplete){
  // clear a flag:
  stringComplete = false;
  // print the string:
  Serial1.print(inputString);
  // clear buffer:
  inputString = ""; 
}

For an intermediate check, you can add one more condition:

if(Serial1.available()>0){
  Serial.write(Serial1.read());
}
Hidden text
#include <Arduino.h>

HardwareSerial SerialPort(2);

bool stringComplete = false;  // whether the string is complete
String inputString = "";         // a String to hold incoming data

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  SerialPort.begin(115200, SERIAL_8N1, 38, 2);
  String str="Ok";
  SerialPort.println(str);
}

void loop() {
  // put your main code here, to run repeatedly:
  while(Serial.available()>0){
    char inChar = (char)Serial.read();
    inputString += inChar;
    stringComplete = true;
  }

  if(stringComplete){
    stringComplete = false;
    SerialPort.print(inputString);
    inputString = "";
  }

  if(SerialPort.available()>0){
    Serial.write(SerialPort.read());
  }

}

Now, if you program a couple of debug boards with this code and connect the serial ports of the microcontrollers with wires, you can make sure that the string is written and sent to another computer. Ping and other terminal delights work again.

Hidden text
Fig 4. One of the intermediate experiments with ESP32-S3

Fig 4. One of the intermediate experiments with ESP32-S3

Note from the author
In the photo above, the ESP32-S3 debug board is programmed with simple source code that allows it to receive a string from the serial port of the first computer and send it to the serial port of the second computer.
The author always tests the functional parts of the code to filter out errors one by one as they appear.

Note from the author
The following paragraphs may seem confusing. To avoid this, it is better to experiment a little with
examples from libraries. Everything will become clearer.

At the next stage we will connect library. Let's configure the modules in the mode FT_FIXED_TRANSMISSION (configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;). The power can be limited to the minimum possible. POWER_24 (configuration.OPTION.transmissionPower = POWER_24;). In the address of one module you can specify ADDL = 0x2 (configuration.ADDL = 0x2;)and in the address of another ADDL = 0x3 (configuration.ADDL = 0x3;).

Hidden text

Note from the author
The author had access to 2W Ebyte E22-400T33D modules for experiments. To properly regulate the power and output debug information, the following section of code was added to the statesNaming.h file:

#elif defined(E22_33)
enum TRANSMISSION_POWER
{
	POWER_33 = 0b00,
	POWER_30 = 0b01,
	POWER_27 = 0b10,
	POWER_24 = 0b11

};

static String getTransmissionPowerDescriptionByParams(byte transmissionPower)
{
	switch (transmissionPower)
	{
		case POWER_33:
		return F("33dBm (Default)");
		break;
		case POWER_30:
		return F("30dBm");
		break;
		case POWER_27:
		return F("27dBm");
		break;
		case POWER_24:
		return F("24dBm");
		break;
		default:
		return F("Invalid transmission power param");
	}
}

Then you can write #define E22_33,and the power information will be displayed correctly. If you do not do this, it will not affect the operation of the system! Only the output of debug information.

Hidden text
void initEbyteE22_400(){
  e22ttl_400.begin();
  ResponseStructContainer c;
	c = e22ttl_400.getConfiguration();
	// It's important get configuration pointer before all other operation
	Configuration configuration = *(Configuration*) c.data;
	Serial.println(c.status.getResponseDescription());
	Serial.println(c.status.code);                    

	printParameters(configuration);                   

    configuration.ADDL = 0x02; // configuration.ADDL = 0x03;
    configuration.ADDH = 0x00;
    configuration.NETID = 0x00;

    configuration.CHAN = 23; // 410.125 + 23 = 433.125 МГц

    configuration.SPED.uartBaudRate = UART_BPS_115200; 
    configuration.SPED.airDataRate = AIR_DATA_RATE_100_96; 
    configuration.SPED.uartParity = MODE_00_8N1;

    configuration.OPTION.subPacketSetting = SPS_240_00;
    configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
    configuration.OPTION.transmissionPower = POWER_24;

    configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
    configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
    configuration.TRANSMISSION_MODE.enableRepeater = REPEATER_DISABLED;
    configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
    configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_TRANSMITTER;
    configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
  
    e22ttl_900.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE);

    printParameters(configuration);                     
  
	ResponseStructContainer cMi;
	cMi = e22ttl_900.getModuleInformation();
	
	ModuleInformation mi = *(ModuleInformation*)cMi.data;

	Serial.println(cMi.status.getResponseDescription()); 
	Serial.println(cMi.status.code);                     

	printModuleInformation(mi);                          

	c.close();
	cMi.close();  
}

This sets the address transmission mode (V library This is written in the section Normal transmission mode). The power is regulated depending on the experimental conditions. The necessary module addresses are set. This will allow when accessing from the program (or from the terminal) on a computer at a specific IP address to contact the required computer with this address. The Ebyte module with a specific address is tied to a computer with a specific IP.

Transmitter

Now let's replace in the condition if(stringComplete) 15th line for the first module Serial1.print(inputString); on ResponseStatus rs = e22ttl.sendFixedMessage(0, 0x3, 23, inputString);and for the second module on ResponseStatus rs = e22ttl.sendFixedMessage(0, 0x2, 23, inputString);

With these changes it turns out that when the next line is formed, instead of transmitting it over the wires, this line is transmitted to the Ebyte module. Which sends it to the radio channel at a specific address. So, when receiving a line via the serial port from the first computer, the data is sent to the radio channel at address 0x3 on the second computer. And when receiving a line via serial from the second computer, the data is sent to the radio channel at address 0x2.

Receiver

To receive, you can use the function from the examples. The data received via the radio channel should be sent to the computer via the serial port:

void somethingAvailableLORA(){
    // If something available
    if (e22ttl.available()>1) {
        // read the String message
    #ifdef ENABLE_RSSI
        ResponseContainer rc = e22ttl.receiveMessageRSSI();
    #else
        ResponseContainer rc = e22ttl.receiveMessage();
    #endif
        // Is something goes wrong print error
        if (rc.status.code!=1){
            // Serial.println(rc.status.getResponseDescription());
        }else{
            // Print the data received
            // Serial.println(rc.status.getResponseDescription());
            
            Serial.print(rc.data);
            
    #ifdef ENABLE_RSSI
            Serial.print(F("RSSI: ")); Serial.println(rc.rssi, DEC);
    #endif
        
        }
    }
}

The entire source code for the experiment can be found at repositories.

Features when working with the library for Ebyte E22

Note from the author
Before the experiments for publication, the author wanted to leave the speed of the UART computer <-> YD-ESP32-23 and YD-ESP32-23 <-> Ebyte E22 equal to 9600 baud. But at the first turn on it turned out that even ping does not pass. If you send only one ping (
ping 10.10.10.2 -c 1), then it will pass. And when sending two – one will pass, and the other will be lost. In fact, the author had experience working with Ebyte E22 and immediately increased the speed of UART computer <-> YD-ESP32-23 and YD-ESP32-23 <-> Ebyte E22 to 115200 baud. And here a difficulty awaited.

Inside the Ebyte E22-400T33D module there is a microcontroller with which the ESP32 interacts. On the one hand, this simplifies the work, but on the other hand, it reduces the speed.
When configured Ebyte E22-400T33D (And for Ebyte E22-400T30D, and probably for other similar modules too. – Author's note.) to work via UART at a speed of 115200, the module stops correctly issuing its configuration and transmitting/receiving data.

The author encountered this feature some time ago and has not yet come up with anything better than manipulating the UART configuration in the ESP32. In relation to the use described in this article, it will be enough after initializing the Ebyte module in the function setup() add the following lines:

Serial1.end();
Serial1.begin(115200, SERIAL_8N1, 18, 17);

Note from the author
This is a hack, and it helps, but not always. The author had to give up the 115200 baud rate when working with these modules in one of the applications. But for this application it will do.

After configuring UART computer <-> YD-ESP32-23 and YD-ESP32-23 <-> Ebyte E22 at 115200 baud ping started working (~600 ms). SSH access started working (I can't say that it's pleasant to work with, but it's noticeably faster than at 2400 baud or 4800 baud via Quansheng UV-K5. – Author's note.). Managed to transfer the file via SCP (The phone ran out of space, so the video won't show the end of the show. – Author's note.).

After this experiment, the author changed the radio channel speed to 19200 baud. Ping began to pass mainly in ~500 ms. SSH and SCP began to work a little faster, but not significantly.

Note from the author
The author would not increase the speed above 9600 baud due to losses. Experiments have not yet been conducted, but obviously there will be losses, and this will negatively affect the quality of communication and file transfer.

Results of the experiment

Now, if you program microcontrollers with this source code, data will be transmitted via a radio channel. The range of transmissions without losses will depend on the communication speed. Then, by adjusting the speed/range, you can solve the problems of communication between several computers in the usual way and at a fairly low cost.

Note from the author
There is an assumption that if you abandon the E22-400T33D and use the E22-400M33S (the letter M in the marking means that there is no microcontroller inside), you can increase the transfer speed. From the UART chain computer <-> YD-ESP32-23 and YD-ESP32-23 <-> Ebyte E22, the transfer via UART YD-ESP32-23 <-> Ebyte E22 will be removed, and then the interaction will go via SPI directly to SX1268.

Using addressing, you can connect three or more computers, but then you will need to figure out how to deal with collisions. During the experiments (both in the UART terminal and on the radio signal spectrum), it is clear that the operating system sends a lot of service information to the network. When connecting three computers, this can already be critical. For example, if at the moment of transferring a file from one computer to another, the third computer starts sending service messages, according to simple rules, the receiver will simply receive a stronger signal. This is a collision. One of the ways is time division. The author in other experiments connected up to 5 devices to each other on these modules, using time division, but that's another story.

Here are some videos. The first computer is connected to the RTL-SDR and you can see the radio spectrum.

Hidden text

On the video ping from PC 1 to PC 2. Speed ​​on the radio channel 9600 baud

Note from the author
The ping command works best. 619 ms response time is very close to the truth, because in other experiments of the author with LoRa the response time was ~400 ms. There it was a little less, because there was no operating system, and all processing was done on the microcontroller.

Hidden text

The video shows the process of connecting the first computer to the second via SSH

Note from the author
You have to wait a long time for the connection, but it still works, and that's good. It's not clear yet where this can be used in real life, but it will come in handy somewhere.

Hidden text

The video shows work via SSH with another computer

Note from the author
This is probably the most interesting video. You can see how the terminal slows down when entering characters and how the radio channel works. It takes time for the command to reach the other computer and return back. But even with such freezes, everything still works

Hidden text

The video shows the process of transferring a file using SCP from one computer to another via a radio channel

Note from the author
And this is the most boring video, because the process of transferring a simple and very small file takes a lot of time. In addition, the smartphone ran out of space at the most inopportune moment. but the process was completed successfully a few seconds after the video ended.

Hidden text

The video shows the process of executing the ping command after increasing the transmission speed over the radio channel to 19200 baud

Note from the author
After increasing the radio channel transmission speed, ping started to be executed 100 ms faster, but some commands sometimes take longer, for example, ~800 ms. It is difficult to say what this is connected with. These radio modules were not created for high data transmission speeds, but for long transmission distances with low energy consumption, and here two computers on the table are connected through them.

Hidden text

The video shows the process of connecting the first computer to the second via SSH at a radio transmission speed of 19200 baud

Note from the author
Increasing the transmission speed over the radio channel has brought its result. In the previous similar video, the connection was completed at about 140 seconds, and now after 70 seconds everything is ready.

Hidden text

The video shows the blinking of LEDs connected to the RX TX of the debug boards

Note from the author
The exchange process between computers is ongoing, and this can be seen even by the LEDs that are soldered onto the boards.

Hidden text

The video shows the process of executing the ping command on the second computer

Note from the author
Communication is available from both sides

Hidden text

The video shows the spectrum of the radio signal when executing the ping command on the second computer

Hidden text

The video shows the process of transferring a file using SCP via a radio channel at a speed of 19200 baud

Note from the author
At 19200 baud, the file was transferred almost 3 times faster than at 9600 baud.

What to read on this topic

Thank you.

S.N.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *