Skip to content

Commit 86ec82f

Browse files
author
Scott Powell
committed
* Heltec CT62: sensor role (with 2 channel relay support + 1 digital input)
1 parent 1897f51 commit 86ec82f

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

variants/heltec_ct62/HT-CT62Board.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,35 @@
88
#include <helpers/ESP32Board.h>
99

1010
class Heltec_CT62_Board : public ESP32Board {
11+
uint32_t gpio_state = 0;
12+
1113
public:
14+
void begin() {
15+
ESP32Board::begin();
16+
#if defined(PIN_BOARD_RELAY_CH1) && defined(PIN_BOARD_RELAY_CH2)
17+
pinMode(PIN_BOARD_RELAY_CH1, OUTPUT);
18+
pinMode(PIN_BOARD_RELAY_CH2, OUTPUT);
19+
#endif
20+
#if defined(PIN_BOARD_DIGITAL_IN)
21+
pinMode(PIN_BOARD_DIGITAL_IN, INPUT);
22+
#endif
23+
}
24+
uint32_t getGpio() override {
25+
#if defined(PIN_BOARD_DIGITAL_IN)
26+
return gpio_state | (digitalRead(PIN_BOARD_DIGITAL_IN) ? 1 : 0);
27+
#else
28+
return 0;
29+
#endif
30+
}
31+
void setGpio(uint32_t values) override {
32+
#if defined(PIN_BOARD_RELAY_CH1) && defined(PIN_BOARD_RELAY_CH2)
33+
gpio_state = values;
34+
digitalWrite(PIN_BOARD_RELAY_CH1, values & 2);
35+
digitalWrite(PIN_BOARD_RELAY_CH2, values & 4);
36+
#endif
37+
}
1238

13-
uint16_t getBattMilliVolts() override {
39+
uint16_t getBattMilliVolts() override {
1440
#ifdef PIN_VBAT_READ
1541
analogReadResolution(12); // ESP32-C3 ADC is 12-bit - 3.3/4096 (ref voltage/max counts)
1642
uint32_t raw = 0;

variants/heltec_ct62/platformio.ini

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,24 @@ lib_deps =
8686
${Heltec_ct62.lib_deps}
8787
${esp32_ota.lib_deps}
8888
densaugeo/base64 @ ~1.4.0
89+
90+
[env:Heltec_ct62_sensor]
91+
extends = Heltec_ct62
92+
build_flags =
93+
${Heltec_ct62.build_flags}
94+
-D ADVERT_NAME='"HT-CT62 Sensor"'
95+
-D ADVERT_LAT=0.0
96+
-D ADVERT_LON=0.0
97+
-D ADMIN_PASSWORD='"password"'
98+
-D PIN_BOARD_SDA=-1
99+
-D PIN_BOARD_SCL=-1
100+
-D PIN_BOARD_RELAY_CH1=0
101+
-D PIN_BOARD_RELAY_CH2=1
102+
-D PIN_BOARD_DIGITAL_IN=19
103+
; -D MESH_PACKET_LOGGING=1
104+
; -D MESH_DEBUG=1
105+
build_src_filter = ${Heltec_ct62.build_src_filter}
106+
+<../examples/simple_sensor>
107+
lib_deps =
108+
${Heltec_ct62.lib_deps}
109+
${esp32_ota.lib_deps}

0 commit comments

Comments
 (0)