Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
3cf93f02
Commit
3cf93f02
authored
4 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
LoRaWAN seems to work on ESP32
parent
c594f2d1
master
develop
experimental/example_for_iotwebconf
senseair_s8
v0.3.0
v0.2.3
v0.2.2
v0.2.1
v0.2.0
v0.1.0
archive/refactor/src_structure
archive/experimental/wifimanager
archive/experimental/simple
archive/experimental/save_lora_session
archive/experimental/save_config
archive/experimental/ota
archive/experimental/binary_clock
archive/experimental/autoconnect
archive/dev/debugcalib
archive/debug/loop_too_fast
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
ampel-firmware.h
+3
-0
ampel-firmware.h
ampel-firmware.ino
+14
-0
ampel-firmware.ino
co2_sensor.cpp
+6
-0
co2_sensor.cpp
co2_sensor.h
+3
-0
co2_sensor.h
util.h
+2
-0
util.h
with
28 additions
and
0 deletions
+28
-0
ampel-firmware.h
+
3
-
0
View file @
3cf93f02
...
...
@@ -10,6 +10,9 @@
#ifdef MQTT
# include "mqtt.h"
#endif
#ifdef LORAWAN
# include "lorawan.h"
#endif
#include
"util.h"
#include
"wifi_util.h"
...
...
This diff is collapsed.
Click to expand it.
ampel-firmware.ino
+
14
-
0
View file @
3cf93f02
...
...
@@ -99,7 +99,12 @@ void setup() {
mqtt
::
initialize
(
"CO2sensors/"
+
SENSOR_ID
);
#endif
}
csv_writer
::
initialize
();
#ifdef LORAWAN
lorawan
::
initialize
();
#endif
}
/*****************************************************************
...
...
@@ -107,6 +112,15 @@ void setup() {
*****************************************************************/
void
loop
()
{
#ifdef LORAWAN
//LMIC Library seems to be very sensitive to timing issues, so run it first.
lorawan
::
process
();
if
(
lorawan
::
waiting_for_confirmation
)
{
// If node is waiting for join confirmation from Gateway, nothing else should run.
return
;
}
#endif
//NOTE: Loop should never take more than 1000ms. Split in smaller methods and logic if needed.
//TODO: Restart every day or week, in order to not let t0 overflow?
uint32_t
t0
=
millis
();
...
...
This diff is collapsed.
Click to expand it.
co2_sensor.cpp
+
6
-
0
View file @
3cf93f02
...
...
@@ -175,11 +175,17 @@ namespace sensor {
}
logToSerial
();
//TODO: Move the 3 back to ampel-firmware.ino and remove headers from co2_sensor.h
csv_writer
::
logIfTimeHasCome
(
timestamp
,
co2
,
temperature
,
humidity
);
#ifdef MQTT
mqtt
::
publishIfTimeHasCome
(
timestamp
,
co2
,
temperature
,
humidity
);
#endif
#ifdef LORAWAN
lorawan
::
preparePayloadIfTimehasCome
();
#endif
}
if
(
should_calibrate
)
{
...
...
This diff is collapsed.
Click to expand it.
co2_sensor.h
+
3
-
0
View file @
3cf93f02
...
...
@@ -13,6 +13,9 @@
#ifdef MQTT
# include "mqtt.h"
#endif
#ifdef LORAWAN
# include "lorawan.h"
#endif
namespace
config
{
extern
uint16_t
measurement_timestep
;
// [s] Value between 2 and 1800 (range for SCD30 sensor)
...
...
This diff is collapsed.
Click to expand it.
util.h
+
2
-
0
View file @
3cf93f02
...
...
@@ -24,6 +24,8 @@ namespace ntp {
String
getLocalTime
();
}
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define seconds() (millis() / 1000UL)
extern
uint32_t
max_loop_duration
;
const
extern
String
SENSOR_ID
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets