Skip to content
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

Merged
merged 3 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/espurna/config/arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//#define ALLNET_4DUINO_IOT_WLAN_RELAIS
//#define ALLTERCO_SHELLY1
//#define ALLTERCO_SHELLY2
//#define ALLTERCO_SHELLY1PM
//#define ARILUX_AL_LC01
//#define ARILUX_AL_LC02
//#define ARILUX_AL_LC02_V14
Expand Down
45 changes: 45 additions & 0 deletions code/espurna/config/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -3103,6 +3103,51 @@
#define RELAY2_PIN 5
#define RELAY2_TYPE RELAY_TYPE_NORMAL

#elif defined(ALLTERCO_SHELLY1PM)
// Info
#define MANUFACTURER "ALLTERCO"
#define DEVICE "SHELLY1PM"

// Buttons
#define BUTTON1_PIN 4
#define BUTTON1_MODE BUTTON_SWITCH
#define BUTTON1_RELAY 1

#define BUTTON2_PIN 2
#define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON2_LNGCLICK BUTTON_MODE_RESET
#define BUTTON2_LNGLNGCLICK BUTTON_MODE_FACTORY

// Relays
#define RELAY1_PIN 15
#define RELAY1_TYPE RELAY_TYPE_NORMAL

// Light
#define LED1_PIN 0
#define LED1_PIN_INVERSE 1

// HJL01 / BL0937
#ifndef HLW8012_SUPPORT
#define HLW8012_SUPPORT 1
#endif
#define HLW8012_SEL_PIN 12
#define HLW8012_CF1_PIN 13
Copy link
Collaborator

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?

Copy link
Contributor Author

@tonilopezmr tonilopezmr Jul 18, 2019

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

#define HLW8012_SEL_PIN 5

Copy link
Collaborator

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

Copy link
Contributor Author

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

#define HLW8012_CF_PIN 5

#define HLW8012_SEL_CURRENT LOW
#define HLW8012_CURRENT_RATIO 25740
#define HLW8012_VOLTAGE_RATIO 313400
#define HLW8012_POWER_RATIO 3414290
#define HLW8012_INTERRUPT_ON FALLING

//Temperature
#define NTC_SUPPORT 1
#define SENSOR_SUPPORT 1
#define NTC_BETA 3350
#define NTC_R_UP 10000
#define NTC_R_DOWN 0
#define NTC_R0 10000

// -----------------------------------------------------------------------------

#elif defined(LOHAS_9W)
Expand Down
10 changes: 10 additions & 0 deletions code/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,16 @@ build_flags = ${common.build_flags_2m1m} -DALLTERCO_SHELLY2
upload_port = ${common.ota_upload_port}
upload_flags = ${common.ota_upload_flags}

[env:allterco-shelly1pm]
board = ${common.board_2m}
build_flags = ${common.build_flags_2m1m} -DALLTERCO_SHELLY1PM

[env:allterco-shelly1pm-ota]
board = ${common.board_2m}
build_flags = ${common.build_flags_2m1m} -DALLTERCO_SHELLY1PM
upload_port = ${common.ota_upload_port}
upload_flags = ${common.ota_upload_flags}

[env:xiaomi-smart-desk-lamp]
board = ${common.board_1m}
build_flags = ${common.build_flags_1m0m} -DXIAOMI_SMART_DESK_LAMP
Expand Down