Skip to content

Merge intern examples #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 143 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
608d35d
Bootstrap BMP280 example
Jun 24, 2021
602973a
Add Fritzing schematic
Jun 24, 2021
fad0af7
Add register configuration and raw data reads
Jun 25, 2021
ec4c72e
Add README
Jun 25, 2021
64524e9
Fix a few compiler complaints
Jun 25, 2021
957ce0d
Finish temperature and pressure compensation
Jun 25, 2021
00c2bb2
Make a few minor improvements
Jun 28, 2021
6d11741
Fix inconsistent formatting
Jun 28, 2021
894ef0b
Update Fritzing schematic to use half breadboard
Jun 28, 2021
0af033b
Remove use of pointers in conversion functions
Jun 29, 2021
fe75b04
Ensure consistency with other BME280 example
Jun 29, 2021
6ff1a13
Bootstrap OLED example
Jun 29, 2021
768026c
Add Fritzing schematic
Jun 29, 2021
5673e82
Add README doc
Jun 29, 2021
94e4483
Set up commands and init process
Jun 30, 2021
1d3ff52
Fix typo in Fritzing schematic names
Jun 30, 2021
848ea0b
Update README doc
Jun 30, 2021
cb81a60
Add header file with a raspberry (pi)
Jun 30, 2021
309af50
Add buffer printing utils
Jun 30, 2021
d5ee81a
Finish initialization process
Jun 30, 2021
b100f39
Add pixel rendering utils
Jun 30, 2021
cbc4de8
Add example code in main
Jun 30, 2021
c3b3b30
Fix formatting and use #defines
Jul 1, 2021
2d6cb91
Include link to specific board used
Jul 1, 2021
da78569
Clarify pin numbers in comments
Jul 1, 2021
d69fc57
Remove RST pin from schematic
Jul 1, 2021
ca4d47f
Fix a few typos and make minor improvements
Jul 1, 2021
4589222
Fix polling interval to avoid collisions
Jul 1, 2021
c1c083b
Further clarify wording in README
Jul 1, 2021
5246692
Add Python script to convert image to SSD1306 format
Jul 1, 2021
04c5927
Switch to smaller breadboard
Jul 1, 2021
e58018f
Print render area in lefthand corner
Jul 1, 2021
98d69b9
Reshuffle words in README
Jul 1, 2021
9230918
Make a few improvements to Python script
Jul 2, 2021
901c0b5
Make further improvements to Python script
Jul 2, 2021
cd045e8
Add example to general README
Jul 2, 2021
c790c8b
Add project to general README
Jul 2, 2021
b685dde
Use alphabetical order for last commit
Jul 2, 2021
fa88fb2
Bootstrap example
Jul 9, 2021
f29e22a
Add README
Jul 9, 2021
af2257e
Add Fritzing schematic
Jul 9, 2021
c35c9aa
Add example to general README
Jul 9, 2021
1975e44
Fix typo
Jul 9, 2021
a20d433
Add main
Jul 9, 2021
8b55f4b
Add final changes
Jul 9, 2021
af936d1
Fix typo
Jul 9, 2021
6b0b5b6
Bootstrap example
Jul 12, 2021
374e394
Add Fritzing schematic
Jul 12, 2021
9e82afa
Add example to general README
Jul 12, 2021
ac5db84
Add example for MCP9808 Digital Temperature Sensor
aayushijhaveri Jul 12, 2021
fc76e10
Add sensor initialization
Jul 12, 2021
ba7b1d3
Flesh out documentation
Jul 12, 2021
aaaa5cb
Fix typo
Jul 12, 2021
dfc90dc
Retrieve data from MCP9808 registers
aayushijhaveri Jul 12, 2021
29b9946
changed i2c read/write
aayushijhaveri Jul 12, 2021
965a1e3
Push latest changes
Jul 13, 2021
90289fe
Improve signed integer calculations
Jul 13, 2021
19ec70f
Polish sensor value conversions
Jul 14, 2021
b9c0322
Fix typo
Jul 14, 2021
2199a83
Remove unused comment
Jul 14, 2021
afb2e52
Make a few fixes
Jul 14, 2021
64ab919
Add comments and use floats
Jul 14, 2021
b307c2e
Add wiring diargrams and i2c communication with board
aayushijhaveri Jul 15, 2021
f6872dd
Change wiring diagram
aayushijhaveri Jul 15, 2021
ea231c4
Print data to higher precision
aayushijhaveri Jul 15, 2021
38db78b
Bootstrap example
Jul 15, 2021
ddda8ba
Update README wiring info
aayushijhaveri Jul 15, 2021
c4b0292
Add Fritzing diagram
Jul 15, 2021
5e9638e
Add documentation
Jul 15, 2021
71a7358
Changes to README and Fritzing diagrams
aayushijhaveri Jul 15, 2021
525338a
Change wiring layout
aayushijhaveri Jul 15, 2021
0e6c8a4
Add comment to cmake file
aayushijhaveri Jul 15, 2021
cb6aa73
Add convenience functions
Jul 15, 2021
cd1f724
Restructure code and chnage wiring diagram
aayushijhaveri Jul 15, 2021
4998477
Minor edits to README and code
aayushijhaveri Jul 15, 2021
cb06ae3
Complete docs
Jul 15, 2021
34154c4
Add rainbow background!!
Jul 15, 2021
1c0af50
Add note on RGB
Jul 15, 2021
7781a8b
Add brief code description
Jul 15, 2021
12560fd
Clarify warning about voltages
Jul 15, 2021
3a2b0b1
Remove incorrect write and read bits
Jul 15, 2021
4bbf10d
Improve docs text and fix typos
Jul 16, 2021
897c5e9
Make further tweaks to example
Jul 16, 2021
dd8f65c
Don't connect jumpers to board pins
Jul 16, 2021
9dffd1b
Make further clarifications
Jul 16, 2021
d58bab5
Make clarifications, remove superfluous text
Jul 19, 2021
560452b
Swap example order in README
Jul 19, 2021
b7a8957
Tweak conversion factor, remove extra comment
Jul 19, 2021
2b8c44b
Remove read/write mode and unused registers
aayushijhaveri Jul 19, 2021
8366ff1
Add program files
aayushijhaveri Jul 19, 2021
b87e4d9
Add documentation
aayushijhaveri Jul 19, 2021
7d7fb42
Add input to README directory
aayushijhaveri Jul 19, 2021
c27e5e1
Bootstrap project
Jul 30, 2021
aa31ea1
Add finished PIO code
Jul 30, 2021
1b5cafe
Add code and link dependencies
aayushijhaveri Aug 2, 2021
74f51ac
Fix submodule addition
aayushijhaveri Aug 2, 2021
504a4f8
Minor change to comment
aayushijhaveri Aug 13, 2021
00320a8
Add code and documentation
aayushijhaveri Aug 18, 2021
bfcd5e5
revert file
aayushijhaveri Aug 18, 2021
cab604f
Merge branch 'lis3dh' of https://github.com/aayushijhaveri/pico-examp…
aayushijhaveri Aug 18, 2021
e150c32
Remove accidental changes
aayushijhaveri Aug 18, 2021
293ef63
Final touches
aayushijhaveri Aug 20, 2021
4cfc857
Add to main Readme
aayushijhaveri Aug 20, 2021
b9f1eff
Merge pull request #142 from matiasilva/lcd-uart
Oct 14, 2021
04a1e58
Merge pull request #136 from matiasilva/mpl3115a2-altimeter
Oct 14, 2021
a6cbffc
Merge pull request #135 from matiasilva/ics-40180-microphone
Oct 14, 2021
b75cc68
Merge pull request #130 from matiasilva/oled-i2c
Oct 14, 2021
4caac4d
Merge pull request #127 from matiasilva/develop
Oct 14, 2021
5ee2e41
Merge pull request #149 from aayushijhaveri/lan8720_ethernet
Oct 14, 2021
73d4816
Merge branch 'merge-intern-examples' into lis3dh
Oct 14, 2021
c14417b
Merge branch 'merge-intern-examples' into mma8451_3axis_accelerometer
Oct 14, 2021
7217d88
Merge pull request #144 from aayushijhaveri/mma8451_3axis_accelerometer
Oct 14, 2021
d692580
Merge branch 'merge-intern-examples' into MCP9808_tempsensor
Oct 14, 2021
132ecb2
Revert "Add example for the LAN8720"
aallan Oct 15, 2021
e6918f5
Merge pull request #162 from raspberrypi/revert-149-lan8720_ethernet
Oct 15, 2021
cb5a4ef
Added Graham's suggestions from original PR. Compiles, not tested
JamesH65 Oct 15, 2021
88d5649
Change .org to .com
JamesH65 Oct 18, 2021
6342c43
Update README.adoc
JamesH65 Oct 18, 2021
1e340ca
Fix missing semicolon
aallan Oct 19, 2021
67c8eef
Merge pull request #148 from matiasilva/i2s-microphone
Oct 19, 2021
66e728f
Merge branch 'merge-intern-examples' into lis3dh
Oct 19, 2021
f0600ac
Merge pull request #154 from aayushijhaveri/lis3dh
Oct 19, 2021
cc918a6
Merge branch 'merge-intern-examples' into MCP9808_tempsensor
Oct 19, 2021
cdf8d82
Merge pull request #143 from aayushijhaveri/MCP9808_tempsensor
Oct 19, 2021
056b825
Retrieve data
aayushijhaveri Aug 4, 2021
ba00610
Set and read time
aayushijhaveri Aug 4, 2021
896814a
Add alarm feature
aayushijhaveri Aug 5, 2021
79c5fa6
Add diagram and documentation
aayushijhaveri Aug 5, 2021
bcf3c89
Add to main README
aayushijhaveri Aug 5, 2021
680ffd8
Minor format changes
aayushijhaveri Aug 5, 2021
8baf2e9
Change function names
aayushijhaveri Aug 5, 2021
6cd8bc7
Changes to Fritzing diagram
aayushijhaveri Aug 6, 2021
5ebd17f
Minor change to readme
aayushijhaveri Aug 13, 2021
31e686c
another minor change
aayushijhaveri Aug 13, 2021
0f71421
Merge pull request #166 from lurch/new_150 (Add example for the PCF85…
Oct 19, 2021
de4661e
Read GPS data + wiring diagram
aayushijhaveri Aug 6, 2021
28009ef
Final code
aayushijhaveri Aug 13, 2021
2613c44
add documentation
aayushijhaveri Aug 13, 2021
8259d74
add detail to ReadME
aayushijhaveri Aug 13, 2021
f4d2586
Eliminate blank lines
aayushijhaveri Aug 13, 2021
22e5d52
Minor fix to readme
aayushijhaveri Aug 18, 2021
549684d
Add to ReadMe
aayushijhaveri Aug 20, 2021
2e4ad1e
Merge pull request #167 from lurch/new_151
Oct 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ App|Description
[hello_adc](adc/hello_adc)|Display the voltage from an ADC input.
[joystick_display](adc/joystick_display)|Display a Joystick X/Y input based on two ADC inputs.
[adc_console](adc/adc_console)|An interactive shell for playing with the ADC. Includes example of free-running capture mode.
[microphone_adc](adc/microphone_adc)|Read analog values from a microphone and plot the measured sound amplitude.

