Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
249ec0f
Adjusts example 1, adds additional function to ultrasonic class
edspark May 27, 2024
82ea547
Adds some examples that will be rolled in shortly
edspark May 28, 2024
8cf35e8
Adds write to getDistance
edspark May 28, 2024
64bff81
Adds I2C commands to relevant function
edspark May 28, 2024
11ad0f1
Updates examples, add comments, and licenses
edspark May 29, 2024
e0bc499
Removes unterminated comment
edspark May 29, 2024
ee168f5
Fixes missing include and indentation
edspark May 29, 2024
fe78ad5
Changes name of example 2 for camel case consistency
edspark May 29, 2024
89efacb
Uses the new writeBlock method, changes type for changeAddress functi…
edspark May 30, 2024
5131495
Removes bus files, adds bus files as submodule (may not work), adds w…
edspark May 30, 2024
3663b74
Fixes submodule path (maybe)
edspark May 30, 2024
00e5dd6
Adds toolkit as dependency for Arduino library manager
edspark May 30, 2024
4523063
Removes underscore in Toolkit listing
edspark May 30, 2024
6997329
Removes git submodule
edspark May 30, 2024
e5bf0b2
Updates workflow
edspark May 30, 2024
0b4ba7a
Fixes polarity of echo pin to reflect change to firmware
edspark May 31, 2024
787e410
Cleaning up last example
edspark Jun 3, 2024
b47b595
Re-adds dependency
edspark Jun 5, 2024
9e4e186
Re-adds original `changeAddress` function and changes the current on …
edspark Jun 6, 2024
c6415b9
Changes conversion function
edspark Jun 7, 2024
d5ecebc
Adds link to OLED library
edspark Jun 7, 2024
41d07b8
Adds updated method for changing address while commenting out older m…
edspark Jun 7, 2024
b8715e0
Reorders examples
edspark Jun 7, 2024
c4f3779
Adds example using trigger and echo pins
edspark Jun 7, 2024
ac1f217
Removes include
edspark Jun 14, 2024
35223a5
Adds new parameter to constructor, updates examples with new parameter
edspark Jun 18, 2024
fe2c0aa
Minor fix to function calls now used in the toolkit
edspark Jun 18, 2024
d100f66
Fix to firmware check
edspark Jun 18, 2024
5a36824
Fixes to comments and some formatting
edspark Jun 18, 2024
c58db09
Adds on more comment
edspark Jun 18, 2024
c51c6b0
Changes `getDistance()` back to its original name `triggerAndRead()`
edspark Jun 19, 2024
8668f36
Removes erroneous include
edspark Jun 19, 2024
4578da4
Fixes error when writing new address to the ultrasonic object forcing…
edspark Jun 21, 2024
2278ae6
Update README.md
loricrotser Jun 21, 2024
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
16 changes: 16 additions & 0 deletions .github/workflows/add_issue_to_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Add new issue to main project

on:
issues:
types:
- opened

jobs:
add-to-project:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@main
with:
project-url: https://github.com/orgs/sparkfun/projects/19
github-token: ${{ secrets.DEFECT_ADD_TO_PROJECT }}
110 changes: 110 additions & 0 deletions .github/workflows/compile-sketch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Cross-compilation

on:
- push
#- pull_request


jobs:
compile-sketch:
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
board:
# Uno
# https://github.com/arduino/ArduinoCore-avr/blob/master/boards.txt
- fqbn: arduino:avr:mega
platforms: |
- name: arduino:avr
source-url: https://downloads.arduino.cc/packages/package_index.json

# ESP32
# https://github.com/espressif/arduino-esp32/blob/master/boards.txt
- fqbn: esp32:esp32:esp32
platforms: |
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

# ESP32-S2
# https://github.com/espressif/arduino-esp32/blob/master/boards.txt
- fqbn: esp32:esp32:esp32s2
platforms: |
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

# ESP32-C3
# https://github.com/espressif/arduino-esp32/blob/master/boards.txt
- fqbn: esp32:esp32:esp32c3
platforms: |
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

