Compilation Error for 3phase sketch using PlatformIO and Visual Sudio Code

Hi, I am trying to use the 3 phase sketch on an Emontx. I tried to use PlatformIO using atom, however it failed to load it properly - I kept getting a please restart message. A search of atom and PlatformIO help sections directed me to use Visual studio code, which is supported by platformIO . I downloaded this and have platformIO running. I loaded the 3 phase firmware from guthub and edited as directed in the user guide. One message that comes up with visual studio is that it does not support .ino files and they should be converted to .cpp Is this the correct thing to do. I attempted to compile the sketch as is and it failed. the error log as follows. Can you help please?

> Executing task in folder emontx-3phase-master: C:\Users\Patday\.platformio\penv\Scripts\platformio.exe run <

Warning! `env_default` configuration option in section [platformio] is deprecated and will be removed in the next release! Please use `default_envs` instead
Processing emontx-3phase (platform: atmelavr; framework: arduino; board: uno)
-------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR 2.2.0 > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
 - framework-arduino-avr 5.0.0
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
Converting src.ino
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:191:0: warning: "VOLTSPIN" redefined
 #define VOLTSPIN 0
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:179:0: note: this is the location of the previous definition
 #define VOLTSPIN 2
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:192:0: warning: "CT1PIN" redefined
 #define CT1PIN 1
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:180:0: note: this is the location of the previous definition
 #define CT1PIN 3
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:193:0: warning: "CT2PIN" redefined
 #define CT2PIN 2
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:181:0: note: this is the location of the previous definition
 #define CT2PIN 0
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:194:0: warning: "CT3PIN" redefined
 #define CT3PIN 3
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:182:0: note: this is the location of the previous definition
 #define CT3PIN 1
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:196:0: warning: "LEDPIN" redefined
 #define LEDPIN 6
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:183:0: note: this is the location of the previous definition
 #define LEDPIN 9
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:197:0: warning: "RFMSELPIN" redefined
 #define RFMSELPIN 4     // Pins for the RFM Radio module
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:184:0: note: this is the location of the previous definition
 #define RFMSELPIN 10
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:198:0: warning: "RFMIRQPIN" redefined
 #define RFMIRQPIN 3
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:185:0: note: this is the location of the previous definition
 #define RFMIRQPIN 2
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:200:0: warning: "W1PIN" redefined
 #define W1PIN 5         // 1-Wire pin for temperature
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:187:0: note: this is the location of the previous definition
 #define W1PIN 4         // 1-Wire pin for temperature
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:211:0: warning: "LEDPIN" redefined
 #define LEDPIN 9
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:196:0: note: this is the location of the previous definition
 #define LEDPIN 6
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:212:0: warning: "RFMSELPIN" redefined
 #define RFMSELPIN 5   // See Wiki
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:197:0: note: this is the location of the previous definition
 #define RFMSELPIN 4     // Pins for the RFM Radio module
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:215:0: warning: "W1PIN" redefined
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
 #define W1PIN 4       // 1-Wire pin for temperature
LDF Modes: Finder ~ chain, Compatibility ~ soft
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:200:0: note: this is the location of the previous definition
Looking for DallasTemperature  #define W1PIN 5         // 1-Wire pin for temperature
 library in registry
Found:  ^
https://platformio.org/lib/show/54/DallasTemperature
LibraryManager: Installing C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:224:0: warning: "LEDPIN" redefined
id=54 @ 3.7.7
 #define LEDPIN 6
Using cache: C:\Users\Patday\.platformio\.cache\3e\d36164871f40eedbe43f0e3f85d41a3e
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:211:0: note: this is the location of the previous definition
 #define LEDPIN 9
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:225:0: warning: "RFMSELPIN" redefined
 #define RFMSELPIN 10    // Pins for the RFM Radio module
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:212:0: note: this is the location of the previous definition
 #define RFMSELPIN 5   // See Wiki
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:226:0: warning: "RFMIRQPIN" redefined
 #define RFMIRQPIN 2

 ^
Unpacking  [############################--------]   78%
Unpacking  [#############################-------]   81%C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:213:0: note: this is the location of the previous definition

Unpacking  [##############################------]   84%
Unpacking  [###############################-----]   87% #define RFMIRQPIN 3   // See Wiki

Unpacking  [################################----]   90%
Unpacking  [#################################---]   93% ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:228:0: warning: "W1PIN" redefined

Unpacking  [##################################--]   96% #define W1PIN 5         // 1-Wire pin for temperature

Unpacking  [####################################]  100%
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:215:0: note: this is the location of the previous definition
 #define W1PIN 4       // 1-Wire pin for temperature
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:243:0: warning: "PHASE2" redefined
 #define PHASE2 (NUMSAMPLES/3)                    // Delay for the Phase 2 voltage 
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:240:0: note: this is the location of the previous definition
 #define PHASE2 (NUMSAMPLES/6)                    // Delay for the Phase 2 voltage 
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:244:0: warning: "PHASE3" redefined
 #define PHASE3 (NUMSAMPLES*2/3)                  // Delay for the Phase 3 voltage
 ^
C:/Users/Patday/Downloads/emontx-3phase-master/emontx-3phase-master/src/src.ino:241:0: note: this is the location of the previous definition
 #define PHASE3 (NUMSAMPLES/3)                    // Delay for the Phase 3 voltage
 ^
DallasTemperature @ 3.7.7 has been successfully installed!
Installing dependencies
Looking for OneWire library in registry
Found: https://platformio.org/lib/show/1/OneWire
LibraryManager: Installing id=1
Using cache: C:\Users\Patday\.platformio\.cache\21\36e4877e55d4cd5b0be34fccc5ff1121
OneWire @ 2.3.5 has been successfully installed!
Looking for JeeLib  library in registry
Found: UndefinedPackageVersion: Could not find a version that satisfies the requirement 'c057b5f4c0' for your system 'windows_amd64':
https://platformio.org/lib/show/252/JeeLib  File "C:\Users\Patday\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 168:

LibraryManager: Installing     env.SConscript("$BUILD_SCRIPT")
id=252  File "C:\Users\Patday\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 597:
 @ c057b5f4c0
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Patday\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 286:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\Users\Patday\.platformio\platforms\atmelavr\builder\main.py", line 161:
    target_elf = env.BuildProgram()
  File "C:\Users\Patday\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Patday\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 62:
    env.ProcessProjectDeps()
  File "C:\Users\Patday\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Patday\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 131:
    project_lib_builder = env.ConfigureProjectLibBuilder()
  File "C:\Users\Patday\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Patday\.platformio\penv\lib\site-packages\platformio\builder\tools\piolib.py", line 1036:
    project.install_dependencies()
  File "C:\Users\Patday\.platformio\penv\lib\site-packages\platformio\builder\tools\piolib.py", line 868:
    lm.install(uri)
  File "c:\users\patday\.platformio\penv\lib\site-packages\platformio\managers\lib.py", line 281:
    force=force,
  File "c:\users\patday\.platformio\penv\lib\site-packages\platformio\managers\package.py", line 704:
    pkg_dir = self._install_from_piorepo(name, requirements)
  File "c:\users\patday\.platformio\penv\lib\site-packages\platformio\managers\lib.py", line 119:
    requirements or "latest", util.get_systype()
======================================================= [FAILED] Took 8.41 seconds =======================================================

Environment           Status    Duration
--------------------  --------  ------------
emontx-3phase         FAILED    00:00:08.411
emontx-3phase_deploy  IGNORED
================================================== 1 failed, 0 succeeded in 00:00:08.411 ==================================================
The terminal process "C:\Users\Patday\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1.

I am unable to support platformio. I recommend using the Arduino IDE, installed according to the instructions in the ‘Learn’ section.

You can get the Arduino IDE from the Windows Store - easy install.

Thanks for the pointer ill try Arduino IDE which I already have installed, however I was following the guides on the web site which suggests the easiest method is with PlatformIO. This has also been recommended in other compilation error topics that I have viewed on this forum. Taken from Technical — OpenEnergyMonitor 0.0.1 documentation

Using Arduino IDE

Either PlatformIO or Arduino IDE can be used to compile and upload the firmware. This example will use PlatformIO since we consider it the easiest method. If you wish to use Arduino IDE see this Learn article.

Thanks for the help, and I do try to research things before coming to this forum. :smiley:

Platformio was billed as the best thing since sliced bread, but it moved files around and broke my system. Software that interferes with an existing system without permission is malware, in my book. For exactly that reason, I will not install it again and so I am unable to support it.

There are 2 distinct things going on here. The PIO referred to is often the PIO installable on an RPi. I have used this successfully with absolutely no issues.

The probability is that, when PIO is installed on Windows, it attempts to do some migration from the Arduino IDE and this may have resulted in what Robert has seen - and that may have been an early version that had some ‘quirks’. I have not done this so cannot comment, but PIO isn’t malware.

In addition, VSCode does provide some very tight integration to other systems such as PIO. I have to say I have never been that comfortable with understanding that integration so, although I use VSCode, I don’t use PIO on that platform.

IIRC, Robert had already made the switch to Linux when PIO messed up his system.

Absolutely right. One sniff of Win 8 and I quit Windoze. It was the second bad experience I had, the first was when a friend’s burglar alarm phoned me and Windoze decided it was much more important to update itself than allow me to look at the security cameras.

I know darned well it moved files, because a script that had worked many times suddenly failed - it couldn’t find the files. And when I looked, they’d moved. If that isn’t either utter stupidity, malicious or supremely negligent, I don’t know what else it can be.

I tried it with a completely open mind. After that, no way will I look at it again. Ever.

Hi Guys,
Thanks for all the interesting stuff about platformio and malware etc. Its interesting how things change over time with the different software develoments.

I am now back onto this 3phase sketch to use on my emontx. I have attempted to complie the sketch, but its failing with the following message

exit status 1
‘rfm_init’ was not declared in this scope

Im thinking that this has something to do with the radio module, and the copy of part of the sketch concerning this is as follows:-

// RFM settings                                  // THIS SKETCH WILL NOT WORK WITH THE RFM12B radio.
//#define EMONESP                                // Uncomment to use the sketch with EmonESP and comment out the line below #define RFM69CW
#define RFM69CW                                  // The type of Radio Module, or none.
                                                 // Can be RFM69CW 
                                                 //   or SERIALOUT if a wired serial connection is used 
                                                 //   or EMONESP if an ESP WiFi module is used
                                                 //     (see http://openenergymonitor.org/emonnode/3872) 
                                                 //   or don't define anything if neither radio nor serial connection is required - in which case 
                                                 //      the IDE serial monitor output will be for information and debugging only.
                                                 // The sketch will hang if the wrong radio module is specified, or if one is specified and not fitted.
                                                 // For all serial output, the maximum is 9600 baud. The emonESP module must be set to suit.
                                                 
#undef RF12_433MHZ
#undef RF12_868MHZ
#undef RF12_915MHZ                               // Should not be present, but can cause problems if they are.

#define RF12_433MHZ                              // Frequency of RFM module can be 
                                                 //    RF12_433MHZ, RF12_868MHZ or RF12_915MHZ. 
                                                 //  You should use the one matching the module you have.
                                                 //  (Note: this is different from the normal OEM definition.)

I have an emonTx straight out of the box - Can you help please?

What’s the betting it can’t find rfm_send( ) either?

You need to extract the DIRECTORY “emonTx_3Phase_PLL” that was in the .zip file you downloaded, and put it complete with all its contents into your Arduino Sketchbook directory. I’m fairly certain it will then compile when you use the proper Arduino IDE. I can’t speak for anything else.

(If in doubt, use the checksums in the post to verify the integrity of the download and the constituent files after you’ve unzipped them.)

Hi, I was trying to save myself some work and copied the file that I had editted in PIO and used that in Arduino IDE. I have now started again and re-editted the src file. I’ve also found some time during the day, which also helps!

I hope I’m nearly there, however…

It gives me a message saying it has “done uploading” but it also seems to be looking for libraries in the wrong places. Here is the last few lines of the debug window:-

Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire 
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
Using library OneWire at version 2.3.5 in folder: C:\Users\Patday\Dropbox\OEM\Software\libraries\OneWire 
Using library EEPROM at version 2.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\EEPROM 
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-size" -A "C:\\Users\\Patday\\AppData\\Local\\Temp\\arduino_build_887584/src.ino.elf"
Sketch uses 21916 bytes (67%) of program storage space. Maximum is 32256 bytes.
Global variables use 944 bytes (46%) of dynamic memory, leaving 1104 bytes for local variables. Maximum is 2048 bytes.
Invalid library found in C:\Users\Patday\Dropbox\OEM\Software\libraries\libraries: no headers files (.h) found in C:\Users\Patday\Dropbox\OEM\Software\libraries\libraries
Invalid library found in C:\Users\Patday\Dropbox\OEM\Software\libraries\libraries: no headers files (.h) found in C:\Users\Patday\Dropbox\OEM\Software\libraries\libraries

The last two lines indicate that it is looking for .h files in …\software\libraries\libraries however it was set to look in …\software for its libraries. This being confirmed a few lines earlier when it finds the OneWire in …\software\libraries\OneWire.

Can you help please?

It seems your file structure is well messed up.

Unfortunately, the Arduino IDE ignores paths when searching for users’ libraries, so you cannot have two different library files of the same name even though they’re in different sub-directories of the library tree. The logic behind that escapes me, because it’s contrary to what everyone else has always done (in my experience, anyway). Those messages indicate that it’s found some files that it thinks should be libraries somewhere in the library tree, and it’s trying to use them.

My solution to that is to zip those files and delete the originals, or move them out of the ‘library’ tree.

So in my “libraries” directory, I have whole load of old libraries, all safely bundled up in zip files where it can’t get at them, but when there’s a problem - I can.

PIO handles different libraries in different folders pretty well :rofl: <GRD> - I’ll get my hat…