### Clocks

Expand Down Expand Up @@ -76,8 +77,16 @@ App|Description
App|Description
---|---
[bus_scan](i2c/bus_scan) | Scan the I2C bus for devices and display results.
[bmp280_i2c](i2c/bmp280_i2c) | Read and convert temperature and pressure data from a BMP280 sensor, attached to an I2C bus.
[lcd_1602_i2c](i2c/lcd_1602_i2c) | Display some text on a generic 16x2 character LCD display, via I2C.
[mcp9808_i2c](i2c/mcp9808_i2c) | Read temperature, set limits and raise alerts when limits are surpassed.
[lis3dh_i2c](i2c/lis3dh_i2c) | Read acceleration and temperature value from a LIS3DH sensor via I2C
[mma8451_i2c](i2c/mma8451_i2c) | Read acceleration from a MMA8451 accelerometer and set range and precision for the data.
[mpl3115a2_i2c](i2c/mpl3115a2_i2c) | Interface with an MPL3115A2 altimeter, exploring interrupts and advanced board features, via I2C.
[mpu6050_i2c](i2c/mpu6050_i2c) | Read acceleration and angular rate values from a MPU6050 accelerometer/gyro, attached to an I2C bus.
[oled_i2c](i2c/oled_i2c) | Convert and display a bitmap on a 128x32 SSD1306-driven OLED display
[pa1010d_i2c](i2c/pa1010d_i2c) | Read GPS location data, parse and display data via I2C.
[pcf8523_i2c](i2c/pcf8523_i2c) | Read time and date values from a real time clock. Set current time and alarms on it.

