I won’t investigate (as I’m too busy), but I would be almost certain that this is the case.
The solution of course is to use a self-contained sounder that needs only a d.c. signal to drive it, and turn on a digital output for the duration you want the sounder to sound, rather than driving a piezo element directly as you appear to be doing.
Be aware that the interference may well happen in both directions. It’s been a while but from memory AVR interrupts aren’t nestable - they’re all at the same priority. So just as the latency introduced by the ADC interrupt impacts on the tone’s timer interrupt, so too the tone’s timer interrupt might introduce enough latency to disturb the ADC work.
Continuing my (on and off) efforts to make emontx (and firmware EmonTxV3CM) work for me, I downloaded version 2.1 of the library from github and bumped into a compile error involving variable assumedVrms. Further digging around reveals that github no longer hosts the most recent version (2.2.1), which I downloaded as provided elsewhere in this forum. This version fixes the problem by renaming the variable, just as I did!
However, looking at the zip file I downloaded, I do not see the .h file for v2.2.1. Am I missing something?
If so, what I see in that file is a directory named emonlibCM within which is a .cpp and .h file containing comments indicating version 2.2.0. I also see at the root directory of that zip a .cpp file, but not a .h file, with comments indicating version 2.2.1. Is that what you see?
That clarifies the problem. The release seems to have got tangled up, the header file was always the correct one - it was unchanged, the cpp file just hadn’t got put into the sub-directory to replace the 14th Sept version. I’ve updated the release page with a new zip file, but not changed the version number as the code is unchanged.
Hello,
Unless I missed something, the Arduino Due doesn’t seem to be supported at all by EmonLibCM. Is this correct (although I saw a reference to the board in the code)?
And if so, any chance to see support for the Due in a near future? Is there any I could help with this, despite my near complete lack of development skills?
Thanks!
You are indeed correct. The code is very closely integrated to the timing characteristics of the Atmel 328P. No consideration has been given to using an alternative host, and I don’t foresee being able to offer very much assistance to anyone who wishes to attempt a port within the foreseeable future; I am far too preoccupied not only with the Atmel-DB, but with commitments outside of OEM.
Hello @Robert.Wall and thank you for the great work. I am trying to use EmonLibCM with esp32 and platformio but I am finding some challenges. For example, these two inclusions can’t work because util and OneWire.h are not there in the library folder.
#include <util/crc16.h>
#include <OneWire.h>
Among other squiggles, I believe these should be small issues for a seasoned person but I am not one.
I have tried getting the two files from the internet and pasted them in my folder but they too came with their own squiggles.
Is there a specific resource for using this library in platformio? or I have to fight it out
I cannot recommend using platformio. When I tried it, it moved files and destroyed my system, so I refuse to have it on my machine ever again.
All I can suggest is you get a copy of the Arduino IDE, preferably V1.8.19 (v2.x.x has restrictions I don’t like - e.g. you can’t use an external editor) and follow the instructions in the Docs section here for setting it up. Even so, you must remember emonLibCM was written for the ATMega 328P and I have no idea whether it will run correctly or at all on an ESP32. Also, bear in mind that there are questions regarding the performance of the ADC in the ESP32 - it’s generally regarded as not being very good - for details you need to search the Internet.
It was hyped as “the best thing since sliced bread”. I found this not to be the case. Maybe bugs have been removed since, I don’t know. I’m not running the risk of having to spend a few hours putting things to rights again.
I know the instructions in Docs for setting up the Arduino IDE work for the Atmel ATMega 328P, this is all I can say.
I switched to arduino ide but I have gotten the same errors as I was getting in platformio. util/crc16.h can not be located. How should I prepare before using the emonLibCM library.
That part of code, it is trying to include those files but they are not their in the library folder. but the complaint starts at util/crc16.h and none at SPI.h despite it not being there as well. which makes me believe something is wrong with my installation or something. someone kindly help bring me to speed.
Are you sure you don’t have the files? I run under Ubuntu 24.04 and the path for crc16.h is
…arduino-1.8.19/hardware/tools/avr/avr/include/util/crc16.h
I have multiple copies of spi.h, and one copy of SPI.h in …arduino-1.8.19/hardware/arduino/avr/libraries/SPI/src/SPI.h
Did you install all the libraries and all the steps (like renaming some) as listed on the same page?