Skip to content

Commit

Permalink
Add ESP32 and ESP8266 support (#9)
Browse files Browse the repository at this point in the history
* feat: Add esp8266 board

* fix: Point to own fork to check compilation

* fix: Add another macro to test

* fix: Apply latest working version

* feat: Add ESP32 board firmware generation

* fix: Working pins for ESP32

* fix: Make use of local file system for building ESP boards

* fix: Final working version of ESP32

* fix: Fix pin numbering

* fix: Add pin function on select options

* fix: Make use oc consistent name in select for ESP boards

* fix: Add more general boards.

* fix: Use pin number instead of macros

* fix: Fix pin numering to be in order
  • Loading branch information
yeyeto2788 authored Dec 15, 2023
1 parent 341c52c commit 79c4258
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 5 deletions.
16 changes: 11 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
set -e
mkdir -p build/
cd yaml/
configs=("bk7231t" "bk7231n" "rtl8710bn")
configs=("bk7231t" "bk7231n" "rtl8710bn" "esp8266" "esp32")
for config in ${configs[@]}; do
esphome compile kickstart-${config}.yaml
cp .esphome/build/kickstart-${config}/.pioenvs/kickstart-${config}/firmware.uf2 ../build/kickstart-${config}-$1.uf2
cp .esphome/build/kickstart-${config}/.pioenvs/kickstart-${config}/*.ota.rbl ../build/ || true
cp .esphome/build/kickstart-${config}/.pioenvs/kickstart-${config}/*.ota.ug.bin ../build/ || true

esphome compile kickstart-${config}.yaml

if [ $config = "esp8266" ] || [ $config = "esp32" ]; then
cp .esphome/build/kickstart-${config}/.pioenvs/kickstart-${config}/firmware.bin ../build/kickstart-${config}-$1.bin
else
cp .esphome/build/kickstart-${config}/.pioenvs/kickstart-${config}/firmware.uf2 ../build/kickstart-${config}-$1.uf2
cp .esphome/build/kickstart-${config}/.pioenvs/kickstart-${config}/*.ota.rbl ../build/ || true
cp .esphome/build/kickstart-${config}/.pioenvs/kickstart-${config}/*.ota.ug.bin ../build/ || true
fi
done

cp .esphome/build/kickstart-bk7231t/.pioenvs/kickstart-bk7231t/*.ota.rbl ../build/OpenBK7231T_OTA_upgrade_to_esphome_$1.rbl || true
Expand Down
43 changes: 43 additions & 0 deletions components/pinscan/pinscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,49 @@ static const int PIN_MAP[] = {
PIN_PA30, // PA30 / UART2_TX / I2C0_SDA / PWM4

};
#elif defined(USE_ESP8266)
static const int PIN_MAP[] = {
0, // GPIO0
1, // GPIO1
2, // GPIO2 / SDA
3, // GPIO3
4, // GPIO4
5, // GPIO5 / SCL
12, // GPIO12 / MISO
13, // GPIO13 / MOSI
14, // GPIO14 / SCK
15, // GPIO15 / SS
16, // GPIO16
};
#elif defined(USE_ESP32)
static const int PIN_MAP[] = {
0, // GPIO0
1, // GPIO1
2, // GPIO2
3, // GPIO3
4, // GPIO4
5, // GPIO5
12, // GPIO12
13, // GPIO13
14, // GPIO14
15, // GPIO15
16, // GPIO16
17, // GPIO17
18, // GPIO18
19, // GPIO19 / MISO
21, // GPIO21 / SDA
22, // GPIO22 / SCL
23, // GPIO23 / MOSI
25, // GPIO25 / DAC1
26, // GPIO26 / DAC2
27, // GPIO27
32, // GPIO32
33, // GPIO33
34, // GPIO34
35, // GPIO35
36, // GPIO36
39, // GPIO39
};
#else
#error "Unsupported chip type"
#endif
Expand Down
17 changes: 17 additions & 0 deletions yaml/import-esp32.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
esphome:
name: kickstart-esp32

esp32:
board: esp32dev

logger:
web_server:
captive_portal:
mdns:
api:
ota:

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
17 changes: 17 additions & 0 deletions yaml/import-esp8266.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
esphome:
name: kickstart-esp8266

esp8266:
board: esp01_1m

logger:
web_server:
captive_portal:
mdns:
api:
ota:

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
105 changes: 105 additions & 0 deletions yaml/kickstart-base-esp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
substitutions:
name: REPLACEME
import_url: REPLACEME

esphome:
name: $name
project:
name: lt.kickstart
version: "1.0"

dashboard_import:
package_import_url: $import_url
import_full_config: true

external_components:
source: ../components
components:
- pinscan
- hub_api
refresh: 10 min

logger:
baud_rate: 115200
logs:
select: ERROR
sensor: ERROR
text_sensor: ERROR

ota:

wifi:
ap:
ssid: $name

captive_portal:

mdns:

api:
reboot_timeout: 0s

web_server:
local: true

pinscan:
id: scanner
pin_state_sensor:
name: -> Pin State


select:
- platform: template
id: mode
name: -> Pin Mode
options:
- INPUT
- INPUT_PULLUP
- OUTPUT_HIGH
- OUTPUT_LOW
optimistic: true
on_value:
- pinscan.set_mode:
id: scanner
mode: !lambda "return id(mode).active_index().value();"

- platform: template
id: pin
name: -> Pin
optimistic: true
on_value:
- pinscan.set_pin:
id: scanner
pin: !lambda "return id(pin).active_index().value() - 1;"
- pinscan.set_mode:
id: scanner
mode: !lambda "return id(mode).active_index().value();"

text_sensor:
- platform: wifi_info
ip_address:
id: ip_address
name: IP Address
- platform: debug
device:
name: Device Info
reset_reason:
name: Reset Reason

button:
- platform: factory_reset
name: Reset to Factory Settings
- platform: restart
name: Restart

debug:
update_interval: 5s

sensor:
- platform: debug
free:
name: Heap Free
loop_time:
name: Loop Time
- platform: uptime
name: Uptime
41 changes: 41 additions & 0 deletions yaml/kickstart-esp32.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
substitutions:
name: kickstart-esp32
import_url: github://libretiny-eu/esphome-kickstart/yaml/import-esp32.yaml@master

packages:
base: !include kickstart-base-esp.yaml

esp32:
board: esp32dev

select:
- platform: template
id: !extend pin
options:
- Select PIN
- GPIO0
- GPIO1
- GPIO2
- GPIO3
- GPIO4
- GPIO5 / SS
- GPIO12
- GPIO13
- GPIO14
- GPIO15
- GPIO16
- GPIO17
- GPIO18 / SCK
- GPIO19 / MISO
- GPIO21 / SDA
- GPIO22 / SCL
- GPIO23 / MOSI
- GPIO25 / DAC1
- GPIO26 / DAC2
- GPIO27
- GPIO32
- GPIO33
- GPIO34
- GPIO35
- GPIO36
- GPIO39
26 changes: 26 additions & 0 deletions yaml/kickstart-esp8266.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
substitutions:
name: kickstart-esp8266
import_url: github://libretiny-eu/esphome-kickstart/yaml/import-esp8266.yaml@master

packages:
base: !include kickstart-base-esp.yaml

esp8266:
board: esp01_1m

select:
- platform: template
id: !extend pin
options:
- Select PIN
- GPIO0
- GPIO1
- GPIO2 / SDA
- GPIO3
- GPIO4
- GPIO5 / SCL
- GPIO12 / MISO
- GPIO13 / MOSI
- GPIO14 / SCK
- GPIO15 / SS
- GPIO16

0 comments on commit 79c4258

Please sign in to comment.