Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arduino-block-course
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
Stefan Gehr
arduino-block-course
Commits
ef9b0477
Commit
ef9b0477
authored
2 years ago
by
Stefan Gehr
Browse files
Options
Downloads
Patches
Plain Diff
bugfixes and stuff for testing
parent
9c65511a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
solarpump/sayNumber.ino
+39
-39
39 additions, 39 deletions
solarpump/sayNumber.ino
solarpump/solarpump.ino
+7
-3
7 additions, 3 deletions
solarpump/solarpump.ino
solarpump/temperature.ino
+42
-9
42 additions, 9 deletions
solarpump/temperature.ino
with
88 additions
and
51 deletions
solarpump/sayNumber.ino
+
39
−
39
View file @
ef9b0477
This diff is collapsed.
Click to expand it.
solarpump/solarpump.ino
+
7
−
3
View file @
ef9b0477
...
...
@@ -27,7 +27,7 @@ static int8_t checkButton() {
}
// 5 C temperature difference turns a pump on
const
float
ONTEMPDIFF
=
5
.0
;
const
float
ONTEMPDIFF
=
20
.0
;
// At 1 C difference it turns off again
const
float
OFFTEMPDIFF
=
1.0
;
...
...
@@ -35,13 +35,13 @@ void controlPump(uint8_t pumpPin, float tempUp, float tempDown) {
// pump is turned on
if
(
digitalRead
(
pumpPin
))
{
// turn it off if the difference is less than OFFTEMPDIFF
if
(
tempUp
-
tempDown
<
O
N
TEMPDIFF
)
{
if
(
tempUp
<
tempDown
+
O
FF
TEMPDIFF
)
{
digitalWrite
(
pumpPin
,
LOW
);
}
// pump is turned off
}
else
{
// turn it on if the difference is more than ONTEMPDIFF
if
(
tempUp
-
tempDown
>
ONTEMPDIFF
)
{
if
(
tempUp
>
tempDown
+
ONTEMPDIFF
)
{
digitalWrite
(
pumpPin
,
HIGH
);
}
}
...
...
@@ -159,8 +159,12 @@ void displayLight(bool turnOn) {
void
setup
(
void
)
{
lcd
.
init
();
Serial
.
begin
(
9600
);
// start the relevant libraries used by temperature.cpp
temperatureBegin
();
// TESTING: temp1up with a poti
pinMode
(
A0
,
INPUT
);
// start the mp3 library
mp3Setup
();
...
...
This diff is collapsed.
Click to expand it.
solarpump/temperature.ino
+
42
−
9
View file @
ef9b0477
...
...
@@ -6,6 +6,7 @@
/* No new valid temperature for < 60 seconds? I sleep.
* No new valid temperature for > 60 seconds? REAL PROBLEM!
*/
// TESTING: only 10 seconds for testing
const
uint32_t
ERRORTIME
=
10000
;
// Update the temperature only every second
const
uint32_t
TEMPUPDATETIME
=
1000
;
...
...
@@ -20,6 +21,7 @@ const uint32_t TEMPUPDATETIME = 1000;
* function below work the same, except that they use another
* temperature sensor library
*/
/*
static OneWire oneWireT1up(T1UP);
static DallasTemperature dallasTemps(&oneWireT1up);
UPDATESTATE t1up(float* temp) {
...
...
@@ -52,6 +54,36 @@ UPDATESTATE t1up(float* temp) {
prevMillis = curMillis;
return SUCCESS;
}
*/
// TESTING: Using poti for testing
UPDATESTATE
t1up
(
float
*
temp
)
{
static
uint32_t
prevMillis
=
0
;
static
uint32_t
errorStartMillis
=
0
;
uint32_t
curMillis
=
millis
();
// only update once a second
if
(
curMillis
-
prevMillis
<
TEMPUPDATETIME
)
{
return
UNCHANGED
;
}
float
tempC
=
(
float
)
map
(
analogRead
(
A0
),
0
,
1023
,
0
,
100
);
// check if error occured
if
(
tempC
==
0
||
tempC
==
100
)
{
if
(
errorStartMillis
)
{
// check if error occurred longer than some seconds (10s)
if
(
curMillis
-
errorStartMillis
>
ERRORTIME
)
{
return
LONG_TIME_ERROR
;
}
}
else
{
errorStartMillis
=
curMillis
;
}
return
ERROR
;
}
// update temperature and time variables
*
temp
=
tempC
;
errorStartMillis
=
0
;
prevMillis
=
curMillis
;
return
SUCCESS
;
}
// DOWN temperature for solar system 1
static
DHT
dhtT1down
(
T1DOWN
,
DHT11
);
...
...
@@ -136,7 +168,8 @@ UPDATESTATE t2down(float* temp) {
// start the relevant libraries
void
temperatureBegin
(
void
)
{
dallasTemps
.
begin
();
// TESTING
//dallasTemps.begin();
dhtT1down
.
begin
();
dhtT2up
.
begin
();
dhtT2down
.
begin
();
...
...
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