Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Robot-Sensor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
René Ebeling
Robot-Sensor
Commits
0db73f0f
Commit
0db73f0f
authored
6 months ago
by
Rene Ebeling
Browse files
Options
Downloads
Patches
Plain Diff
changed the ST library to the library from the vl53l7cx
parent
d51f6c72
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Arduino/4_vl53l5cx_clean_with_STlibrary/4_vl53l7cx_clean_with_STlibrary/4_vl53l7cx_clean_with_STlibrary.ino
+42
-37
42 additions, 37 deletions
..._clean_with_STlibrary/4_vl53l7cx_clean_with_STlibrary.ino
images/pico-gpios-600x422.png
+0
-0
0 additions, 0 deletions
images/pico-gpios-600x422.png
with
42 additions
and
37 deletions
Arduino/4_vl53l5cx_clean_with_STlibrary/4_vl53l
5
cx_clean_with_STlibrary/4_vl53l
5
cx_clean_with_STlibrary.ino
→
Arduino/4_vl53l5cx_clean_with_STlibrary/4_vl53l
7
cx_clean_with_STlibrary/4_vl53l
7
cx_clean_with_STlibrary.ino
+
42
−
37
View file @
0db73f0f
/**
******************************************************************************
* @file VL53L
5
CX_Sat_HelloWorld.ino
* @file VL53L
7
CX_Sat_HelloWorld.ino
* @author STMicroelectronics
* @version V1.0.0
* @date 11 November 2021
* @brief Arduino test application for the STMicrolectronics VL53L
5
CX
* @brief Arduino test application for the STMicrolectronics VL53L
7
CX
* proximity sensor satellite based on FlightSense.
* This application makes use of C++ classes obtained from the C
* components' drivers.
...
...
@@ -38,22 +38,22 @@
******************************************************************************
*/
/*
* To use these examples you need to connect the VL53L
5
CX satellite sensor directly to the Nucleo board with wires as explained below:
* pin 1 (GND) of the VL53L
5
CX satellite connected to GND of the Nucleo board
* pin 2 (IOVDD) of the VL53L
5
CX satellite connected to 3V3 pin of the Nucleo board
* pin 3 (AVDD) of the VL53L
5
CX satellite connected to 5V pin of the Nucleo board
* pin 4 (PWREN) of the VL53L
5
CX satellite connected to pin A5 of the Nucleo board
* pin 5 (LPn) of the VL53L
5
CX satellite connected to pin A3 of the Nucleo board
* pin 6 (SCL) of the VL53L
5
CX satellite connected to pin D15 (SCL) of the Nucleo board
* pin 7 (SDA) of the VL53L
5
CX satellite connected to pin D14 (SDA) of the Nucleo board
* pin 8 (I2C_RST) of the VL53L
5
CX satellite connected to pin A1 of the Nucleo board
* pin 9 (INT) of the VL53L
5
CX satellite connected to pin A2 of the Nucleo board
* To use these examples you need to connect the VL53L
7
CX satellite sensor directly to the Nucleo board with wires as explained below:
* pin 1 (GND) of the VL53L
7
CX satellite connected to GND of the Nucleo board
* pin 2 (IOVDD) of the VL53L
7
CX satellite connected to 3V3 pin of the Nucleo board
* pin 3 (AVDD) of the VL53L
7
CX satellite connected to 5V pin of the Nucleo board
* pin 4 (PWREN) of the VL53L
7
CX satellite connected to pin A5 of the Nucleo board
* pin 5 (LPn) of the VL53L
7
CX satellite connected to pin A3 of the Nucleo board
* pin 6 (SCL) of the VL53L
7
CX satellite connected to pin D15 (SCL) of the Nucleo board
* pin 7 (SDA) of the VL53L
7
CX satellite connected to pin D14 (SDA) of the Nucleo board
* pin 8 (I2C_RST) of the VL53L
7
CX satellite connected to pin A1 of the Nucleo board
* pin 9 (INT) of the VL53L
7
CX satellite connected to pin A2 of the Nucleo board
*/
/* Includes ------------------------------------------------------------------*/
#include
<Arduino.h>
#include
<Wire.h>
#include
<ArduinoJson.h>
#include
<vl53l
5
cx_class.h>
#include
<vl53l
7
cx_class.h>
#include
<string.h>
#include
<stdlib.h>
#include
<stdio.h>
...
...
@@ -61,19 +61,19 @@
#include
<assert.h>
#include
<stdlib.h>
#define DEV_I2C Wire
#define DEV_I2C1 Wire1
#define DEV_I2C
0
Wire
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif
#define LedPin LED_BUILTIN
#define LPN_PIN0
3
#define LPN_PIN0
14
#define I2C_RST_PIN0 27
#define PWREN_PIN 27
#define LPN_PIN1
7
#define LPN_PIN1
15
#define I2C_RST_PIN1 27
#define PWREN_PIN 27
...
...
@@ -93,14 +93,15 @@ uint16_t sensoraddress3 = 0x67;
uint16_t
wait_for_i2c
=
50
;
uint16_t
imageWidth
=
8
;
uint16_t
ranging_frequency
=
15
;
pin_size_t
SDA1_PIN
=
6
;
pin_size_t
SCL1_PIN
=
7
;
JsonDocument
doc
;
// Components.
VL53L
5
CX
sensor0
(
&
DEV_I2C
,
LPN_PIN0
,
I2C_RST_PIN0
);
VL53L
5
CX
sensor1
(
&
DEV_I2C
,
LPN_PIN1
,
I2C_RST_PIN1
);
VL53L
5
CX
sensor2
(
&
DEV_I2C
,
LPN_PIN2
,
I2C_RST_PIN2
);
VL53L
5
CX
sensor3
(
&
DEV_I2C
,
LPN_PIN2
,
I2C_RST_PIN2
);
VL53L
7
CX
sensor0
(
&
DEV_I2C
0
,
LPN_PIN0
,
I2C_RST_PIN0
);
VL53L
7
CX
sensor1
(
&
DEV_I2C
0
,
LPN_PIN1
,
I2C_RST_PIN1
);
VL53L
7
CX
sensor2
(
&
DEV_I2C
0
,
LPN_PIN2
,
I2C_RST_PIN2
);
VL53L
7
CX
sensor3
(
&
DEV_I2C
0
,
LPN_PIN2
,
I2C_RST_PIN2
);
void
blink_led_loop
(
void
);
...
...
@@ -139,8 +140,12 @@ void setup()
Serial
.
println
(
"Initialize... Please wait, it may take few seconds..."
);
// Initialize I2C bus.
DEV_I2C
.
begin
();
DEV_I2C
.
setClock
(
1000000
);
DEV_I2C0
.
begin
();
DEV_I2C0
.
setClock
(
1000000
);
delay
(
50
);
DEV_I2C1
.
begin
();
DEV_I2C1
.
setClock
(
1000000
);
delay
(
50
);
// Initialize and configure sensors
...
...
@@ -163,10 +168,10 @@ void setup()
void
loop
()
{
// Declare the result data variables for each sensor
VL53L
5
CX_ResultsData
Results0
;
VL53L
5
CX_ResultsData
Results1
;
VL53L
5
CX_ResultsData
Results2
;
VL53L
5
CX_ResultsData
Results3
;
VL53L
7
CX_ResultsData
Results0
;
VL53L
7
CX_ResultsData
Results1
;
VL53L
7
CX_ResultsData
Results2
;
VL53L
7
CX_ResultsData
Results3
;
// Process each sensor data and save to respective JSON arrays
processSensorData
(
sensor0
,
Results0
,
doc
[
"sensor0"
].
to
<
JsonArray
>
(),
"sensor0"
);
...
...
@@ -196,7 +201,7 @@ void i2cScanner()
delay
(
wait_for_i2c
);
}
void
initializeSensor
(
VL53L
5
CX
&
sensor
,
uint16_t
sensorAddress
,
int
lpnPin
,
int
i2cRstPin
)
{
void
initializeSensor
(
VL53L
7
CX
&
sensor
,
uint16_t
sensorAddress
,
int
lpnPin
,
int
i2cRstPin
)
{
digitalWrite
(
lpnPin
,
HIGH
);
// Activate sensor power
delay
(
wait_for_i2c
);
...
...
@@ -206,30 +211,30 @@ void initializeSensor(VL53L5CX &sensor, uint16_t sensorAddress, int lpnPin, int
delay
(
wait_for_i2c
);
// Set I2C address
sensor
.
vl53l
5
cx_set_i2c_address
(
sensorAddress
<<
1
);
sensor
.
vl53l
7
cx_set_i2c_address
(
sensorAddress
<<
1
);
delay
(
wait_for_i2c
);
// Set resolution and frequency
sensor
.
vl53l
5
cx_set_resolution
(
VL53L
5
CX_RESOLUTION_8X8
);
sensor
.
vl53l
7
cx_set_resolution
(
VL53L
7
CX_RESOLUTION_8X8
);
delay
(
wait_for_i2c
);
sensor
.
vl53l
5
cx_set_ranging_frequency_hz
(
ranging_frequency
);
sensor
.
vl53l
7
cx_set_ranging_frequency_hz
(
ranging_frequency
);
delay
(
wait_for_i2c
);
// Start ranging
sensor
.
vl53l
5
cx_start_ranging
();
sensor
.
vl53l
7
cx_start_ranging
();
delay
(
wait_for_i2c
);
// Reset LPN and I2C pins
digitalWrite
(
lpnPin
,
LOW
);
}
void
processSensorData
(
VL53L
5
CX
&
sensor
,
VL53L
5
CX_ResultsData
&
results
,
const
JsonArray
&
data
,
const
char
*
sensorKey
)
{
void
processSensorData
(
VL53L
7
CX
&
sensor
,
VL53L
7
CX_ResultsData
&
results
,
const
JsonArray
&
data
,
const
char
*
sensorKey
)
{
uint8_t
NewDataReady
=
0
;
uint8_t
status
;
// Wait for data to be ready
do
{
status
=
sensor
.
vl53l
5
cx_check_data_ready
(
&
NewDataReady
);
status
=
sensor
.
vl53l
7
cx_check_data_ready
(
&
NewDataReady
);
}
while
(
!
NewDataReady
);
// Turn LED on to indicate data processing
...
...
@@ -237,13 +242,13 @@ void processSensorData(VL53L5CX &sensor, VL53L5CX_ResultsData &results, const Js
// If data is ready, get the ranging data and store it in the JSON array
if
((
!
status
)
&&
(
NewDataReady
!=
0
))
{
status
=
sensor
.
vl53l
5
cx_get_ranging_data
(
&
results
);
status
=
sensor
.
vl53l
7
cx_get_ranging_data
(
&
results
);
JsonArray
sensorData
=
doc
[
sensorKey
].
to
<
JsonArray
>
();
// Process the results and add them to the JSON array
for
(
int
y
=
imageWidth
*
(
imageWidth
-
1
);
y
>=
0
;
y
-=
imageWidth
)
{
for
(
int
x
=
0
;
x
<=
imageWidth
-
1
;
x
++
)
{
sensorData
.
add
(
results
.
distance_mm
[
VL53L
5
CX_NB_TARGET_PER_ZONE
*
(
x
+
y
)]);
sensorData
.
add
(
results
.
distance_mm
[
VL53L
7
CX_NB_TARGET_PER_ZONE
*
(
x
+
y
)]);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
images/pico-gpios-600x422.png
0 → 100644
+
0
−
0
View file @
0db73f0f
105 KiB
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment