The goal was to design some fancy switch to my Home Assistant installation. Because there was always not enough buttons, I decided to build a device that will solve this problem. I chose Microchip (Atmel) touch buttons and SAML series microcontroller for the project. For communication with HASS I decided to use Bluetooth Low Energy, mainly for educational reasons. In this case I used one of my favourites SoC nRF52833 :)
- Six touch buttons with one tap function (two taps in the near future)
- Communication based on Bluetooth Low Energy by Nordic nRF52833 or nRF52840 chips
- Round IPS 1, 28'' color display
- Twelve WS2812B RGB LED
- Buzzer and vibration
- Move detection
- BME280 sensor
- Low power consumption: about 500uA (LCD off, BLE connection, LEDs off)
- Power supply: standard Li-ion 3, 7V battery
- Charging: USB-C port or Wireless Qi standard charger
The device consists of three boards: main board, touch board and IPS board and it has "sandwich" construction. Casing is made of clear plexi.
IPS board is quite simple. It contains only connector to solder IPS displays soldering tape and a couple of elements to drive backlight. This pcb is pernamently mounted to touch board with four connectrors. Two of them have four pins in 1, 27mm raster and provide signals to IPS screen. The two other connectors have only one pin, for mechanical stability.
Touch board has got six round, 14mm diameter, touch buttons. In the middle of each one of them, there is the hole to install LED underneath. Pcb has two 4-pins and two 6-pin 2, 54mm raster connectors. Connectors on touch board are soldered only to bottom layer, not to make any marks on top side of the board. Connectors provide signals to touch buttons, round IPS display and LEDs.
Main board contains most of electronics. It's equiped with two main microcontrollers. One of them is ATSAML10E15A and the second is nRF52833 build in EBYTE E73-2G4M08S module. In the beginning I used nRF52840 module (the same producer) but because this chip is hardly available I decided to use much easier to buy nRF52833. Main board has got four 2, 54mm sockets which are intended to mount touch board.
Device is powered by standard Li-ion 900mAh battery. Battery could be charging from USB-C connector or wireless charger build on BQ51013. I used 900mAh battery capacity, but you can use any Li-ion battery, which you can fit under pcb, beetwen nylon distances. Charging is currently set to 500mA max, but you can adjust it (resistor R9) to battery you use, details in ST4054 manual. I used also similar MCP73831, but finally I mounted ST chip. Charging battery state and full battery state are signalized by LED on the bottom side of device. LED under device signalize state of device like: low battery state, BLE connection, charging, etc.
Another effects:
- bluetooth connected: short blue every 30sec
- bluetooth not connected: short green every 30sec
- low battery (<5%): short red every 30sec
- battery charged: green until USB plug is connected
Battery monitoring is realized on gauge counter MAX17048.
Main power is 3V. It's delivered from buck converter TPS62742. LEDs are powered from boost converter TPS61023, which provides 5V from battery voltage and it's switched on only when LEDs are in use. LEDs power is switched off, because WS2812B drivers inside LEDs are not very power save :) Vibration and buzzer are powered directly form battery.
Main microcontroller is nRF52833 (you can use also compatibile nRF52840 module - EBYTE E73-2G4M08S1C). It's responsible for almost all system logic. Firmware was build on SDK_17.1.0 and SoftDevice s140_nrf52_7.2.0.
SAM10LE15A is responsible for touch buttons. Firmware is prepared based on examples from in Microchip Studio. It quite simple, controls six buttons and makes autocalibration. Data is being send by TWI interface (master device).
IPS display function is also relatively simple right now. It shows battery and charging states, Bluetooth connection and allows to operate on simple settings menu. In the near future I'll try to add some notication from Home Assistant. Display is drivered by 32MHz SPI interface, but unfortunately it's to slow to show images in super short time (maybe I should work on my display driver).
LEDs are drivered by I2S driver, which was adapted to make signals compatible with WS2812B.
Device is also equipped in accelerometer which detect move and turn on the screen for couple second.
There is couple additional free footprint on board for future design. Eg: BME280, ATTEC508, LSM6DSM, flash memory N25Q032 (QSPI interface, works only with nRF52840), RTC clock RV-8803-C7, thermometer TMP117.
I tried to optimize the system, so that it would consume as little power as possible. It consumes about 500uA right now (measured on battery). Measurement made by Nordic Power Profiler II.
This device can be use in many ways, but to work with Home Assistant it has to use special gate. I know, if we want to connect with HASS it could be done another, simpler way, without gateway, using only e.g. ESP32. But this project had educational target and I really wanted to play with Bluetooth Low Energy ;)
5. Bluetooth Low Energy to MQTT gateConnection between Home Assistant and my device is possible thank to ESP32 gate and special hass add-on - Bluetooth LE to MQTT
The author of both is my friend Paweł Bliźniuk.
Details on:
https://github.com/blizniukp/esp32_ble2mqtt
6. Casing- plexi pipe: 90mm diameter, 3mm pipe wall thikness, 25mm long
- plexi cover: 90m diameter, 1, 5mm thikness - 2 pieces
- any small silicon legs - 6 pieces
- M2, 5x5 nylon screw - 8 pieces,
- 10mm long, M2, 5 distances - 4 pieces
The casing is transparent, so that everybody could see what is inside and how it's built. I used plexi, which is quite simple in mechanical tooling, even at home without special tools like CNC mill. How I made the casing:
1. Cut the pipe by hand saw to length 30mm. Unfortunatelly I didn't find the place where they cut by mechanical saw elements shorter than 50mm.
2. Polish up both sides of the pipe by mechanical srewdriver and sandpaper e.g. 120
3. Finish it up by smaller sandpaper e.g. 220
4. Drill 10mm hole to USB plug.
5. Glue top cover to pipe with plexi glue (there is a lot of plexi glue on market, I used ARTCOFIX - probably you can't buy it outside Poland)
6. Glue silicone feet to bottom cover.
7. Mount 10mm nylon distances to main board. Use M2, 5 nylon screws.
8. Drill four 0, 8mm holes on the edge of pipe and bottom cover of casing.
9. Attach the whole device to the bottom cover of casisng, by four M2, 5 nylon screws.
10. Use four miniature screws to screw on pipe and bottom cover.
I ordered bottom and top round parts of casing in one of the companies, which can cut materials with laser. They prepared bottom ring with screw holes.
https://github.com/piotrvvilk/BLErounpadMicrochipFirmware
7.2. Nordic firmwarehttps://github.com/piotrvvilk/BLEroundpadNRF52Firmware
8. What will be done in next steps:- double tap function
- messages from HASS
- BME280
- TMP117
Comments
Please log in or sign up to comment.