Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-010
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-010
2021-010
Commits
b766716c
Commit
b766716c
authored
Jun 21, 2021
by
Lakshan Wijewardana W.M.W-IT18132588
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update files
parent
a3612a17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
25 deletions
+160
-25
Esp-32-wifi_module/test1.ino
Esp-32-wifi_module/test1.ino
+0
-25
Esp-32-wifi_module/test1/test1.ino
Esp-32-wifi_module/test1/test1.ino
+160
-0
No files found.
Esp-32-wifi_module/test1.ino
deleted
100644 → 0
View file @
a3612a17
#include <BlynkSimpleEsp32.h>
// You should get Auth Token in the Blynk App.
char
auth
[]
=
"6ikeJYVUS8PQafB-0GB37QZLsU_KosZx"
;
// Your WiFi credentials.
// Set password to "" for open networks.
char
ssid
[]
=
"Lakshan|-_-|"
;
char
pass
[]
=
"641080748v"
;
int
led
=
32
;
void
setup
()
{
// Debug console
Serial
.
begin
(
9600
);
Blynk
.
begin
(
auth
,
ssid
,
pass
);
pinMode
(
led
,
OUTPUT
);
}
void
loop
()
{
Blynk
.
run
();
}
Esp-32-wifi_module/test1/test1.ino
0 → 100644
View file @
b766716c
// Your sketch must #include this library, and the Wire library
// (Wire is a standard library included with Arduino):
#include <SparkFunTSL2561.h>
#include <Wire.h>
// Create an SFE_TSL2561 object, here called "light":
SFE_TSL2561
light
;
// Global variables:
boolean
gain
;
// Gain setting, 0 = X1, 1 = X16;
unsigned
int
ms
;
// Integration ("shutter") time in milliseconds
void
setup
()
{
// Initialize the Serial port:
Serial
.
begin
(
9600
);
Serial
.
println
(
"TSL2561 example sketch"
);
// Initialize the SFE_TSL2561 library
light
.
begin
();
// Get factory ID from sensor:
// (Just for fun, you don't need to do this to operate the sensor)
unsigned
char
ID
;
if
(
light
.
getID
(
ID
))
{
Serial
.
print
(
"Got factory ID: 0X"
);
Serial
.
print
(
ID
,
HEX
);
Serial
.
println
(
", should be 0X5X"
);
}
// Most library commands will return true if communications was successful,
// and false if there was a problem. You can ignore this returned value,
// or check whether a command worked correctly and retrieve an error code:
else
{
byte
error
=
light
.
getError
();
printError
(
error
);
}
// The light sensor has a default integration time of 402ms,
// and a default gain of low (1X).
// If you would like to change either of these, you can
// do so using the setTiming() command.
// If gain = false (0), device is set to low gain (1X)
// If gain = high (1), device is set to high gain (16X)
gain
=
0
;
// If time = 0, integration will be 13.7ms
// If time = 1, integration will be 101ms
// If time = 2, integration will be 402ms
// If time = 3, use manual start / stop to perform your own integration
unsigned
char
time
=
2
;
// setTiming() will set the third parameter (ms) to the
// requested integration time in ms (this will be useful later):
Serial
.
println
(
"Set timing..."
);
light
.
setTiming
(
gain
,
time
,
ms
);
// To start taking measurements, power up the sensor:
Serial
.
println
(
"Powerup..."
);
light
.
setPowerUp
();
// The sensor will now gather light during the integration time.
// After the specified time, you can retrieve the result from the sensor.
// Once a measurement occurs, another integration period will start.
}
void
loop
()
{
// ms = 1000;
// light.manualStart();
delay
(
ms
);
// light.manualStop();
// Once integration is complete, we'll retrieve the data.
// There are two light sensors on the device, one for visible light
// and one for infrared. Both sensors are needed for lux calculations.
// Retrieve the data from the device:
unsigned
int
data0
,
data1
;
if
(
light
.
getData
(
data0
,
data1
))
{
// getData() returned true, communication was successful
Serial
.
print
(
"data0: "
);
Serial
.
print
(
data0
);
Serial
.
print
(
" data1: "
);
Serial
.
print
(
data1
);
// To calculate lux, pass all your settings and readings
// to the getLux() function.
double
lux
;
// Resulting lux value
boolean
good
;
// True if neither sensor is saturated
// Perform lux calculation:
good
=
light
.
getLux
(
gain
,
ms
,
data0
,
data1
,
lux
);
// Print out the results:
Serial
.
print
(
" lux: "
);
Serial
.
print
(
lux
);
if
(
good
)
Serial
.
println
(
" (good)"
);
else
Serial
.
println
(
" (BAD)"
);
}
else
{
// getData() returned false because of an I2C error, inform the user.
byte
error
=
light
.
getError
();
printError
(
error
);
}
}
void
printError
(
byte
error
)
// If there's an I2C error, this function will
// print out an explanation.
{
Serial
.
print
(
"I2C error: "
);
Serial
.
print
(
error
,
DEC
);
Serial
.
print
(
", "
);
switch
(
error
)
{
case
0
:
Serial
.
println
(
"success"
);
break
;
case
1
:
Serial
.
println
(
"data too long for transmit buffer"
);
break
;
case
2
:
Serial
.
println
(
"received NACK on address (disconnected?)"
);
break
;
case
3
:
Serial
.
println
(
"received NACK on data"
);
break
;
case
4
:
Serial
.
println
(
"other error"
);
break
;
default:
Serial
.
println
(
"unknown error"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment