Hedda
(Hedda)
May 21, 2024, 8:00am
2
Looks like tomaszduda23 ’s work on basic support for nRF52840 for ESPHome progressing very nicely and just yesterday he marked his pull request as ready for review and testing by devs/testers:
dev ← tomaszduda23:nrf52
opened 11:17PM - 10 Jan 24 UTC
# What does this implement/fix?
It is possible to buy cheap [nrf52840 module]… (https://github.com/joric/nrfmicro/wiki). It would be very convenience to program it using yaml files.
It is proof of concept for support NRF52 on esphome.
It requires:
- https://github.com/esphome/esphome/pull/7049
## How to upload
There are few options:
1. with stlink `python -m esphome upload tests/test12.2.yaml --device PYOCD`
2. if board have adafruit bootloader image has to build with
```yaml
nrf52:
board: adafruit_itsybitsy_nrf52840
```
to upload `python -m esphome upload tests/test12.3.yaml`
3. if board support UF2
```bash
cp ./tests/.esphome/build/nrf52-test-nrf-adafruit/.pioenvs/nrf52-test-nrf-adafruit/zephyr/zephyr.uf2 /media/0321-5432/
```
4. BLE OTA with mcuboot `python -m esphome upload tests/test12.2.yaml` to specify mac address of BLE device `python -m esphome upload tests/test12.2.yaml --device AA:BB:CC:11:22:33`
## TODO
**Arduino**
moved to https://github.com/esphome/esphome/pull/6228
**Zephyr**
- [x] GPIO
- [x] CDC DFU (0.8.2 is more stable) - adafruit
- [x] CDC logger
- [x] nrf-sdk based
- [x] UART0 logger
- [ ] UART0 logger tested
- [x] BLE OTA - mcuboot
- [ ] ~CDC OTA - mcuboot recover~ (`FLASH' overflowed by 11320 bytes)
- [x] CDC OTA - mcuboot
- [ ] serial OTA - mcuboot recovery
- [x] watchdog
- [x] BLE logger
- [x] preferences for restore mode
- [x] preferences for adafruit
- [ ] disable update of preferences during OTA - why is it done for other platforms?
- [x] fix arm builds
- [x] add pyocd to upload
- [x] move to main branch for smp
- [x] move to main branch for smpclient
- [x] move debug config to separate component
- [ ] validate prj.conf after compilation to make sure that config was applied correctly
- [ ] GPIO interrupts
- [ ] what to do if image cannot be confirmed during OTA?
- [x] implement get mac
- [x] change name for dfu?
- [x] adc
- [ ] pull up does not work for P0.17 and P0.20
- [ ] change voltage (it works only twice without erase)
- [ ] delete files if app.overlay change
- [x] i2c - moved to https://github.com/esphome/esphome/pull/8150
- [x] smpclient do not support serial https://github.com/intercreate/smpclient/issues/22
- [x] ~check why toolchain rebuilds all files even though single file changed https://github.com/tomaszduda23/esphome/pull/2~ prj.conf address is random generated which triggers rebuild
Fix review comments https://github.com/esphome/esphome/pull/6075#issuecomment-2094929824
- [x] fix build with python 3.9
- https://github.com/intercreate/smpclient/issues/16
- [x] move tests to new structure in tests/components/<component>
- [x] check #6459
- [x] move small changes unrelated components to own PRs
- https://github.com/esphome/esphome/pull/6679
- [x] wrapped code with #ifdef USE_ZEPHYR or #ifdef USE_NRF52
How to communicate with HA? Options:
- [ ] BLE serial
- 10KB/s - 2M PHY, interval of 7.5 ms, 247MTU
- [ ] BTHome
- https://github.com/esphome/feature-requests/issues/1862
- sensors only
- [ ] custom BLE service
- https://novelbits.io/bluetooth-5-speed-maximum-throughput/
- [ ] openthread https://openthread.io/codelabs/openthread-hardware#1
- https://github.com/esphome/esphome/pull/8410
- [x] zigbee https://github.com/esphome/esphome/pull/7340
The SoC has only 1MB of memory. All above consume:
```bash
RAM: [= ] 5.9% (used 14736 bytes from 248832 bytes)
Flash: [== ] 17.9% (used 146000 bytes from 815104 bytes)
```
## update adafruit bootloader
```bash
git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader
cd Adafruit_nRF52_Bootloader
make BOARD=nice_nano all
make BOARD=nice_nano SERIAL=/dev/ttyACM0 flash-dfu
```
## Types of changes
- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Other
**Related issue or feature (if applicable):** fixes <link to issue>
**Pull request in [esphome-docs](https://github.com/esphome/esphome-docs) with documentation (if applicable):** esphome/esphome-docs#<esphome-docs PR number goes here>
## Test Environment
- [ ] ESP32
- [ ] ESP32 IDF
- [ ] ESP8266
- [ ] RP2040
- [ ] BK72xx
- [ ] RTL87xx
- [x] nrf52840
## Example entry for `config.yaml`:
```yaml
---
nrf52:
# board: adafruit_itsybitsy_nrf52840
board: adafruit_feather_nrf52840
# framework:
# variant: nrf-sdk
# bootloader: adafruit
# bootloader: mcuboot
esphome:
name: nrf52-test-nrf
logger:
level: DEBUG
logs:
switch: NONE
switch:
- platform: gpio
pin:
number: 15
inverted: true
mode:
output: true
id: gpio_15
interval:
- interval: 500ms
then:
- switch.toggle: gpio_15
output:
- platform: gpio
pin:
number: 14
inverted: true
mode:
output: true
id: rest_gpio
ota:
- platform: zephyr_mcumgr
zephyr_ble_server:
```
## Checklist:
- [x] The code change is tested and works locally.
- [x] Tests have been added to verify that the new code works (under `tests/` folder).
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated in [esphome-docs](https://github.com/esphome/esphome-docs).
Btwy, also wanted to mention missed that @NateLust previous begun porting ESPHome to nRF52840:
TLDR
I ported ESPHome to run on top of ZephyrRTOS. Using this I was able to build against the Adafruit Feather 52840 Express, and create an OpenThread mesh network (not WiFi) which is used to communicate with my Home assistant instance.
Slightly Longer
I have long enjoyed how easy it was to make smart home devices using ESPHome, but was always interested in moving away from Wifi (range issues, congested IPs, power consumption, etc). Because of the fantastic job @OttoWinter did in creating abs…
Looks like @NateLust has not updated his forked esphome repository the last year and seems like the “zephyr-dev” branch there is latest:
There do not seem to be any new posts from @NateLust on this since he posted this zephyrESPHomeGuide in little over 1-year ago:
This is a page for installation scripts and various bits of info
PS: Noted that @NateLust did also make more progress on Thread/OpenThread for ESPHome than any other have I seen so far(?).