Skip to content

Commit a6e0bca

Browse files
authored
Merge pull request #1 from gbr1/ext
added ultrasonic and external temperature
2 parents 265460f + 81eb3f4 commit a6e0bca

11 files changed

+312
-86
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# General
2+
.DS_Store
3+
.AppleDouble
4+
.LSOverride
5+
6+
# Icon must end with two \r
7+
Icon
8+
9+
# Thumbnails
10+
._*
11+
12+
# Files that might appear in the root of a volume
13+
.DocumentRevisions-V100
14+
.fseventsd
15+
.Spotlight-V100
16+
.TemporaryItems
17+
.Trashes
18+
.VolumeIcon.icns
19+
.com.apple.timemachine.donotpresent
20+
21+
# Directories potentially created on remote AFP share
22+
.AppleDB
23+
.AppleDesktop
24+
Network Trash Folder
25+
Temporary Items
26+
.apdisk

examples/ScienceJournal/ScienceJournal.ino

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
This file is part of the Arduino_GroveI2C_Ultrasonic library.
2+
This file is part of the Arduino_ScienceKitCarrier library.
33
Copyright (c) 2023 Arduino SA. All rights reserved.
44
55
This library is free software; you can redistribute it and/or
@@ -24,17 +24,14 @@ unsigned long lastNotify = 0;
2424

2525
ScienceKitCarrier science_kit;
2626

27-
rtos::Thread _t(osPriorityHigh);
28-
rtos::Thread _tu;
29-
27+
rtos::Thread _thread_update_sensors;
3028

29+
bool _is_connected = false;
3130

3231

