ESP32 Python - DIGITAL LOSS-BER TESTER for radio amateur networks DMR, YSF, D-STAR.

rn6ljk
Posts: 1
Joined: Sun Feb 10, 2019 7:09 am

ESP32 Python - DIGITAL LOSS-BER TESTER for radio amateur networks DMR, YSF, D-STAR.

Postby rn6ljk » Sun Feb 10, 2019 8:25 am

If you, are not sure whether accept you, and with what quality in radio amateur networks DMR, YSF or D-STAR networks, then you will be helped by DIGITAL LOSS BER TESTER, having displayed your call sign whether packets of your transfer, and percent of errors were lost.
DIGITAL LOSS BER TESTER a tester is the device for removal, accumulation and information display about passings of a signal in radio amateur networks DMR, YSF, D-Star at observance of a condition that the radio station of the user carries out data exchange with network by means of the MMDVM device under control of the Pi-Star program.
The device consists of the client and server parts executed on microcontrollers of ESP-32, ESP-8266 series. The server addresses the Dashboard page of the Pi-star program, reads out indications of the last connection with an interval 5-10 with, transfers them to the server (IoT) ThingSpeak. A client part with an interval 10 with reads out data with ThingSpeak and brings them to the OLED monitor. A set of indications represents the sequence of the following attributes: call sign, connection time, BER value, Loss value. The platform of programming of ESP-32 and ESP-8266 is MicroPython.
Image
When developing and debugging the author applied the following ready payments:
1. TTGO New WiFi Bluetooth Module 18650 Battery holder ESP32 4 MB SPI Flash 4 MB Psram 2A fuse
2. 868 мГц-915 мГц SX1276 ESP32 Lora 0.96 OLED Bluetooth WI-FI Lora
3. D1 mini - Mini NodeMcu 4M bytes Lua WIFI Internet of Things development board based ESP8266 by WeMos
All three payments are stitched under programming on MicroPython since payments come stitched under Arduino. The author used the EsPy.exe program.
The technique is in detail described here:
https://github.com/jungervin/EsPy
Posledniyeversiya of firmwares of MicroPython are downloaded from here:
http://micropython.org/download
On sale there are payments with hardwired Micropython, but the author did not test them.

The payment of SX1276 ESP32 Lora of 0.96 inches the blue OLED display is applied to a client part and it is required to write in it the Client.py file. Technique here: https://github.com/jungervin/EsPy.
Image
Server part gathers according to the scheme:
Image

Listing for each payment:
Client.py
  1. #ESP-32 Lora  -
  2. #sapmple for RC7LL
  3. #
  4.  
  5. Coll='RC7LL'    # sample
  6. GET="https://api.thingspeak.com/channels/631265/fields/1.json?api_key=****************&results=1"
  7.  
  8. import time
  9. import network
  10. import machine
  11. import ssd1306  # ssd1396  
  12. from machine import Pin,I2C
  13. save_entities=False
  14. p16 = Pin(16, Pin.OUT)
  15. p16.value(1)
  16. i2c = machine.I2C(-1, machine.Pin(15), machine.Pin(4))
  17. oled = ssd1306.SSD1306_I2C(128, 32, i2c)
  18.  
  19. oled.fill(0)
  20. oled.text('Tester DMR', 0, 0)
  21. oled.show()
  22.  
  23. j=7 # количество WIFI точек
  24.  
  25. # массив с именами и паролями точек WIFI
  26. ssid = [['WIFI1','WIFI2','WIFI3','WIFI4', 'WIFI5','WIFI6','WIFI7'], ['pass1','pass2','pass3','pass4', 'pass5', 'pass6','pass7']]
  27.  
  28. wifi = network.WLAN(network.STA_IF)
  29. time.sleep(2)
  30. wifi.active(True)
  31. time.sleep(2)
  32. i=0
  33. for i in range (j):
  34.     wifi.connect(ssid[0][i], ssid[1][i])
  35.     time.sleep(5)
  36.     con=wifi.isconnected()
  37.     if con:
  38.         ssid[0][i]
  39.         con
  40.         oled.fill(0)
  41.         oled.text(ssid[0][i], 0, 00)
  42.         oled.text('True', 0, 10)
  43.         oled.show()
  44.         break
  45.     else:
  46.         ssid[0][i]
  47.         con
  48.         oled.fill(0)
  49.         oled.text(ssid[0][i], 0, 00)
  50.         oled.text('False', 0, 10)
  51.         oled.show()
  52.         continue
  53.  
  54. import urequests
  55. s=1
  56. while s ==1:
  57.  
  58.     time.sleep(5)
  59.     if wifi.isconnected():
  60.         ss=urequests.get(GET)
  61.         i=ss.text.find(Coll)-9
  62.         if i > 0:
  63.             col=''
  64.             while ss.text[i]!='"':
  65.                 col=col+ss.text[i]
  66.                 i=i+1            
  67.             oled.fill(0)
  68.             oled.text(col, 0, 00)            
  69.             loss=''
  70.             j=col.find("|")+1
  71.             if j>0:
  72.                 while col[j]!='|':
  73.                     loss=loss+col[j]
  74.                     j=j+1      
  75.                 loss_="loss="+loss+"%"
  76.                 oled.text(loss_, 0, 10)
  77.                 ber=''
  78.                 j=j+1
  79.                 col=col+" "
  80.                 while col[j]!='|':
  81.                     ber=ber+col[j]
  82.                     j=j+1      
  83.                 ber_="ber ="+ber+"%"
  84.                 oled.text(ber_, 0, 20)
  85.                 oled.show()
  86.  
  87. oled.fill(0)
  88. oled.text(col, 0, 00)
  89. oled.text(loss_, 0, 10)
  90. oled.text("S T O P  Tester", 0, 20)
  91. oled.show()
Connect.py :
  1. #ESP32  Connect  
  2. #  
  3. #  https://github.com/LilyGO/TTGO-T8-ESP32                                                                                #    
  4.  
  5. ip="http://192.168.8.104/"
  6. passw='**********'
  7. ssid= '**********'
  8.  
  9. Coll_1='RN6LJK '   
  10. GET_1="https://api.thingspeak.com/update?api_key=****************&field1="
  11. Coll_2='RC7LL '    
  12. GET_2="https://api.thingspeak.com/update?api_key=****************&field1="
  13. Coll_3='RA3AET '   
  14. GET_3="https://api.thingspeak.com/update?api_key=****************&field1="
  15.  
  16. import time
  17. import network
  18. import machine
  19. import urequests
  20. from machine import Pin,I2C
  21. save_entities=False
  22. p12 = Pin(12, Pin.OUT)  #12
  23. p12.value(1)
  24. sta_if = network.WLAN(network.STA_IF)
  25. time.sleep(2)
  26. sta_if.active(True)
  27. time.sleep(2)
  28. sta_if.connect(ssid,passw)
  29. time.sleep(5)
  30. sta_if.isconnected()
  31.  
  32.  
  33. t0=1    #  0  pin12
  34. tt=4    #
  35. d1=21   # d1, d2   "<tr><td align="
  36. d2=29
  37. t_o=7   # thingspeak.com
  38.  
  39.  
  40. f1_old='00:00:00'
  41.  
  42. while True:
  43.  
  44.     p12.value(1)
  45.    
  46.     if sta_if.isconnected():
  47.         r=[0]
  48.         r = urequests.get(ip)
  49.         time.sleep(tt)
  50.  
  51.         c=r.text.find(">TX</td><td></")   #
  52.         if c>6500:          #
  53.             c=-10
  54.  
  55.         if c <0:
  56.             c=r.text.find("<tr><td align=")  #
  57.             f1=r.text[c+d1:c+d2]             #  
  58.            
  59.             ber=''                          # BER
  60.             c=r.text.find("%</td></tr>")
  61.             i=c+1
  62.             while r.text[i]!=">":
  63.                 i=i-1
  64.             j=i+1
  65.             while r.text[j]!="%":
  66.                 ber=ber+r.text[j]
  67.                 j=j+1
  68.             ber="|"+ber+"|"
  69.             f4=ber
  70.             c=r.text.find("%</td><td")
  71.             loss=''                     #  LOSS
  72.             i=c+1
  73.             while r.text[i]!=">":
  74.                 i=i-1
  75.             j=i+1
  76.             while r.text[j]!="%":
  77.                 loss=loss+r.text[j]
  78.                 j=j+1
  79.             loss="|"+loss
  80.             f3=loss
  81.  
  82.             col=''                            #
  83.             i=r.text.find('</a></td><td align="left">TG')  
  84.             while r.text[i]!=">":
  85.                 i=i-1
  86.             i=i+1
  87.             while r.text[i]!='<':
  88.                 col=col+r.text[i]
  89.                 i=i+1
  90.             f2=col+" "
  91.  
  92.  
  93.             if ((f2==Coll_1) and (f1 != f1_old)):   #RN6LJK
  94.                 f1_old=f1
  95.                 f1_old
  96.                 f2
  97.                 ss=[0]
  98.                 ss=urequests.get(GET_1+f1+" "+f2+f3+f4)  
  99.                 time.sleep(t_o)
  100.                 print(ss.text)
  101.  
  102.             if ((f2==Coll_2) and (f1 != f1_old)):   #RC7LL
  103.                 f1_old=f1
  104.                 f1_old
  105.                 f2
  106.                 ss=[0]
  107.                 ss=urequests.get(GET_2+f1+" "+f2+" "+f3+f4)  
  108.                 time.sleep(t_o)
  109.                 print(ss.text)
  110.  
  111.             if ((f2==Coll_3) and (f1 != f1_old)):   #RA3AET
  112.                 f1_old=f1
  113.                 f1_old
  114.                 f2
  115.                 ss=[0]
  116.                 ss=urequests.get(GET_3+f1+" "+f2+f3+f4)  
  117.                 time.sleep(t_o)
  118.                 print(ss.text)
  119.        
  120.             p12.value(0)
  121.             time.sleep(t0)
  122.             continue
  123.         p12.value(0)
  124.         time.sleep(t0)
  125.         continue
  126.     continue
Control.py:
  1. import time
  2. import machine
  3. from machine import Pin
  4. save_entities=False
  5. p16 = Pin(16, Pin.IN)  #D0  # Connect - р12
  6. p14 = Pin(14, Pin.OUT) #D5  # Connect - RST
  7. p2 = Pin(2, Pin.OUT)        #
  8. p14.value(1)
  9. tz=5    #
  10. tp=3    #
  11. time.sleep(tz)
  12. t10=time.time()
  13. t00=time.time()
  14.  
  15. while True :
  16.    
  17.     pp=p16.value()
  18.     if pp ==1:
  19.         p2.value(0)
  20.         t11=time.time()
  21.         tt1=t11-t10
  22.         t00=time.time()
  23.         if tt1>tp:
  24.             print('tt1zzz=')
  25.             tt1                 #
  26.             p13.value(0)
  27.             p13.value(1)
  28.             time.sleep(tz)
  29.             p14.value(0)
  30.             p14.value(1)
  31.             time.sleep(tz)
  32.             t10=time.time()
  33.             t00=time.time()
  34.     if pp ==0:
  35.         p2.value(1)
  36.         t01=time.time()  
  37.         tt0=t01-t00      
  38.  
  39.         if tt0>tp:
  40.             print('tt0zzz=')    #
  41.             tt0
  42.             p13.value(1)
  43.             p13.value(0)
  44.             time.sleep(tz)
  45.             p14.value(0)
  46.             p14.value(1)
  47.             time.sleep(tz)
  48.             t10=time.time()
  49.             t00=time.time()
  50.         t10=time.time()
********************* END********************
RN6LJK@MAIL.RU
Attachments
Client.png
Client.png (747.61 KiB) Viewed 451 times
Shema.png
Shema.png (393.67 KiB) Viewed 451 times
Head.png
Head.png (344.46 KiB) Viewed 451 times

Who is online

Users browsing this forum: No registered users and 1 guest