Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Käppler
ampel-firmware
Commits
3cf93f02
Commit
3cf93f02
authored
Dec 25, 2020
by
Eric Duminil
Browse files
LoRaWAN seems to work on ESP32
parent
c594f2d1
Changes
5
Hide whitespace changes
Inline
Side-by-side
ampel-firmware.h
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"
...
...
ampel-firmware.ino
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
();
...
...
co2_sensor.cpp
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
)
{
...
...
co2_sensor.h
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)
...
...
util.h
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
;
...
...
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