3332
void setup() {
34-
pinMode(8,OUTPUT);
35-
pinMode(7,OUTPUT);
3633

37-
science_kit.begin(NO_AUXILIARY_THREADS); // Doesn't start the BME688 thread for the moment
34+
science_kit.begin(NO_AUXILIARY_THREADS); // Doesn't start the BME688 and external temperature threads for the moment
3835

3936
if (!BLE.begin()) {
4037
while(1);
@@ -75,34 +72,22 @@ void setup() {
7572

7673
BLE.addService(service);
7774
BLE.advertise();
78-
science_kit.startAuxiliaryThreads(); // start the BME688 thread
79-
_t.start(loop_data);
80-
_tu.start(update);
81-
}
8275

83-
bool _is_connected = false;
76+
science_kit.startAuxiliaryThreads(); // start the BME688 and External Temperature Probe threads
8477

85-
void loop_data() {
86-
bool last_connected_status = _is_connected;
87-
while (1) {
88-
delay(1000);
89-
if (last_connected_status != _is_connected) {
90-
digitalWrite(7, _is_connected ? HIGH : LOW);
91-
}
92-
}
78+
//_thread_check_connection.start(loop_data);
79+
_thread_update_sensors.start(update); // this thread updates sensors
9380
}
9481

82+
9583
void update(void){
9684
while(1){
97-
digitalWrite(8,HIGH);
9885
science_kit.update(ROUND_ROBIN_ENABLED);
99-
digitalWrite(8,LOW);
10086
rtos::ThisThread::sleep_for(20);
10187
}
10288
}
10389

104-
void loop() {
105-
90+
void loop(){
10691
BLEDevice central = BLE.central();
10792
if (central) {
10893
_is_connected = true;
@@ -112,9 +97,9 @@ void loop() {
11297
updateSubscribedCharacteristics();
11398
lastNotify=millis();
11499
}
115-
116100
}
117-
} else {
101+
}
102+
else {
118103
delay(100);
119104
_is_connected = false;
120105
}
@@ -182,12 +167,19 @@ void updateSubscribedCharacteristics() {
182167
humidityCharacteristic.writeValue(science_kit.getHumidity());
183168
}
184169

170+
// need to be fix
185171
if(sndIntensityCharacteristic.subscribed()) {
186-
sndIntensityCharacteristic.writeValue(0);
172+
if (science_kit.getUltrasonicIsConnected()){
173+
sndIntensityCharacteristic.writeValue(science_kit.getDistance()*100.0);
174+
}
175+
else{
176+
sndIntensityCharacteristic.writeValue(-1.0);
177+
}
187178
}
188179

180+
// need to be fix
189181
if(sndPitchCharacteristic.subscribed()) {
190-
sndPitchCharacteristic.writeValue(0);
182+
sndPitchCharacteristic.writeValue(science_kit.getExternalTemperature());
191183
}
192184

193185
if (inputACharacteristic.subscribed()){

examples/ScienceJournal/ble_config.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
This file is part of the Arduino_ScienceKitCarrier library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
120
#ifndef __BLE_CONFIG_H__
221
#define __BLE_CONFIG_H__
322

examples/simple_temperature/simple_temperature.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
This file is part of the Arduino_GroveI2C_Ultrasonic library.
2+
This file is part of the Arduino_ScienceKitCarrier library.
33
Copyright (c) 2023 Arduino SA. All rights reserved.
44
55
This library is free software; you can redistribute it and/or

keywords.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ getPhase2 KEYWORD2
6969
getRange1 KEYWORD2
7070
getRange2 KEYWORD2
7171

72+
beginUltrasonic KEYWORD2
73+
updateUltrasonic KEYWORD2
74+
getDistance KEYWORD2
75+
getTravelTime KEYWORD2
76+
getUltrasonicIsConnected KEYWORD2
77+
78+
beginExternalTemperature KEYWORD2
79+
updateExternalTemperature KEYWORD2
80+
getExternalTemperature KEYWORD2
81+
getExternalTemperatureIsConnected KEYWORD2
82+
threadExternalTemperature KEYWORD2
83+
7284
#######################################
7385
# Constants
7486
#######################################
@@ -91,15 +103,22 @@ G_EARTH LITERAL1
91103

92104
BME688_CS LITERAL1
93105

106+
OW_PIN LITERAL1
107+
EXTERNAL_TEMPERATURE_DISABLED LITERAL1
108+
94109
ERR_BEGIN_APDS LITERAL1
95110
ERR_BEGIN_INA LITERAL1
96111
ERR_BEGIN_IMU LITERAL1
97112
ERR_BEGIN_BME LITERAL1
98113
ERR_BEGIN_RESISTANCE LITERAL1
99114
ERR_BEGIN_FUNCTION_GENERATOR_CONTROLLER LITERAL1
115+
ERR_BEGIN_ULTRASONIC LITERAL1
116+
ERR_BEGIN_EXTERNAL_TEMPERATURE LITERAL1
100117

101118
ROUND_ROBIN_DISABLED LITERAL1
102119
ROUND_ROBIN_ENABLED LITERAL1
103120

104-
START_AUXILIARY_THREADS LITERAL1
105121
NO_AUXILIARY_THREADS LITERAL1
122+
START_AUXILIARY_THREADS LITERAL1
123+
START_INTERNAL_AMBIENT_SENSOR LITERAL1
124+
START_EXTERNAL_AMBIENT_SENSOR LITERAL1

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Arduino_ScienceKitCarrier
2-
version=0.1.0
2+
version=0.1.8
33
author=Arduino, Giovanni di Dio Bruno
44
maintainer=Arduino <info@arduino.cc>
55
sentence=Library and firmware for Arduino Science Kit R3
@@ -8,4 +8,4 @@ category=Communication
88
url=https://github.com/gbr1/Arduino_ScienceKitCarrier
99
architectures=mbed,mbed_nano
1010
includes=Arduino_ScienceKitCarrier.h
11-
depends=Arduino_APDS9960,ArduinoBLE,WiFiNINA,INA2xx,Arduino_BMI270_BMM150,BSEC Software Library
11+
depends=Arduino_APDS9960,ArduinoBLE,WiFiNINA,INA2xx,Arduino_BMI270_BMM150,BSEC Software Library,Arduino_GroveI2C_Ultrasonic,OneWireNg

0 commit comments

Comments
 (0)