Skip to content

Commit a7a60e4

Browse files
Update/Add Examples
Include BME688 for SPI, I2C, and BLE examples
1 parent 851e6db commit a7a60e4

File tree

3 files changed

+218
-2
lines changed

3 files changed

+218
-2
lines changed

docs/example-I2C.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ This sketch allows users to scan for devices connected to the primary I^2^C bus
1717
</center>
1818

1919

20+
2021
## Peripheral Devices
2122
The RA6M5 Thing Plus features a Qwiic connector to seamlessly integrate with devices from [SparkFun's Qwiic Ecosystem](https://www.sparkfun.com/qwiic). While users are free to utilize any I^2^C device, we recommend the [Qwiic devices](https://www.sparkfun.com/categories/399) from our catalog.
2223

24+
2325
??? note "Optional Hardware"
2426
<div class="grid cards" markdown>
2527

@@ -113,12 +115,15 @@ The RA6M5 Thing Plus features a Qwiic connector to seamlessly integrate with dev
113115
</div>
114116

115117

118+
116119
### MAX17048 Fuel Gauge
117120
The MAX17048 fuel gauge measures the approximate charge/discharge rate, state of charge, and voltage of a connected LiPo battery. We recommend the [SparkFun MAX1704x Arduino library](https://github.com/sparkfun/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library) be utilized in the Arduino IDE, to connect to the MAX17048 on the RA6M5 Thing Plus. Once the [library is installed in the Arduino IDE](../software_overview-arduino/#max17048-fuel-gauge), users will find several example sketches listed in the **File** > **Examples** > **SparkFun MAX1704x Fuel Gauge Arduino Library** > drop-down menu. We recommend the following examples for users:
118121

122+
119123
- `Example1_Simple.ino`
120124
- `Example4_MAX17048_KitchenSink.ino`
121125

126+
122127
??? note "Optional Hardware"
123128
<div class="grid cards" markdown>
124129

@@ -168,6 +173,7 @@ The MAX17048 fuel gauge measures the approximate charge/discharge rate, state of
168173
</div>
169174

170175

176+
171177
=== "`Example1_Simple.ino`"
172178
Users can find this sketch in the **File** > **Examples** > **SparkFun MAX1704x Fuel Gauge Arduino Library** > **Example1_Simple** drop-down menu.
173179

@@ -184,3 +190,75 @@ The MAX17048 fuel gauge measures the approximate charge/discharge rate, state of
184190
```cpp
185191
--8<-- "https://raw.githubusercontent.com/sparkfun/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/main/examples/Example4_MAX17048_KitchenSink/Example4_MAX17048_KitchenSink.ino"
186192
```
193+
194+
195+
196+
### BME688 Environmental Sensor
197+
Users are free to utilize any hardware they already have; however, we recommend the [BME688 environmental sensor](https://www.sparkfun.com/products/19096). The board includes a Qwiic connector on the edge of the board and can be easily attached to the RA6M5 Thing Plus with a [Qwiic cable](https://www.sparkfun.com/products/17260). In addition, a [hookup guide](https://learn.sparkfun.com/tutorials/1168) and [Arduino library](https://github.com/BoschSensortec/Bosch-BME68x-Library) for the sensor are available.
198+
199+
200+
??? note "Optional Hardware"
201+
<div class="grid cards" markdown>
202+
203+
- <a href="https://www.sparkfun.com/products/19096">
204+
<figure markdown>
205+
![Product Thumbnail](https://cdn.sparkfun.com/assets/parts/1/8/6/9/6/19096-SparkFun_Environmental_Sensor_Breakout_-_BME688__Qwiic_-01.jpg)
206+
</figure>
207+
208+
---
209+
210+
**SparkFun Environmental Sensor - BME688 (Qwiic)**<br>
211+
SEN-19096</a>
212+
213+
214+
- <a href="https://www.sparkfun.com/products/17260">
215+
<figure markdown>
216+
![Product Thumbnail](https://cdn.sparkfun.com/assets/parts/1/6/2/4/7/17260-Flexible_Qwiic_Cable_-_50mm-01.jpg)
217+
</figure>
218+
219+
---
220+
221+
**Flexible Qwiic Cable - 50mm**<br>
222+
PRT-17260</a>
223+
224+
</div>
225+
226+
227+
??? arduino "Install Arduino Library"
228+
Users will need to install the [Bosch BME68x Arduino library](https://github.com/BoschSensortec/Bosch-BME68x-Library) for the sensor. In the Arduino IDE, users can install it by searching for `BME68x Sensor Library`, in the **Library Manager**:
229+
230+
BME68x Sensor Library
231+
232+
233+
234+
Users can find this sketch in the **File** > **Examples** > **BME68x Sensor library** > **forced_mode** drop-down menu. *For more details on utilizing the BME68x breakout board, please refer to our [hookup guide](https://learn.sparkfun.com/tutorials/1168) for the sensor.*
235+
236+
237+
238+
??? code "`forced_mode.ino`"
239+
!!! warning "I^2^C Modifications"
240+
By default, this example utilizes the SPI bus; therefore, some modifications must be made:
241+
242+
- The chip select pin no longer needs to be defined:
243+
244+
{--
245+
#ifndef PIN_CS
246+
#define PIN_CS SS
247+
#endif
248+
--}
249+
250+
- The I^2^C bus must be initialized, instead of the SPI bus:
251+
252+
{--SPI.begin();--}
253+
{++Wire.begin();++}
254+
255+
- The sensor must be initialized with the Wire class, instead of the SPI class:
256+
257+
/* initializes the sensor based on {--SPI--}{++Wire++} library */
258+
{--bme.begin(PIN_CS, SPI);--}
259+
{++bme.begin(BME68X_I2C_ADDR_LOW, Wire)++}
260+
261+
262+
```cpp
263+
--8<-- "https://raw.githubusercontent.com/boschsensortec/Bosch-BME68x-Library/master/examples/forced_mode/forced_mode.ino"
264+
```

docs/example-SPI.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ The simplest way to test the SPI interface is with just a jumper *(wire)* and lo
7575

7676

7777
## Peripheral Device
78-
A more direct method for testing the SPI interface is with an actual SPI device. Users are free to utilize any hardware they already have; however, we recommend the [BME68x environmental sensor](https://www.sparkfun.com/products/19096), below. Its SPI pins are broken out on the edge of the board and can be easily connected to the RA6M5 Thing Plus. In addition, a [hookup guide](https://learn.sparkfun.com/tutorials/1168) and [Arduino library](https://github.com/BoschSensortec/Bosch-BME68x-Library) for the sensor are available.
78+
A more direct method for testing the SPI interface is with an actual SPI device.
79+
80+
### BME688 Environmental Sensor
81+
Users are free to utilize any hardware they already have; however, we recommend the [BME688 environmental sensor](https://www.sparkfun.com/products/19096), below. Its SPI pins are broken out on the edge of the board and can be easily connected to the RA6M5 Thing Plus. In addition, a [hookup guide](https://learn.sparkfun.com/tutorials/1168) and [Arduino library](https://github.com/BoschSensortec/Bosch-BME68x-Library) for the sensor are available.
7982

8083

8184
??? note "Optional Hardware"
@@ -149,8 +152,14 @@ A more direct method for testing the SPI interface is with an actual SPI device.
149152
</div>
150153

151154

155+
??? arduino "Install Arduino Library"
156+
Users will need to install the [Bosch BME68x Arduino library](https://github.com/BoschSensortec/Bosch-BME68x-Library) for the sensor. In the Arduino IDE, users can install it by searching for `BME68x Sensor Library`, in the **Library Manager**:
157+
158+
BME68x Sensor Library
159+
160+
152161

153-
Users can find this sketch in the **File** > **Examples** > **Bosch BME68x Sensor** > **forced_mode** drop-down menu. *For more details on utilizing the BME68x breakout board, please refer to our [hookup guide](https://learn.sparkfun.com/tutorials/1168) for the sensor.*
162+
Users can find this sketch in the **File** > **Examples** > **BME68x Sensor library** > **forced_mode** drop-down menu. *For more details on utilizing the BME68x breakout board, please refer to our [hookup guide](https://learn.sparkfun.com/tutorials/1168) for the sensor.*
154163

155164

156165

docs/example-codeless.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,141 @@ In order to operate the `codelessBLE_peripheral.ino` and `codelessBLE_central.in
7878
=== "`codelessBLE_peripheral.ino`"
7979
This sketch requires a [Qwiic BME280 sensor](https://www.sparkfun.com/products/15440), connected by a [Qwiic cable](https://www.sparkfun.com/products/17260), to be connected the RA6M5 Thing Plus. The sketch demonstrates a basic BLE solution, by transmitting data from the BME280 to another BLE device. Users can find this sketch in the **File** > **Examples** > **SparkFun Renesas Codeless BLE** > **codelessBLE_peripheral** drop-down menu.
8080

81+
82+
??? arduino "Install Arduino Library"
83+
For this example, the [SparkFun BME280 Arduino Library](https://github.com/sparkfun/SparkFun_BME280_Arduino_Library) will need to be installed. In the Arduino IDE, users can install it by searching for `SparkFun BME280 Arduino Library`, in the **Library Manager**:
84+
85+
SparkFun BME280 Arduino Library
86+
87+
8188
??? code "`codelessBLE_peripheral.ino`"
8289
```cpp
8390
--8<-- "https://raw.githubusercontent.com/sparkfun/SparkFun_Thing_Plus_RA6M5/main/Firmware/CodelessBLE/examples/codelessBLE_peripheral/codelessBLE_peripheral.ino"
8491
```
8592

8693

94+
!!! tip "BME688 Replacement"
95+
Users can also modify this example to utilize the [Qwiic BME688 sensor](https://www.sparkfun.com/products/19096) that is mentioned in some of the other examples. *For more details on utilizing the BME68x breakout board, please refer to our [hookup guide](https://learn.sparkfun.com/tutorials/1168) for the sensor.*
96+
97+
98+
<div class="grid cards" markdown>
99+
100+
- <a href="https://www.sparkfun.com/products/19096">
101+
<figure markdown>
102+
![Product Thumbnail](https://cdn.sparkfun.com/assets/parts/1/8/6/9/6/19096-SparkFun_Environmental_Sensor_Breakout_-_BME688__Qwiic_-01.jpg)
103+
</figure>
104+
105+
---
106+
107+
**SparkFun Environmental Sensor - BME688 (Qwiic)**<br>
108+
SEN-19096</a>
109+
110+
111+
- <a href="https://www.sparkfun.com/products/17260">
112+
<figure markdown>
113+
![Product Thumbnail](https://cdn.sparkfun.com/assets/parts/1/6/2/4/7/17260-Flexible_Qwiic_Cable_-_50mm-01.jpg)
114+
</figure>
115+
116+
---
117+
118+
**Flexible Qwiic Cable - 50mm**<br>
119+
PRT-17260</a>
120+
121+
</div>
122+
123+
124+
??? arduino "Install Arduino Library"
125+
Users will need to install the [Bosch BME68x Arduino library](https://github.com/BoschSensortec/Bosch-BME68x-Library) for the sensor. In the Arduino IDE, users can install it by searching for `BME68x Sensor Library`, in the **Library Manager**:
126+
127+
BME68x Sensor Library
128+
129+
130+
??? code "Modifications"
131+
- Link the BME68x Arduino library:
132+
133+
{--#include "SparkFunBME280.h"--}
134+
{++#include "bme68xLibrary.h"++}
135+
136+
- Create an instance of the `Bme68x` class:
137+
138+
{--BME280 myBME280;--}
139+
{++Bme68x bme;++}
140+
141+
- Initialize and configure the sensor:
142+
143+
{--
144+
if(!myBME280.beginI2C())
145+
{
146+
Serial.println("Sensor didn't respond. Check wiring!");
147+
while(1);
148+
}
149+
150+
Serial.println("Connected to BME280.");
151+
--}
152+
{++
153+
bme.begin(BME68X_I2C_ADDR_LOW, Wire)
154+
155+
if(bme.checkStatus())
156+
{
157+
if (bme.checkStatus() == BME68X_ERROR)
158+
{
159+
Serial.println("Sensor error:" + bme.statusString());
160+
return;
161+
}
162+
else if (bme.checkStatus() == BME68X_WARNING)
163+
{
164+
Serial.println("Sensor Warning:" + bme.statusString());
165+
}
166+
}
167+
168+
/* Set the default configuration for temperature, pressure and humidity */
169+
bme.setTPH();
170+
171+
/* Configure the sensor to forced mode */
172+
bme.setOpMode(BME68X_FORCED_MODE);
173+
++}
174+
175+
- Update the `loop()` to retrieve data from the BME688
176+
177+
{--
178+
if((loop_start_time - millis()) > 100) // If it's been more than 100ms
179+
{
180+
reset_loop = true;
181+
if(bleConnected)
182+
{
183+
digitalWrite(LED_BUILTIN, HIGH);
184+
printstring = "|"+String(myBME280.readTempC())+","+String(myBME280.readFloatHumidity())+","+String(myBME280.readFloatPressure());
185+
Serial.print(myBLEPeripheral.sendCommand(printstring));
186+
digitalWrite(LED_BUILTIN, LOW);
187+
}
188+
--}
189+
{++
190+
191+
bme68xData data;
192+
193+
if((loop_start_time - millis()) > 100) // If it's been more than 100ms
194+
{
195+
reset_loop = true;
196+
if(bleConnected)
197+
{
198+
digitalWrite(LED_BUILTIN, HIGH);
199+
200+
delayMicroseconds(bme.getMeasDur()); // Wait for measurement data
201+
202+
/* Retrieve data from BME688 sensor*/
203+
if (bme.fetchData())
204+
{
205+
bme.getData(data);
206+
printstring = "|"+String(data.temperature)+","+String(data.humidity)+","+String(data.pressure);
207+
}
208+
209+
Serial.print(myBLEPeripheral.sendCommand(printstring));
210+
digitalWrite(LED_BUILTIN, LOW);
211+
}
212+
++}
213+
214+
215+
87216
=== "`codelessBLE_central.ino`"
88217
This sketch requires a [Qwiic OLED Display](https://www.sparkfun.com/products/24606) to be connected the RA6M5 Thing Plus, by a [Qwiic cable](https://www.sparkfun.com/products/17260). The sketch receives data transmitted from a RA6M5 Thing Plus, programmed with the `codelessBLE_peripheral.ino` sketch, and displays that data on the OLED display. Users can find this sketch in the **File** > **Examples** > **SparkFun Renesas Codeless BLE** > **codelessBLE_central** drop-down menu.
89218

0 commit comments

Comments
 (0)