B4R Question Trying to get esp8266 battery voltage using #ifC

davelew1s

Active Member
Licensed User
Longtime User
I am trying to get this code to work .... it comes from EREL and i am sure this worked several years ago ... but not now.
TEST:
Sub Process_Globals
   Public Serial1 As Serial
   Private Timer1 As Timer
   Private VCC As UInt 'ignore
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   Timer1.Initialize("Timer1_Tick", 1000)
   Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick
   RunNative("GetVCC", Null)
   Log(VCC)
End Sub

#if C
 ADC_MODE(ADC_VCC);
void GetVCC (B4R::Object* o) {
   b4r_main::_vcc = ESP.getVcc();
}
#End if

This is part of the error code->
ERROR:
bd2b9390ef\\esp32/include/" "@C:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esp32-arduino-libs\\idf-release_v5.1-bd2b9390ef\\esp32/flags/includes" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esp32-arduino-libs\\idf-release_v5.1-bd2b9390ef\\esp32/dio_qspi/include" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.0.2\\cores\\esp32" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.0.2\\variants\\d1_mini32" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.0.2\\libraries\\WiFi\\src" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.0.2\\libraries\\Network\\src" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.0.2\\libraries\\NetworkClientSecure\\src" "@C:\\Users\\davel\\AppData\\Local\\Temp\\arduino\\sketches\\B0FAA760E0F6BCFF267CAD2FF741BB8D/build_opt.h" "@C:\\Users\\davel\\AppData\\Local\\Temp\\arduino\\sketches\\B0FAA760E0F6BCFF267CAD2FF741BB8D/file_opts" "C:\\Users\\davel\\AppData\\Local\\Temp\\arduino\\sketches\\B0FAA760E0F6BCFF267CAD2FF741BB8D\\sketch\\Scheduler.cpp" -o "C:\\Users\\davel\\AppData\\Local\\Temp\\arduino\\sketches\\B0FAA760E0F6BCFF267CAD2FF741BB8D\\sketch\\Scheduler.cpp.o"

C:\Users\davel\Desktop\ifC test\Objects\src\b4r_main.cpp:10:11: error: expected constructor, destructor, or type conversion before '(' token

   10 |   ADC_MODE(ADC_VCC);

      |           ^

C:\Users\davel\Desktop\ifC test\Objects\src\b4r_main.cpp: In function 'void GetVCC(B4R::Object*)':

C:\Users\davel\Desktop\ifC test\Objects\src\b4r_main.cpp:12:25: error: 'class EspClass' has no member named 'getVcc'

   12 |    b4r_main::_vcc = ESP.getVcc();

      |                         ^~~~~~

"C:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esp-x32\\2302/bin/xtensa-esp32-elf-g++" -MMD -c "@C:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esp32-arduino-libs\\idf-release_v5.1-bd2b9390ef\\esp32/flags/cpp_flags" -w -Os -DF_CPU=240000000L -DARDUINO=10607 -DARDUINO_D1_MINI32 -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD=\"D1_MINI32\"" "-DARDUINO_VARIANT=\"d1_mini32\"" -DARDUINO_PARTITION_default "-DARDUINO_HOST_OS=\"windows\"" "-DARDUINO_FQBN=\"esp32:esp32:d1_mini32:UploadSpeed=921600,CPUFreq=240,FlashFreq=80,PartitionScheme=default,DebugLevel=none,EraseFlash=none\"" -DESP32 -DCORE_DEBUG_LEVEL=0 -DARDUINO_USB_CDC_ON_BOOT=0 "@C:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esp32-arduino-libs\\idf-release_v5.1-bd2b9390ef\\esp32/flags/defines" "-IC:\\Users\\davel\\Desktop\\ifC test\\Objects\\src" -iprefix "C:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esp32-arduino-libs\\idf-release_v5.1-bd2b9390ef\\esp32/include/" "@C:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esp32-arduino-libs\\idf-release_v5.1-bd2b9390ef\\esp32/flags/includes" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esp32-arduino-libs\\idf-release_v5.1-bd2b9390ef\\esp32/dio_qspi/include" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.0.2\\cores\\esp32" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.0.2\\variants\\d1_mini32" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.0.2\\libraries\\WiFi\\src" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.0.2\\libraries\\Network\\src" "-IC:\\Users\\davel\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\3.0.2\\libraries\\NetworkClientSecure\\src" "@C:\\Users\\davel\\AppData\\Local\\Temp\\arduino\\sketches\\B0FAA760E0F6BCFF267CAD2FF741BB8D/build_opt.h" "@C:\\Users\\davel\\AppData\\Local\\Temp\\arduino\\sketches\\B0FAA760E0F6BCFF267CAD2FF741BB8D/file_opts" "C:\\Users\\davel\\AppData\\Local\\Temp\\arduino\\sketches\\B0FAA760E0F6BCFF267CAD2FF741BB8D\\sketch\\rESP8266WiFi.cpp" -o "C:\\Users\\davel\\AppData\\Local\\Temp\\arduino\\sketches\\B0FAA760E0F6BCFF267CAD2FF741BB8D\\sketch\\rESP8266WiFi.cpp.o"

Using library WiFi at version 2.0.0 in folder: C:\Users\davel\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\libraries\WiFi

Using library Networking at version 1.0.0 in folder: C:\Users\davel\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\libraries\Network

Using library NetworkClientSecure at version 2.0.0 in folder: C:\Users\davel\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\libraries\NetworkClientSecure

Error during build: exit status 1

[92mUsed library[0m        [92mVersion[0m [90mPath[0m

[93mWiFi[0m                2.0.0   [90mC:\Users\davel\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\libraries\WiFi[0m

[93mNetworking[0m          1.0.0   [90mC:\Users\davel\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\libraries\Network[0m

[93mNetworkClientSecure[0m 2.0.0   [90mC:\Users\davel\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\libraries\NetworkClientSecure[0m

[92mUsed platform[0m [92mVersion[0m [90mPath[0m

[93mesp32:esp32[0m   3.0.2   [90mC:\Users\davel\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2[0m

I have searched but didn't find anything that helped so any help will be welcome.
Thanks.
 

JohnC

Expert
Licensed User
Longtime User
When you say "it comes from EREL", please provide link to that original code.

Also try changing line #15 to this:
B4X:
VCC = RunNative("GetVCC", Null)
 
Upvote 0

davelew1s

Active Member
Licensed User
Longtime User
When you say "it comes from EREL", please provide link to that original code.

Also try changing line #15 to this:
B4X:
VCC = RunNative("GetVCC", Null)
Thanks for the reply ... this is the original i just copy/paste the code. I tried changing line 15 same error
 
Upvote 0
Top