TP-Link HS110

For issues with communication ports, protocols, etc.
badidea
Posts: 1570
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: TP-Link HS110

Postby badidea » Nov 06, 2019 16:57

Dinosaur wrote:@badidea, dowloaded the zip and it compiles ok, but when I run it:
"Waiting for connection" and then quits with Error 141.

I could not find anywhere in the code where your IP detail is stored.
Without thoroughly reading all the code can you explain this please, so I can test it for a long duration.

In "HS110_power_logger_03.bas", line 263:
retCon = hs110.connect("HS110-1", 9999)
Change "HS110-1" with your IP and try again.

Error 141 seems to be: "SIGPIPE, The SIGPIPE signal is sent to a process when it attempts to write to a pipe without a process connected to the other end." Or: "Write on a pipe with no one to read it".

BTW: Getting the code Windows compatible will be some work. My non-blocking connect() addition to SNC gives a few errors:

Code: Select all

C:\Tools\FreeBASIC-1.04.0-win32\fbc.exe -w all "HS110_power_logger_03.bas" (in directory: D:\Projects\FreeBASIC\hs110\HS110_power_logger)
D:\Projects\FreeBASIC\hs110\HS110_power_logger\inc\snc.bi(318) error 41: Variable not declared, fcntl in 'dim as long flags = fcntl(sock, F_GETFL, NULL)'
D:\Projects\FreeBASIC\hs110\HS110_power_logger\inc\snc.bi(321) error 3: Expected End-of-Line, found 'fcntl' in 'fcntl(sock, F_SETFL, flags or O_NONBLOCK)'
D:\Projects\FreeBASIC\hs110\HS110_power_logger\inc\snc.bi(339) error 14: Expected identifier, found 'socklen_t' in 'dim as socklen_t optlen = sizeof(optval)'
D:\Projects\FreeBASIC\hs110\HS110_power_logger\inc\snc.bi(340) warning 3(1): Passing different pointer types, at parameter 4 of GETSOCKOPT()
D:\Projects\FreeBASIC\hs110\HS110_power_logger\inc\snc.bi(340) error 41: Variable not declared, optlen in 'getsockopt(sock, SOL_SOCKET, SO_ERROR, @optval, @optlen)'
D:\Projects\FreeBASIC\hs110\HS110_power_logger\inc\snc.bi(349) error 9: Expected expression, found 'fcntl' in 'flags = fcntl(sock, F_GETFL, NULL)'
D:\Projects\FreeBASIC\hs110\HS110_power_logger\inc\snc.bi(351) error 3: Expected End-of-Line, found 'fcntl' in 'fcntl(sock, F_SETFL, flags and not(O_NONBLOCK))'
Compilation failed.

The main issue seems to be 'fcntl'
Dinosaur
Posts: 1300
Joined: Jul 24, 2005 1:13
Location: Searcy AR USA
Contact:

Re: TP-Link HS110

Postby Dinosaur » Nov 06, 2019 19:14

Hi All

Just making sure I have everything right before I leave the Power monitor running for a day or two.
Changed the location of the plug to record my frequent coffee boils.
The kettle shows the following:
1500 Watt
120 VAC
Being a resistive element, I guess the power factor will be close to 1.
The following is what was recorded.

Code: Select all

13:00:38   123.946   13.828   1703.844   0.994
13:00:39   123.829   13.859   1713.343   0.998
13:00:40   123.879   13.835   1711.153   0.998
13:00:41   124.057   13.819   1711.537   0.998
13:00:42   124.114   13.797   1709.732   0.998
13:00:43   124.053   13.776   1706.245   0.998
13:00:44   123.974   13.752   1702.143   0.998
13:00:45   123.953   13.738   1700.172   0.998
13:00:46   123.968   13.728   1699.176   0.998
13:00:47   123.897   13.713   1696.351   0.998
13:00:48   123.865   13.703   1694.674   0.998
13:00:49   124.061   13.714   1698.752   0.998
13:00:50   124.184   13.709   1699.767   0.998
13:00:51   124.081   13.715   1699.154   0.998
13:00:52   124.264   13.719   1702.154   0.998
13:00:53   124.102   13.709   1698.654   0.998
13:00:54   124.128   13.699   1697.931   0.999
13:00:55   124.039   13.698   1696.542   0.999
13:00:56   123.959   13.700   1695.554   0.998
13:00:57   124.088   13.696   1696.953   0.998
13:00:58   124.183   13.693   1697.972   0.999
13:00:59   124.159   13.697   1697.956   0.998
13:01:00   124.198   13.698   1698.651   0.998
However the display shows the Wattage as crawling along the 0 (zero) mark.
The Voltage shows correctly around 120 and the Amperage also just above 0.
I noticed that the graticule is graduated from 0 to 100 for the wattage, are you considering automatic scaling or switches to set it?

