So I finally found time to fiddle with the CPU and RAM meters again today. Between Uni assignments and The Witcher 2, I haven’t really had much time for hacking, but after finishing The Witcher 2, I had to do something to procrastinate.
So I sat down and wrote a little Python script to grab the current CPU load and RAM usage. To do this, a module needed to be imported into the script. WMI. Windows management instrumentation. Other given modules are also needed. For example, serial and time. So we can actually TALK to the Arduino. You know, I hear that’s handy for what I’m doing…
As you can see, I’m sending the data as a string of characters, with a begin and end byte.
So, I’ve got the data, and I’m pushing it to the Arduino, now all I need to do is get the Arduino to do something with it! Remember those bytes I put in between the data bytes? Yep. Let’s use those to tell the micro controller what data packet is going to which display.
Basically, on Serial.available > 0, we check the byte, if it’s the byte that precedes the CPU byte, we set a flag as 1, if it’s the byte that precedes the RAM byte, we set the flag as 0, if it’s the byte at the end of the stream, do nothing, we don’t need that data. Ultimately I could remove it, but I like having the option for letting the micro controller know that the transmission is finished, but I digress. With any other byte, we check the flag and output the value to the corresponding meter. Simple.
I originally tried to be all fancy like and send it in 2 data packets with the Most significant nibble of each byte in the first packet, then the least significant byte as the second packet. Basically multiplexing the data. For no real reason but to try and implement something I had learnt in my communications theory class. Well, as you can see, that fell through. The Python script managed to encode and send the data, but for the life of me I couldn’t get the Arduino to decode the data. I’ll probably keep fiddling, but for now, it’s working.
See?
The left meter is RAM and the right is CPU. You can also see where I’m working on the SD card interface.
The CPU output is quite jumpy because the CPU load is changing all the time, I’m working on some action smoothing methods that I can implement on the Arduino, just something else I need to work on.
The final product plan is a mounted set of monitors with LED backlighting and a custom back planes. As you can see, I’m not really measuring mA, so I was planning on scanning in the current back planes and photoshooping some new ones that suit my project, just to give it that finished look.
Yeah I know, I’m avoiding the SD interface. I’m a little daunted by it honestly. But to be fair, I’m avoiding a lot of things, aka, uni work. So on that note, I leave you. Enjoy this quick update!
Hi 🙂
I want to build me a little monitor for my computer. Do I have to use some special sort of Gauge? Can I just use something like this: http://www.ebay.de/itm/DC-1A-Ampmeter-Analog-1-0-AMP-Current-Panel-Meter-Ammeter-Gauge-85C1-/270997338551 ?
How many of that can I hook onto my little Arduino?
Thanks, udo
Hi! You will want to use a 1mA panel gauge as opposed to a 1A gauge so you dont fry your Arduino, max current draw is 200mA. Most Arduinos have 6 pwm channels (analog out) so you can have up to 6 gauges attached to them. If you get a 1mA gauge, simply use the same value reistor as I did above and vary the analog out according to your data. Best of luck! Let me know how it goes!
Here we go. More details are on this post https://waitwhatquestionmark.wordpress.com/2011/05/18/new-project-analog-cpu-and-ram-usage-meters/ On Jun 29, 2012 8:13 AM, “Phill Ogden” wrote:
> Hi! You will want to use a 1mA panel gauge as opposed to a 1A gauge so you > dont fry your Arduino, max current draw is 200mA. Most Arduinos have 6 pwm > channels (analog out) so you can have up to 6 gauges attached to them. If > you get a 1mA gauge, simply use the same value reistor as I did above and > vary the analog out according to your data. Best of luck! Let me know how > it goes!
wow thanks ^^
i somehow planned my layout a bit and ended up with 6 gauges, fits perfectly 😀
i want to show: cpu, ram, battery, network receive, network send, fan speed
and i’m thinking about doing it over wifi but we’ll see cause they are a little expensive xD
i’ll blog about it and put a link here when i’m done 🙂