Hi!
does anyone here happen to know anything about a header file called "gpios_id.h"?
Should it be part of the Arduino IDE? Or maybe the ESP8266 core for Arduino package? Or some other library?
I'm trying to use the following library. It #includes "gpios_id.h" and that results in a compile error (file not found).
I have asked in an "issue" under that repository but I'm not getting a reply.
I also tried to find it through Google but no luck. All that came up was more people asking for that file (for the same and some other libraries that seem to use it) but none of them seem to have received an answer.
I'm using Arduino IDE 1.8.13, Visual Studio 2017 Community with Visual Micro 2021.106.10 and ESP8266 Core 2.4.2.
Does anyone know where I can get that file? Or maybe someone could provide it here, if its licence allows that?
Did you mean "gpios_id.h"? I couldn't find that either.
My suggestion would be to comment out the include. If you are lucky, everything that was in that file was moved to one of the other files and you will get no errors. If not, start searching for the declarations of any identifiers that are not defined. Perhaps you will find that the file has been renamed.
Thanks! Yes, of course... I meant "gpios_id.h" - must have been a copy-paste error. Too bad I can't edit my post.
The first thing I tried was commenting out the #include. That made it worse. It then behaved as if the library I wanted to use was not included (it couldn't find the functions defined in that library). Unfortunately I didn't find a way to show me which parts of the library were using definitions from "gpios_id.h". I'll try again...
Thanks! I edited the post. Not sure why I didn't see the edit button before.
However, commenting out that #include doesn't help (as I mentioned above). It does then not recognise any of teh functions in the HLW8012 library. I get this when trying to compile:
Error linking for board Generic ESP8266 Module
Build failed for project 'ESP_single_socket_test'
ESP_single_socket_test.cpp.o: (.text.setup+0x14): undefined reference to HLW8012_init(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)
ESP_single_socket_test.cpp.o: In function setup
ESP_single_socket_test.ino:41: undefined reference to HLW8012_init(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)
ESP_single_socket_test.ino:46: undefined reference to HLW8012_getCurrent()
ESP_single_socket_test.cpp.o: (.text.loop+0x2c): undefined reference to HLW8012_getVoltage()
ESP_single_socket_test.cpp.o: (.text.loop+0x30): undefined reference to HLW8012_getActivePower()
ESP_single_socket_test.cpp.o: (.text.loop+0x34): undefined reference to HLW8012_getApparentPower()
ESP_single_socket_test.cpp.o: (.text.loop+0x38): undefined reference to HLW8012_getPowerFactor()
ESP_single_socket_test.cpp.o: (.text.loop+0x40): undefined reference to HLW8012_getEnergy()
ESP_single_socket_test.cpp.o: (.text.loop+0xbc): undefined reference to HLW8012_getCurrent()
ESP_single_socket_test.cpp.o: In function loop
ESP_single_socket_test.ino:49: undefined reference to HLW8012_getVoltage()
ESP_single_socket_test.ino:53: undefined reference to HLW8012_getActivePower()
ESP_single_socket_test.ino:56: undefined reference to HLW8012_getApparentPower()
ESP_single_socket_test.ino:60: undefined reference to HLW8012_getPowerFactor()
ESP_single_socket_test.ino:64: undefined reference to HLW8012_getEnergy()
collect2.exe*: error: ld returned 1 exit status
I think that the problem is C and C++ using different linking conventions. The library contains a C file (HLW8012_ESP82.c) but the HLW8012_ESP82.h file is being included in C++ file. The linker is looking for the functions under their C++ names but the library is using their C names.
One quick fix is to rename HLW8012_ESP82.c to HLW8012_ESP82.cpp.
The proper fix is to instead change the line in your sketch that says:#include "HLW8012_ESP82.h"
Ah, ok, I wasn't aware of this C vs C++ difference. Good to know, thanks.
With this change to "extern "C"..." it seems to get a little further but still causes errors when compiling.
HLW8012_ESP82.c.o: In function _calculateDefaultMultipliers
Error linking for board Generic ESP8266 Module
HLW8012_ESP82.c:96: undefined reference to get_pin_mux
Build failed for project 'ESP_single_socket_test'
HLW8012_ESP82.c:96: undefined reference to get_pin_func
HLW8012_ESP82.c.o: In function HLW8012_checkCFSignal
HLW8012_ESP82.c:67: undefined reference to get_pin_mux
HLW8012_ESP82.c:68: undefined reference to get_pin_mux
HLW8012_ESP82.c:69: undefined reference to get_pin_func
HLW8012_ESP82.c.o: In function HLW8012_getCurrentMultiplier
HLW8012_ESP82.c:102: undefined reference to get_pin_func
HLW8012_ESP82.c.o: In function HLW8012_setVoltageMultiplier
HLW8012_ESP82.c:107: undefined reference to get_pin_mux
HLW8012_ESP82.c.o: In function HLW8012_setPowerMultiplier
HLW8012_ESP82.c:108: undefined reference to get_pin_mux
HLW8012_ESP82.c:108: undefined reference to get_pin_func
HLW8012_ESP82.c:108: undefined reference to get_pin_func
HLW8012_ESP82.c:108: undefined reference to get_pin_mux
HLW8012_ESP82.c:108: undefined reference to get_pin_mux
HLW8012_ESP82.c:108: undefined reference to get_pin_func
HLW8012_ESP82.c:108: undefined reference to get_pin_func
HLW8012_ESP82.c.o: In function HLW8012_init
HLW8012_ESP82.c:110: undefined reference to get_pin_mux
HLW8012_ESP82.c:113: undefined reference to get_pin_mux
HLW8012_ESP82.c:130: undefined reference to get_pin_mux
HLW8012_ESP82.c:132: undefined reference to get_pin_mux
collect2.exe*: error: ld returned 1 exit status
I'm guessing these "undefined references" would be defined in the missing "gpios_id.h". At least now I know what it is trying to use from "gpios_id.h". It appears to be some low-level IO pin stuff; presumably faster than the standard Arduino pin functions.
I don't know how much it will help but I found this file called "hw/esp8266.h" which may be a replacement for "gpios_id.h". In it the macros "get_pin_func" and "get_pin_mux" were changed to "GET_PIN_FUNC" and "GPIOx_MUX".
This was for a little project where I took one of these WiFi controllable plug thingies that go in between a power socket and the plug of the device and replaced the MCU "daughterboard" with an ESP8266 module so that I can run my own software on it.
It has a relay, a button and a couple of LEDs that I can already control.
It also has a BL0937 power meter chip that I would have wanted to read out. I tried to find a library for that chip but nothing seems to work. I think for now I'll give up on that and just use it to switch things on and off.
Unless someone knows of a BL0937 library that runs on an ESP8266 (without RTOS or anything like that) that actually works.
The interface to the chip looks fairly trivial. There are two output pins on which are sent pulses. The time between pulses (frequency of pulses) determines the value of one of the three parameters. One pin is for 'power' (Watts) and the other pin can be switched between 'current' (Amps) and 'voltage' (Volts). If you can hook the two pins to interrupts, the measurement of time between pulses is easy. Does the ESP8266 core support attachInterrupt()?