//  update the TTL port speed of the JSY-194 sensor from 9600 to 38400 //
//  * ESP32 + JSY-MK-194 (pins 16 and 17)

#include <HardwareSerial.h>

#define RXD2 16
#define TXD2 17


void setup() {

  Serial.begin(115200);
  Serial2.begin(4800, SERIAL_8N1, RXD2, TXD2); // CONNECTION PORT WITH THE JSY-MK-194 SENSOR

             }


void loop() {

delay (60);

byte msg[] = {0x00,0x10,0x00,0x04,0x00,0x01,0x02,0x01,0x08,0xAA,0x12}; // switch TTL port to 38400
// 00 10 00 04 00 01 02 01 06 2B D6 to switch to 9600
// 00 10 00 04 00 01 02 01 08 AA 12 to switch to 38400

 int i;
 int len=11; 

// send the request to switch the port from 9600 to 38400 //

 for(i = 0 ; i < len ; i++)
{
      Serial2.write(msg[i]); 
         
}
 len = 0;
                   
            }     