Power Usage Logging


I was thinking about how we have a plugin that tracks filament used, and run time. So, why not add power logging into the mix?

Of course, this wouldn't just be a "simple" coding feature. It would require some external hardware as well. Which comes with its own set of problems.

So, why not just use a plug based power monitor? Well, it is mostly just nice to have all of the data at your finger tips. Just think about the possibility of tracking exactly how much power usage there is for each print. You could provide far better pricing per a print, or simply see exactly how much power you are using for each print.

Though, honestly, I just love having more data. So I would enjoy having one more set of data to look at. There can be practical uses for it, but that is secondary. Thoughts, feelings, suggestions?


Some people have requested that I incorporate that data into my TPLink-Smartplug and Tasmota Plugins. Just haven't had the time to do it.


That would be really cool! No worries, life tends to get busy. Considering that it is something you are not getting paid for, you have every right to focus on other things. :slight_smile:

If possible, it would be great to see this kind of functionality added to your plugin! At your leisure of course. :slight_smile:

After looking into your plugin, another thought comes to mind. Would it be possible to have something like a smoke alarm connected to the Pi, which would trigger an emergency power off?
I know this is a little jaunt off of the original suggestion, but it has just been on my mind a bit. Since printer fires are a possibility.


I use a "Sonoff POW" Switch (<10€) to remotely turn on my printer and also for a automatic safe shutdown of printer plus raspi after print. Works pretty good!
The next step is to use the measuring feature and put this to the CostEstimation Plugin.

But at the moment I am thinking about the best implementation-strategy (mqtt vs. rest)...so it could take some time.

Do you have an other "measuring-device" in mind?



There is a plugin that handles power statistics, its at the bottom https://plugins.octoprint.org/plugins/stats/


That plugin estimates the power usage. This thread is talking about incorporating hardware that will measure the power usage. If they get something working, it will be interesting to compare the two methods.


@OllisGit Use the MQTT protocol. It is more lightweight and you can subscribe to topics. With REST you have more overhead and you have to poll the data.


Hey there,

we are using two different printers each one with a Sonoff POW and a Octopi. For us it would be also helpfull to switch an unmodified Sonoff with the Octoprint software.
The Sonoff switches the Printer and the Raspberry. It would be great if you can say "set Sonoff Timer 5 Minutes then shut off" and "shut down Raspberry". So you have a save shutdown for the Raspberry and the extruder can cool off before shutdown.

It would be great if this feature is coming one day. The Fanbase of Sonoff devices are also growing.

Greetings and a nice Day


I've actually got a TP-Link HS100 (Smart Plug) on my 3D printer. Let's see what we can get from that:

From the tplink-smarthome-api repository's code's getSysInfo() method...

{ err_code: 0,
  sw_ver: '1.2.5 Build 171129 Rel.174814',
  hw_ver: '1.0',
  model: 'HS100(US)',
  mac: '50:C7:BF:00:00:00',
  deviceId: '80069AD7319B764961265EE8--REDACTED--435A',
  fwId: '00000000000000000000000000000000',
  oemId: '37589AA1F5C--REDACTED--7760127E5',
  alias: 'my 3D printer',
  dev_name: 'Wi-Fi Smart Plug',
  icon_hash: '',  relay_state: 1,  on_time: 4177,  active_mode: 'none',
  feature: 'TIM',  updating: 0,  rssi: -33,  led_off: 0,
  latitude: 32.717157,  longitude: -117.138388 }

Calling the emeter.getmonthstats() method seems to be throwing...

  response: { err_code: -1, err_msg: 'module not support' } }

So maybe the power monitoring is in other products. I'll do a little research on this one.


The HS110 is the model that has power monitoring. The lastest version of the TPLink-Smartplug plugin does now support the display of the emeter data. Eventually I will look into logging that data by print/gcode file name. Was wondering if any developers here know right away if there is a way to extend the metadata of the file list? Seems like that would make the most sense to add to rather than keeping an entirely separate db mechanism.


I bought the HS110, btw. I was able to pull in the power-related information. This is JavaScript.

const { Client } = require('tplink-smarthome-api');

const client = new Client();
// https://github.com/plasticrake/tplink-smarthome-api
var fPricePerKWH = 0.16;
var fChargePerKWH = fPricePerKWH * 3;
function calculateCost(jsonPower) {
  console.log('$' +
    (jsonPower.power * fChargePerKWH).toFixed(2).toString()
// Look for devices, log to console, and turn them on
client.startDiscovery().on('device-new', (device) => {
  if (device.model == 'HS110(US)') {


Nice, basically the same thing I'm doing now. What I found interesting is that the US model returns the data in a different way then the EU models, involving additional math in the situation when supporting both.


My perma-vaporware Pi addon sniffs how much power is coming in (as 12-26v) and observes power usage there. As a subset I have the output of the bucket circuit. That'll tell us what a Pi is using at 'idle', among other things.


I've got a killer app based around that thing. I just don't have any time these days.


I've been working on the next release of the TP-LinkSmartplug plugin to get the energy data to log and display, and so far so good...

Currently will only work with US energy monitoring plugs because for some reason the data is returned differently ( kWh vs Wh and MW vs W ).


Wow. You should make a printer farm—version of that and up-sell to those guys. That sounds like it would be damn useful when you have a roomful of these things.


In theory you could set-up one octoprint to monitor the whole farm since the plugin supports multiple devices. The graph displays on which plug is selected in the pull down, and the individual settings. I just finished some tweaking to the axes to overlay different ranges. It's getting there.


that looks good jneilliii!

I got my latest prototype up and running yesterday, some things need to be reworked, but I love getting the power stats out of it:

Bus Voltage:    5.212 V
Supply voltage: 5.214 V
Bus Current:    313.186 mA
Power:          1533.537 mW
Shunt voltage:  6.460 mV

Might have to fork your tplink smart plug to make an easy graph :slight_smile: