# Arduino Errors trying to compile old firmware

**URL:** <https://community.openenergymonitor.org/t/arduino-errors-trying-to-compile-old-firmware/10039>\
**Category:** Hardware\
**Created:** [10 February 2019 10:45 UTC](https://community.openenergymonitor.org/t/arduino-errors-trying-to-compile-old-firmware/10039 "2019-02-10T10:45:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://community.openenergymonitor.org/u/ian)\
**Post date:** [10 February 2019 10:45 UTC](https://community.openenergymonitor.org/t/arduino-errors-trying-to-compile-old-firmware/10039/1 "2019-02-10T10:45:38Z")

</div>

Hi

I need to make a minor change to firmware that I have on an old emonTX. I note the original file date was 2012.  
First thing I did was to try and compile the original file before I make changes.

This produce some errors.

Back in 2012 I probably used an older jeelib library than that currently installed which is from [git@github.com](mailto:git@github.com):openenergymonitor/jeelib.git.  
My guess is that changes to Arduino are causing the problem and not the library but I do not have the knowledge to work out the fix.

```auto
Arduino: 1.8.7 (Windows 10), Board: "Arduino/Genuino Uno"
In file included from D:\MicroProcessors\ArduinoCode\libraries\jeelibstable/JeeLib.h:18:0,
from D:\MicroProcessors\ArduinoCode\MyEmontTX\MyEmontTX.ino:36:

D:\MicroProcessors\ArduinoCode\libraries\jeelibstable/RF12.h:56:25: error: expected ',' or '...' before numeric constant

 #define RF12_433MHZ 1 ///< RFM12B 433 MHz frequency band.
                         ^
D:\MicroProcessors\ArduinoCode\MyEmontTX\MyEmontTX.ino:29:14: note: in expansion of macro 'RF12_433MHZ'
 #define freq RF12_433MHZ // frequency - match to same frequency as RFM12B module (change to 868Mhz or 915Mhz if appropriate)
              ^
D:\MicroProcessors\ArduinoCode\libraries\jeelibstable/RF69.h:10:33: note: in expansion of macro 'freq'
     void setFrequency (uint32_t freq);
                                 ^

```

Any help would be much appreciated.

Ian

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [10 February 2019 11:52 UTC](https://community.openenergymonitor.org/t/arduino-errors-trying-to-compile-old-firmware/10039/2 "2019-02-10T11:52:32Z")

</div>

I have an emonTx V2 that I use for testing/debugging (because there’s a lot of I/O pins I can hang a 'scope on), and I don’t have a problem. Which sketch are you trying to compile?

The “freq” error is a naming conflict - I can’t remember the details now.

(EmonLibCM runs on a V2, when you define the I/O pins - that’s what I last used mine for.)

[Edit]  
Looking at my copy of `emonTx_CT123_Voltage.ino` and comparing it against the Git version. I have  
`#define FREQ RF12_433MHZ ` whereas the “official” Git version is `#define RF_freq RF12_433MHZ`  
The conflict (IIRC) was there - the normal convention is to use CAPITALS in pre-processor substitutions, but G&T have never respected that, and that’s the likely source of the trouble. But if you tell me the sketch (or post it), I’ll take a look.

---

<div class="post-metadata">

**Author:** ![ian](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://community.openenergymonitor.org/u/ian)\
**Post date:** [10 February 2019 12:30 UTC](https://community.openenergymonitor.org/t/arduino-errors-trying-to-compile-old-firmware/10039/3 "2019-02-10T12:30:25Z")

</div>

Thank you Robert

The file is a very early one from Glyn and Tristan so hard to identify. Plus I hacked it by trial and error to monitor a pin to check a boiler state. I am not even sure of the emonTx version, I have not pulled it out of service yet. It is very early. As I say the file I modded in 2012.

Therefore I attach the complete directory.  
[MyEmontTX.zip](https://community.openenergymonitor.org/uploads/default/original/2X/8/82276bf4d4773e3a46da15cf968cc1a87938977d.zip) (3.7 KB)

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [10 February 2019 13:02 UTC](https://community.openenergymonitor.org/t/arduino-errors-trying-to-compile-old-firmware/10039/4 "2019-02-10T13:02:39Z")

</div>

That’s apparently all it was…  
I’ve replaced `freq` with `FREQ` in lines 29 & 97

```auto
#define FREQ RF12_433MHZ   

    rf12_initialize(10, FREQ,210); 

```

and it compiles for me (with a warning - normal - that “‘prog\_uint8\_t’ is deprecated”) and transmits 14 bytes:  
00 00 00 00 64 ce 64 ce 64 ce 64 ce 18 00

64 ce = -12700, so it doesn’t look far wrong.

I can’t test the RTC part, nor (I presume) the connected display.

---

<div class="post-metadata">

**Author:** ![ian](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://community.openenergymonitor.org/u/ian)\
**Post date:** [10 February 2019 15:54 UTC](https://community.openenergymonitor.org/t/arduino-errors-trying-to-compile-old-firmware/10039/5 "2019-02-10T15:54:07Z")

</div>

Thank you.

I don’t think I would have worked that out on my own.

Now compiles without error.

---

<div class="post-metadata">

**Author:** ![Vster](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@Vster](https://community.openenergymonitor.org/u/Vster)\
**Post date:** [13 February 2019 09:37 UTC](https://community.openenergymonitor.org/t/arduino-errors-trying-to-compile-old-firmware/10039/6 "2019-02-13T09:37:09Z")

</div>

I had this a while back, if you change the ‘freq’ to something else, like ‘frequ’, it’ll compile just fine.

---

<div class="post-metadata">

**Author:** ![pb66](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/pb66/32/27_2.png) [@pb66](https://community.openenergymonitor.org/u/pb66)\
**Post date:** [13 February 2019 11:52 UTC](https://community.openenergymonitor.org/t/arduino-errors-trying-to-compile-old-firmware/10039/7 "2019-02-13T11:52:31Z")

</div>

> [@Vster](#):
>
> if you change the ‘freq’ to something else, like ‘frequ’, it’ll compile just fine.

That could explain why there was an apparent shift from using `freq` to using `RF_freq` in the various older sketches.

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [13 February 2019 14:03 UTC](https://community.openenergymonitor.org/t/arduino-errors-trying-to-compile-old-firmware/10039/8 "2019-02-13T14:03:38Z")

</div>

That’s right. IIRC, JeeLib changed internally to use “freq”. (I don’t know what it was originally.) OEM has previously used “freq” in a pre-processor substitution for the (integer) value that’s eventually used to select the numbers to load into the RFM registers. This is despite the convention that all such _names_ should be UPPERCASE. The replacement text need not be upper case, but in our case the replacement text RF12\_433MHZ is itself the subject of a substitution in RF12.h:  
`#define RF12_433MHZ 1 ///< RFM12B 433 MHz frequency band.`

It would be quite in order, though obscure, to write:  
`rf12_initialize(8, 1, 210);`

The reason why I recommended using FREQ was to stay with convention, so everybody knows it’s not a normal variable.