Regards
EDIT: Another suggestion is to have a re-read of the file and displaying it at a rate of say 1 min = 1sec and a Pause button to allow observation
of an event. About 25 years ago I built a weigher for diamonds at 3 per second. The diamonds slid down a tube that was weighed. The software
had to many features to mention, but it looked for a "flat stable spot" and used that weight to classify the diamond into a catagory.
Unfortunately none of that software is allowed to be used.
badidea
Posts: 1570
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: TP-Link HS110

Postby badidea » Nov 06, 2019 20:06

badidea wrote:More stuff to do:
- Line plots instead of dots
- Rolling plots
- Auto-scale plots
- Test with Windows

Also, the plots are not designed for > 1 hour operation. Working on that. The logging should continue to work.
For now, you can change scaling in 'set_graphs.bas'
badidea
Posts: 1570
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: TP-Link HS110

Postby badidea » Nov 07, 2019 23:37

Making some progress. Auto-scale based on data in plots (e.g. last 5 minutes) and line-plots.
Now the y-axis numbers are a bit weird. Each plot probably needs a different scaling strategy.
* power factor: Always 0 ... 1
* voltage: Rounding up and down (e.g. for plot below: 241 ... 243 V)
* power & current maybe always from 0 to a nice number like 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, etc.
Image
Dinosaur
Posts: 1300
Joined: Jul 24, 2005 1:13
Location: Searcy AR USA
Contact:

Re: TP-Link HS110

Postby Dinosaur » Nov 08, 2019 0:54

Hi All

Jeez those pics bring back memories.
My experience with this is to initialize the scale to the higher range, and then I usually
scale the screen to see the critical area I am interested in.
Clipping the top of the spikes in those circumstances are ok, as long as you get the detail
in the area you are interested in.

BUT, I guess if you need a lot of detail you get a cro .

Regards
badidea
Posts: 1570
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: TP-Link HS110

Postby badidea » Nov 10, 2019 0:59

I have updated my power logger:
- Works with Windows again
- Rolling plots
- Auto scaling y-axis

Source: https://nr100.home.xs4all.nl/badidea/HS ... logger.zip

Device IP can be set in variable 'deviceNameOrIp' (line 274 of 'HS110_power_logger_04.bas')
Display time can be set in constant 'GRAPH_X_SCALE' (line 270 of 'HS110_power_logger_04.bas')

I don't have a plan for a detailed interface with zooming on data. Data is also written to file for further analysis options.

Technical note:
For Windows, I switched back to the standard client connect call. I could not get the connect working with a fixed timeout. Maybe Windows does not support this. Not a big issue as the standard timeout under Windows is much shorter then under linux. I can look further into setting the number of retries so that linux and Windows behave the same. With freeBASIC version of:

'int synRetries = 2; // Send a total of 3 SYN packets => Timeout ~7s
'setsockopt(fd, IPPROTO_TCP, TCP_SYNCNT, &synRetries, sizeof(synRetries));
Dinosaur
Posts: 1300
Joined: Jul 24, 2005 1:13
Location: Searcy AR USA
Contact:

Re: TP-Link HS110

Postby Dinosaur » Nov 10, 2019 16:00

Hi All

Great work badidea, love the auto scaling.
Only one complaint, when the screen is set for 1024x768 the text at the bottom is not readable.
Same issue I had with the 7" screen, that is the Title bar.
BY resetting it to 1024x738 it works, but the graticule becomes a bit distorted.

I will test further.

Regards

Return to “Hardware Interfaces / Communication”

Who is online

Users browsing this forum: No registered users and 1 guest