This is a simple baremetal project where an MCU (FRDM-KL25 dev board) is used to communicate to a temperature sensor (BMP280) and then displays this data to an OLED display. Communication is done via I2C and power supply given from a PC. This was purely a hobbyist project. I had undertaken this for the below reasons:
- simply to learn I2C communication between peripherals.
- develop the skill to read (swim) through a datasheet and seek out for the necessary info.
- understand how to use better the FRDM-KL25 MCU.
That being said, the API's that I had made over NXP's communication might be of some use to the community, hence I am pushing this project here. I'm happy also to receive feedback on the same. The code is pretty rustic, but I've tried to make the API's as modular/abstract as possible.
Development IDE : MCUXpresso Programming Language : C
Also credits to Eran Duchan for his awesome code generator to output the bitmaps of Calibri 7pt that I use on my display.
The actual prototype with the dev board would look something like this
- All the files meant for build are in the "source" directory.
- Each of the sensors have their own files and access the i2c using the APIs in the i2c_comm.c folder.
- bitmap_array.c is a Middlware file that is a library of all the characters that can be drawn on the OLED display in bitmapped format.
- The main program runs in the MKL25Z4_Project.c file.
Below are the sources that helped me through this project
- FRDM-KL25 User Manual
- FRDM-KL25's Pinouts
- Have a look through NXP's APIs online that could be used to configure GPIO's, set up I2C, etc, like this for example.
- Or manually configure them by referring to the Reference Manual here. Chapters 11,12 (on PORT control and Clock Gating), 38 (on I2C) and and 41 (on GPIOs) would be of interest.
- Have a read through SSD1306's Datasheet.
- Finally, BMP280's datasheet here.
- Make sure MCUXpresso is downloaded and open a workspace
- Download this git repo and then go to File->Open Projects From File System
- Go to the path directory and select this folder(shown in below pic) and click Finish
- The project should be opened as shown below.
- Using the hammer button, you can build to generate the .bin and .axf files for flash and debug.
- Power up the FRDM-KL25Z on the SDA USB port (the port on the right if the ports face down).
- Next, to flash either flash directly as shown in the pic below and selecting "Program Flash Action Using PEMicro probes"
- Or just click on the Blue beetle that says "Debug", which flashes and enters into Debug mode via openSDA.
- After flashing you should see the temperature getting updated at an interval of every 1s.
https://github.com/jsj3408/TempSensor-Display/assets/78897360/3e16e7c9-fd25-4978-bded-dfe8442fa5f0