Hi! I have a working code on a nano board and i decided to use an Heltec ESP32 for the Touch pins, the small screen, low power consumption and wireless control.
The problem i'm facing is the code works fine when compiling it to the nano or a uno board. When i compile it to ESP32 i get compiling errors. The errors are all elements not declared in scope and one is encoder port pin not defined.
Why is this happening? I taught i only had to be aware of the difference in hardware.
Please do this:
- When you encounter an error, you’ll see a button on the right side of the orange bar “Copy error messages” in the Arduino IDE (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button…
- In a forum reply here, click on the reply field.
- Click the </> button on the forum toolbar. This will add the forum’s code tags markup to your reply.
- Press “Ctrl + V”. This will paste the error between the code tags.
- Move the cursor outside of the code tags before you add any additional text to your reply.
If the text exceeds the forum’s 9000 character limit, save it to a .txt file and post it as an attachment. If you click the “Reply” button here, you will see an “Attachments and other settings” link that will allow you to make the attachment.
Here are the errors i get. This is what i get when i verify the code with arduino IDE. I get more when using Platformio on VS Code.
Arduino: 1.8.12 (Windows 10), Board: "WiFi LoRa 32, Disabled, 240MHz (WiFi/BT), 921600, None, REGION_EU868, None"
C:\Users\ggsxx\Documents\Arduino\libraries\Arduino\StackDuino\StackDuino.ino: In function 'void setup()':
StackDuino:30:15: error: 'A1' was not declared in this scope
#define ENC_B A1 //rotary encoder (15)
C:\Users\ggsxx\Documents\Arduino\libraries\Arduino\StackDuino\StackDuino.ino:98:11: note: in expansion of macro 'ENC_B'
C:\Users\ggsxx\Documents\Arduino\libraries\Arduino\StackDuino\StackDuino.ino: In function 'int8_t encoder_read()':
StackDuino:31:18: error: 'PINC' was not declared in this scope
#define ENC_PORT PINC //rotary encoder (a port not a pin)
C:\Users\ggsxx\Documents\Arduino\libraries\Arduino\StackDuino\StackDuino.ino:228:15: note: in expansion of macro 'ENC_PORT'
old_AB |= ( ENC_PORT & 0x03 ); //add current state
exit status 1
'A1' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
here are the errors i get when compiling with Platformio in VS Code
A1 was not declared in this scope
PINC was not declared in this scope
button _main_change was not declared in this scope
identifier A1 was not defined in this scope
button rotary_change was not declared in this scope
stepper_enable is not declared in this code
stepper_step was not declared in this scope
stepper_disable was not declared in this scope
Those are code issues.
Any chance you can post your actual code ?
Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.
The code works properly when compiling on the arduino ide with nano board selected and not when compiling with the esp32 board selected. I know there is probably something wrong with Platformio compiler when i compile the sketch.
If you suspect a platformio error should you not be on thier forums ?
Looking at the errors, some questions (note that I'm not familiar with the ESP).
Does the ESP have a pin called A1? Does it have an analogue input?
Does the ESP32 have a register called PINC? You have written / borrowed code that is bypassing the hardware abstraction layer by directly accessing registers.
Your only option is to understand your code and next modify it for the ESP.
You are right! The Esp32 has 18 ADC pins. And the code accesses directly the register for speed has this is to read an encoder. I am now trying to find the equivalant for the esp32.
Thanks a lot !