-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Shelly 1PM #1822
Add Shelly 1PM #1822
Conversation
When I request twice the espurna page, I get this error:
|
It is a serialization error comming from Line 389 in 746ad70
This is not related to my changes then I'm going to create an issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird behavior: When I set LED1_PIN 0 espurna doesn't set pinMode to OUTPUT then if I try to run the following command GPIO 0 0 it's not working, then If I set manually pinMode(0, OUTPUT) and turn on/off using the wall switch once, then the led it's always ON, even if the LED_MODE_OFF is activated.
You sure that this is not related to some old version? aac2e1e fixed a bug where settings received wrong values every reboot.
Current always is zero but power it's fine, why?
Looking at hlw library source, voltage and current are read via cf1, so that's expected
#define HLW8012_SUPPORT 1 | ||
#endif | ||
#define HLW8012_SEL_PIN 12 | ||
#define HLW8012_CF1_PIN 13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment here too that they are unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, they are unused but I didn't know if I comment that then It will take another default pin that we don't want. If espurna will take default values for those SEL
and CF1
, we need to change it to the default unused pins we want, am I correct?
Here is an example: SEL
is by default one of the currently used pins which is 5
espurna/code/espurna/config/sensors.h
Line 440 in 868d4d5
#define HLW8012_SEL_PIN 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, defaults are copying the first Sonoff POW, so something must be there. I was thinking of adding a comment, not removing the pin definitions. But, I think you can use GPIO_NONE
(0x99) instead of the real ones. Arduino layer for digitalWrite, pinMode, attachInterrupt etc. has these two kinds of checks:
func(pin) {
if(pin < 16){
...
} else if(pin == 16){
...
}
}
Or just pin < 16
, so they will do nothing
ref:
https://github.com/esp8266/Arduino/blob/2.3.0/cores/esp8266/core_esp8266_wiring_digital.c
https://github.com/esp8266/Arduino/blob/master/cores/esp8266/core_esp8266_wiring_digital.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I didn't know that, I will change it for GPIO_NONE
Based on gitter discussion, we may want to hide unused magnitudes. HLW8012Sensor does not yet support this, but here is one example of dynamic magnitude list in the BMX280Sensor: espurna/code/espurna/sensors/BMX280Sensor.h Lines 226 to 232 in 0b73882
So this can be HLW8012_CURRENT, HLW8012_VOLTAGE... etc. In case we want to modify this at runtime, appropriate settings can be added (for example, hlwVoltage 1 or 0)
This implementation requires index counting in type() and index() too, besides initial _count setting. Maybe magnitude list can be kept as an array / vector? MAGNITUDE_... are basic ints and you can even pass std::initializer_list as a func argument to set internal array just using a constructor / update method (if it is from std::... though) |
💣 Issue
🎩 What is the goal?
Integrate Shelly 1PM with espurna to control the relay, control built-in led, read wall switch changes, get current and temperature.
📝 How is it being implemented?
GPIO15
GPIO4
BL0937
, Shelly1PM doesn't use CF1 and SEL then I set a free GPIO's for that two values, here is theBL0937
configuration:GPIO12
//UNUSEDGPIO13
//UNUSEDGPIO5
GPIO0
with a reverse signal.NTCSensor
GPIO2
LED_MODE_ON
(Someone can test it too?)LED1_PIN 0
espurna doesn't setpinMode
toOUTPUT
then if I try to run the following commandGPIO 0 0
it's not working, then If I set manuallypinMode(0, OUTPUT)
and turn on/off using the wall switch once, then the led it's always ON, even if theLED_MODE_OFF
is activated.