How to automatic packet transmission of Microchip RN2903 every 2 minutes?

I am new to play with LoRaWAN and using Microchip RN 2903 to repeat packet transmission after every minute or two for 30 packets to check the packet delivery rate in the presence of an RF transmitter operating on the same co bands as the end devices. Now, I am using Termite terminal utility to communicate through a serial port to send a packet using the command: mac tx uncnf 1 payload.

I send 30 packets in total with 1 or 2 minutes delay. How can I write a script to automate this transmission so the device keeps on sending messages without my manual issuance of command? Any idea would be appreciated.

Since you really shouldn’t be transmitting that frequently, why should anyone help you?

Perhaps before running experiments you should put some more thought into the nature of this interfering transmitter and why you expect it to be an issue.

We are actually checking the interference of data packet communication with the power of RF chargers in the vicinity to operate on the same frequencies. We are trying to gauge how does it impact the standard communication (in the absence of RF transmitter). Any problem?

why we should not be transmitting as long as we comply with fair access policy?

Send 1 packet to comply instead of 30.

1 packet per day? while operating on DR3, we can send 530 messages per day to comply with fair usage. what are you referring to?

I am seeking help with automatic message transmission if you have idea?

I understood 30 packets per 1 - 2 minutes.

Even if you transit every minute, TTN wants wants every minutes, not minute. What’s the reason for so much frequent transmissions?

You can simply have your interference, transmit and check what happened.

If I understood, you want this. (I don’t know about RN)

I would write a python script. What you’re suggesting shouldn’t take more than 40 lines or so.
If you’re developing on a system with linux on it, you probably already have python on it.
I could write a quick example of such a script, maybe I’ll post something later today.

1 Like

Something like this, I believe the code is self-explaining and should be easy to customise.
By default, it expects to be run on Linux with a USB-serial converter on /dev/ttyUSB0 and as a user which has write access to the serial port (e.g. in ‘dialout’ group). On Windows, I think you can use parameter -s COMx. This depends on python serial port support, so you have to install that too, it’s usually called ‘python3-serial’ I think.

#!/usr/bin/env python3

import time
import argparse
import serial

def send(serialport, bitrate, text, iterations, interval):
    print(f'Sending "{text}" with interval {interval} to {serialport} @ {bitrate}"')
    with serial.Serial(serialport, bitrate) as ser:
        for i in range(iterations):
            print(f'Iteration {i}/{iterations}')
            ser.write(text.encode('ascii'))
            ser.write('\n'.encode('ascii'))
            time.sleep(interval)

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-s", "--serialport", help="The serial port", default="/dev/ttyUSB0")
    parser.add_argument("-b", "--bitrate", help="Serial port bit rate", default=57600)
    parser.add_argument("-t", "--text", help="The text to send", default="mac tx uncnf 1")
    parser.add_argument("-n", "--iterations", help="The number of iterations", default=30)
    parser.add_argument("-i", "--interval", help="The poll interval (seconds)", default=10.0)
    args = parser.parse_args()

    send(args.serialport, args.bitrate, args.text, int(args.iterations), float(args.interval))

if __name__ == "__main__":
    main()
3 Likes

Serial terminal programs like TeraTerm have script allows serial transmission in loops, with variables

1 Like

Thanks very much Bertrik for your help. I am using system with windows. I ll give it a try to see what happens.

I am new to TeraTerm. I ll also have a look on it how can we write a short script on that. If you can share some example, that would be appreciated.