Hi everyone,
I’m just getting started with Platformio and tried to build what I thought would be a simple example using the OneWire library. I’m getting this error at the moment.
Can anyone please point me in the right direction to fix it? My platformio.ini looks like this:
Many thanks in advance,
Andy
Yeah, the latest released library version isn’t compatible with the 2.0.3 Arduino core, as can be read publically in
opened 01:30AM - 11 Apr 22 UTC
closed 10:42AM - 04 Jun 22 UTC
**Board**
Esp32S2 Dev Module and Esp32S3 Dev Module
**Device Description**
… NodeMcu-32S or Esp32-S3-DevKitC-1 v1.6
Testing with Dallas OneWire Temperature sensor
**Hardware Configuration**
GPIO 2 connected to Dallas Temperature sensor
**Version**
latest master
**IDE Name**
Arduino IDE 1.8.20
**Operating System**
Windows 10
**Flash frequency**
80 Mhz
**PSRAM enabled**
no
**Upload speed**
921600
**Description:**
I am getting an error while compiling sample/example code for Dallas Temperature sensor.
Steps to generate the error:
1- Load the code: File -> Examples -> Dallas Temperature -> Simple
2- verify / Compile
Compiler generates the following error:
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;
It appears that "esp32_gpioMux" is no longer defined!!!
**Sketch:**
// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/*
* The setup function. We only start the sensors here
*/
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
/*
* Main function, get and show the temperature
*/
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print("Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
// After we got the temperatures, we can print them here.
// We use the function ByIndex, and as an example get the temperature from the first sensor only.
float tempC = sensors.getTempCByIndex(0);
// Check if reading was successful
if(tempC != DEVICE_DISCONNECTED_C)
{
Serial.print("Temperature for the device 1 (index 0) is: ");
Serial.println(tempC);
}
else
{
Serial.println("Error: Could not read temperature data");
}
}
### Errors or Incorrect Output
Debug Message
In file included from C:\Users\eghav\AppData\Local\arduino15\packages\esp32\hardware\esp32\2.0.3-RC1\cores\esp32/Arduino.h:36,
from C:\Users\eghav\Documents\Arduino\libraries\OneWire\OneWire.cpp:142:
C:\Users\eghav\Documents\Arduino\libraries\OneWire\util/OneWire_direct_gpio.h: In function 'void directModeInput(uint32_t)':
C:\Users\eghav\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\eghav\AppData\Local\arduino15\packages\esp32\hardware\esp32\2.0.3-RC1\cores\esp32/esp32-hal.h:73:47: note: in definition of macro 'ESP_REG'
#define ESP_REG(addr) *((volatile uint32_t *)(addr))
^~~~
C:\Users\eghav\Documents\Arduino\libraries\OneWire\util/OneWire_direct_gpio.h: In function 'void directModeOutput(uint32_t)':
C:\Users\eghav\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\eghav\AppData\Local\arduino15\packages\esp32\hardware\esp32\2.0.3-RC1\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 ESP32S3 Dev Module.
By looking at Commits · PaulStoffregen/OneWire · GitHub you can see that the Tasmota people have landed a fix PR for Arduino core 2.x just 2 days ago, so you will need to specify
lib_deps =
milesburton/DallasTemperature@^3.9.1
https://github.com/PaulStoffregen/OneWire.git
to get the latest library version from the Git that has the fix.
Super, thanks Max! I googled several times and got nothing, but I guess the issue is quite new. Thanks for supplying a fix:-).