A CPP file isn't an Arduino file. It doesn't know about anything Arduino-esque unless you tell it about it. The simplest way is to just add, at the top of the file: #include <Arduino.h>


First, a few general notes: The difference between char str[2] and char* str = (char*) malloc(2) is irrelevant to you problem. It changes the place where the array is stored, the meaning of sizeof str, and malloc() will blow up your RAM if you call it repeatedly and forget to free(). In your code, sizeof(txt) is the constant 2: the actual size in bytes of ...

Only top voted, non community-wiki answers of a minimum length are eligible