# Artemis / Apollo3
# https://github.com/sparkfun/Arduino_Apollo3/blob/main/boards.txt
- fqbn: SparkFun:apollo3:sfe_artemis_atp
platforms: |
- name: SparkFun:apollo3
source-url: https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/master/package_sparkfun_apollo3_index.json

# ESP8266
# https://github.com/esp8266/Arduino/blob/master/boards.txt
- fqbn: esp8266:esp8266:thingdev
platforms: |
- name: esp8266:esp8266
source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json

# SAMD21
# https://github.com/arduino/ArduinoCore-samd/blob/master/boards.txt
- fqbn: arduino:samd:mkr1000
platforms: |
- name: arduino:samd
# source-url: https://downloads.arduino.cc/packages/package_index.json

# Nano BLE 33 / nRF52840
# https://github.com/arduino/ArduinoCore-mbed/blob/master/boards.txt
- fqbn: arduino:mbed:nano33ble
platforms: |
- name: arduino:mbed
# source-url: https://downloads.arduino.cc/packages/package_index.json

# RP2040
# https://github.com/arduino/ArduinoCore-mbed/blob/master/boards.txt
- fqbn: rp2040:rp2040:sparkfun_promicrorp2040
platforms: |
- name: rp2040:rp2040
source-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

# STM32
# https://github.com/arduino/ArduinoCore-mbed/blob/master/boards.txt
- fqbn: STMicroelectronics:stm32:GenF4
platforms: |
- name: STMicroelectronics:stm32
source-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Branch name
run: echo running on branch ${GITHUB_REF##*/}

- name: Compile Sketch
uses: arduino/compile-sketches@v1.1.0
with:
platforms: ${{ matrix.board.platforms }}
fqbn: ${{ matrix.board.fqbn }}
libraries: |
- source-path: ./
- name: SparkFun Toolkit
sketch-paths: |
- examples/Example1_BasicReadings
enable-warnings-report: true
enable-deltas-report: true
verbose: true

# outputs:
# report-artifact-name: ${{ steps.report-artifact-name.outputs.report-artifact-name }}

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
</th>
</tr>
<tr align="center">
<td><a href="https://www.sparkfun.com/products/17777"><img src="https://cdn.sparkfun.com//assets/parts/1/6/9/1/6/17777-SparkFun_Qwiic_Ultrasonic_Distance_Sensor_-_HC-SR04-01.jpg" alt=""></a></td>
<td><a href="https://www.sparkfun.com/products/24805"><img src="https://cdn.sparkfun.com/assets/parts/2/5/0/9/7/SEN-24805-Ultrasonic-Distance-Sensor-Feature.jpg" alt=""></a></td>
</tr>
<tr align="center">
<td><a href="https://www.sparkfun.com/products/17777">SparkFun Qwiic Ultrasonic Distance Sensor - HC-SR04</a></td>
<td><a href="https://www.sparkfun.com/products/24805">SparkFun Ultrasonic Distance Sensor - TCT40 (Qwiic)</a></td>
</tr>
</table>

You may be familiar with the classic [HC-SR04 distance sensor](https://www.sparkfun.com/products/15569), it is great for providing non-contact distance readings from 2cm to 400cm. The SparkFun Qwiic Ultrasonic Distance Sensor improves on the classic by adding a pair of Qwiic connectors to it, so now you can communicate over I2C and daisy chain any other Qwiic product of your choosing.
The SparkFun Qwiic Ultrasonic Distance Sensor, a user-friendly upgrade to the popular HC-SR04 sensor, offers non-contact distance measurement from 2cm to 400cm with an accuracy of 3mm. This sensor is designed to seamlessly integrate with the Qwiic ecosystem for I<sup>2</sup>C communication, making it a breeze to add to your existing projects and daisy-chain with other Qwiic components.

If you prefer to bypass the Qwiic connector and I2C you can also access the VCC, Trigger, Echo, and Ground pins broken out on the edge of the board. Please be aware that this ultrasonic sensor comes uncalibrated and you will need manipulate the raw output for your specific application.
With its wide range of applications, the SparkFun Qwiic Ultrasonic Distance Sensor is a versatile tool for robotics projects, obstacle avoidance systems, and any application that requires accurate distance measurement without physical contact. Its adaptability makes it a valuable addition to your toolkit.

Repository Contents
-------------------
Expand All @@ -27,8 +27,8 @@ Repository Contents

Documentation
--------------
* **[GitHub Repo](https://github.com/sparkfun/Zio-Qwiic-Ultrasonic-Distance-Sensor)** - GitHub repo for the SparkFun Qwiic Ultrasonic Distance Sensor - HC-SR04 Hardware Files.
* **[Hookup Guide](https://learn.sparkfun.com/tutorials/qwiic-ultrasonic-distance-sensor-hc-sr04-hookup-guide)** - Basic hookup guide for the SparkFun Qwiic Ultrasonic Distance Sensor - HC-SR04.
* **[GitHub Repo](https://github.com/sparkfun/SparkFun_Ultrasonic_Distance_Sensor-Qwiic/tree/v11_Firmware_v01)** - GitHub repo for the SparkFun Ultrasonic Distance Sensor - TCT40 (Qwiic) Hardware Files.
* **[Hookup Guide](https://docs.sparkfun.com/SparkFun_Ultrasonic_Distance_Sensor-Qwiic/)** - Basic hookup guide for the SparkFun Ultrasonic Distance Sensor - TCT40 (Qwiic).

License Information
-------------------
Expand Down
64 changes: 41 additions & 23 deletions examples/Example1_BasicReadings/Example1_BasicReadings.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/* SparkFun Ulrasonic Distance Sensor - Example 1 Basic Distance Sensing
*
* Product:
* * SparkFun Qwiic Ultrasonic Distance Sensor - HC-SR04 (SEN-1XXXX)
* * https://www.sparkfun.com/1XXXX
*
* Written By: Elias Santistevan
* Date: 06/2024
*
* SPDX-License-Identifier: MIT
*
* Copyright (c) 2024 SparkFun Electronics
*/

#include "SparkFun_Qwiic_Ultrasonic_Arduino_Library.h"

// Create an ultrasonic sensor object
Expand All @@ -12,33 +26,37 @@ uint8_t deviceAddress = kQwiicUltrasonicDefaultAddress; // 0x2F

void setup()
{
// Start serial
Serial.begin(115200);
Serial.println("Qwiic Ultrasonic Example 1 - Basic Readings");
// Start serial
Serial.begin(115200);
Serial.println("Ultrasonic Distance Sensor Example 1 - Basic Readings");

Wire.begin();
Wire.begin();

// Attempt to begin the sensor
while (myUltrasonic.begin(deviceAddress) == false)
{
Serial.println("Ultrasonic sensor not connected, check your wiring and I2C address!");
delay(1000);
}
// Attempt to begin the sensor
while (myUltrasonic.begin(deviceAddress) == false)
{
Serial.println("Ultrasonic sensor not connected, check your wiring and I2C address!");
delay(2000);
}

Serial.println("Ultrasonic sensor connected!");
Serial.println("Ultrasonic sensor connected!");
}

void loop()
{
// Get measurement from sensor. Note that the mesaured distance actually
// comes from the previous trigger, so measurements will be slightly delayed
uint16_t distance = 0;
myUltrasonic.triggerAndRead(distance);

// Print measurement
Serial.print("Distance (mm): ");
Serial.println(distance);

// Wait a bit
delay(100);
}
uint16_t distance = 0;
myUltrasonic.triggerAndRead(distance);

// Print measurement
Serial.print("Distance (mm): ");
Serial.println(distance);

//Serial.println("Distance (cm): ");
//Serial.print((distance / 10.0), 2);

//Serial.println("Distace (in): ");
//Serial.print((distance / 25.4), 2);

// Wait a bit
delay(250);
}
94 changes: 0 additions & 94 deletions examples/Example2_ChangeAddress/Example2_ChangeAddress.ino

This file was deleted.

Loading