(Web)Sockets support

Hi everyone,

I’m using IoTaWatt to monitor current in a restaurant, to prevent overload and - in future - drop loads in case of peaks.
Currently I’m loading the JSON-formatted status via HTTP (http:///status?state=yes&inputs=yes) 3 times a second, wich works really good, but still has a lot of overhead due to establishing a full TCP connection each query,…

Is it planned to create a socket interface, like websocket, to query data from?

kind regards

Short answer - sorry, no.

You might want to rethink this when I tell you what’s going on under the hood. Depending on how many inputs you have active and what your supply frequency is, the data just isn’t there. A fully loaded IoTaWatt (14 channels) at 50Hz, will sample at most 33 cycles per second, and dividing that by 15, each input is sampled 33/15 = 2.2 times per second, so reading the power value three times per second is greater than the resolution of the sampling.

Another factor to consider is that the API you are using is intended to power the screen display, not provide real time data for process control. There is a damping function applied to that output stream so that even a one second interval reading (which is what the display app strives for) is a decaying average of recent values.

Lastly, IoTaWatt uses the synchronous web server, for several reasons that are a different conversation. So the very act of presenting three server requests per second will decrease the sample rate and diminish the resolution of the data, if not the accuracy.

The datalog is not damped, but is an average of the power in the 5 second interval that each entry represents. I would encourage you to use that data, via the feed/data/ API.

My sense is that if you have a need to monitor current on multiple circuits at sub-second resolution, modifying the software to use async websockets isn’t going to solve your problem. The IoTaWatt software is designed to provide accurate power and energy utilization over minutes, days, weeks, etc., and does a pretty good job of that.

If I were to approach the problem of monitoring current at sub second resolution, I think I would decrease the resolution of the per-channel sampling from (at 60Hz) 640 to 40, and sample all of the channels during each cycle. It’s a complete rewrite of the firmware, but a more appropriate way to use the hardware to do real-time power monitoring at the sub-second level for process control.

how fast would you like the data movement if 2 samples a second is not fast enough. in my wifi oscilloscope that has 8 probes the only way i could do that was with udp in either push or pull (or in broadcast) … then i could handle as fast as the esp could read the anlog and write udp for broadcast from all the analog inputs of the mcp3006 . where TCP I was not able to do because of the overhead and was not able to handle 1 set of probes… . you could push/pull/broadcast UDP all the raw analog data to a PI ( computer) from Iotawatt and do all the sub processing on a PI . all you would do is use something based my esp oscilloscope to transmit the raw data bump it configuration to handle two mcp30XX ( i believe the iotawatt has 2 mcp30xx) then write your decoding software to process it on the pi or computer . how I would probably do it is rewrite the wifiudpscope ( found on oem and github). and instead of combining the high and low byte in to one port break it down further an assign 16 ports one for each analog output. then just use the a base iotawatt firmware or oem’s to write your software for the pi and instead of looking at the analog, point it to the virtual com port on the pi which would represent each analog port on the iotawatt. and process the incoming data from there … all in realtime

then you could easily process each individual “analog port” how ever you like … I think the restraint of the esp was 15000sps for 8 ports ( approximately 2000 samples per second per analog port ) so 16 ports would be probably 1000 sample per second

for my oscilloscope on an esp i could do 15000 samples a second at 3 bit (4095) . so its network load was about 45kb/s so 4 bit resolution( 65535) would be 60kb/s not a very big network load

Hi @stephen, Hi @overeasy,

thank you very much for your replies!!
Before it gets tooo technical lets stop the discussion right now :slight_smile:

The real need is to prevent the fuses to be overloaded - the current aim is to prevent the main fuses to be overloaded. As these fuses are really slow-acting, 1 per minute would be enough. In future, the metering system might change, so we don’t pay for each kWh but also for 1/4-hour peaks, so we would not just prevent blackouts but also save money,…

Why do I want (not need) to increase frequency?
With a higher frequency we increase agility and can find the device, causing high currents, much easier. But higher frequency would mean that one measurement per second is still high enough - and from what you wrote it should be possible even when metering all 14 inputs.

The responsiveness of the HTTP-server is absolutely great, so the need of a socket or UDP transmission of the data is not a must.

So that said, I’m really happy with the IoTaWatt :slight_smile:

kind regards

from the description above sounds more like you need an electrician to come in to split up your loads and install a larger panel or second panel. if you’re popping the main breaker as often as it seams… before you burn your place down.

i am not sure how well a major delay in processing inputs would help- especially in a restaurant environment. as elements would be pulsing on and off constantly and you would be controlling elements that might not even be on at that moment that you’re turning them down . then you would have to build/buy SSR and install them on all your elements right at the elements themselves as your kitchen stuff is probably digital controlled and browning them not going to turn out so well for you. and if your shutting down refrigeration systems that can be done with simple reply. - but they have to be timed delayed so they have to stay off for several minutes. to give them time they to de pressurize otherwise you are placing alot of extra wear on them and most likely they have to be sequences if you have more then one so one refrigeration unit does not stay off too long or all come on at the same time – not impossible just quite the under taking

Just sounds to me like the first step is to assess the situation, which the IoTaWatt can help with. @asterix555 seems to be doing that. I read the comments as not so much an overloaded service as a billing system with a component based on demand, which is one of the real high-yield uses for an energy monitor in a commercial environment. With a little data in the history-log, even a low-tech management strategy to pick the low-hanging fruit might be all that’s needed.

@stephen: the goal is to leverage the load between all 3 phase in daily business - wich changes in case of a restaurant with an event venue almost every day. Beside of leveraging we also need to cut peaks by dropping off load - manually or automatically.

The main breaker popped once since installing the first monitoring (and alarming) unit 3 years ago. The load was around 50/75/55 Amps for some minutes,…
It was mainly caused by misconfiguration of the alarm. We got a photovoltaic and wanted to substract the current coming from PV, but instead of substracting 5-30 amps we substracted 230volts, so the result was below zero and the alarm didn’t work anyore. The employees didn’t power off any devices and the fuse broke.

If that doesn’t help (and from the observation over the last 3 years it does pretty well) we can either dig into what devices consume that migh power at exactly that time - and avoid that in future. That wasn’t easily possible with the old system (allnet powermeter) as it cost more than 3x of IoTaWatt and had only 6 inputs.

Next step is an upgrade of the metering station plus upgrade of the cable from the grid plus complete replacement of at least one electric rack. Not that cheap :slight_smile:

By picking the low-hanging fruit, as @overeasy mentioned, is imho the first and most effective way to solve an issue. There is no need to iron, to cool down the cold store at the same time as the oven is heating and the diswasher is running. With the alarm, in most cases it was caused - and stopped - by personnel that started - and stopped - washing and ironing.

In near future I’d like also to control some heavy consumers like pizza oven depending on current power status. Eg. preheat during afternoon, when sun is shining, cut off during peak, as the oven keeps an acceptable temperature for almost an hour,… But as you said, you can virtually control any power consuming device remote, but you always have to ensure you get best results and don’t drive the personnel crazy :smile:

but thank you for all your comments - wich are now far away from my original question but that’s okay :slight_smile:

no worries - – not so familiar with 3 phase other then i use to build 3 phase wind gens . I get the 50/75/55 so your main breaker only 75 amp or there about. to me it seams your power distribution is a little uneven. ` it would seam to me a majority of your single phase stuff is operating on phase A/B and B/C perhaps if you balanced your distribution abit so more single phase stuff ran phase A/C-- and you seam to be overloading when doing laundry and popping so uneven at 20 - 25 amp differences between the phases . you might be able to balance it just by swapping a round a couple of leads on a couple of breakers – but talk to an electrician about that I never really worked with 3 phase that much

The main breaker is a 3-phase 50 amps breaker, 50 or even 55 amps does almost nothing, but 75 amps does. The load was not even that time, correct, but as I said before the load change almost on daily base, eg when a live band build up dozens of 500W halogen PAR-lights and all connected to phase B,…

Therefore you don’t need an electrican but someone, who tells the band if they want light they should choose another phase or use the installed LED lights :slight_smile:

again no worries- though surprised your fuses operate much differently then what I am use too. and your venue has such small energy capacity… our basic house capacity is 200 amps is bigger then your 50amp 3phase in your restaurant which is such a thin margin you are working with at 34 kw our basic house by example works with 48KW margin…

200amps single phase? ok, we have 3x 100 Amps in total, shared by one 3x50 Amp Meter, one 3x65A and one 35A. The 35A is the standard for private houses here in austria, 65 is the absolute maximum with conventional metering and - of corse - 3x100A is the maximum load given by the line from the grid,…

The restaurant grew over the last 10 years but reached now almost all limits in case of space for the building, for parking and even electricity. As we’re now on the edge to complete redo the electric installation (if the new metering system and new cables from the grid are required) and we didn’t change to power efficient devices (especially for lights) yet we see a big chance to continue work with the current system,…

yes 200 amp on a single phase( split phase 120/240) I just find it interesting-- so it a 2 business attached or the two panels are for the restaurant on the main floor and one private dwelling above the main floor (i assume )… restaurant a tough business… my dad had one for 10 or 12 years… well hopefully you are able to sort out your issues–