PostFrontal Forum
PostFrontal Forum
LK8000_Support_Forum | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 LK8000 International Support
 Hardware
 Connecting FLARM, Vario, Radio via WiFi Interface

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
AlphaLima Posted - 18/02/2020 : 08:44:48
If you wand to connect your device via Wifi here is a Do it yourself project based on the ESP32 and Arduino IDE
https://github.com/AlphaLima/ESP32-Serial-Bridge

(Sorry, the previous thread was deleted accidently)
15   L A T E S T    R E P L I E S    (Newest First)
ElEsido Posted - 21/03/2024 : 23:07:33
Hello All

I've been trying to implement this on and off over the last years and never quite succeeded - I am determined to get it done this time but I've hit some road blocks - could somebody help me, please?

Firstly, I've tried a NODE MCU ESP32S and I couldn't get anything uploaded to them (not even Blink). So I tried Wemos Llin32 V 1.0.0 and uploading Blink worked there. As did uploading the serial-wifi sketch.

Regarding the Sketch: I have the following code which says "version 2" - I must admit that over the years I forgot where I downloaded this, but this appears to be different than what AlphaLima had put on Github. Does anybody know if this the latest code, or if the Github version by AlphaLima is the better source?

bool debug = false;

#define VERSION "2.00"

// For AP mode:
String ssid;  // You will connect your phone to this Access Point
String pw; // and this is the password

IPAddress ip(192, 168, 4, 1); // From RoboRemo app, connect to this IP
IPAddress netmask(255, 255, 255, 0);

// You must connect the phone to this AP, then:
// menu -> connect -> Internet(TCP) -> 192.168.4.1:8880  for UART0
//                                  -> 192.168.4.1:8881  for UART1
//                                  -> 192.168.4.1:8882  for UART2




#define NUM_COM   3                 // total number of COM Ports
#define DEBUG_COM 0                 // debug output to COM0
/*************************  COM Port 0 *******************************/
#define UART_BAUD0 19200            // Baudrate UART0
#define SERIAL_PARAM0 SERIAL_8N1    // Data/Parity/Stop UART0
#define SERIAL0_RXPIN 21            // receive Pin UART0
#define SERIAL0_TXPIN 1             // transmit Pin UART0
#define SERIAL0_TCP_PORT 2000       // Wifi Port UART0
/*************************  COM Port 1 *******************************/
#define UART_BAUD1 19200            // Baudrate UART1
#define SERIAL_PARAM1 SERIAL_8N1    // Data/Parity/Stop UART1
#define SERIAL1_RXPIN 16            // receive Pin UART1
#define SERIAL1_TXPIN 17            // transmit Pin UART1
#define SERIAL1_TCP_PORT 4352       // Wifi Port UART1
/*************************  COM Port 2 *******************************/
#define UART_BAUD2 19200            // Baudrate UART2
#define SERIAL_PARAM2 SERIAL_8N1    // Data/Parity/Stop UART2
#define SERIAL2_RXPIN 15            // receive Pin UART2
#define SERIAL2_TXPIN 4             // transmit Pin UART2
#define SERIAL2_TCP_PORT 4353       // Wifi Port UART2

#define bufferSize 1024


//////////////////////////////////////////////////////////////////////////

// ESP32 WiFi <-> 3x UART Bridge
// originally by AlphaLima
// www.LK8000.com


// Disclaimer: Don't use  for life support systems
// or any other situations where system failure may affect
// user or environmental safety.

#include <esp_wifi.h>
#include <WiFi.h>
#include <WebServer.h>
#include <WiFiClient.h>
#include <WebConfig.h>
#include <SPIFFS.h>

HardwareSerial Serial_one(1);
HardwareSerial Serial_two(2);
HardwareSerial* COM[NUM_COM] = {&Serial, &Serial_one , &Serial_two};

#define MAX_NMEA_CLIENTS 4
WiFiServer server_0;
WiFiServer server_1;
WiFiServer server_2;
WiFiServer *server[NUM_COM]={&server_0,&server_1,&server_2};
WiFiClient TCPClient[NUM_COM][MAX_NMEA_CLIENTS];

int com0_br, com1_br, com2_br, com0_tcp, com1_tcp, com2_tcp, tx_power;

uint8_t buf1[NUM_COM][bufferSize];
uint16_t i1[NUM_COM]={0,0,0};

uint8_t buf2[NUM_COM][bufferSize];
uint16_t i2[NUM_COM]={0,0,0};

uint8_t BTbuf[bufferSize];
uint16_t iBT =0;


String params = "["
  "{"
  "'name':'ssid',"
  "'label':'Name of WLAN',"
  "'type':"+String(INPUTTEXT)+","
  "'default':'HB-3280-HS'"
  "},"
  "{"
  "'name':'pwd',"
  "'label':'WLAN Password',"
  "'type':"+String(INPUTTEXT)+","
  "'default':'Flightcomputer'"
  "},"
 "{"
  "'name':'com0_br',"
  "'label':'COM0 Baudrate',"
  "'type':"+String(INPUTNUMBER)+","
  "'min':40,'max':115000,"
  "'default':'19200'"
  "}," 
  "{"
  "'name':'com0_tcp_port',"
  "'label':'COM0 TCP Port',"
  "'type':"+String(INPUTNUMBER)+","
  "'min':40,'max':65000,"  
  "'default':'4352'"
  "},"
  "{"
  "'name':'com1_br',"
  "'label':'COM1 Baudrate',"
  "'type':"+String(INPUTNUMBER)+","
  "'min':40,'max':115000,"
  "'default':'19200'"
  "}," 
  "{"
  "'name':'com1_tcp_port',"
  "'label':'COM1 TCP Port',"
  "'type':"+String(INPUTNUMBER)+","
  "'min':40,'max':65000,"
  "'default':'4353'"
  "},"
 "{"
  "'name':'com2_br',"
  "'label':'COM2 Baudrate',"
  "'type':"+String(INPUTNUMBER)+","
  "'min':40,'max':115000,"
  "'default':'19200'"
  "}," 
  "{"
  "'name':'com2_tcp_port',"
  "'label':'COM2 TCP Port',"
  "'type':"+String(INPUTNUMBER)+","
  "'min':40,'max':65000,"
  "'default':'2000'"
  "},"
  "{"
  "'name':'tx_power',"
  "'label':'Tx Power',"
  "'type':"+String(INPUTRANGE)+","
  "'min':40,'max':80,"
  "'default':'50'"
  "},"
  "{"
  "'name':'debug_on',"
  "'label':'Debug on',"
  "'type':"+String(INPUTCHECKBOX)+","
  "'default':'0'"
  "}"  
  "]";

WebConfig conf;

// Set web server port number to 80
WebServer web(80);  // Object of WebServer(HTTP port, 80 is defult)


void setup() {

  delay(500);

  SPIFFS.begin(true);
  conf.setDescription(params);
  conf.readConfig();
  assign_values();

  server_0 = WiFiServer(com0_tcp);
  server_1 = WiFiServer(com1_tcp);
  server_2 = WiFiServer(com2_tcp);

  COM[0]->begin(com0_br, SERIAL_PARAM0, SERIAL0_RXPIN, SERIAL0_TXPIN);
  COM[1]->begin(com1_br, SERIAL_PARAM1, SERIAL1_RXPIN, SERIAL1_TXPIN);
  COM[2]->begin(com2_br, SERIAL_PARAM2, SERIAL2_RXPIN, SERIAL2_TXPIN);
  
  if(debug) COM[DEBUG_COM]->println("\n\nLK8000 WiFi serial bridge V1.00");
  
  if(debug) COM[DEBUG_COM]->println("Open ESP Access Point mode");
  //AP mode (phone connects directly to ESP) (no router)
  WiFi.mode(WIFI_AP);

  if (conf.values[0] != "") {
   COM[DEBUG_COM]->printf("ssid, pw: %s -%s\n",ssid.c_str(), pw.c_str());
  } 
  WiFi.softAP(ssid.c_str(), pw.c_str()); // configure ssid and password for softAP
  delay(2000);
  WiFi.softAPConfig(ip, ip, netmask); // configure ip address for softAP 

  COM[0]->println("Starting TCP Server 1");  
  if(debug) COM[DEBUG_COM]->println("Starting TCP Server 1");  
  server[0]->begin(); // start TCP server 
  server[0]->setNoDelay(true);
  COM[1]->println("Starting TCP Server 2");
  if(debug) COM[DEBUG_COM]->println("Starting TCP Server 2");  
  server[1]->begin(); // start TCP server 
  server[1]->setNoDelay(true);
  COM[2]->println("Starting TCP Server 3");
  if(debug) COM[DEBUG_COM]->println("Starting TCP Server 3");  
  server[2]->begin(); // start TCP server   
  server[2]->setNoDelay(true);

  esp_err_t esp_wifi_set_max_tx_power((uint8_t) tx_power);  //min 40, max 80

  web.on("/", handle_root);
  web.begin();
  if(debug) COM[DEBUG_COM]->println("Starting Web Server"); ;
  delay(100);


}


void loop() 
{  
  
  for(int num= 0; num < NUM_COM ; num++)
  {
    if (server[num]->hasClient())
    {
      for(byte i = 0; i < MAX_NMEA_CLIENTS; i++){
        //find free/disconnected spot
        if (!TCPClient[num][i] || !TCPClient[num][i].connected()){
          if(TCPClient[num][i]) TCPClient[num][i].stop();
          TCPClient[num][i] = server[num]->available();
          if(debug) COM[DEBUG_COM]->print("New client for COM"); 
          if(debug) COM[DEBUG_COM]->print(num); 
          if(debug) COM[DEBUG_COM]->println(i);
          continue;
        }
      }
      //no free/disconnected spot so reject
      WiFiClient TmpserverClient = server[num]->available();
      TmpserverClient.stop();
    }
  }
 
  for(int num= 0; num < NUM_COM ; num++)
  {
    if(COM[num] != NULL)          
    {
      for(byte cln = 0; cln < MAX_NMEA_CLIENTS; cln++)
      {               
        if(TCPClient[num][cln]) 
        {
          while(TCPClient[num][cln].available())
          {
            buf1[num][i1[num]] = TCPClient[num][cln].read(); // read char from client (LK8000 app)
            if(i1[num]<bufferSize-1) i1[num]++;
          } 

          COM[num]->write(buf1[num], i1[num]); // now send to UART(num):
          i1[num] = 0;
        }
      }
  
      if(COM[num]->available())
      {
        while(COM[num]->available())
        {     
          buf2[num][i2[num]] = COM[num]->read(); // read char from UART(num)
          if(i2[num]<bufferSize-1) i2[num]++;
        }
        // now send to WiFi:
        for(byte cln = 0; cln < MAX_NMEA_CLIENTS; cln++)
        {   
          if(TCPClient[num][cln])                     
            TCPClient[num][cln].write(buf2[num], i2[num]);
        }
        i2[num] = 0;
      }
    }    
  }

  web.handleClient();
}


// Handle root url (/)
void handle_root() {
  conf.handleFormRequest(&web);
  if (web.hasArg("SAVE")) {
    uint8_t cnt = conf.getCount();
    COM[DEBUG_COM]->printf("*********** Konfiguration ************, %i elements\n", cnt);
    for (uint8_t i = 0; i<cnt; i++) {
      COM[DEBUG_COM]->print(conf.getName(i));
      COM[DEBUG_COM]->print(" = ");
      COM[DEBUG_COM]->println(conf.values[i]);
    }
    conf.writeConfig();
  }
}

// Handle root url (/)
void assign_values() {
    ssid =     conf.getString("ssid");
    pw =     conf.getString("pwd");
    com0_br = conf.getInt("com0_br");
    com0_tcp = conf.getInt("com0_tcp_port");
    com1_br = conf.getInt("com1_br");
    com1_tcp = conf.getInt("com1_tcp_port");
    com2_br = conf.getInt("com2_br");
    com2_tcp = conf.getInt("com2_tcp_port");
    tx_power = conf.getInt("tx_power");
    debug = conf.getBool("debug");
}


This code generates an Wifi network to which I can connect my cell phone. I a test setup with two FDTI232's and a and MAX 3232 and an associated power supply wtih some caps (as suggested in the thread about this project on the German Segelflugforum which unfortunately is inaccessible in the meantime). I wanted to test that with some instances of YAT (Yet Another Terminal) but I am completely lost and I couldn't establish a connection. Could somebody walk me through a test process, please?


Lastly, I have been working on a PCB and I'm not sure if I thought of everything. I am no electronic engineer - at all - would somebody with the skills mind taking a look, please? Happy to share all files, I've made it in Eagle. Connections are the PDA port of an LX8080 that provides PWR and a 3.3v signal; and a serial connection to the radio with a 12V signal level.
Images: https://www.swisstransfer.com/d/51e8a42a-33d3-402a-b870-986be942d161
Eagle Files: https://www.swisstransfer.com/d/63539391-4cfb-44e2-ba62-6836768d02c3
(Both links are valid until 20 April 2024 - happy to re-share later.

Thanks so much for any help with this!
Kind regards
Sam (ElEsido)
Marco from Hangar 5 Posted - 25/07/2023 : 12:15:43
After 5 years trying to make Wifi work in my Glider, I have given up on it after finding out that connecting my new Galaxy A34 with multiple Bt adapters is possible after all. (see new topic 'Lxnav Powermouse + S80 + Soartronic Bt')

During my first gliding vacation earlier this year I had heaps of problems with the wifi connection, it dropped all the time when flying above cities and villages where of course hundreds of wifi transmitters are broadcasting their availability and internet connectivity.. Today's phones give priority over wifi with internet than the wifi for RS232 data transmission, so the onboard wifi network is dropped all the time. I could re-connect but was quite cumbersome and highly anoying.

Sure, when using wifi on a stand alone device like an Oudi or vertica, it probably works fine, but with smartphones like I do for about 15 years now.. its a pain.

Note that this is a Smartphone issue, the wifi serial bridge is just fine,
So, if someone is looking for a highly configurable wifi serial bridge made by Alphalima, with 3 comports (so 3 devices can be connected), USB Power supply (5V/1.5 amps), red and blue wire leads for power, please drop me a private message.. You will only need to pay shipping costs (about €10 within Europe). First come first served, paypal accepted or IBAN.
antonka Posted - 28/12/2021 : 18:52:22
in the meantime I changed 2 more things in the wifi initialisation:
I set a channel. And I reduce wifi power so the squelch of the radio can stay low!


int channel = 1;


uint32_t brown_reg_temp = READ_PERI_REG(RTC_CNTL_BROWN_OUT_REG); //save WatchDog register

WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector



//AP mode (phone connects directly to ESP) (no router)
WiFi.mode(WIFI_AP);

WiFi.softAP(ssid, pw, channel); // configure ssid and password for softAP
delay(2000); // VERY IMPORTANT
WiFi.softAPConfig(ip, ip, netmask); // configure ip address for softAP
WiFi.setTxPower(WIFI_POWER_2dBm); // MINUS_1dBm, 2, 5 7 8_5 11 13 15 17...

WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, brown_reg_temp); //enable brownout detector


antonka Posted - 26/11/2021 : 09:23:42
I made 3 fully assembled PCBs for the project.
- one with RJ45 für FLARM and RJ11 for FLARM-PLug, COM0 and COM2.
- one with RJ45 für FLARM and RJ11 for FLARM-PLug, COM0 and COM2+ELT
- one with 4 RJ45

for COM1 ( FLARM in my case ) i use a MAX3222 to be able to switch the TX line on/off. - Via software, switch or solder point.

http://www.kaser.at/img/Version-3.pdf
http://www.kaser.at/img/Version-4.pdf

If you want to supply the ELT with GPS info you have to use my Software. Otherwise you can use the Standard Firmware with a "brownout" workaround. - you get that from me....
- dont use BT. never worked stable for me. If you get it working, let me know.
fabe Posted - 11/11/2021 : 21:45:59
Hello,
Thanks to AlphaLima for sharing the project.
Are there other PCB projects (with or without components).
If so, can we buy them.
Thanks in advance.
Fox Posted - 13/04/2021 : 12:54:44
Thanks to AlphaLima for sharing the project

My esp works well at home, hope the same on air :-)
I have only change on config.h the bound rate for my old garmin gps to test it

@antonka
I have use a fixed DC>DC step down converter 12->3.3 v to power ESP32 and TTL>RS232 converter, that is the same to your, now all work good.




antonka Posted - 12/04/2021 : 15:44:38
az-delivery is known for good quality and you will not have any problems as the software works fine for a standard setup.
Just be careful with the MAX3232 PCBs.
I had many of them not working. And you need a good step down converter for the ESP to get it working on 12V. A Linear Regulator is no good solution as they waste to much energy.
I did my first atempt like this: http://www.kaser.at/img/Version-1.pdf - sorry its in german...
Fox Posted - 08/04/2021 : 11:48:49
I have found on Amazon market this model " ESP32 NodeMCU Module WLAN WiFi Development Board with CP2102 " from az delivery https://www.az-delivery.de/en/products/esp32-developmentboard hope it woking fine
can't find Node32s
antonka Posted - 08/04/2021 : 01:54:13
The Wroom 32 and Wroom 32D Modules are fine. 4MB Versions are fine. 8 and 16Mb work as well but are not nescessary.

Never use S2 for this porject. They only support 2 Serial Channels.
AlphaLima Posted - 07/04/2021 : 21:10:06
Node32S
Fox Posted - 07/04/2021 : 18:26:19
there are, on the market, many variations of the ESP32, which one is better to choose? Or which one is best to avoid? https://en.wikipedia.org/wiki/ESP32
antonka Posted - 06/04/2021 : 13:09:30
Thanks to Alphalima for the great Software!

Anyway it took me quite some time to get the hardware working.

