Home › Forums › The libraries hosted on the site › EByte LoRa e22 UART devices sx1262/sx1268 › E22 channel scanner needs help
Tagged: channel scanning, E22-900T30D, esp32
- This topic has 6 replies, 2 voices, and was last updated 1 year, 1 month ago by
Renzo Mischianti.
-
AuthorPosts
-
-
13 March 2024 at 20:25 #30035
I want to scan LoRa frequencies to choose a low traffic channel for a LoRaWAN. sendTester.ino below sends a transparent mode message on channel 0x23 every second and scanner.ino listens cycling through a small range of channels that includes 0x23. It reports channels with non-zero rssi values.
The problem is that scanner.ino hears a few consecutive (5 – 10) messages on 0x23 but then goes deaf. I’m baffled. Is a buffer overflowing?
sendTest.ino
/* * sends a message on channel 23 at 1 second intervals */ #include "Arduino.h" #include "LoRa_E22.h" // ---------- esp32 pins -------------- LoRa_E22 e22ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1 void setup() { Serial.begin(9600); delay(500); // Startup all pins and UART e22ttl.begin(); // If you have ever change configuration you must restore It 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 = 0x23; 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(); } void loop() { // Send message ResponseStatus rs = e22ttl.sendMessage("Hello, world?"); // Check if problem with sending Serial.println(rs.getResponseDescription()); delay(1000); }
<div></div>
scanner.ino/* Look for LoRa transmissions - test with sendTester.ino * scans channels 0 - 80 * receives in transparent mode * writes received channel id, RSSI, message to stdout */ #include "Arduino.h" #include "LoRa_E22.h" // ---------- esp32 pins -------------- LoRa_E22 e22ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1 #define ENABLE_RSSI true Configuration configuration; ResponseStructContainer c; int channel = 0x00; void setup() { Serial.begin(9600); delay(500); // Startup all pins and UART e22ttl.begin(); c = e22ttl.getConfiguration(); configuration = *(Configuration*) c.data; Serial.println(c.status.getResponseDescription()); configuration.ADDL = 0x03; configuration.ADDH = 0x00; configuration.NETID = 0x00; // configuration.CHAN = 0x23; 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(); } void loop() { channel = channel % 0x25; // scan only 0x22 - 0x24 for testing if (channel == 0x00) { channel = 0x22; } c = e22ttl.getConfiguration(); // change to next channel configuration = *(Configuration*) c.data; configuration.CHAN = channel; e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); Serial.print("channel "); Serial.println(channel); c.close(); delay(1000); while (!e22ttl.available()>1) { ;} // wait for message ResponseContainer rc = e22ttl.receiveMessageRSSI(); // read the String message // If something goes wrong print error if (rc.status.code!=1) { Serial.print("1 "); Serial.println(rc.status.getResponseDescription()); } else if (rc.rssi > 0) { // Print the data received Serial.print(channel); Serial.print("\t"); Serial.print(rc.rssi); Serial.print("\t"); Serial.print(rc.data); Serial.print("\n"); } channel++; }
-
15 March 2024 at 08:31 #30080
Hi Sid,
try to put a bigger delay for every transmission and give our a feedback.
Bye Renzo -
16 March 2024 at 22:51 #30084
When I commented out the code that sets the frequency in the iteration through the channels …
c = e22ttl.getConfiguration(); // change to next channel configuration = *(Configuration*) c.data; configuration.CHAN = channel; e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); Serial.print("channel "); Serial.println(channel); c.close();
the sketch stays on the setup() channel 0x23 and receives the transmission properly. Should I give up on scanning or is there a good way to change the channel on the fly?
-
17 March 2024 at 10:40 #30102
Hi Sid,
try to put the procedure in a function to check if something in the context remains dirty.
Use only local variables and not global ones.
Bye Renzo -
18 March 2024 at 22:21 #30111
Sorry to be a pest and grateful for your help so far, still haven’t been able to change E22 channels on the fly. I replaced the inline channel-changing code with a function as you suggested but that didn’t fix it. The sketch receives data when the channel is fixed but doesn’t when I cycle through the channel, as in the code blow. I re-implemented it with a Pi Pico and get the same behaviour. Have you other suggestions?
/* Look for LoRa transmissions - on Pi Pico, test with sendTester.ino * scans channels 0x22 - 0x24 * receives in transparent mode * writes received channel id, RSSI, message to stdout * * E22 ----- Raspberry Pi Pico * M0 ----- 10 * M1 ----- 11 * TX ----- 9 (PullUP) * RX ----- 8 (PullUP) * AUX ----- 2 (PullUP) */ #include "Arduino.h" #include "LoRa_E22.h" #define ENABLE_RSSI true #define beeper 25 // led signals LoRa reception // ---------- Raspberry PI Pico pins -------------- LoRa_E22 e22ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1 // ------------------------------------- int channel = 0x00; void setup() { Serial.begin(9600); delay(500); // Startup all pins and UART e22ttl.begin(); // If you have ever change configuration you must restore It Configuration configuration; ResponseStructContainer c; c = e22ttl.getConfiguration(); 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(); } void loop() { channel = channel % 0x25; if (channel == 0x00) { channel = 0x22; } // cycle through only 0x22 - 0x24 set_channel(channel); // receives ok if this line commented out Serial.print("channel "); Serial.println(channel); delay(2000); if (e22ttl.available()>1) { // read the String message ResponseContainer rc = e22ttl.receiveMessageRSSI(); // Is something goes wrong print error if (rc.status.code!=1) { Serial.print("0 "); Serial.println(rc.status.getResponseDescription()); } else if (rc.rssi > 0) { // Print the data received // Serial.println(rc.status.getResponseDescription()); Serial.print(channel); Serial.print("\t"); Serial.print(rc.rssi); Serial.print("\t"); Serial.print(rc.data); Serial.print("\n"); } } channel++; } void set_channel(int chan) { Configuration configuration; ResponseStructContainer c; c = e22ttl.getConfiguration(); // change radio to arg channel configuration = *(Configuration*) c.data; configuration.CHAN = chan; e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); c.close(); }
-
8 April 2024 at 22:34 #30297
I’m able to scan channels now. Instead of only changing the channel and saving that parameter alone with setConfiguration() in loop() as in the code above, I copied all of the setup() code between e22ttl.begin() and c.close() into the function set_channel() and call it in loop(), iterating through the channels successfully. When I removed all of the parameter assignments except CHAN from the function, it still worked. Now I see that the above code would have worked if I’d included e22ttl.begin() in the function.
-
8 April 2024 at 22:36 #30298
Hi Sid,
thanks for your feedback, if you can share your code, I think can be usefully for a lot of people.
Bye Renzo
-
-
AuthorPosts
- You must be logged in to reply to this topic.