Skip to content

Commit

Permalink
feat:add readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahbagyapan committed Apr 19, 2024
1 parent ac047de commit 891e0e3
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Read Temperature Sensor Data on Raspberry Pi Pico

## Prerequisites

Before diving into code, you need to **install prerequisites**. You can see it from [here](INSTALLATION.md)

## The Code

The code below initializes the internal temperature sensor and UART, prepares them for use. The while loop read data from sensor and write it to the UART once per seconds.

```c++
int main() {

UART_Init();
TEMPERATURE_Init();

while (1) {

uint8_t ui8TemperatureCelsius = TEMPERATURE_Read();

UART_PutString(ui8TemperatureCelsius);
UART_PutChar('\n');

sleep_ms(1000);
}

}
```

## Compiling The Code

To compile the source code we need to create a CMake file to automate the process. CMake files allow us to easily build source files into one easy to use file.

Firstly we need to create folder that name is build.

```console
mkdir build
cd build
```

Then, we need to import essential pico-sdk-libraries

```console
cmake ..
```

Now, we can compile source files

```console
cd ..
cmake --build build
```

## Uploading The Code

Now that we compiled the code we can deploy to our microcontroller.

> **Note !:** To upload the compiled code, you need to start your Raspberry Pi Pico in **flash mode**. To start in flash mode you need to press **bootsel button** before plug in cable.
```console
cp build/main.ef2 <your-rasp-pi-pico-path>
```

0 comments on commit 891e0e3

Please sign in to comment.