What to change in the emonlib library to port to esp-8266

Hi, i've seen a similar post on this, but it seems to get a little lost, so i would like to ask more directly for some guidance.

 

I would like to try to run this emons software on an esp-8266, it can be programmed in the same way as an arduino with the newly created arduino ide board manager. It has more  capacity than an arduino, with the added bonus of wifi on the same board. 

there are a few snags:

1/. The esp runs only on 3.3v dc

2/. It has a 10-bit adc input, but only reads from 0-1v 

3/. I'm no great programmer!

 

I was wondering if anyone had been involved much in working with the library could suggest which sections would need to be modified. A lot of libraries work without modification, but i can see that this library would need to be modified to work. 

 

Any pointers would be greatfully received.

Regards

Gambituk

Paul Reed's picture

Re: What to change in the emonlib library to port to esp-8266

gambituk's picture

Re: What to change in the emonlib library to port to esp-8266

Hi, thanks for the reply, this is indeed the post that i was referencing, i was just looking for more info or confirmation that this is indeed all that needs to be modified or are there other functions. The poster here has suggested some changes, but nobody has really commented on whether this is correct or if there is more or less than this that needs to be changed.

 

Thanks for any further answers

Gambituk

gambituk's picture

Re: What to change in the emonlib library to port to esp-8266

Hi, should i judge by the lack of specific answers that i'm in the wrong forum? or does nobody really remember what was needed at the time this library was put together :/ I guess either scenario is totally understandable.

 

I was really just looking for a clear authorative yay or nay to get me going in the right direction. 

dBC's picture

Re: What to change in the emonlib library to port to esp-8266

I suspect you need somebody who is very familiar with the library and very familiar with your chosen platform, and that's probably a very small group of people, possibly just you and Juan from Spain.  The best way to find out what needs changing is to port it, and then report back.

Apart from porting all the places where it bangs on AVR hardware, or Arduino interfaces to AVR hardware, you probably need to make sure your environment is real-time enough.   If you want to calculate real power in software, you need to make sure your Voltage and Current readings are taken at exactly the same time before you multiply them together, and you need to take a lot of them quickly.   On the AVR, that's not exactly possibly, but you can measure them 104usecs apart which is close enough for most purposes, and because that offset is deterministic and constant, you can compensate for it in s/w.  It appears as just another source of phase-error that adds or subtracts to all the other sources (CT phase error, VT phase error).

Robert Wall's picture

Re: What to change in the emonlib library to port to esp-8266

Everything that emonLib does is, I think, explained somewhere in Building Blocks. I'm reasonably familiar with emonLib, but I haven't got the first clue about the esp-8266. So adding to dBC's comment, if you understand how emonLib works to process the raw data into meaningful values, then with a good understanding of the esp-8266, you can rewrite the library.

pb's picture

Re: What to change in the emonlib library to port to esp-8266

One issue I can see is the single channel of ADC.  If you want to do accurate power measuring you need to sample both current and voltage quickly as dBC mentions.  To do this with an ESP module you would need to use some form of external analog switch, or perhaps an external ADC.  I have been using an ESP module for temperature (1wire) monitoring but that has significantly less real-time restrictions on operation.  The processor seems to be quite fast, but not sure how well it will keep up with real-time power monitoring since almost all the onboard features (WiFi etc) are software driven so take up a significant chunk of processing time.

What is your overall reason for using an ESP module?  If it is primarily to get WiFi access what about using it in conjunction with a standard Arduino board as a simple WiFi bridge?

gambituk's picture

Re: What to change in the emonlib library to port to esp-8266

Hi, Thanks for the answers. What appealed about the esp is having it as a small but powerful device. But looking again at the restrictions and considering the points that you have made perhaps i will look at continuing to use an arduino and then using the esp just as a wifi module. It was somehow attractive to just have it running on the esp as a full S.O.C. with just power and ct in.

 

Food for thought....

 

Thanks guys.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.