This is an example of how to use the Notecard and the note-c library with the native STM32 SDK.
The board that I used for testing is the Nucleo-L432KC kit with STM32L432 MCU. This board was selected because of its minimalism and the fact that it has an integrated debug probe.
As a proof-of-concept, it implements the same functions as the note-arduino library's JSON example.
One other notable feature of this example is that it implements a working example of the STM32's extremely low-power STOP2 mode. When running the example, the STM32 draws so little power that it is highly applicable, by using the code here, for battery-powered applications. An extension of this example allows one to hook a wire to one of the STM32's GPIO pins, simulating a button press that will also wake up the STM32 to update its sensor readings.
Before you begin using the software, wire your Nucleo development board to the Notecarrier containing the Notecard. You may wire it for Serial, I2C, or both. In order to do so, you'll need some standard female-to-female header wires to jumper between the boards. For reference, the Nucleo's user manual is here
- Connect the Notecarrier's GND pin to any of the Nucleo's GND pins
- For Serial
- Connect the Notecarrier's RX to the Nucleo's D1/TX pin (USART1_TX PA9)
- Connect the Notecarrier's TX to the Nucleo's D0/RX pin (USART1_RX PA10)
- For I2C
- Connect the Notecarrier's SDA pin to the Nucleo's D4 pin (I2C1_SDA PB7)
- Connect the Notecarrier's SCL pin to the Nucleo's D5 pin (I2C1_SCL PB6)
- In order to simulate a "button" for testing
- Connect a wire to the Nucleo's D12 pin (GPIO PB4). You will simulate a button press by temporarily touching it to any Nucleo GND pin.
- Connect both the Notecarrier and Nucleo to power by using their USB connectors to connect them to your development machine.
In order to do development with this example, you will need to download and install STMicroelectronics's free IDE called STM32CubeIDE. During installation it will ask you to specify a directory to contain your projects. Remember this directory path, because that's where you'll download this example.
Clone this note-stm32l4 repo into the projects folder that you selected during IDE installation, as follows. You'll note that the latest copy of the note-c C library is already loaded by default, as a subdirectory of the note-stm32l4 directory.
STM32CubeIDE projects folder
├ note-stm32l4
├ note-c
In STM32CubeIDE, open the note-stm32l4 project. Make sure that you edit the "my" definitions at the top of example.c so that this example will send data to your notehub.io project, and so that it uses serial or I2C as you wish. By using the standard Debug build configuration, you should be able to build and run the project.
This example has been tested with both UART and with I2C, and it has been verified that the project's STOP2 mode works very reliably. Note that in event.h there is a conditional (defaulted ON) that uses the green LED on the Nucleo to indicate whether or not the STM32 is in STOP2 mode. If it's OFF, it is stopped. (Note that it will never enter STOP2 mode while you are in the debugger, else the debugger would halt.)
We love issues, fixes, and pull requests from everyone. By participating in this project, you agree to abide by the Blues Inc code of conduct.
For details on contributions we accept and the process for contributing, see our contribution guide.
For Notecard SDKs and Libraries, see:
- note-c for Standard C support
- note-go for Go
- note-python for Python
Copyright (c) 2019 Blues Inc. Released under the MIT license. See LICENSE for details.