I think the issue here is that the BlynkHandlers.h file in the Blynk library contains a list of virtual pin translations, and this is an extract…
#define V28 28
#define V29 29
#define V30 30
#define V31 31
#ifdef BLYNK_USE_128_VPINS
#define V32 32
#define V33 33
#define V34 34
#define V35 35
So, if #ifdef BLYNK_USE_128_VPINS
is false
then the maximum useable variable pin number is V31, which is why V32 is not recognised in your case.
I believe that this done to ensure that devices with lower memory aren’t bloated by the library.
I think (and I’ve not really studied this) that the BlynkDetectDevice.h
library file decides which type of device should have more virtual pins, and which should have less. As far as I know, this is device detection is done with the pre-defined constants that are passed from the compiler and come from the board definition files, so will vary depending on which board type you choose in the IDE when compiling the device.
I think you can override the BlynkDetectDevice.h
default for your board type by adding this line to your sketch…
#define BLYNK_USE_128_VPINS
You should probably add it after #define BLYNK_DEVICE_NAME "xxx"
and before #include <BlynkSimpleEthernet2.h>
The Blynk sketch builder examples will normally use BLYNK_WRITE(V9)
rather than creating an alias for V9.
Aliases can be very useful, but not the way you’ve used them.
What you’re doing here:
#define VIRTUAL_PIN_V9 V9
is creating an alias called VIRTUAL_PIN_V9
and telling the compiler that every time it sees this alias it should replace it with V9
during the compilation process.
However, there’s no benefit to doing this. The whole point of using aliases is that it:
a) Makes the code easier to read and
b) Allows a pin assignment (virtual or physical) to be changed in one “lookup table” rather than having to change every occurrence in the sketch
For example it’s common to create descriptive aliases for physical pins like this:
// Physical pins:
#define power_relay 4
#define DHT_pin 14
#define error_LED 2
With this type of arrangement, if you want to swap your relay from physical pin 4 to pin 5 on your board you just make one change, to the:
#define power_relay 4
line of code, rather than having to do a find/replace on your sketch, which isn’t easy as the number 4
may occur in may different places in the sketch, many of which will have nothing to do with your reference to a pin number.
It also makes code easier to follow when you do things like:
virtualWrite (power_relay, LOW);
and even better, if your relay is active LOW, as it’s turned-on by pulling the pin LOW, which is counter-intuitive. so, if you add aliases like:
#define on LOW
#define off HIGH
then your code could look like this:
virtualWrite (power_relay, on);
That way, switching to a different type of relay would only need you to swap your on/off aliases around to achieve the same functionality.
Adding aliases for virtual pins isn’t as common, but can be useful for the same reasons. If you created aliases like this:
// Virtual pins for widget controls:
#define on_off_switch_widget V1
#define status_led_widget V2
#define delay_slider_widget V3
#define pause_button_widget V4
The you could have code like:
BLYNK_WRITE(delay_slider_widget)
and
Blynk.virtualWrite(status_led_widget, 1)
or Blynk.virtualWrite(status_led_widget, on)
with an additional alias for on
Including the virtual pin number in the alias makes no sense, as if you wanted to change the virtual pin number you’d either have to change all of the aliases too, or live with mis-matched and confusing aliases.
Which is why I said…
Pete.