The CJMCU-8223 is a small breakout board featuring an NRF51822 and an LIS3DH accelerometer. It is shown above attached to an SSD1306 Oled display. Programs are loaded on to it using an ST-Link debugger clone.
There are many different ways to program this chip but I decided to develop code for it using the online compiler at mbed.org. This environment allows you write and compile code within your browser. Compiled programs are dropped in to your downloads directory in the form of “hex” files. These downloads can then be written to your target MCU using your preferred debugger. The advantage of this approach is that you don’t have to set up a toolchain on your PC and, you can avail of lots of ready made libraries and example code.
This particular example provides two Gatt services over BLE. An LEDService allows a connected bluetooth device to control the blue LED on the breadboard. An accelerometer service allows the connected device read the accelerometer values (scaled up by a factor of 1000 to avoid floating point printing). The code for this example can be found via this link over at mbed.org.
When you compile this code, the hex file delivered to your PC needs to be uploaded to the NRF51822. This is done as follows:
In one command window (terminal) start openocd as shown here:
Leaving that window running, open a new one and run telnet entering the commands shown below.
Once you have done this, type reset into the telnet session and the board should start running.
You can interact with the board using BLE Scanner on your phone or maybe work with node.js or python to develop a PC based application.
If you need to do some debugging, it is possible to export the program from the mbed environment into a format that is compatible with a number of toolchains (including gcc/gdb). I have tried this and it works pretty well although you may need to disable interrupts on the MCU while doing this as the debugger can get confused if there is bluetooth activity during the debug session.
nice work !! what is the address of the OLED I don’t see defined in the code? do you have a schematic this setup ?
Hi Walter, I don’t have a schematic on me right now but SDA is on P0_30, SCL is on P0_0. The OLED address is 0x3c (shift left 1 bit for read/write bit). See OLED.h for more details.
Hi FDUIGNAN, nice work! sorry if I’m bothering you, but do you have a video tutorial of accelerometer bluetooth?
Hi Sulis, I don’t have a video tutorial but I’m happy to answer any questions you may have
thank you for your answer, I will try it first then when I have any problems I will ask you
Please, do you have the CJMCU-8223 datasheet?
I don’t have a datasheet but you can find the schematic and other information here https://www.robotshop.com/eu/en/nrf51822-bluetooth-40-module-pins.html
Ok. Thank you.
There’s also a schematic here