Skip to content

Sonoff dual r2 + DALLAS in GPIO9 Failed getting lock #1958

Closed
@reydecopas

Description

Hi,
I am trying to add a dallas sensor to a sonoff dual r2, after compiling with -DDALLAS_PIN=9 -DDALLAS_SUPPORT=1 -DSENSOR_SUPPORT=1
and modifying hardware.h to
//#define BUTTON2_PIN 9 // Button 1 on header
#define BUTTON2_PIN GPIO_NONE // Button 1 on header

I am getting in the console:
[294200] [SENSOR] Initializing Dallas @ GPIO9
[294201] [GPIO] Failed getting lock for GPIO9
[294201] [SENSOR] -> ERROR 7

What am I doing wrong?

With tasmota I can read temperature in GPIO9

Activity

mcspr

mcspr commented on Oct 24, 2019

@mcspr
Collaborator

Firmware tracks Dallas GPIO usage via some helper methods here:

bool gpioGetLock(unsigned char gpio) {
if (gpioValid(gpio)) {
unsigned int mask = 1 << gpio;
if ((_gpio_locked & mask) == 0) {
_gpio_locked |= mask;
DEBUG_MSG_P(PSTR("[GPIO] GPIO%u locked\n"), gpio);
return true;
}
}
DEBUG_MSG_P(PSTR("[GPIO] Failed getting lock for GPIO%u\n"), gpio);
return false;
}

But it does not even get to the locking part, because GPIO number is less than 12:
if (gpio <= 5) return true;
if (12 <= gpio && gpio <= 15) return true;

Adjusting 12 to 9 will fix the specific issue, because 8285 does not have GPIO9 connected to the SPI

reydecopas

reydecopas commented on Oct 24, 2019

@reydecopas
Author

perfect!!! thank you!! it works!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Sonoff dual r2 + DALLAS in GPIO9 Failed getting lock · Issue #1958 · xoseperez/espurna