### Interpolator

Expand Down Expand Up @@ -172,6 +181,7 @@ App|Description
App|Description
---|---
[hello_uart](uart/hello_uart) | Print some text from one of the UART serial ports, without going through `stdio`.
[lcd_uart](uart/lcd_uart) | Display text and symbols on a 16x02 RGB LCD display via UART
[uart_advanced](uart/uart_advanced) | Use some other UART features like RX interrupts, hardware control flow, and data formats other than 8n1.

### USB Device
Expand Down
1 change: 1 addition & 0 deletions adc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ if (NOT PICO_NO_HARDWARE)
add_subdirectory(dma_capture)
add_subdirectory(hello_adc)
add_subdirectory(joystick_display)
add_subdirectory(microphone_adc)
endif ()
12 changes: 12 additions & 0 deletions adc/microphone_adc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
add_executable(microphone_adc
microphone_adc.c
)

# pull in common dependencies and adc hardware support
target_link_libraries(microphone_adc pico_stdlib hardware_adc)

# create map/bin/hex file etc.
pico_add_extra_outputs(microphone_adc)

# add url via pico_set_program_url
example_auto_set_url(microphone_adc)
48 changes: 48 additions & 0 deletions adc/microphone_adc/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
= Attaching a microphone using the ADC

This example code shows how to interface the Raspberry Pi Pico with a standard analog microphone via the onboard analog to digital converter (ADC). In this example, we use an ICS-40180 breakout board by SparkFun but any analog microphone should be compatible with this tutorial. SparkFun have https://learn.sparkfun.com/tutorials/mems-microphone-hookup-guide[written a guide] for this board that goes into more detail about the board and how it works.

