Skip to content
Snippets Groups Projects
Commit df9ec0bd authored by Dan Stone's avatar Dan Stone
Browse files

inpoutweek1

parent 4aab515b
No related branches found
No related tags found
No related merge requests found
# 12. Output devices
# 12. Input devices
This week I worked on defining my final project idea and started to getting used to the documentation process.
## Research
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
## BMP280 and Arduino
> "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
I decided to the the Adafruit BMP280 Barometric Pressure + Temperature Sensor as it was an I2C enabled sensor we had
in the lab.
## Useful links
First of all I found the data sheet [here](https://cdn-learn.adafruit.com/downloads/pdf/adafruit-bmp280-barometric-pressure-plus-temperature-sensor-breakout.pdf)
- [Jekyll](http://jekyll.org)
- [Google](http://google.com)
- [Markdown](https://en.wikipedia.org/wiki/Markdown)
In the data sheet there is a clear pint out
## Code Example
![](..//images/imagW12/BMP280pintout.png
Use the three backticks to separate code.
I decided to to try it out on an arduino first.
I got it wired up as per the example in the data sheet
![](../images/imagW12/BMPArduinowiring.png)
I downloaded the BMP library and ran the example test code
![](../images/imagW12/BMPLibraryinstall.png)
I uploaded the example code
```c
/***************************************************************************
This is a library for the BMP280 humidity, temperature & pressure sensor
This example shows how to take Sensor Events instead of direct readings
Designed specifically to work with the Adafruit BMP280 Breakout
----> http://www.adafruit.com/products/2651
These sensors use I2C or SPI to communicate, 2 or 4 pins are required
to interface.
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing products
from Adafruit!
Written by Limor Fried & Kevin Townsend for Adafruit Industries.
BSD license, all text above must be included in any redistribution
***************************************************************************/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp; // use I2C interface
Adafruit_Sensor *bmp_temp = bmp.getTemperatureSensor();
Adafruit_Sensor *bmp_pressure = bmp.getPressureSensor();
```
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
while ( !Serial ) delay(100); // wait for native usb
Serial.println(F("BMP280 Sensor event test"));
unsigned status;
//status = bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID);
status = bmp.begin();
if (!status) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring or "
"try a different address!"));
Serial.print("SensorID was: 0x"); Serial.println(bmp.sensorID(),16);
Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
Serial.print(" ID of 0x60 represents a BME 280.\n");
Serial.print(" ID of 0x61 represents a BME 680.\n");
while (1) delay(10);
}
/* Default settings from datasheet. */
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
Adafruit_BMP280::FILTER_X16, /* Filtering. */
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
bmp_temp->printSensorDetails();
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
sensors_event_t temp_event, pressure_event;
bmp_temp->getEvent(&temp_event);
bmp_pressure->getEvent(&pressure_event);
Serial.print(F("Temperature = "));
Serial.print(temp_event.temperature);
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(pressure_event.pressure);
Serial.println(" hPa");
Serial.println();
delay(2000);
}
```
## Gallery
![](../images/sample-photo.jpg)
I got the following error
16:19:39.376 -> BMP280 Sensor event test
16:19:40.949 -> Could not find a valid BMP280 sensor, check wiring or try a different address!
16:19:40.997 -> SensorID was: 0x0
16:19:41.030 -> ID of 0xFF probably means a bad address, a BMP 180 or BMP 085
16:19:41.096 -> ID of 0x56-0x58 represents a BMP 280,
16:19:41.128 -> ID of 0x60 represents a BME 280.
16:19:41.193 -> ID of 0x61 represents a BME 680.
16:20:11.940 -> BMP280 Sensor event test
16:20:11.974 -> Could not find a valid BMP280 sensor, check wiring or try a different address!
I reinspected my wiring and while it matched the once for the data sheet I did notice that I had put the I2C wires
into the wrong place in the Arduino .... a quick correction and we are off to the races.
16:20:12.236 -> ID of 0x61 represents a BME 680.
16:20:47.963 -> BMP280 Sensor event test
16:20:48.086 -> ------------------------------------
16:20:48.119 -> Sensor: BMP280
16:20:48.119 -> Type: Ambient Temp (C)
16:20:48.185 -> Driver Ver: 1
16:20:48.185 -> Unique ID: 280
16:20:48.217 -> Min Value: -40.00
16:20:48.217 -> Max Value: 85.00
16:20:48.250 -> Resolution: 0.01
16:20:48.283 -> ------------------------------------
16:20:48.316 ->
16:20:48.316 -> Temperature = 27.73 *C
16:20:48.349 -> Pressure = 991.60 hPa
16:20:48.349 ->
16:20:50.315 -> Temperature = 27.67 *C
16:20:50.315 -> Pressure = 991.53 hPa
No I wanted to check the temp and so start blowing hot air on the sensor and quickly say the temp start to climb
16:35:41.981 -> Temperature = 23.54 *C
16:35:41.981 -> Pressure = 991.40 hPa
16:35:42.041 ->
16:35:43.962 -> Temperature = 23.54 *C
16:35:43.995 -> Pressure = 991.41 hPa
16:35:44.037 ->
16:35:45.998 -> Temperature = 23.53 *C
16:35:45.998 -> Pressure = 991.42 hPa
16:35:46.037 ->
16:35:47.984 -> Temperature = 24.20 *C
16:35:48.034 -> Pressure = 991.42 hPa
16:35:48.076 ->
16:35:50.007 -> Temperature = 25.51 *C
16:35:50.007 -> Pressure = 991.43 hPa
16:35:50.049 ->
16:35:51.982 -> Temperature = 26.59 *C
16:35:52.014 -> Pressure = 991.43 hPa
16:35:52.060 ->
16:35:53.994 -> Temperature = 27.44 *C
16:35:54.025 -> Pressure = 991.48 hPa
16:35:54.070 ->
16:35:55.996 -> Temperature = 28.02 *C
16:35:56.029 -> Pressure = 991.50 hPa
16:35:56.073 ->
16:35:58.035 -> Temperature = 28.32 *C
16:35:58.035 -> Pressure = 991.52 hPa
16:35:58.079 ->
16:36:00.042 -> Temperature = 28.68 *C
16:36:00.042 -> Pressure = 991.55 hPa
16:36:00.082 ->
16:36:02.045 -> Temperature = 29.02 *C
16:36:02.045 -> Pressure = 991.58 hPa
16:36:02.090 ->
16:36:04.032 -> Temperature = 29.14 *C
16:36:04.065 -> Pressure = 991.60 hPa
16:36:04.108 ->
16:36:06.051 -> Temperature = 29.19 *C
16:36:06.097 -> Pressure = 991.61 hPa
16:36:06.097 ->
16:36:08.046 -> Temperature = 29.27 *C
16:36:08.078 -> Pressure = 991.61 hPa
16:36:08.122 ->
16:36:10.069 -> Temperature = 29.75 *C
16:36:10.069 -> Pressure = 991.61 hPa
16:36:10.115 ->
16:36:12.075 -> Temperature = 30.21 *C
16:36:12.075 -> Pressure = 991.68 hPa
16:36:12.118 ->
16:36:14.074 -> Temperature = 30.77 *C
16:36:14.120 -> Pressure = 991.68 hPa
## BMP280 moving to the RP2040
I set up the basic connection with the using the following pinout
![](../images/imagW12/BMPRP2040PINTOUT.png)
Made the connections to the sensor
![](../images/imagW12/BMP280RP2040CONNECTED.png)
And we are live:
![](../images/imagW12/BMP280RP2040LIVE.png)
## BMP280 and Fab Xiao
I wanted to hook up the sensor the to board I made based on the fab xiao. It was pretty
straight forward following the same code I used with the the RP2040 stand alone
The pinout for the board is
![](../images/imagW12/Fabxiao1.png)
I hooked up the sensor
![](../images/imagW12/Fabxiao2.png)
## Video
and here you go as I blow hot air the temp goes up:
### From Vimeo
![](../images/imagW12/Xiaoreading.png)
<iframe src="https://player.vimeo.com/video/10048961" width="640" height="480" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<p><a href="https://vimeo.com/10048961">Sound Waves</a> from <a href="https://vimeo.com/radarboy">George Gally (Radarboy)</a> on <a href="https://vimeo.com">Vimeo</a>.</p>
### From Youtube
<iframe width="560" height="315" src="https://www.youtube.com/embed/jjNgJFemlC4" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
## 3D Models
<div class="sketchfab-embed-wrapper"><iframe width="640" height="480" src="https://sketchfab.com/models/658c8f8a2f3042c3ad7bdedd83f1c915/embed" frameborder="0" allow="autoplay; fullscreen; vr" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>
<p style="font-size: 13px; font-weight: normal; margin: 5px; color: #4A4A4A;">
<a href="https://sketchfab.com/models/658c8f8a2f3042c3ad7bdedd83f1c915?utm_medium=embed&utm_source=website&utm_campaign=share-popup" target="_blank" style="font-weight: bold; color: #1CAAD9;">Dita&#39;s Gown</a>
by <a href="https://sketchfab.com/francisbitontistudio?utm_medium=embed&utm_source=website&utm_campaign=share-popup" target="_blank" style="font-weight: bold; color: #1CAAD9;">Francis Bitonti Studio</a>
on <a href="https://sketchfab.com?utm_medium=embed&utm_source=website&utm_campaign=share-popup" target="_blank" style="font-weight: bold; color: #1CAAD9;">Sketchfab</a>
</p>
</div>
You can find the code [here](../files/Week12/bmp280_sensortest.zip)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment