How to use a serial port in a custom plugin? (for new RESOL plugin)

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
chunter1
Normal user
Posts: 82
Joined: 22 Jan 2016, 22:40

How to use a serial port in a custom plugin? (for new RESOL plugin)

#1 Post by chunter1 » 28 Apr 2016, 14:13

I would like to write a plugin for a solar collector controller from RESOL. (DeltaSol Pro)
The controller has a serial port and sends temperature and status data periodically.

What i need is an advice how to correctly implement a serial port in an ESPEasy plugin that receives data also in the background.
I found a plugin using "#include <SoftwareSerial.h>" but i am not sure if it can be used to capture data arriving periodically?

miim
New user
Posts: 5
Joined: 20 Mar 2016, 09:53

Re: How to use a serial port in a custom plugin? (for new RESOL plugin)

#2 Post by miim » 28 Apr 2016, 20:47

Hi chunter1
you should use SoftwareSerial.h only if you need a second serial port on the esp8266: it simulates a software serial port with a gpio.
It works very well for me, but it is not robust to interferences/glitches...
e.g. http://www.esp8266.nu/forum/viewtopic.p ... 1087#p5915

If you need only one serial port, just use Serial.begin
e.g. https://github.com/ESP8266nu/ESPEasy/bl ... Serial.ino
https://github.com/ESP8266nu/ESPEasy/bl ... er2Net.ino

b.r.
miim

chunter1
Normal user
Posts: 82
Joined: 22 Jan 2016, 22:40

Re: How to use a serial port in a custom plugin? (for new RESOL plugin)

#3 Post by chunter1 » 29 Apr 2016, 00:57

Is it correct, that with your plugin i can connect the serial output of a device to a ESP8266 pin and the data will be available in a terminal that connects to the espeasy onthe specified TCP port?
What terminal do you recommend for testing?
I tried putty using telnet and the specified port - however there is no data coming in.
I guess telnet is the wrong thing to use?

miim
New user
Posts: 5
Joined: 20 Mar 2016, 09:53

Re: How to use a serial port in a custom plugin? (for new RESOL plugin)

#4 Post by miim » 29 Apr 2016, 19:51

Hi chunter1
as I wrote before, do not use my plugin _P030_swser.ino with SoftwareSerial, which is not trivial.
Use the standard ser2net plugin, which is not mine.
https://github.com/ESP8266nu/ESPEasy/bl ... er2Net.ino
It is much easier and more stable; use my plugin only if you need 2 serial ports at the same time.

You set the port at which you want to connect e.g. 1234, then you connect with telnet, or what you want to the port
e.g.

Code: Select all

telnet 10.0.2.2 1234
if you have a unix laptop and you are receiving hex code

Code: Select all

nc 10.0.2.2 1234 | hexdump -C

for _P020_Ser2Net.ino use IO01(D10) and IO03(D9)
for my _P030_swser.ino use IO14(D5) and IO12(D6)

Post Reply

Who is online

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