PlatformIO Community

Platformio and mysensors for atmega328p on breadboard -- was not declared in this scope

Hi all,

I’ve not had much luck with my post in the mysensors forum, so I thought I’d try here as well before I start creating GH issues.

Basically, I used platformio (cli) with an Arduino Nano to build this sketch using these instructions with minimal issues – one private function I had to move around (known issue) but other than that it worked like a charm.

Now I want to make a version of the same sketch using an atmega328p on a breadboard. I’m hoping it should work as it’s the same MCU.

However, I’m running into a slew of errors, mostly “not declared in this scope.” My INO file is unchanged.

In file included from .piolibdeps/MySensors_ID548/MySensors.h:257:0,
from rf24_temp/src/tempsensor.ino:38:
.piolibdeps/MySensors_ID548/core/MyTransport.cpp: In function 'void stInitTransition()':
.piolibdeps/MySensors_ID548/core/MyTransport.cpp:80:45: error: 'hwReadConfigBlock' was not declared in this scope
sizeof(transportConfig_t));
^
.piolibdeps/MySensors_ID548/core/MyTransport.cpp: In function 'void stInitUpdate()':
.piolibdeps/MySensors_ID548/core/MyTransport.cpp:108:61: error: 'hwWriteConfig' was not declared in this scope
hwWriteConfig(EEPROM_NODE_ID_ADDRESS, (uint8_t)MY_NODE_ID);
^
.piolibdeps/MySensors_ID548/core/MyTransport.cpp: In function 'void stUplinkUpdate()':
.piolibdeps/MySensors_ID548/core/MyTransport.cpp:232:43: error: 'hwMillis' was not declared in this scope
_transportSM.lastUplinkCheck = hwMillis();
^
.piolibdeps/MySensors_ID548/core/MyTransport.cpp: In function 'void transportSwitchSM(transportState_t&)':
.piolibdeps/MySensors_ID548/core/MyTransport.cpp:342:37: error: 'hwMillis' was not declared in this scope
_transportSM.stateEnter = hwMillis(); // save time
^
.piolibdeps/MySensors_ID548/core/MyTransport.cpp: In function 'uint32_t transportTimeInState()':
.piolibdeps/MySensors_ID548/core/MyTransport.cpp:347:18: error: 'hwMillis' was not declared in this scope
return hwMillis() - _transportSM.stateEnter;

So far I’ve found a few useful links:

What I’ve tried (with a pio run target=clean before each attempted build):

  • Adding #include <Arduino.h> or #include "Arduino.h" to the top of my sketch
    • nothing changes
  • Specifying build_flags = -I/path/to/MySensors
    • nothing changes
  • Specifying lib_ignore = MySensors
    • nothing changes

My platformio.ini:

[env:328p8m]
platform = atmelavr
board = 328p8m
framework = arduino
upload_protocol = usbasp
lib_deps = 
    MySensors
    DallasTemperature

Any ideas? Again, this builds fine with the same code but using a nano as the target platform, just won’t build for the atmega328p for some reason. Thanks for any help you can provide!

  • platformio (cli) 3.4.1
  • mysensors (lib #548) 2.1.1
  • MacOS 10.13.1

Does it work with Arduino IDE?

Sorry should have specified, yes it does, I do not get these compilation errors.

The problem is linked with outdated DallasTemperature library and a bug with 328p8m board config. I fixed that last moment. This works for me

[env:328p8m]
platform = https://github.com/platformio/platform-atmelavr.git
board = 328p8m
framework = arduino
lib_deps =
    MySensors
    https://github.com/milesburton/Arduino-Temperature-Control-Library.git

Sweet, thanks for the update. Looks like this required 3.5 (not yet released as stable)?

Yes, PIO Core 3.5 is planned for release this month.

@ivankravets

Currently compiles great under 3.5 and the below config. Thanks again!

[env:328p8m]
platform = atmelavr
board = 328p8m
framework = arduino
upload_protocol = usbasp
lib_deps = 
    MySensors
    https://github.com/milesburton/Arduino-Temperature-Control-Library.git