Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
November 2021 Blimp Competition
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Shahrul Kamil bin Hassan
November 2021 Blimp Competition
Commits
92f3c4ed
Commit
92f3c4ed
authored
3 years ago
by
Zhaoliang Zheng
Browse files
Options
Downloads
Patches
Plain Diff
upgrade the distance and send it all together
parent
4df58dbc
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/ESP32_communication/Two-way/ESP32_master/ESP32_master.ino
+9
-4
9 additions, 4 deletions
...ESP32_communication/Two-way/ESP32_master/ESP32_master.ino
Code/ESP32_communication/Two-way/ESP32_slave/ESP32_slave.ino
+18
-8
18 additions, 8 deletions
Code/ESP32_communication/Two-way/ESP32_slave/ESP32_slave.ino
with
27 additions
and
12 deletions
Code/ESP32_communication/Two-way/ESP32_master/ESP32_master.ino
+
9
−
4
View file @
92f3c4ed
...
...
@@ -3,7 +3,8 @@
#include
<Wire.h>
// REPLACE WITH THE MAC Address of your receiver (SLAVE)
uint8_t
broadcastAddress
[]
=
{
0x40
,
0xF5
,
0x20
,
0x44
,
0xB6
,
0x4C
};
// uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xB6, 0x4C}; // #4
uint8_t
broadcastAddress
[]
=
{
0xC4
,
0xDD
,
0x57
,
0x9E
,
0x91
,
0x74
};
// #1
String
success
;
// Define variables to store BME280 readings to be sent
...
...
@@ -11,6 +12,7 @@ String strdata = "";
String
valdata
=
""
;
String
quedata
=
""
;
int
count
=
0
;
int
count_digit
=
0
;
// Define variables to store incoming readings
String
incomingStr
=
""
;
...
...
@@ -100,9 +102,11 @@ void loop()
sentData
.
StrD
=
strdata
;
Serial
.
println
(
sentData
.
StrD
);
}
if
(
isDigit
(
inChar
)
||
inChar
==
'.'
||
inChar
==
'-'
){
if
(
(
isDigit
(
inChar
)
||
inChar
==
'.'
||
inChar
==
'-'
)
&&
(
count_digit
<=
9
))
{
valdata
+=
char
(
inChar
);
count_digit
+=
1
;
}
if
(
inChar
==
'?'
){
quedata
+=
char
(
inChar
);
sentData
.
QueM
=
quedata
;
...
...
@@ -119,8 +123,8 @@ void loop()
sentData
.
QueM
=
""
;
}
else
{
// sentData.ValD = 0;
Serial
.
print
(
"ValD"
);
Serial
.
println
(
sentData
.
ValD
);
Serial
.
print
(
"ValD"
);
Serial
.
println
(
sentData
.
ValD
);
Serial
.
print
(
"QueM:"
);
Serial
.
println
(
sentData
.
QueM
);
}
...
...
@@ -135,6 +139,7 @@ void loop()
strdata
=
""
;
quedata
=
""
;
count
=
0
;
count_digit
=
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Code/ESP32_communication/Two-way/ESP32_slave/ESP32_slave.ino
+
18
−
8
View file @
92f3c4ed
...
...
@@ -4,7 +4,8 @@
// REPLACE WITH THE MAC Address of your receiver (MASTER)
// Slave: 40:F5:20:44:B6:4C
uint8_t
broadcastAddress
[]
=
{
0x3C
,
0x61
,
0x05
,
0x4A
,
0xCF
,
0x00
};
// uint8_t broadcastAddress[] = {0x3C, 0x61, 0x05, 0x4A, 0xCF, 0x00};
uint8_t
broadcastAddress
[]
=
{
0x40
,
0xF5
,
0x20
,
0x44
,
0xB6
,
0x4C
};
// #4
String
success
;
// Define variables to store BME280 readings to be sent
...
...
@@ -27,9 +28,8 @@ int8_t threshold[6] = {Lmin, Lmax, Amin, Amax, Bmin, Bmax};
int
base_speed
=
70
;
int
seeking_speed
=
70
;
int
lidar_thres
=
300
;
// mm
int
gbx
=
0
,
gby
=
0
;
int
gbx
=
0
,
gby
=
0
,
gbd
=
0
;
double
gbc
=
0
;
// =====================================================================================
//Structure the sending data
...
...
@@ -262,8 +262,13 @@ void ChangeVariables(){
lidar_thres
=
getDoubleVal
(
strData
,
"lth"
,
valData
,
lidar_thres
);
//------ green ball x, y----
gbx
=
getDoubleVal
(
strData
,
"gbx"
,
valData
,
gbx
);
gby
=
getDoubleVal
(
strData
,
"gby"
,
valData
,
gby
);
gbc
=
getDoubleVal
(
strData
,
"gbc"
,
valData
,
gbc
);
gbx
=
gbc
/
1000000
;
gby
=
fmod
(
gbc
,
1000000
)
/
1000
;
//(gbc.toInt() % 1000000)/1000;
gbd
=
fmod
(
gbc
,
1000
);
// gbc.toInt() % 1000;
// gbx = getDoubleVal(strData,"gbx",valData,gbx);
// gby = getDoubleVal(strData,"gby",valData,gby);
}
...
...
@@ -338,12 +343,17 @@ void print_allvariables(){
Serial
.
print
(
"Kpy:"
);
Serial
.
println
(
Kpy
);
Serial
.
print
(
"|"
);
Serial
.
print
(
"gbc:"
);
Serial
.
print
(
gbc
);
Serial
.
print
(
"|"
);
Serial
.
print
(
"gbx:"
);
Serial
.
print
(
gbx
);
Serial
.
print
(
"|"
);
Serial
.
print
(
"gby:"
);
Serial
.
println
(
gby
);
Serial
.
print
(
gby
);
Serial
.
print
(
"gbd:"
);
Serial
.
println
(
gbd
);
Serial
.
println
(
"---------------------------
\n
"
);
print_count
+=
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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