Best plugin to start from for 2-way serial communication

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
fluppie
Normal user
Posts: 81
Joined: 09 Oct 2015, 13:23

Best plugin to start from for 2-way serial communication

#1 Post by fluppie » 06 Jun 2019, 00:36

I want to develop a serial plugin for ESP Easy that sends and receives commands over software serial.
Which plugin is the best to start from? Using 2-way communication, send and receive.

For example the command to fetch the serial number of the connected device:

Code: Select all

byte stx[] = {0x02};
byte etx[] = {0x03};
byte ack[] = {0x06};
byte cmd1[] = {0x30, 0x34, 0x36, 0x34}; //0464 // Serial Number
byte cmd2[] = {0x30, 0x38, 0x36, 0x38}; //0868 // Unknown
byte cmd3[] = {0x30, 0x39, 0x36, 0x39}; //0969 // Operating time

        mySerial.write(stx[0]);
        mySerial.write(cmd1[0]);
        mySerial.write(cmd1[1]);
        mySerial.write(cmd1[2]);
        mySerial.write(cmd1[3]);
        mySerial.write(etx[0]);
Then to parse incoming data:

Code: Select all

        
//============serial num=============//
void serial_num()
{
  data_array[10] = 0; //terminate original string early
  Serial.print("Serial number: ");
  Serial.println(&data_array[2]);

}

void operating_time()
{
  data_array[10] = 0; //terminate original string early
  runningtime = strtoul(&data_array[2], NULL, 16);
  Serial.println(runningtime); // in quarter seconds

  Serial.print("Running Time: ");
  float runningtimef = runningtime;
  Serial.println(runningtimef / 4 / 60 / 60); // divide decimal number / 4 / 60 / 60 to get running time in hours
}

fluppie
Normal user
Posts: 81
Joined: 09 Oct 2015, 13:23

Re: Best plugin to start from for 2-way serial communication

#2 Post by fluppie » 03 Aug 2019, 10:57

Anyone who can tell me which serial plugin is using the best for send / receive within the plugin?

TD-er
Core team member
Posts: 1811
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Best plugin to start from for 2-way serial communication

#3 Post by TD-er » 03 Aug 2019, 13:12

I am already working on it.
See my progress here:
https://github.com/TD-er/ESPEasy/tree/f ... rial_proxy

Current status:
It can read a string from serial and send it (as a string) to a controller.

Still to do:
- user define init string (to initiate device connected)
- Add some timeout settings (when is a sentence finished, or when to send init string again)
- Add pin to allow to reset connected device
- Option to interpret received data as numerical.
- Receive strings/values from controller. (that's going to be a lot of work)

fluppie
Normal user
Posts: 81
Joined: 09 Oct 2015, 13:23

Re: Best plugin to start from for 2-way serial communication

#4 Post by fluppie » 05 Aug 2019, 11:09

OK cool, I tried the custom and dev build. Or should I self-compile to get this one in?

TD-er
Core team member
Posts: 1811
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Best plugin to start from for 2-way serial communication

#5 Post by TD-er » 05 Aug 2019, 20:47

Self compile.
I have not yet included in any build, since it is really a work in progress.
But since it also needed some changes in the rest of ESPeasy I didn't want to wait to long to merge it or else I may trouble myself in merging future pull requests.
So that's why I already merged it, but it will change in the next week.
A work-in-progress so to speak.

fluppie
Normal user
Posts: 81
Joined: 09 Oct 2015, 13:23

Re: Best plugin to start from for 2-way serial communication

#6 Post by fluppie » 07 Aug 2019, 14:28

Do I need to define/undefine something? Since it's not appearing in the normal, testing and dev build when self-compiling.

fluppie
Normal user
Posts: 81
Joined: 09 Oct 2015, 13:23

Re: Best plugin to start from for 2-way serial communication

#7 Post by fluppie » 06 Sep 2019, 11:34

Any update on this? Is it included in the testing builds or do we need to uncomment something to use it?

TD-er
Core team member
Posts: 1811
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Best plugin to start from for 2-way serial communication

#8 Post by TD-er » 06 Sep 2019, 11:50

The SerialProxy plugin is merged into mega branch and should be included in the "custom" build (if that one is included in the nightly's)

fluppie
Normal user
Posts: 81
Joined: 09 Oct 2015, 13:23

Re: Best plugin to start from for 2-way serial communication

#9 Post by fluppie » 06 Sep 2019, 20:48

ESP_Easy_mega-20190903_custom_ESP8266_4M1M

Should be this one then :)?

TD-er
Core team member
Posts: 1811
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Best plugin to start from for 2-way serial communication

#10 Post by TD-er » 07 Sep 2019, 00:28

Yep, please let me know if you like the general idea of it or need some changes to make it really useful.
It is currently only sending 1 string you can specify in the plugin and sending any line of text to the controller you specify.
N.B. not all controllers support sending strings, but at least the MQTT controllers do.

hipek189
Normal user
Posts: 1
Joined: 22 Nov 2018, 19:00

Re: Best plugin to start from for 2-way serial communication

#11 Post by hipek189 » 15 Oct 2019, 17:30

Hey great thing would be good if two sides could communicate with the mqtt controller

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 21 guests