[TIP]
======
An analog to digital converter (ADC) is responsible for reading continually varying input signals that may range from 0 to a specified reference voltage (in the Pico's case this reference voltage is set by the supply voltage and can be measured on pin 35, ADC_VREF) and converting them into binary, i.e. a number that can be digitally stored.
======

The Pico has a 12-bit ADC (ENOB of 8.7-bit, see https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf[RP2040 datasheet section 4.9.3 for more details]), meaning that a read operation will return a number ranging from 0 to 4095 (2^12 - 1) for a total of 4096 possible values. Therefore, the resolution of the ADC is 3.3/4096, so roughly steps of 0.8 millivolts. The SparkFun breakout uses an OPA344 operational amplifier to boost the signal coming from the microphone to voltage levels that can be easily read by the ADC. An important side effect is that a bias of 0.5*Vcc is added to the signal, even when the microphone is not picking up any sound.

The ADC provides us with a raw voltage value but when dealing with sound, we're more interested in the amplitude of the audio signal. This is defined as one half the peak-to-peak amplitude. Included with this example is a very simple Python script that will plot the voltage values it receives via the serial port. By tweaking the sampling rates, and various other parameters, the data from the microphone can be analysed in various ways, such as in a Fast Fourier Transform to see what frequencies make up the signal.

[[microphone_adc_plotter_image]]
[pdfwidth=75%]
.Example output from included Python script
image::microphone_adc_plotter.png[]

== Wiring information

Wiring up the device requires 3 jumpers, to connect VCC (3.3v), GND, and AOUT. The example here uses ADC0, which is GP26. Power is supplied from the 3.3V pin.

WARNING: Most boards will take a range of VCC voltages from the Pico's default 3.3V to the 5 volts commonly seen on other microcontrollers. Ensure your board doesn't output an analogue signal greater than 3.3V as this may result in permanent damage to the Pico's ADC.

[[ics-40180-adc_wiring]]
[pdfwidth=75%]
.Wiring Diagram for ICS-40180 microphone breakout board.
image::microphone_adc_bb.png[]

== List of Files

CMakeLists.txt:: CMake file to incorporate the example in to the examples build tree.
microphone_adc.c:: The example code.

== Bill of Materials

.A list of materials required for the example
[[ics-40180-adc-bom-table]]
[cols=3]
|===
| *Item* | *Quantity* | Details
| Breadboard | 1 | generic part
| Raspberry Pi Pico | 1 | http://raspberrypi.com/
| ICS-40180 microphone breakout board or similar | 1 | https://www.sparkfun.com/products/18011[From SparkFun]
| M/M Jumper wires | 3 | generic part
|===


48 changes: 48 additions & 0 deletions adc/microphone_adc/microphone_adc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "hardware/adc.h"
#include "hardware/uart.h"
#include "pico/binary_info.h"

/* Example code to extract analog values from a microphone using the ADC
with accompanying Python file to plot these values

Connections on Raspberry Pi Pico board, other boards may vary.

GPIO 26/ADC0 (pin 31)-> AOUT or AUD on microphone board
3.3v (pin 36) -> VCC on microphone board
GND (pin 38) -> GND on microphone board
*/

#define ADC_PIN 0
#define ADC_VREF 3.3
#define ADC_RANGE (1 << 12)
#define ADC_CONVERT ADC_VREF / (ADC_RANGE - 1)

int main() {
stdio_init_all();
printf("Beep boop, listening...\n");

bi_decl(bi_program_description("Analog microphone example for Raspberry Pi Pico")); // for picotool
bi_decl(bi_1pin_with_name(ADC_PIN, "ADC input pin"));

adc_init();
adc_gpio_init(ADC_PIN + 26);
adc_select_input(ADC_PIN);

uint adc_raw;
while (1) {
adc_raw = adc_read(); // raw voltage from ADC
printf("%.2f\n", adc_raw * ADC_CONVERT);
sleep_ms(10);
}

return 0;
}
Binary file added adc/microphone_adc/microphone_adc.fzz
Binary file not shown.
Binary file added adc/microphone_adc/microphone_adc_bb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added adc/microphone_adc/microphone_adc_plotter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions adc/microphone_adc/plotter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python3

# Grabs raw data from the Pico's UART and plots it as received

# Install dependencies:
# python3 -m pip install pyserial matplotlib

# Usage: python3 plotter <port>
# eg. python3 plotter /dev/ttyACM0

# see matplotlib animation API for more: https://matplotlib.org/stable/api/animation_api.html

import serial
import sys
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.lines import Line2D

# disable toolbar
plt.rcParams['toolbar'] = 'None'

class Plotter:
def __init__(self, ax):
self.ax = ax
self.maxt = 250
self.tdata = [0]
self.ydata = [3.3/2]
self.line = Line2D(self.tdata, self.ydata)

self.ax.add_line(self.line)
self.ax.set_ylim(0, 3.3)
self.ax.set_xlim(0, self.maxt)

def update(self, y):
lastt = self.tdata[-1]
if lastt - self.tdata[0] >= self.maxt: # drop old frames
self.tdata = self.tdata[1:]
self.ydata = self.ydata[1:]
self.ax.set_xlim(self.tdata[0], self.tdata[0] + self.maxt)

t = lastt + 1
self.tdata.append(t)
self.ydata.append(y)
self.line.set_data(self.tdata, self.ydata)
return self.line,


def serial_getter():
# grab fresh ADC values
# note sometimes UART drops chars so we try a max of 5 times
# to get proper data
while True:
for i in range(5):
line = ser.readline()
try:
line = float(line)
except ValueError:
continue
break
yield line

if len(sys.argv) < 2:
raise Exception("Ruh roh..no port specified!")

ser = serial.Serial(sys.argv[1], 115200, timeout=1)

fig, ax = plt.subplots()
plotter = Plotter(ax)

ani = animation.FuncAnimation(fig, plotter.update, serial_getter, interval=1,
blit=True, cache_frame_data=False)

ax.set_xlabel("Samples")
ax.set_ylabel("Voltage (V)")
fig.canvas.manager.set_window_title('Microphone ADC example')
fig.tight_layout()
plt.show()
2 changes: 1 addition & 1 deletion gpio/dht_sensor/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dht.c:: The example code.
|===
| *Item* | *Quantity* | Details
| Breadboard | 1 | generic part
| Raspberry Pi Pico | 1 | http://raspberrypi.org/
| Raspberry Pi Pico | 1 | http://raspberrypi.com/
| 10 kΩ resistor | 1 | generic part
| M/M Jumper wires | 4 | generic part
| DHT-22 sensor | 1 | generic part
Expand Down
2 changes: 1 addition & 1 deletion gpio/hello_7segment/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ hello_7segment.c:: The example code.
|===
| *Item* | *Quantity* | Details
| Breadboard | 1 | generic part
| Raspberry Pi Pico | 1 | http://raspberrypi.org/
| Raspberry Pi Pico | 1 | http://raspberrypi.com/
| 7 segment LED module | 1 | generic part
| 68 ohm resistor | 7 | generic part
| DIL push to make switch | 1 | generic switch
Expand Down
8 changes: 8 additions & 0 deletions i2c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
if (NOT PICO_NO_HARDWARE)
add_subdirectory(bmp280_i2c)
add_subdirectory(bus_scan)
add_subdirectory(lcd_1602_i2c)
add_subdirectory(mcp9808_i2c)
add_subdirectory(lis3dh_i2c)
add_subdirectory(mma8451_i2c)
add_subdirectory(mpl3115a2_i2c)
add_subdirectory(mpu6050_i2c)
add_subdirectory(oled_i2c)
add_subdirectory(pa1010d_i2c)
add_subdirectory(pcf8523_i2c)
endif ()
12 changes: 12 additions & 0 deletions i2c/bmp280_i2c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
add_executable(bmp280_i2c
bmp280_i2c.c
)

# pull in common dependencies and additional i2c hardware support
target_link_libraries(bmp280_i2c pico_stdlib hardware_i2c)

# create map/bin/hex file etc.
pico_add_extra_outputs(bmp280_i2c)

# add url via pico_set_program_url
example_auto_set_url(bmp280_i2c)
41 changes: 41 additions & 0 deletions i2c/bmp280_i2c/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
= Attaching a BMP280 temp/pressure sensor via I2C

This example code shows how to interface the Raspberry Pi Pico with the popular BMP280 temperature and air pressure sensor manufactured by Bosch. A similar variant, the BME280, exists that can also measure humidity. There is another example that uses the BME280 device but talks to it via SPI as opposed to I2C.

The code reads data from the sensor's registers every 500 milliseconds and prints it via the onboard UART. This example operates the BMP280 in _normal_ mode, meaning that the device continuously cycles between a measurement period and a standby period at a regular interval we can set. This has the advantage that subsequent reads do not require configuration register writes and is the recommended mode of operation to filter out short-term disturbances.

[TIP]
======
The BMP280 is highly configurable with 3 modes of operation, various oversampling levels, and 5 filter settings. Find the datasheet online (https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf) to explore all of its capabilities beyond the simple example given here.
======

== Wiring information

Wiring up the device requires 4 jumpers, to connect VCC (3.3v), GND, SDA and SCL. The example here uses the default I2C port 0, which is assigned to GPIO 4 (SDA) and 5 (SCL) in software. Power is supplied from the 3.3V pin from the Pico.

WARNING: The BMP280 has a maximum supply voltage rating of 3.6V. Most breakout boards have voltage regulators that will allow a range of input voltages of 2-6V, but make sure to check beforehand.

[[bmp280_i2c_wiring]]
[pdfwidth=75%]
.Wiring Diagram for BMP280 sensor via I2C.
image::bmp280_i2c_bb.png[]

== List of Files

CMakeLists.txt:: CMake file to incorporate the example into the examples build tree.
bmp280_i2c.c:: The example code.

== Bill of Materials

.A list of materials required for the example
[[bmp280_i2c-bom-table]]
[cols=3]
|===
| *Item* | *Quantity* | Details
| Breadboard | 1 | generic part
| Raspberry Pi Pico | 1 | http://raspberrypi.com/
| BMP280-based breakout board | 1 | https://shop.pimoroni.com/products/bmp280-breakout-temperature-pressure-altitude-sensor[from Pimoroni]
| M/M Jumper wires | 4 | generic part
|===


Loading