This chip "ST25DV04K" from STMicro can be used for showing an internal status of a home appliance to the user's smart phone.
[Note] I lately migrated from TrueSTUIO+CubeMX to CubeIDE. The quality of CubeIDE 1.0.0 is NOT good. Some precautions I learned by doing for 24 hours wasting a lot of time:
- Always start a new STM32 project from CubeIDE, do not generate code from CubeMX.
- Do not regenerate code on CubeIDE -- if you need some config modifications, create a new project on CubeIDE again, although it is a waste of time.
- Otherwise, you will face a lot of errors at a build time or a debug time, including communication errors with the targe board over ST-Link.
[1] A smart phone initiates a service.
Sleeping
[STM32] [ST25DV]<---RF----[Smart phone] User
^ GPO
| |
+----------------+
Interrupt
[1b(optional)] The device notifies a BLE central of the RF field change event
+--------NOTIFY---------------------------->[BLE central]
|
[RN4020]
[STM32] [ST25DV]<---RF----[Smart phone] User
[2] The device prepares a service for the user in a very short time.
[Local service function]
|
v
[STM32] [ST25DV]<---RF----[Smart phone] User
Service preparation
[3] The device provides a service URL to the smartphone.
[STM32]---I2C--->[ST25]----RF--->[Smart phone]----GET---->[Web application server]
(URL)
[4] The smartphone fetchs the page from a web server.
[STM32] [ST25] [Smart phone]<---200 OK--[Web application server]
Note: the last data written on the tag (e.g., on EEPROM) will remain even if the battery dies.
- Initial setup: URL of its startup manual page
- Serial number (fixed number): URL of a user registration page
- Some additional reference info (content ID) to a base URL: content ID shown on a digital signage currently
- Error code: URL of its trouble shooting page
- etc
In this project, I only support a serial number that is incremented every time the user hold his or her smart phone over the NFC tag. In case of the signage use case, content ID is appended to its base URL as "&ref=".
IDE: CubeIDE from STMicro.
==> Code
- The code supports power management for the MCU.
- The code puts the MCU into sleep after start up, so CubeIDE cannot communicate with the MCU. In this case, hold a smart phone over the antenna to keep the MCU awaken.
- To disable the power management (to use GPO on PA9 as an interrupt to signal RF change to MCU), just comment out the following line:
main.c
#define SLEEP_ENABLED
UART commands
Command | Description |
---|---|
.l | Lock RF write (default) |
.u | Unlock RF write |
.r | Reset (and clear EEPROM) |
<base url w/o protocol>?loc= | Write base URL to Area 2 on EEPROM |
Note: The current implementation of local service function just copies the base URL with a serial number, as an internal status of a home appliance, appended to Area 1 on EEPROM.
==> Code
==> Code
I refered to the schematic of X-NUCLEO-NFC04A1(ST25DV04K) to design Arduino shield for ANT7-T-ST25DV04K with some modifications as follows:
- I omitted some small stuff such as bypass capacitors, because the board size is small.
- I chose 10k ohm pull-up registors for I2C. I think 10k ohm is relatively large, but it should work at 400kHz of SCL clock cycle in my experience.
- I chose a 51k ohm pull-up registor for open-drain GPO.
==> Circuit
==> Universal board
BSP folder is removed whenever code is generated by CubeMX after the initial generation. Copy BSP into the folder manually to cope with the problem.
"ADUX1020" from Analog Devices is very interesting as a very small contactless gester sensing device in combination with dynamic NFC tag (not limited to STMicro's products but also from other makers such as NXP or SONY).