Working with a Devkit was fine for the first test. But poor MAX3232 Board quality and way to long soldering effort made me think about a constucting a PCB fitting my needs:

- being able to connect a ELT and support it with GPS data - and have the feedback LED on the Board as well. eg for ACK-E04
- being able to switch Data communication between Wifi and a Cockpit Socket
- use RJ45 connector for FLARM and bridge it to another RJ45 for a Cockpit Socket
- use ether RJ10 or RJ45 Connectors for the other Ports
- As an option supply 5V for charging if needed.

Challenging was the Option to switch TX to FLARM between Wifi and Cockpit Socket as in RS232 never use both inputs at the same time.
First I used a relay. That really worked fine but was way to expensive. - 3-4 Euros...
So I ended with a MAX 3222 and switch the TX-Line on and of ether by a switch or by software.

Also challenging was the baud rate reduction for the ELT. To see other Planes via FLARM on LK8000 you need at least 19200 Baud. So the software had to be modified to send only the GPS data to the ELT with 9600 Baud (the maximum Rate for the E04)

Another workaround had to be done against the so called "brownout problem" when switching on WIFI during boot. That was never a problem on the DevKits but I could not solve it yet on the PCBs. I found a Software solution which works fine now:

if(debug) COM[DEBUG_COM]->println("\n\nLK8000 WiFi serial bridge V1.00");
  #ifdef MODE_AP 
      if(debug) COM[DEBUG_COM]->println("Open ESP Access Point mode");

      uint32_t brown_reg_temp = READ_PERI_REG(RTC_CNTL_BROWN_OUT_REG); //save WatchDog register

      WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector

      //AP mode (phone connects directly to ESP) (no router)
      WiFi.mode(WIFI_AP);
   
      WiFi.softAP(ssid, pw); // configure ssid and password for softAP
      delay(2000); // VERY IMPORTANT
      WiFi.softAPConfig(ip, ip, netmask); // configure ip address for softAP

      WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, brown_reg_temp); //enable brownout detector

  #endif


You can see the progress of project on http://www.kaser.at/post.html
jlder Posted - 05/10/2020 : 15:32:41
Thanks AL,
I have played a bit more with the ESP.
As said, I also changed the code to get an echo on all connected devices, including BT, and it works.
I am using this device : SP-Cow ESP-32S which I found on Amazon.
For noob like me, I found a good tutorial at : https://dronebotworkshop.com/esp32-intro/
For WIFI and BT to compile, it is necessary to use the setup that AL posted on github, in particular the partition scheme: minimal SPIFFS.

I was thinking about using BT to configure the board at startup (BT active only for a few seconds to wait for a connection). This would allow to change ssid/pswd and other configuration items. This could be useful for clubs with multiple gliders using same setup.

AlphaLima Posted - 01/10/2020 : 11:21:00
Hi JL,
Bluetooth does not work correctly in this setup due to resource limitations of the Arduino ESP32 librrary. Keep it disabled!
Yes you the debug informations on COM0, you can disable it bay changing
bool debug = true;
into
bool debug = false;
the file config.h

https://github.com/AlphaLima/ESP32-Serial-Bridge/blob/master/config.h#L10
jlder Posted - 27/09/2020 : 23:45:41
Hello AlphaLima,

I just compiled and ran this sketch on an ESP32.
Beside having to push on the BOOT switch to allow connection and transfer to the ESP32,it seems to work.
I get the LK8000 WIFI ssid on my phone and can connect.
I need to wire the TTL/RS232 boards to verify if I can connect to FLARM and GPS.

Question, I couldn't see the BT on my phone and, looking at the code, I don't understand what the purpose of BT in this sketch.
Can you explain?
Edit: I did forget to include BT in the config file. Now I can see the BT. I have modifed the code to echo whatever is entered on one line TCP, BT, UART back on all lines. Purpose was to verify bilateral communication. I used serial bluetooth terminal and TCP terminal on my android phone to allow connection.

I also noticed that UART 0 is used to broadcast the messages when in debug. On my board, this is the UART port which is used to connect with the PC when connecting the USB interface.
Is this typical?
This means that if a device is connected to the UART 0, there is a conflict.

Regards,
JL

PostFrontal Forum © PostFrontal - La community del Volo a Vela Go To Top Of Page
This page was generated in 0.12 seconds. Snitz Forums 2000

Since 2006, owned and maintained by PostFrontal S.A.S. di Giuliano Golfieri & c. - VAT ID: IT05264240960
THIS WEBSITE ONLY USES FUNCTIONAL COOKIES
Privacy & Cookie Policy