I’ve looked the the Open Energy Monitor project in the past, and in particular their eMonLib, and i was pleased to find out that they added support for ARM devices a while ago, and the latest version compiles fine on the STM32.
I didn’t even need to change any settings for the number of ADC bits, as they default it to 12 bits for ARM.
The hardware side of things, has proved to be the trickiest, and don’t think i have the optimal solution yet.
The system needs an AC input to measure the voltage and phase of the mains voltage, which is achieved using a transformer. I looked in my box of salvaged parts, and tried a small transformer from a mains alarm clock, but the waveform on the 12V output was far from a perfect sine wave. I then tried another transformer (of unknown origin) and it was better but not perfect.
But in the end, i found a 12V DC charger branded as Panasonic, and i removed the internal bridge rectifier and smoothing caps etc, and this delivers a nice sine wave, albeit at around 16V , as its not under any load.
The 16V is fed into a voltage divider, consisting of a 10k resistor in series with a 10k trim pot. Actually, i should change this for a 33k in series with 10k pot, to get better resolution on the pot, but does allow me to reduce the 16V down to 3V even as it stands.
The current is measured by a current clamp. The one i have is labeled SCT-013-030, and designed to measure up to 30A. But the 30A value, must relate to its use with a particular monitoring system, because the only difference between any of the models of this cheap brand of clamp, is the limiting circuit inside the clamp.
On the 030 it has a 68 Ohm resistor in parallel with the output, but i found this reduced the voltage being produced by normal domestic loads ( of a few kW) to just a new hundred millivolts. So i took the clamp apart, which is an easy process, as its not glued or even screwed together; and I removed the internal (ballast) resistor, and i use an external 200 ohm trim pot, on my input conditioning board, to calibrate 3V AC to about 4kW.
Anyway, its now all working, but i find that noise on the ADC inputs is a bit of an issue.
I think the noise is mostly coming in on the supply, i.e the USB from the computer.
I’ve taken a look at supply noise from various USB power supplies and some are better than the PC and some are worse.
But either way, I think i need to try to remove as much noise as i can, because at the moment, my system is registering around 40W of fluctuating power consumption even when my test rig (an oil filled electrical radiator) is not turned on.
But i also meed to confirm whether this stray noise is actually pickup by the current transformer, from the mains wire to my soldering iron etc etc.
The next steps are a probably going to be more of a software challenge, as i need to transmit this data, and i have selected a NRF905 device for this purpose, as the data has to go thorough several brick walls, which i know greatly attenuate high frequency signals like WIfi or devices like the NRF24L01.
I think there are a choice of 2 libs for the NRF905, RadioHead is one of them, but AFIK this has not been ported yet, and my prove to be challenging.
Anyway, i will keep you guys posted with any progress.
The term for the resistor is “burden” resistor and the value must be reasonably low to reduce noise; in fact, the subject is rather complex, but adequately represented on the Internet. The resistor, ideally must match the impedance of the current-sensing coil at the AC frequency being monitored. Otherwise, the voltage across the resistor will not be linear to the current flow.
Ray
Sorry for the misnomer on that resistor name.
Re: Resistor value to match the impedance of the coil.
From what I understood by reading the Open Energy Monitor website, was that the two different models of current clamps (transformers), had the same coil but the one labelled SCT-013-000 doesnt have a burden resistor, but has back to back 22V zeners, where as the SCT-013-030 (which I have), has an internal 68 ohm resistor.
But its common for people to take these apart and use an external resistor which is a higher value, – normally 2 or 3 times higher.
Actually, its odd if the lower current version i.e the 030 (30A) has the burden resistor and the 000 (100A) does not.
I presume this is because they expect people to use an external burden resistor on the 000
I think perhaps I should have ordered the 100A version, as its the one that they recommend on the Open Energy Monitor site
http://openenergymonitor.org/emon/build … ransformer
So I’ll order another one, as perhaps the coil on the SCT-013-000 is different from the 030.
I can also experiment with various loads to see how linear / non-linear these things are.
I know that even the ( domestic ) commercially available power monitors are terribly non-linear , my dad has a correction table printed next to his display unit on an “OWL” branded monitor, as it overreads below 500W and under-reads above about 1kW
Ultimately I’m sure it would be possible to build some sort of interpolating lookup table and then calibrate a particular clamp in a particular location
Especially if you can do this by using the mains power meter for the whole house (supplied by the power company), as most of these have an LED that flashes at a rate proportionate to current consumption (and I’ve already built an AVR based solution to monitor that data, several years ago)
BTW.
If you ask why I’m building a current clamp version, when I can read the power company’s meter…
Its because their LEDs only seem to flash when consuming power and not exporting it. Often the LED just stays on permanently when you are exporting power (or doesn’t flash at all)
Ideally I could get the data straight from the power companies meter, but it seems to be a closed system in most cases, or requires you to only use authorized / certified hardware even to view the data via XBee etc ![]()
Edit.
Generally, it appears that people think the two clamps have basically the same windings on the internal transformers
http://openenergymonitor.org/emon/node/2447
However whether this is really true or not us probably open to debate unless someone has really compared then side by side.
http://www.microchip.com/wwwproducts/De … e=en567281
http://www.microchip.com/wwwproducts/De … e=en520376
http://www.st.com/web/en/catalog/sense_ … ?sc=stpm01
http://www.ti.com/lit/ml/slyt428/slyt428.pdf
http://www.cirrus.com/en/products/cs5463.html
Of course just a tiny sample, and I am sure you are well aware of them, but they are dozens and dozens of functional block sdesigned to monitor just about every parameter you could want, and often pretty damn cheap.
Of course they all have their own particular interfacing requirements, however they do have the advantage of having plenty of information on right/wrong approaches in such interfacing ![]()
They also tend to take care of such things as powerfactor, etc.
I know you have working interfacing, just thought I would throw those out there..
Just make sure you get the isolation nice and solid ![]()
Actually, I do have some power measurement chips. But I can’t recall who makes them.
I did consider using them a while ago, but I’d need to write a library for them, and the OpenEnergyMonitor guys already did a great job with their code, and its well supported.
Also, I can’t recall how much the measurement chips cost. I don’t think they were that expensive, but for some people ,if the Arduino will a decent job without external specialized chips, then they’ll take that option. (Me included)
I think the other downside with the chips I have, is that they are surface mount, and I had to solder them manually into an expansion / adaptor board even before I could start to use the,
But now you mention it, I will try to dig them out and see what they are. (None of the part numbers in your list rang a bell with me)
Edit.
I have some of the old Cirrus Logic 5460A devices, which I bought a few years ago. http://www.cirrus.com/en/products/cs5460a.html
They have been succeeded by the one you linked to.
I’m not sure what the differences are between the old and new versions, I’m sure the new one is better somehow.
If you know of any example code set setting up the registers on the 5460 (or the 5463), please could you post a link, as at the moment all I can find is the datasheet, and these devices have multiple registers (20 or more) that need to be configured for them to work correctly.
Ultimately I’m sure it would be possible to build some sort of interpolating lookup table and then calibrate a particular clamp in a particular location
Some of this is due to the “power factor” but, if your design can calculate AC power factor, you also have the answer to the power flow back into the commercial system.
http://hyperphysics.phy-astr.gsu.edu/hb … owfac.html
http://hyperphysics.phy-astr.gsu.edu/hb … werac.html
Ray
I’ve not looked at how eMonLib does it, but its calculates both real and apparent power as well as power factor ( which are all related )
You have to calibrate for phase offset between the voltage and current inputs, using a parameter in the voltage setup function.
However if the current clamp’s detected waveform shifts phase depending on the amount of current being drawn, that will obviously have a big effect on the results.
I’m not sure if I have damaged one of the Analog inputs on my RedPill, but i’m now seeing some strange results when I remove the current clamp and clip it back on in the opposite direction.
The power being shown is a lot different.
I will need to analyse whats going on, using my scope, to see if the amplitude of the current waveform is really any different, or whether this is another phase / power factor issue.
Or, whether, as has been suggested in the OpenEnergyMonitor forum, that I’m getting crosstalk between the two inputs; as they are on adjacent pins PA0 and PA1 and I’m using a Breadboard to connect an external Veroboard, containing the initial signal conditioning components, to the RedPill.
BTW.
Ray…
I was thinking about intergating an ESP8266 with this power monitor, probably running a mini web server.
Have you tried any of the ESP8266 web server stuff recently, (I’ve only used the web server code before the Arduino port)
Also ESP8266 to STM32 comms… Any ideas?
You’ve made a couple of references to 3 volts. I hope you mean peak-to-peak and not rms. 1 volt rms (2.8V p-p) would be about optimum for feeding the analog input on a 3.3 volt processor. The zero crossing point should be offset from ground to half the supply voltage, or 1.65 vdc. Otherwise, the cpu could be damaged by the voltage going below ground or above Vcc. The schematic for the open eMon shows this configuration.
If the CT is remote, you should use a twisted pair wire from the CT to the CPU.
No worries
I use basically the same voltage divider as in the OpenEnergyMonitor TX hardware designs, except I use Vcc from the STM32 board, which is 3.3V, and hence generates a mid point voltage of 1.65V
Then the inputs are scaled using pot’s (10k resistor in series with a 10k pot for the voltage sense as I’m using a 12V RMS transformer) and a 200 ohm burden resistor on the CT clamp so that all inputs are within 3.3V peak to peak offset by 1.65V
This is now working really well.
I thought I had an issue with one of my voltage dividers producing 1.45 instead of 1.65V, however after disassembling and re-assembling the circuit to prove what was wrong, the problem transpired to be the load put on the divider by my scope.
The voltage divider consists of two 270k resistors in series with a 10uF capacitor to ground. The OpenEnergyMonitor Tx board actually uses 470k resistors in its divider, but I didn’t have any to hand, and 270k sounded plenty high enough.
I think the high value resistors is to attempt to reduce noise on the bias point voltage produced by the voltage divider.
I compared data capture using the STM32 vs a Nano (after re-adjusting the input values to provide the greater voltage range required by the Nano), and the STM32 seems to give much more stable results for the AC voltage and also the AC current measurements.
I suspect this is caused by a combination of factors.
1. ADC sample time and data processing is substantially faster (this appears to be 3 to 4 times faster than AVR), hence more time slice sampling of the waveform
2. ADC is 12 bits instead of 10, hence 4 x the precision
3. variables in the main calculation are double, but on the AVR these are 4 byte floats not really doubles, but on ARM they will be 8 byte, hence calculation precision will be better (but I’m not sure how much difference that really makes)
So…
I now need to get the NRF905 lib working so I can send this data to where its needed.
I know the guys at Oem very well – and I have been slowly trying to get them to take an interest in the STM32. We have workshops about once a year to share ideas and generally improve the open hardware scene here in the UK.
Have you considered the Hope RF RFM12 and RFM69 (433MHz)? Both these devices are well supported by oem libraries and very cost effective.
I designed a little board for them last November which was basically an RFM12/RFM69 and an ATmega328 with all it’s pins broken out to a header. It allowed a Pi to talk to their wireless ecosystem using it’s USART.
http://shop.openenergymonitor.com/rfm69 … ver-board/
Good luck with the energy monitor. Have you considered trying running the ‘103 with a LiPo cell. That will confirm if your noise is coming from the PC’s USB supply. Make sure that VDDA is well decoupled – some of the cheap boards are a bit lacking in supply rail decoupling.
Ken
Re:RFM12 and RFM69
RFM12 is an option, but i happened to already have some NRF905 modules from a previous project.
I thought i had some RFM12’s but i can’t find them at the moment.
I designing this system for use in an brick built garage, adjoining a brick built house.
All the walls are either concrete (breezeblock) or solid red house bricks.
The house already has a number of other devices running on 433Mhz, including 3 wireless power meters, plus 2 other systems I built to automatically operate some remote control mains sockets. But all those systems are on AM 433Mhz
i considered 2.4Ghz but the attenution though several brick walls is too high.
So i thought I’d experiment with the NRF905 as i think its multi band, not just 433mhz
However its all R&D at the moment.
Re:Powering from LIPO
I will need to rig something up, which retains the usb data lines and ground to the PC, but powers from another source. I think i will need to cut open one of my USB extension cables, and cut the 5V wire, then power the board separately.
I have a linear bench power supply, or i could use a lipo. The LIPO is a smooth supply, but the voltage will slowly drop over time, and hence the readings will possibly get messed up, i.e as VREF is connected to VCC on most boards.
But the lipo would be the best way to get some no-noise readings.
I’ve had good support from several people on the OpenEnergyMonitor forum
http://openenergymonitor.org/emon/node/11021
At the moment, It seems the STM32 is substantially better for this task than the AVR boards, but to be absolutely sure i need to run both the AVR and STM32 on a noise free supply
Similar to this:
http://www.aliexpress.com/item/Free-Shi … 5.html?s=p
however there are many many options.
Regards,
Stuart.
I’ve just tried powering the board + ILI9341 display from a LIPO pack from an old Nokia phone, and the charger unit, charges it to more voltage than the ILI9341 can handle. I think its around 3.8V, but the ILI9341 seems to not initialise if the voltage is above around 3.5V (I’m not sure of the specific voltage)
It doesn’t seem to do any harm to the display, but I have not left it connected, and I’ve gone back to using a linear bench power supply.
As has been discussed here, LiFePO4 is a bit better in those regards, however still not great, and goes quite a bit deeper when discharged.
Of course the high discharge voltages are to be avoided anyway… so its really the high end you mainly need to worry about usually.
As you wont be dropping the voltage much, a reasonable LDO would do the trick while not dropping you a lot of wasted power over most of the range.
Otherwise buck/boost can also get around 90%, and allow you to go higher/lower, but at the cost of complexity of course.
LDOs in these apps are generally considered to give in the region of 90% efficiency..
if you want to switch, I would use a LTC3531 for <200ma, but thats just me, but you may gain next to nothing over a good LDO.
or there is always a diode drop ![]()
I’m now running the power monitor attached to a ILI9341 display from my bench PSU and I’m getting less noise, so that the AC mains voltage noise percentage is around 0.4%.
I suspect the current noise is similar, but hard to measure as I don’t have a constant current load, because my electric fire as a load changes in resistance as it heats up.
I’m found a lib for the NRF905 which I’m going to try https://github.com/zkemble/nRF905
But to save the hassle of having to wire another 12 wires, I’m designing a single sided PCB which I’m going to attempt to make on my CNC router.
(However this is as much about whether the router makes a usable job of milling a pcb as it is about anything else !)
Milling pcbs on a router is all very well – but I encourage you to learn Eagle or KiCAD to the point where you are confident to send your own designs to a board-house.
There are some good online tutorials, and if you make the board fit into 50x50mm or 100x100mm – there are some great hobbyist deals to be had from Seeedstudio Fusion PCB or dirtycheap pcb http://dirtypcbs.com/ – like 10 boards for US$14 to US$25.
You will gain huge satisfaction receiving you first professionally manufactured board, complete with attractive solder resist and component legend.
Very soon you will be making SMT designs – and no longer need us hardware dinosaurs…….
Teach a man to fish………….
Ken
My plan is only to mill prototypes, so I know the schematic and placement and symbol definitions are OK
I finally got a simple design completed last night, that only needs 3 tracks on the top (which i will manually make using wires)
Once i know the design is OK, I can send it away for 2 layer manufacture.
I actually ordered some pre-designed boards from DirtyCheap PCBs last week, and they were dispatched a few days ago, so it will be interesting to see how long they take to get here.
I used to do some schematic design as part of my first job after graduating. But I was working for a large company who had a separate small team of people who’s sole job was PCB layout (on CAD), however that was many years ago.
Doing schematic capture in Eagle is OK, but I’ve somehow managed to “drop” the Vcc symbol from the built in libraries, and cant work out how to get it back.
Perhaps i need to re-install the Lbr file that contains this.
I did start to look at exporting a DIL40 package and try to convert it to the pin names etc on a Maple mini, but I couldnt figure out how to change the numbers of the pins to their names ![]()
However i’m slowly working out how to use Eagle…
At that time, I’ve started learning Kicad, and as I became more use to it, I like it more than Eagle, especially the fact that footprints are detached from the symbols. I’ve use this site to convert some parts : http://kicad.jp/Eagle2Kicad/
I’ve dabbled a bit with Eagle but recently I downloaded KiCad to see if its any good.
However I’ve not really had time to do much more than install KiCad (especially as their servers seem to be offline some of the time “Bad Gateway” error seems to be a common occurance)
I actually ordered some pre-designed boards from DirtyCheap PCBs last week, and they were dispatched a few days ago, so it will be interesting to see how long they take to get here.
I will preserve with Eagle for the moment, as there is a script to generate milling machine GCode from the Board file.
(I’m not sure if anyone has done the same thing for KiCad – not that this is a show stopper)
I have designed a PCB with a mini maple as a module, and the analog components, as well as the lcd display and the nrf905 tx/rx module, and also , just for good measure an esp8266-12!
I may not fit the esp8266, i only added it as i have space on the board and I may use the same pcb for multiple purposes.
The pcb is now with Dirty Cheap PCBs for manufacture, so I will know in a few weeks just how many mistakes i have made ![]()
With the NRF905, my hacky port of Zac Kemble’s lib seems to partially work. However I currently have a strange bug where when i read the data packet, It looks like each byte is shifted 2 bits to the right.
At the moment, i dont know if this is an issue when the data is transferred to the tx for sending, or when its read out of the Rx unit.
I reads the SPI from inside an ISR, which may be the problem, however it looks like I will need to attach the logic analyser to miso to see just what data is being read from the device.
BTW. Zac’s library, is really just a bunch of functions and not a class, but this probably makes the ISR stuff easier, as i know there are issues with ISRs calling class methods.
The problem transpired to be the SPI speed of DIV2 was too fast for the NRF905.
Strangely, the code to setup various parameters in module e.g. transmission frequency was working fine, and i reliably had it frequency hopping, up in 100khz steps, exactly as expected.
However when it read back the transmit payload buffer , of 32 bytes, it was getting various strange corruptions at the end of each byte.
Changing the SPI speed to DIV4 seems to fix this, but looking in the spec, the max SPI speed is only 10MHz, so i may need to lower this even more, to be truly inside the spec for this device.
And as the payload is only 32 bytes, its really not really going to make a big difference to the overall throughput, as the RF data rate a little around 50 kbps.
I will however try using SPI DMA for these 32 byte buffer reads and writes, just because the STM32 has that facility now that Victor has added the DMA functions.
I am not able to understand how i could detect this. Is is possible using ADC?
I you people have any other idea then please share it with me.
I am not able to understand how i could detect this. Is is possible using ADC?
I you people have any other idea then please share it with me.
The system uses 2 x ADC’s.
One ADC samples the mains voltage (via a step down transformer – and some resistors and capacitors)
And the other ADC is connected to a current clamp (aka current transformer) – which is clamped around the mains Live (active) cable.
The Open Energy Monitor library (emonlib) does all the clever processing to detect the phase angle between the current and the voltage and current waveforms and outputs the voltage, current, power, and power factor.
Direction of power flow is show as negative or positive values (and is closely related to the power factor).
If you want a full explanation of how this works, you should post to the Open Energy Monitor forum.
All I can say is that it works really well with the STM32, and give excellent results in my testing.
Now the next challenge is to make it talk to EmonESP for WiFi data upload, and incorporate MQTT in the STM32 itself.
Now the next challenge is to make it talk to EmonESP for WiFi data upload, and incorporate MQTT in the STM32 itself.
I had also considered just using an ESP8266 for this, and an analog mux , or an external DAC e.g. AD7705
I did some research but I can’t find anyone who has done this, which is a bit surprising.
I know that the main issue is that the ESP8266 only had one ADC and its reads the 0 to 1V range.
People have speculated that you could not get good results reading both voltage and current using the same ADC using an external MUX, but as the ESP8266 is significantly faster than the AVR Arduino (on which the original EMonTX is roughly based), I think this is just speculation and no one has done any serious comparisons between AVR and ESP8266
The STM32 however is bound to give better results as the sampling rate and resolution is better than the ESP’s internal ADC.
External ADC on the ESP8266 however may be an interesting option depending on the functionality of the external ADC.
i.e if the external DAC can be triggered to read the voltage and current inputs simultaneously, or to possibly for the ADC to be doing conversion on one channel while the data is read out from the other channel etc
This may put an ESP8266 solution on par with an STM32 solution.
However it would take a lot of research.
<…>External ADC on the ESP8266 however may be an interesting option depending on the functionality of the external ADC.
i.e if the external DAC can be triggered to read the voltage and current inputs simultaneously, or to possibly for the ADC to be doing conversion on one channel while the data is read out from the other channel etc
This may put an ESP8266 solution on par with an STM32 solution.
However it would take a lot of research.
My existing solution is already to do something similar as I use a Maple Mini, to do the data capture and analysis and just send data via Serial to the ESP8266.
The Maple mini could be replaced by Blue Pill if people were price sensitive.
I guess I was being lazy by using Serial, but as the ESP8266 was not a core part of the project (the display and data transmission on 433Mhz as essential)
I thought connecting via Serial would be fine.
I run the eMon lib so that it samples over 1 second and takes an average. So I only need to send 1 packet of data to the ESP8266 every second, and that packet is quite small, something like 32 bytes, so transferring via Serial isn’t much of a bottleneck
I think the main reason I thought about using an ESP-12 and external MUX was that it was smaller than the Maple Mini, but a bare metal STM32 just needs an external xtal, so would really not be very big if I wanted to just reduce the size, and would not be substantially bigger than either a analog MUX or external ADC
Using only ESP8266 (with sensors) would’ve been an ideal solution. Apart from single ADC input and 1V range, the problem lies in the sampling rate of ESP8266 ADC. The stated official sample rate is 200sps. Some have reported achieving 2.5k sps but there are risks of WDT resets at such high sample rates. To accurately measure power, it’s recommended to measure 20th harmonic which corresponds to 2000sps. A minimum of measuring up to 6th harmonic, i.e., 1200sps is needed.
Realising this, I ordered an external ADC for use with ESP8266, but a common ADC such as ADS1115 has 860sps, way inadequate for this application. Using a more expensive ADC doesn’t make sense because ATMEGA328 or STM32 work out as a cheaper ADC!
Currently, my setup is similar to what your described: a BPB connected to ESP8266 over Serial, sending MQTT data.
My next attempt is towards using a dedicated energy measurement chip (I got an ancient CS5460A for cheap on Ali), interfaced to ESP8266.
RogerClark wrote:BTW.
I know that the main issue is that the ESP8266 only had one ADC and its reads the 0 to 1V range.
People have speculated that you could not get good results reading both voltage and current using the same ADC using an external MUX, but as the ESP8266 is significantly faster than the AVR Arduino (on which the original EMonTX is roughly based), I think this is just speculation and no one has done any serious comparisons between AVR and ESP8266
External ADC on the ESP8266 however may be an interesting option depending on the functionality of the external ADC.
i.e if the external DAC can be triggered to read the voltage and current inputs simultaneously, or to possibly for the ADC to be doing conversion on one channel while the data is read out from the other channel etc
This may put an ESP8266 solution on par with an STM32 solution.
However it would take a lot of research.
The BluePill board costs less than $2 including carriage, using external ADCs would cost many times more than this.
The only drawback is the physical size of the overall system.
You could try that ESP14 as it has an STM8 in the same housing as the ESP8266, but you have to program it using a completely different compiler ( not GCC and not use the Arduino IDE and API as no one has written and STM8 arduino core)
To me, the bulkiest component in an Energy meter is the Voltage sensor, i.e., a transformer/AC-AC adapter. Any dedicated chip that measures voltage (through resistor divider)/current samples and provides isolated I2C/SPI is the holy grail!
To me, the bulkiest component in an Energy meter is the Voltage sensor, i.e., a transformer/AC-AC adapter. Any dedicated chip that measures voltage (through resistor divider)/current samples and provides isolated I2C/SPI is the holy grail!
Well always interesting in measuring (my passion) just found that on my todays search – looks interestting and simple?!?
https://www.hackster.io/whatnick/esp826 … tor-b199ed
Source code: https://github.com/ardyesp/PowerMeter
Its pretty accurate.
Source code: https://github.com/ardyesp/PowerMeter
Its pretty accurate.
One of the ones I made from RBL’s repo ? or perhaps Sandeeps repo ??
i have plenty of nRF51 modules kicking around, so I may build this when I get time.
BTW.
I think in the long term that Sandeep Mistry’s “Arduino nRF5” repo will definitely supersed mine, as his is a much cleaner implementation than the RBL one, as his is not based on mbed.
However he uses OpenOCD and also needs a different version of gcc, which makes the installation more complex.
I’m thinking of building one of your energy monitors.
I’ve been an Electronics Technician (and hobbyist) since 1974, so the hardware part I’m comfortable with.
The code? well, let’s say I can make it work, but I’m not as good with software as I am with hardware.
I have an OpenEnergyMonitor emonTx and one of their emonGLCDs, so I understand the aim of your project.
I didn’t see any references to code other than EmonLib and having looked at the emonTx code, yet knowing
the STM32 is a completely different animal, I thought I’d ask if there is any additional code needed for STmon.
Thanks!
Bill Thomson
(Actually, I can’t remember if I needed to correct for ADC having a greater number of bits in the STM32, actually in the library code – you’d need to double check, but I don’t think so)
I didn’t use the same RF transmitter that the Open Power Monitor used, so I can’t comment on whether the library for the transmitter they used will work
The code I’m curious about is that which makes the calls to EmonLib.
I’m going by what I know of the way the Arduino sketch for a 328 works as I have no direct experience with the STM32.
Thanks!
As ESP8266 already has a emonTX lib I thought “why not adding an external SPI ADC and that’s it???”
I though of using MCP3008 (75-200Ksps) and 8 channels. Should be ok.
But now I’ve read some of the posts on this thread and realized that might not work so great…
I think it doesn’t support multiple sample-and-hold so reading one channel and then another will introduce some error… Is that meaningful at these rates?
If it’s not an option I’ll go for ESP8266 + STM32F103 option.
P.S. I’ve just saw people using ADS1115 (860SPS) but probably power measurements are not accurate (or even done)…
As ESP8266 already has a emonTX lib I thought “why not adding an external SPI ADC and that’s it???”
I though of using MCP3008 (75-200Ksps) and 8 channels. Should be ok.
But now I’ve read some of the posts on this thread and realized that might not work so great…
I think it doesn’t support multiple sample-and-hold so reading one channel and then another will introduce some error… Is that meaningful at these rates?
If it’s not an option I’ll go for ESP8266 + STM32F103 option.
P.S. I’ve just saw people using ADS1115 (860SPS) but probably power measurements are not accurate (or even done)…
You can get a Blue Pill for $2, which is far cheaper than that ADC or even an external multiplexer, and with either of those ESP8266 + external devices options, the sample rate is going to be a lot lower than you get using the STM32F103 to sample the data.
BTW. Although I planned to use an ESP8266 to transmit the data, I found that where I needed to put the TX boxes, was out of wifi range, as it was in the garage, so I ended up transmitting the data to another board using 433Mhz.
All my system does is read the power and broadcast on 433MHz, once per second.
Multiple receiver units around the house display the power.
I was intending to add power control to this system, and I built a power controller capable of modulating a hot water heater, but I never ended up deploying it, because I designed and built it for my sister and my parents to use, but circumstances changed and it was no longer practical to deploy it.
The system was intended to functional where the Emon Tx was the master arbiter and the power controllers would request and be allocated a specific number of watts by the Tx unit, by communicating over 433MHz.
But I still had a huge amount of work to do on it, and it wasnt worth continuing with at the moment.
I’m going to try the ESP8266+MCP3008+emoncms.org approach first because it’s simpler.
If it fails I’ll change the MCP by the STM32.
And then when I have results I’ll change the web server by the Raspberry Pi to keep the data more “private” ![]()
The local displays are also a nice feature!
I’ll have to think about it but maybe adding a TFT to the raspberry as I already got one (only need to get it to work
)…
If you know of large black and white ( non backlit) LCD display, let me known, as Id like to do a battery version of the display.
I am also thinking of adding Bluetooth transmission to my design, so phones and tablets could be used as the display via a simple App.
I could move the whole monitor to the nRF51822, but as I already have multiple systems working fine, it would be easier for me to add Bluetooth to the existing hardware
Big ones I don’t know but tou could run multiple nokia 5110’s. They are reasonably cheap and you could put one digit on each and be readable
Other than that only e-paper. There are 6inch displays from the older kindles that are cheap now. I think some guy got it to work with a raspberry… I dont know if it would work with a microcontroller…
If you uploaded some info on emoncms.org you would already have the GUI made and logged history… But its not a big deal.
I use those Nokia displays on some other projects, but they were too small for this, but i like the idea of 1 digit per display.
I looked at ePaper, but at the moment its expensive because you need a driver board as well as the display.
BTW
I still think using a Blue Pill as the ADC and to calculate the power is cheaper and better ,than using and external DAC or multiplexer, but the choice is yours ![]()
Thats why I considered it.
Dont think these are the ones I saw the first time but they vive an idea:
https://hackaday.io/project/13327-teens … pter-board
I use those Nokia displays on some other projects, but they were too small for this, but i like the idea of 1 digit per display.
Thats why I considered it.
Dont think these are the ones I saw the first time but they vive an idea:
https://hackaday.io/project/13327-teens … pter-board
[rexnanet – Wed Mar 01, 2017 10:45 am] – I’m going to try the ESP8266+MCP3008+emoncms.org approach first because it’s simpler.
Hi! Have you had a chance to progress with your idea?
[PavloPub – Sun Nov 12, 2017 2:14 am] –[rexnanet – Wed Mar 01, 2017 10:45 am] – I’m going to try the ESP8266+MCP3008+emoncms.org approach first because it’s simpler.Hi! Have you had a chance to progress with your idea?
Hi PavloPub,
I’ve actually went for an ESP8266+STM32F103 (blue pill) because of the already available code. But I found a problem, the UART pins on the ESP are connected to the serial-USB adapter, so I have to desolder some resistors for it to work. It’s assembled but not tested yet… ![]()
I was focused on using HW because of another project and didn’t even remember I could use that on this one… Thanks
How fast can it go (reliably)?
Edit:
answering myself: 38400
https://forum.arduino.cc/index.php?topic=431522.0
Probably other libraries could do more but the “stock” one seems to be ok up to 38400.
I’ll give it a try.
I think I sample for 100 half cycles, i.e 1 second, which is time to send over 3000 chars to the ESP8266



