poolmeters CPU usage

Post Reply
Posts: 2038
Joined: Thu Aug 29, 2013 7:16 am

poolmeters CPU usage

Post by jeanmarc » Sun Sep 01, 2013 2:20 pm


You may have notice than the CPU usage of poolmeters is a bit high for his job. It is pyserial the culprit ! ;)
I know nothing much at python, does anyone can improve the script ?

Code: Select all

#!/usr/bin/env python
import serial, sys
#time.sleep(1) # arduino reset cycle
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=1)
if len(sys.argv) > 2:
        print ("Abording: Too many arguments"), sys.exit()
	if sys.argv[1] == 'le': # Elect live
	elif sys.argv[1] == 'gs': # Gas state
	elif sys.argv[1] == 'ws': # Water state
	elif sys.argv[1] == 'elect': # Elect counter
	elif sys.argv[1] == 'gas': # Gas counter
	elif sys.argv[1] == 'water': # Water counter
		print ("Abording:", sys.argv[1] ,"is not a valid argument"),sys.exit()

line = ser.readline(16).decode("utf-8")

Posts: 7
Joined: Sat Sep 28, 2013 9:58 am

Re: poolmeters CPU usage

Post by lan » Sun Sep 29, 2013 9:24 am

Hi JeanMarc,

Thank you for MeterN!

I also notice a maximum CPU usage of about 10% when poolmeters is called every 200ms
Problem not easy to solve in my opinion, without keeping the serial port always open as in 123solar...

If it is not too time consuming for you ,it would be nice if your program could collect
other kind of data, like temperature, etc...
For istance I tried to add my electric water boiler temperature sensor and I
see the data is correctly show in the dashboard/5minutesCSV file, but
the graph is obviously not correct.
Also the daily file should record high/low values I suppose..

That would allow MeterN to manage plenty of other data input.

Have a nice day.

Posts: 2038
Joined: Thu Aug 29, 2013 7:16 am

Re: poolmeters CPU usage

Post by jeanmarc » Sun Sep 29, 2013 9:55 am

Hi Lan,

Thanks for your comments. I believe it would be less CPU consuming if the poolmeters is written in C or something. But i have no real knowledge for that :|

The high/low is a good idea like on the main graph of 123s. I have many improvements I wish to work in meterN but i will currently focus on metering quantity. Maybe i'll work later on for other 'live' values (like temperature, wind speed, humidity..)
I work on that in my spare time. So, don't expect this soon, there is not enough hours in a day ! :)

Posts: 2038
Joined: Thu Aug 29, 2013 7:16 am

Re: poolmeters CPU usage

Post by jeanmarc » Sat Jan 11, 2014 9:29 am

I finally found a pretty nice c script that does the job :) The CPU is dramatically reduced ! hurray :D

It is well named "arduino-serial". Here's the method :

- Download arduino-serial-lib.c, arduino-serial-lib.h and arduino-serial.c
- Put them in your com app folder
- You may edit the default baudrate to 115200 in arduino-serial.c
- Compile gcc -o arduino-serial arduino-serial-lib.c arduino-serial.c
- ln -s /path to you com app/arduino-serial /usb/bin/arduino-serial
- a test :
arduino-serial -q -p /dev/ttyACM0 -S "le" -r
- Now just edit your meters config in meterN using this new command :P

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest