I am using OneWire to read DS18B20 temperature in your ESP8266 telegram project and it works fine. But when I #include OneWire.h in your long range LoRa project with the ESP32, I get the following errors without ever invoking the code, just by including the library:
C:\Users\biz-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\cores\esp32/esp32-hal.h:73:47: note: in definition of macro ‘ESP_REG’
#define ESP_REG(addr) *((volatile uint32_t *)(addr))
^~~~
In file included from C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire-2.3.5\OneWire.cpp:144:
C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire-2.3.5\util/OneWire_direct_gpio.h: In function ‘void directModeOutput(uint32_t)’:
C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire-2.3.5\util/OneWire_direct_gpio.h:189:26: error: ‘rtc_gpio_desc’ was not declared in this scope
uint32_t rtc_reg(rtc_gpio_desc[pin].reg);
^~~~~~~~~~~~~
C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire-2.3.5\util/OneWire_direct_gpio.h:189:26: note: suggested alternative: ‘rtc_io_desc’
uint32_t rtc_reg(rtc_gpio_desc[pin].reg);
^~~~~~~~~~~~~
rtc_io_desc
In file included from C:\Users\biz-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\cores\esp32/Arduino.h:36,
from C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire-2.3.5\OneWire.cpp:142:
C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire-2.3.5\util/OneWire_direct_gpio.h:206:38: error: ‘esp32_gpioMux’ was not declared in this scope
ESP_REG(DR_REG_IO_MUX_BASE + esp32_gpioMux[pin].reg) = pinFunction;
^~~~~~~~~~~~~
C:\Users\biz-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\cores\esp32/esp32-hal.h:73:47: note: in definition of macro ‘ESP_REG’
#define ESP_REG(addr) *((volatile uint32_t *)(addr))
Is there a unique OneWire library for the ESP32?
Hi.
The onewire library to use with the DS18B20 and the ESP32 is the OneWire library by Paul Stoffregen.
See picture below.
Tell me if this solves the issue.
Regards.
Sara
Nope. That’s the library that I had installed. You show version 2.3.4, mine was 2.3.5. However, there was a little box in the lower right corner this morning that said “update.” So I did, now I have version 2.3.6, but it didn’t fix the problem. So I wrote a tiny program to check just the #include <OneWire.h> statement. Here’s the code:
Start your code here
//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>
//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//Libraries for DS18B20 sensor
#include <OneWire.h>
int counter ;
// ========================================
void setup() {
//initialize Serial Monitor
Serial.begin(115200);
Serial.println(“OneWire test”) ; //file name
Serial.println() ;
}
// ========================================
void loop() {
Serial.print(“Sending packet: “);
Serial.println(counter);
counter++;
delay(10000);
}
If I select the Board as “NodeMCU 1.0 (ESP-12E Module)” this compiles correctly. But if the Board is “TTGO LoRa32-OLED” it fails. I previously had multiple OneWire libraries, so I got rid of the extras. Here’s the errors that are generated when the Board is ESP32:
Start your code here
Arduino: 1.8.16 (Windows 10), Board: “TTGO LoRa32-OLED, TTGO LoRa32 V1 (No TFCard), 80MHz, 921600, None”
In file included from C:\Users\biz-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\cores\esp32/Arduino.h:36,
from C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire\OneWire.cpp:142:
C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire\util/OneWire_direct_gpio.h: In function ‘void directModeInput(uint32_t)’:
C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire\util/OneWire_direct_gpio.h:191:38: error: ‘esp32_gpioMux’ was not declared in this scope
ESP_REG(DR_REG_IO_MUX_BASE + esp32_gpioMux[pin].reg) = pinFunction;
^~~~~~~~~~~~~
C:\Users\biz-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\cores\esp32/esp32-hal.h:73:47: note: in definition of macro ‘ESP_REG’
#define ESP_REG(addr) *((volatile uint32_t *)(addr))
^~~~
C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire\util/OneWire_direct_gpio.h: In function ‘void directModeOutput(uint32_t)’:
C:\Users\biz-1\OneDrive\Documents\Arduino\libraries\OneWire\util/OneWire_direct_gpio.h:232:38: error: ‘esp32_gpioMux’ was not declared in this scope
ESP_REG(DR_REG_IO_MUX_BASE + esp32_gpioMux[pin].reg) = pinFunction;
^~~~~~~~~~~~~
C:\Users\biz-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3\cores\esp32/esp32-hal.h:73:47: note: in definition of macro ‘ESP_REG’
#define ESP_REG(addr) *((volatile uint32_t *)(addr))
^~~~
exit status 1
Error compiling for board TTGO LoRa32-OLED.
Sara, this was a suggestion posted in the Arduino Forum. I’m only vaguely aware of what all this means. Does it help?
——– Suggestion from the Arduino Forum —————-
My only 2 suggestions would be to go to the github site of the onewire and report your issue there as you’ve done here. See if an older version of onewire will work.
ESPRESSIF has recently released a new version of the ESP32 core for the ESP-IDF. That core is not compatible, yet, with the ESP32 Arduino Core. From the errors OneWire is using the ESP32 API directly. OneWire may need to be updated.
Hi.
Which version of the ESP32 boards are you using?
Go to Tools > Boards > Boards Manager > ESP32 and check your version.
It seems your are using version 2.0.3. Please downgrade to, for example, 2.0.1 and check if that solves the issue. Or to a version before 2.0.
Regards,
Sara
Sara, I downgraded to 2.0.2 from 2.0.3 for the Arduino ESP32 core and that fixed the problem. Over on the github page there is also a suggestion that there is a version of OneWire (not OneWireNg) that works with 2.0.3, but I have not checked that out. Anyway, I’m reading my DS18B20s just fine, now.
Roger