Problem compiling firmware for emonPi2

Hi,
I received my emonPi2 kit today to monitor my Heat Pump but have run into a problem trying to compile the firmware to enable the analog input for monitoring my Ecodan Sika flow sensor. I have followed the instructions in the docs for both the PlatformIO method and the Arduino IDE method and both show the same error:

/Users/craig/Development/OpenEnergyMonitor/avrdb_firmware/emon_DB_6CT/emon_DB_6CT.ino: In function 'void setup()':
/Users/craig/Development/OpenEnergyMonitor/avrdb_firmware/emon_DB_6CT/emon_DB_6CT.ino:204:3: error: 'Wire1' was not declared in this scope
   Wire1.swap(2);
   ^~~~~
/Users/craig/Development/OpenEnergyMonitor/avrdb_firmware/emon_DB_6CT/emon_DB_6CT.ino:204:3: note: suggested alternative: 'Wire'
   Wire1.swap(2);
   ^~~~~
   Wire
Compiling .pio/build/Upload_USART/FrameworkArduino/UART0.cpp.o
Archiving .pio/build/Upload_USART/lib412/libemonEProm.a
*** [.pio/build/Upload_USART/src/emon_DB_6CT.ino.cpp.o] Error 1

I’m a software developer and also an electronics engineer so although the emonPi2 is new to me, I’m very familiar with software, electronics and micro controllers. But I’ve been trying all sorts of things this evening to resolve my problem without success. Well, I might have solved the problem but I need a sanity check first. :slight_smile:

I believe the issue is to do with the Wire interface and I noticed in the Arduino IDE, there is an option to configure this interface in 4 different ways:

Screenshot 2024-06-21 at 00.42.55

If I set this to one of the 2x options then it compiles fine but I don’t know which of these is the correct one to choose.

Also, if I #define ENABLE_ANALOG then do I need to change #define PULSE_PIN 3 to some other value? If I comment out this define then I get loads of compile errors but I don’t know what effect setting it to 1 or 2 might have.

Any advice would be most welcome.

Many thanks,
Craig.

Hello @craigc

Yes good spot, apologies for missing this in the documentation. You have selected the right option and yes setting PULSE_PIN to 1 is fine.

Thank you @TrystanLea , I appreciate the quick response. :slight_smile:

Is there a way to set this option when using PlatformIO rather than the Arduino IDE given that PIO is the recommended option for firmware compilation and is quite a bit easier to set up?

Also, what is the easiest/best way to get a firmware, which I have compiled on my Mac laptop, uploaded onto the micro controller? Should I scp it onto the Pi and then use avrdude or is there an easier way?

Thanks again,
Craig.

Would love to get this all working via PlatformIO, last time I tried it was not clear how to set these options for DxCore, it might be better now, this was a while a back.

There’s a new option in Emoncms > Update > Update firmware only tool to upload a hex file directly, select the target hardware and the option will appear to upload a hex file:

Ah, perfect! I didn’t have that option but updated EmonCMS and now I have it! I used that to upload my new firmware and now I have an “analog” input available. Just need to physically wire that up and add in the required process steps to generate the heat output value and I should be able to get my CoP value.

I’ll see if I can figure out how to compile successfully with PlatformIO and will let you know if I figure it out.

If you’re updating the docs then please note that I also needed to add an additional library when setting up Arduino IDE for GitHub - greiman/SSD1306Ascii: Text only Arduino Library for SSD1306 OLED displays

Have a great day!
Craig.