We will now understand the various transmission types of our E22 UART LoRa device based on popular Semtech’s SX1262 and SX1268 RF chips.
Ebyte LoRa E22 device for Arduino, esp32 or esp8266 fixed transmission and RSSI
Here a selection of LoRa devices AliExpress (433MHz 5.5Km) - AliExpress (433MHz 10Km) - AliExpress (868MHz 915Mhz 5.5Km) - AliExpress (868MHz 915Mhz 10Km)
In the first part, we’ve used a transparent transmission, so we send to all and receive from all that have the same address e channel.
LoRa E32 transmitting scenarios
But It isn’t a standard scenario, and we usually want to send to a specified point and receive a response.
If you have trouble with the device’s freeze, you must put a pull-up 4.7k resistor or better connect to the device AUX pin.
Normal mode
For normal transmission, you must set M0 and M1 to LOW, and It’s better if you connect the AUX pin to have a better synchronization, but not needed. You can check the connection of the AUX pin in the library complete example connection, and you only must add the PIN to the constructor.
Ebyte LoRa E32 E22 E220 Arduino UNO normal mode breadboard
M0 GND (Set normal mode) M1 GND (Set normal mode) TX PIN 2 (PullUP 4,7KΩ) RX PIN 3 (PullUP 4,7KΩ & Voltage divider) AUX Not connected (PullUP 4,7KΩ) VCC 5v GND GND
and this configuration for Wemos D1 mini:
Ebyte LoRa E32 E22 E220 Wemos D1 normal mode breadboard
M0 GND (Set normal mode) M1 GND (Set normal mode) TX PIN D2 (PullUP 4,7KΩ) RX PIN D3 (PullUP 4,7KΩ) AUX Not connected (PullUP 4,7KΩ) VCC 3.3v/5v GND GND
ESP-32:
Ebyte LoRa E32 E22 E220 ESP32 DEV KIT V1 normal mode breadboard
M0 GND (Set normal mode) M1 GND (Set normal mode) RX TX2 (PullUP 4,7KΩ) TX RX2 (PullUP 4,7KΩ) AUX Not connected (PullUP 4,7KΩ) VCC 3.3v/5v GND GND
Arduino MKR WiFi 1010:
Ebyte LoRa Exx Arduino MKR WiFi 1010 normal mode connected breadboard
M0 GND (Set normal mode) M1 GND (Set normal mode) TX PIN 14 Tx (PullUP 4,7KΩ) RX PIN 13 Rx (PullUP 4,7KΩ) AUX Not connected (PullUP 4,7KΩ) VCC 3.3v/5v GND GND
So you must only instantiate the constructor.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
LoRa_E22 e22ttl(
4
,
5
,
3
,
7
,
6
);
Transparent transmission
Generic sketch, select the correct constructor for every device:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include
"Arduino.h"
#include
"LoRa_E22.h"
LoRa_E22 e22ttl(
4
,
5
,
3
,
7
,
6
);
void
setup
() {
Serial.begin
(
9600
);
delay
(
500
);
e22ttl.begin();
Serial.println
(
"Hi, I'm going to send message!"
);
ResponseStatus rs
=
e22ttl.sendMessage(
"Hello, world?"
);
Serial.println
(rs.getResponseDescription());
}
void
loop
() {
if
(e22ttl.available()>
1
) {
ResponseContainer rc
=
e22ttl.receiveMessage();
if
(rc.status.code
!
=
1
){
Serial.println
(rc.status.getResponseDescription());
}
else
{
Serial.println
(rc.status.getResponseDescription());
Serial.println
(rc.data);
}
}
if
(
Serial.available
()) {
String input
=
Serial.readString();
e22ttl.sendMessage(input);
}
}
If you have already changed the configuration, you must restore the default parameters:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
ResponseStructContainer c;
c
=
e22ttl.getConfiguration();
Configuration configuration
=
*
(Configuration
*
) c.data;
Serial.println
(c.status.getResponseDescription());
configuration.ADDL
=
0x03
;
configuration.ADDH
=
0x00
;
configuration.NETID
=
0x00
;
configuration.CHAN
=
23
;
configuration.SPED.uartBaudRate
=
UART_BPS_9600;
configuration.SPED.airDataRate
=
AIR_DATA_RATE_010_24;
configuration.SPED.uartParity
=
MODE_00_8N1;
configuration.OPTION.subPacketSetting
=
SPS_240_00;
configuration.OPTION.RSSIAmbientNoise
=
RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower
=
POWER_22;
configuration.TRANSMISSION_MODE.enableRSSI
=
RSSI_DISABLED;
configuration.TRANSMISSION_MODE.fixedTransmission
=
FT_TRANSPARENT_TRANSMISSION;
configuration.TRANSMISSION_MODE.enableRepeater
=
REPEATER_DISABLED;
configuration.TRANSMISSION_MODE.enableLBT
=
LBT_DISABLED;
configuration.TRANSMISSION_MODE.WORTransceiverControl
=
WOR_RECEIVER;
configuration.TRANSMISSION_MODE.WORPeriod
=
WOR_2000_011;
e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
c.close();
Transparent transmission and RSSI
Ebyte LoRa E22 device for Arduino, esp32, or esp8266 three devices module SMD
In telecommunications , a received signal strength indicator (RSSI) measures the power present in a received radio signal.
RSSI is usually invisible to a user of a receiving device. However, because signal strength can vary greatly and affect functionality in wireless networking , IEEE 802.11 devices often make the measurement available to users.
This device supports RSSI, and in some situations, It’s very useful. To use It, you must activate the configuration flag.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
ResponseStructContainer c;
c
=
e22ttl.getConfiguration();
Configuration configuration
=
*
(Configuration
*
) c.data;
Serial.println
(c.status.getResponseDescription());
configuration.ADDL
=
0x03
;
configuration.ADDH
=
0x00
;
configuration.NETID
=
0x00
;
configuration.CHAN
=
23
;
configuration.SPED.uartBaudRate
=
UART_BPS_9600;
configuration.SPED.airDataRate
=
AIR_DATA_RATE_010_24;
configuration.SPED.uartParity
=
MODE_00_8N1;
configuration.OPTION.subPacketSetting
=
SPS_240_00;
configuration.OPTION.RSSIAmbientNoise
=
RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower
=
POWER_22;
configuration.TRANSMISSION_MODE.enableRSSI
=
RSSI_ENABLED;
configuration.TRANSMISSION_MODE.fixedTransmission
=
FT_TRANSPARENT_TRANSMISSION;
configuration.TRANSMISSION_MODE.enableRepeater
=
REPEATER_DISABLED;
configuration.TRANSMISSION_MODE.enableLBT
=
LBT_DISABLED;
configuration.TRANSMISSION_MODE.WORTransceiverControl
=
WOR_RECEIVER;
configuration.TRANSMISSION_MODE.WORPeriod
=
WOR_2000_011;
e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
c.close();
After configuration, we can go to use the method created to manage the RSSI value: receiveMessageRSSI()
.
For the transmitter, all the process was managed by configuration; only the receiver must use a “special” method to retrieve the value. So the previous sketch becomes like so:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include
"Arduino.h"
#include
"LoRa_E22.h"
LoRa_E22 e22ttl(
4
,
5
,
3
,
7
,
6
);
void
setup
() {
Serial.begin
(
9600
);
delay
(
500
);
e22ttl.begin();
Serial.println
(
"Hi, I'm going to send message!"
);
ResponseStatus rs
=
e22ttl.sendMessage(
"Hello, world?"
);
Serial.println
(rs.getResponseDescription());
}
void
loop
() {
if
(e22ttl.available()>
1
) {
ResponseContainer rc
=
e22ttl.receiveMessageRSSI();
if
(rc.status.code
!
=
1
){
Serial.println
(rc.status.getResponseDescription());
}
else
{
Serial.println
(rc.status.getResponseDescription());
Serial.println
(rc.data);
Serial.print
(
"RSSI: "
);
Serial.println
(rc.rssi, DEC);
}
}
if
(
Serial.available
()) {
String input
=
Serial.readString();
e22ttl.sendMessage(input);
}
}
Fixed transmission
For fixed transmission, you must set M0 and M1 to LOW, and It’s better to connect the AUX pin to have a better synchronization.
Fixed transmission: point to point
To use this type of transmission, we must set a parameter on configuration and set a specified address for every device.
LoRa E32 Fixed message to a specified device
So first, we must set M0 to LOW and M1 pin to HIGH to enter on program/sleep mode and set the correct address and fixed transmission flag.
If we want to replicate the condition of the sender in the upper image, we must do this configuration.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
ResponseStructContainer c;
c
=
e22ttl.getConfiguration();
Configuration configuration
=
*
(Configuration
*
) c.data;
configuration.ADDL
=
0x02
;
configuration.ADDH
=
0x00
;
configuration.NETID
=
0x00
;
configuration.CHAN
=
23
;
configuration.SPED.uartBaudRate
=
UART_BPS_9600;
configuration.SPED.airDataRate
=
AIR_DATA_RATE_010_24;
configuration.SPED.uartParity
=
MODE_00_8N1;
configuration.OPTION.subPacketSetting
=
SPS_240_00;
configuration.OPTION.RSSIAmbientNoise
=
RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower
=
POWER_22;
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.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
c.close();
Then for the receiver device, we must set this configuration.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
ResponseStructContainer c;
c
=
e22ttl.getConfiguration();
Configuration configuration
=
*
(Configuration
*
) c.data;
configuration.ADDL
=
0x03
;
configuration.ADDH
=
0x00
;
configuration.NETID
=
0x00
;
configuration.CHAN
=
23
;
configuration.SPED.uartBaudRate
=
UART_BPS_9600;
configuration.SPED.airDataRate
=
AIR_DATA_RATE_010_24;
configuration.SPED.uartParity
=
MODE_00_8N1;
configuration.OPTION.subPacketSetting
=
SPS_240_00;
configuration.OPTION.RSSIAmbientNoise
=
RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower
=
POWER_22;
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_RECEIVER;
configuration.TRANSMISSION_MODE.WORPeriod
=
WOR_2000_011;
e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
c.close();
Now we can send a message to the specified device.
1
2
3
4
5
#define
DESTINATION_ADDL
2
ResponseStatus rs
=
e22ttl.sendFixedMessage(
0
, DESTINATION_ADDL,
23
,
"Hello, world?"
);
Serial.println
(rs.getResponseDescription());
The receiver is like the transparent one because the device manages the address and channel.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void
loop
()
{
if
(e22ttl.available()>
1
) {
ResponseContainer rc
=
e22ttl.receiveMessage();
if
(rc.status.code
!
=
1
){
Serial.println
(rc.status.getResponseDescription());
}
else
{
Serial.println
(rc.status.getResponseDescription());
Serial.println
(rc.data);
}
}
}
Pay attention to these lines of code:
15
16
17
18
19
#define
DESTINATION_ADDL
2
You must uncomment the correct DESTINATION_ADDL for the sender and the receiver.
Arduino MKR WiFi 1010 on the breadboard with Ebyte LoRa E22
Sender and receive sketch:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#define
DESTINATION_ADDL
2
#include
"Arduino.h"
#include
"LoRa_E22.h"
LoRa_E22 e22ttl(
4
,
5
,
3
,
7
,
6
);
void
printParameters(struct Configuration configuration);
void
setup
() {
Serial.begin
(
9600
);
delay
(
500
);
e22ttl.begin();
ResponseStructContainer c;
c
=
e22ttl.getConfiguration();
Configuration configuration
=
*
(Configuration
*
) c.data;
Serial.println
(c.status.getResponseDescription());
Serial.println
(c.status.code);
printParameters(configuration);
c.close();
Serial.println
(
"Hi, I'm going to send message!"
);
ResponseStatus rs
=
e22ttl.sendFixedMessage(
0
, DESTINATION_ADDL,
23
,
"Hello, world?"
);
Serial.println
(rs.getResponseDescription());
}
void
loop
() {
if
(e22ttl.available()>
1
) {
ResponseContainer rc
=
e22ttl.receiveMessage();
if
(rc.status.code
!
=
1
){
Serial.println
(rc.status.getResponseDescription());
}
else
{
Serial.println
(rc.status.getResponseDescription());
Serial.println
(rc.data);
}
}
if
(
Serial.available
()) {
String input
=
Serial.readString();
e22ttl.sendFixedMessage(
0
, DESTINATION_ADDL,
23
, input);
}
}
void
printParameters(struct Configuration configuration) {
Serial.println
(
"----------------------------------------"
);
Serial.print
(F(
"HEAD : "
));
Serial.print
(configuration.COMMAND, HEX);
Serial.print
(
" "
);
Serial.print
(configuration.STARTING_ADDRESS, HEX);
Serial.print
(
" "
);
Serial.println
(configuration.LENGHT, HEX);
Serial.println
(F(
" "
));
Serial.print
(F(
"AddH : "
));
Serial.println
(configuration.ADDH, HEX);
Serial.print
(F(
"AddL : "
));
Serial.println
(configuration.ADDL, HEX);
Serial.print
(F(
"NetID : "
));
Serial.println
(configuration.NETID, HEX);
Serial.println
(F(
" "
));
Serial.print
(F(
"Chan : "
));
Serial.print
(configuration.CHAN, DEC);
Serial.print
(
" -> "
);
Serial.println
(configuration.getChannelDescription());
Serial.println
(F(
" "
));
Serial.print
(F(
"SpeedParityBit : "
));
Serial.print
(configuration.SPED.uartParity, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.SPED.getUARTParityDescription());
Serial.print
(F(
"SpeedUARTDatte : "
));
Serial.print
(configuration.SPED.uartBaudRate, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.SPED.getUARTBaudRateDescription());
Serial.print
(F(
"SpeedAirDataRate : "
));
Serial.print
(configuration.SPED.airDataRate, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.SPED.getAirDataRateDescription());
Serial.println
(F(
" "
));
Serial.print
(F(
"OptionSubPacketSett: "
));
Serial.print
(configuration.OPTION.subPacketSetting, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.OPTION.getSubPacketSetting());
Serial.print
(F(
"OptionTranPower : "
));
Serial.print
(configuration.OPTION.transmissionPower, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.OPTION.getTransmissionPowerDescription());
Serial.print
(F(
"OptionRSSIAmbientNo: "
));
Serial.print
(configuration.OPTION.RSSIAmbientNoise, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.OPTION.getRSSIAmbientNoiseEnable());
Serial.println
(F(
" "
));
Serial.print
(F(
"TransModeWORPeriod : "
));
Serial.print
(configuration.TRANSMISSION_MODE.WORPeriod, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
Serial.print
(F(
"TransModeTransContr: "
));
Serial.print
(configuration.TRANSMISSION_MODE.WORTransceiverControl, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getWORTransceiverControlDescription());
Serial.print
(F(
"TransModeEnableLBT : "
));
Serial.print
(configuration.TRANSMISSION_MODE.enableLBT, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
Serial.print
(F(
"TransModeEnableRSSI: "
));
Serial.print
(configuration.TRANSMISSION_MODE.enableRSSI, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
Serial.print
(F(
"TransModeEnabRepeat: "
));
Serial.print
(configuration.TRANSMISSION_MODE.enableRepeater, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getRepeaterModeEnableByteDescription());
Serial.print
(F(
"TransModeFixedTrans: "
));
Serial.print
(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
Serial.println
(
"----------------------------------------"
);
}
Ebyte LoRa E22 device for Arduino, esp32 or esp8266 RSSI signal strength
To manage RSSI, It’s must be enabled via configuration, so the configuration for the sender becomes like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
ResponseStructContainer c;
c
=
e22ttl.getConfiguration();
Configuration configuration
=
*
(Configuration
*
) c.data;
configuration.ADDL
=
0x02
;
configuration.ADDH
=
0x00
;
configuration.NETID
=
0x00
;
configuration.CHAN
=
23
;
configuration.SPED.uartBaudRate
=
UART_BPS_9600;
configuration.SPED.airDataRate
=
AIR_DATA_RATE_010_24;
configuration.SPED.uartParity
=
MODE_00_8N1;
configuration.OPTION.subPacketSetting
=
SPS_240_00;
configuration.OPTION.RSSIAmbientNoise
=
RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower
=
POWER_22;
configuration.TRANSMISSION_MODE.enableRSSI
=
RSSI_ENABLED;
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.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
c.close();
and for the receiver:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
ResponseStructContainer c;
c
=
e22ttl.getConfiguration();
Configuration configuration
=
*
(Configuration
*
) c.data;
configuration.ADDL
=
0x03
;
configuration.ADDH
=
0x00
;
configuration.NETID
=
0x00
;
configuration.CHAN
=
23
;
configuration.SPED.uartBaudRate
=
UART_BPS_9600;
configuration.SPED.airDataRate
=
AIR_DATA_RATE_010_24;
configuration.SPED.uartParity
=
MODE_00_8N1;
configuration.OPTION.subPacketSetting
=
SPS_240_00;
configuration.OPTION.RSSIAmbientNoise
=
RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower
=
POWER_22;
configuration.TRANSMISSION_MODE.enableRSSI
=
RSSI_ENABLED;
configuration.TRANSMISSION_MODE.fixedTransmission
=
FT_FIXED_TRANSMISSION;
configuration.TRANSMISSION_MODE.enableRepeater
=
REPEATER_DISABLED;
configuration.TRANSMISSION_MODE.enableLBT
=
LBT_DISABLED;
configuration.TRANSMISSION_MODE.WORTransceiverControl
=
WOR_RECEIVER;
configuration.TRANSMISSION_MODE.WORPeriod
=
WOR_2000_011;
e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
c.close();
Also, in this sketch, pay attention to these lines of code:
15
16
17
18
19
#define
DESTINATION_ADDL
2
You must uncomment the correct DESTINATION_ADDL for the sender and the receiver.
And here is the sketch with RSSI:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#define
DESTINATION_ADDL
2
#include
"Arduino.h"
#include
"LoRa_E22.h"
LoRa_E22 e22ttl(
4
,
5
,
3
,
7
,
6
);
void
printParameters(struct Configuration configuration);
void
setup
() {
Serial.begin
(
9600
);
delay
(
500
);
e22ttl.begin();
ResponseStructContainer c;
c
=
e22ttl.getConfiguration();
Configuration configuration
=
*
(Configuration
*
) c.data;
Serial.println
(c.status.getResponseDescription());
Serial.println
(c.status.code);
printParameters(configuration);
c.close();
Serial.println
(
"Hi, I'm going to send message!"
);
ResponseStatus rs
=
e22ttl.sendFixedMessage(
0
, DESTINATION_ADDL,
23
,
"Hello, world?"
);
Serial.println
(rs.getResponseDescription());
}
void
loop
() {
if
(e22ttl.available()>
1
) {
ResponseContainer rc
=
e22ttl.receiveMessageRSSI();
if
(rc.status.code
!
=
1
){
Serial.println
(rc.status.getResponseDescription());
}
else
{
Serial.println
(rc.status.getResponseDescription());
Serial.println
(rc.data);
Serial.print
(
"RSSI: "
);
Serial.println
(rc.rssi, DEC);
}
}
if
(
Serial.available
()) {
String input
=
Serial.readString();
e22ttl.sendFixedMessage(
0
, DESTINATION_ADDL,
23
, input);
}
}
void
printParameters(struct Configuration configuration) {
Serial.println
(
"----------------------------------------"
);
Serial.print
(F(
"HEAD : "
));
Serial.print
(configuration.COMMAND, HEX);
Serial.print
(
" "
);
Serial.print
(configuration.STARTING_ADDRESS, HEX);
Serial.print
(
" "
);
Serial.println
(configuration.LENGHT, HEX);
Serial.println
(F(
" "
));
Serial.print
(F(
"AddH : "
));
Serial.println
(configuration.ADDH, HEX);
Serial.print
(F(
"AddL : "
));
Serial.println
(configuration.ADDL, HEX);
Serial.print
(F(
"NetID : "
));
Serial.println
(configuration.NETID, HEX);
Serial.println
(F(
" "
));
Serial.print
(F(
"Chan : "
));
Serial.print
(configuration.CHAN, DEC);
Serial.print
(
" -> "
);
Serial.println
(configuration.getChannelDescription());
Serial.println
(F(
" "
));
Serial.print
(F(
"SpeedParityBit : "
));
Serial.print
(configuration.SPED.uartParity, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.SPED.getUARTParityDescription());
Serial.print
(F(
"SpeedUARTDatte : "
));
Serial.print
(configuration.SPED.uartBaudRate, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.SPED.getUARTBaudRateDescription());
Serial.print
(F(
"SpeedAirDataRate : "
));
Serial.print
(configuration.SPED.airDataRate, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.SPED.getAirDataRateDescription());
Serial.println
(F(
" "
));
Serial.print
(F(
"OptionSubPacketSett: "
));
Serial.print
(configuration.OPTION.subPacketSetting, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.OPTION.getSubPacketSetting());
Serial.print
(F(
"OptionTranPower : "
));
Serial.print
(configuration.OPTION.transmissionPower, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.OPTION.getTransmissionPowerDescription());
Serial.print
(F(
"OptionRSSIAmbientNo: "
));
Serial.print
(configuration.OPTION.RSSIAmbientNoise, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.OPTION.getRSSIAmbientNoiseEnable());
Serial.println
(F(
" "
));
Serial.print
(F(
"TransModeWORPeriod : "
));
Serial.print
(configuration.TRANSMISSION_MODE.WORPeriod, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
Serial.print
(F(
"TransModeTransContr: "
));
Serial.print
(configuration.TRANSMISSION_MODE.WORTransceiverControl, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getWORTransceiverControlDescription());
Serial.print
(F(
"TransModeEnableLBT : "
));
Serial.print
(configuration.TRANSMISSION_MODE.enableLBT, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
Serial.print
(F(
"TransModeEnableRSSI: "
));
Serial.print
(configuration.TRANSMISSION_MODE.enableRSSI, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
Serial.print
(F(
"TransModeEnabRepeat: "
));
Serial.print
(configuration.TRANSMISSION_MODE.enableRepeater, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getRepeaterModeEnableByteDescription());
Serial.print
(F(
"TransModeFixedTrans: "
));
Serial.print
(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);
Serial.print
(
" -> "
);
Serial.println
(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
Serial.println
(
"----------------------------------------"
);
}
Fixed transmission: broadcast
We can test the broadcast communication with the exact configuration of the address and channel.
Broadcast message to a set of channel devices
To do a test, you can create three devices with these three configurations:
Device 1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
configuration.ADDL
=
0x04
;
configuration.ADDH
=
0x00
;
configuration.NETID
=
0x00
;
configuration.CHAN
=
23
;
configuration.SPED.uartBaudRate
=
UART_BPS_9600;
configuration.SPED.airDataRate
=
AIR_DATA_RATE_010_24;
configuration.SPED.uartParity
=
MODE_00_8N1;
configuration.OPTION.subPacketSetting
=
SPS_240_00;
configuration.OPTION.RSSIAmbientNoise
=
RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower
=
POWER_22;
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_RECEIVER;
configuration.TRANSMISSION_MODE.WORPeriod
=
WOR_2000_011;
Device 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
configuration.ADDL
=
0x05
;
configuration.ADDH
=
0x00
;
configuration.NETID
=
0x00
;
configuration.CHAN
=
23
;
configuration.SPED.uartBaudRate
=
UART_BPS_9600;
configuration.SPED.airDataRate
=
AIR_DATA_RATE_010_24;
configuration.SPED.uartParity
=
MODE_00_8N1;
configuration.OPTION.subPacketSetting
=
SPS_240_00;
configuration.OPTION.RSSIAmbientNoise
=
RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower
=
POWER_22;
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_RECEIVER;
configuration.TRANSMISSION_MODE.WORPeriod
=
WOR_2000_011;
Device 3:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
configuration.ADDL = 0x06;
configuration.ADDH = 0x00;
configuration.NETID = 0x00;
configuration.CHAN = 23;
configuration.SPED.uartBaudRate = UART_BPS_9600;
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
configuration.SPED.uartParity = MODE_00_8N1;
configuration.OPTION.subPacketSetting = SPS_240_00;
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower = POWER_22;
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_RECEIVER;
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
1
2
3
4
ResponseStatus rs
=
e22ttl.sendBroadcastFixedMessage(
23
,
"Hello, world?"
);
Serial.println
(rs.getResponseDescription());
Or
1
2
3
ResponseStatus rs
=
e22ttl.sendFixedMessage(BROADCAST_ADDRESS, BROADCAST_ADDRESS,
4
,
"Send message to channel 4"
);
Serial.println
(rs.getResponseDescription());
The receiver, as described, has the same code because the device manages the preamble with Address and Channel.
Here is the sender sketch:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include
"Arduino.h"
#include
"LoRa_E22.h"
LoRa_E22 e22ttl(
4
,
5
,
3
,
7
,
6
);
void
setup
() {
Serial.begin
(
9600
);
delay
(
500
);
e22ttl.begin();
Serial.println
(
"Hi, I'm going to send message!"
);
ResponseStatus rs
=
e22ttl.sendBroadcastFixedMessage(
23
,
"Hello, world?"
);
Serial.println
(rs.getResponseDescription());
}
void
loop
() {
if
(e22ttl.available()>
1
) {
#ifdef
ENABLE_RSSI
ResponseContainer rc
=
e22ttl.receiveMessageRSSI();
#else
ResponseContainer rc
=
e22ttl.receiveMessage();
#endif
if
(rc.status.code
!
=
1
){
Serial.println
(rc.status.getResponseDescription());
}
else
{
Serial.println
(rc.status.getResponseDescription());
Serial.println
(rc.data);
#ifdef
ENABLE_RSSI
Serial.print
(
"RSSI: "
);
Serial.println
(rc.rssi, DEC);
#endif
}
}
if
(
Serial.available
()) {
String input
=
Serial.readString();
ResponseStatus rs
=
e22ttl.sendBroadcastFixedMessage(
23
, input);
Serial.println
(rs.getResponseDescription());
}
}
Fixed transmission: monitoring
As you have already seen on the first schema, you can hear all messages in the specified channel, and you must configure your address like so, with an address equal to 0xFFFF.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
configuration.ADDL
=
BROADCAST_ADDRESS;
configuration.ADDH
=
BROADCAST_ADDRESS;
configuration.NETID
=
0x00
;
configuration.CHAN
=
23
;
configuration.SPED.uartBaudRate
=
UART_BPS_9600;
configuration.SPED.airDataRate
=
AIR_DATA_RATE_010_24;
configuration.SPED.uartParity
=
MODE_00_8N1;
configuration.OPTION.subPacketSetting
=
SPS_240_00;
configuration.OPTION.RSSIAmbientNoise
=
RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower
=
POWER_22;
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_RECEIVER;
configuration.TRANSMISSION_MODE.WORPeriod
=
WOR_2000_011;
To receive the messages:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#define
DESTINATION_ADDL
3
#include
"Arduino.h"
#include
"LoRa_E22.h"
LoRa_E22 e22ttl(
4
,
5
,
3
,
7
,
6
);
void
setup
() {
Serial.begin
(
9600
);
delay
(
500
);
e22ttl.begin();
}
void
loop
() {
if
(e22ttl.available()>
1
) {
#ifdef
ENABLE_RSSI
ResponseContainer rc
=
e22ttl.receiveMessageRSSI();
#else
ResponseContainer rc
=
e22ttl.receiveMessage();
#endif
if
(rc.status.code
!
=
1
){
Serial.println
(rc.status.getResponseDescription());
}
else
{
Serial.println
(rc.status.getResponseDescription());
Serial.println
(rc.data);
#ifdef
ENABLE_RSSI
Serial.print
(
"RSSI: "
);
Serial.println
(rc.rssi, DEC);
#endif
}
}
if
(
Serial.available
()) {
String input
=
Serial.readString();
e22ttl.sendFixedMessage(
0
, DESTINATION_ADDL,
23
, input);
}
}
Thanks
Ebyte LoRa E22 device for Arduino, esp32 or esp8266: settings and basic usage Ebyte LoRa E22 device for Arduino, esp32 or esp8266: library Ebyte LoRa E22 device for Arduino, esp32 or esp8266: configuration Ebyte LoRa E22 device for Arduino, esp32 or esp8266: fixed transmission, broadcast, monitor, and RSSI Ebyte LoRa E22 device for Arduino, esp32 or esp8266: power-saving and sending structured data Ebyte LoRa E22 device for Arduino, esp32 or esp8266: repeater mode and remote settings Ebyte LoRa E22 device for Arduino, esp32 or esp8266: WOR microcontroller and Arduino shield Ebyte LoRa E22 device for Arduino, esp32 or esp8266: WOR microcontroller and WeMos D1 shield Ebyte LoRa E22 device for Arduino, esp32 or esp8266: WOR microcontroller and esp32 dev v1 shield
Shield and PCB