Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sensor System
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Institut für Informatik
QE Research Group
FORTE
Sensor System
Commits
bcb77765
Commit
bcb77765
authored
2 years ago
by
Zoe Pfister
Browse files
Options
Downloads
Patches
Plain Diff
allow rtc time synchronization using NTP.
Closes
#4
parent
6419d106
No related branches found
No related tags found
5 merge requests
!39
Merge Develop into Main
,
!19
development into master
,
!17
Inital Host, initial Client
,
!10
merge serial comm and sd write into espnow
,
!8
merge sensor_readout into develop
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
host/fipy/lib/rtc_time.py
+28
-0
28 additions, 0 deletions
host/fipy/lib/rtc_time.py
host/fipy/main.py
+12
-9
12 additions, 9 deletions
host/fipy/main.py
with
40 additions
and
9 deletions
host/fipy/lib/rtc_time.py
0 → 100644
+
28
−
0
View file @
bcb77765
from
time
import
sleep
from
machine
import
RTC
class
RTCTime
:
def
__init__
(
self
,
main_ntp_server
:
str
=
"
pool.ntp.org
"
,
backup_ntp_server
:
str
=
"
time.nist.gov
"
,
update_interval_seconds
:
int
=
3600
,
):
self
.
rtc
=
RTC
()
self
.
_setup_ntp
(
main_ntp_server
,
backup_ntp_server
,
update_interval_seconds
)
def
_setup_ntp
(
self
,
main_ntp_server
:
str
,
backup_ntp_server
:
str
,
update_interval_seconds
:
int
):
print
(
"
Setting up NTP
"
)
self
.
rtc
.
ntp_sync
(
main_ntp_server
,
update_interval_seconds
,
backup_ntp_server
)
while
not
self
.
rtc
.
synced
():
print
(
self
.
rtc
.
synced
())
sleep
(
1
)
def
get_time
(
self
):
return
self
.
rtc
.
now
()
def
is_synchronized
(
self
):
return
self
.
rtc
.
synced
()
This diff is collapsed.
Click to expand it.
host/fipy/main.py
+
12
−
9
View file @
bcb77765
...
@@ -5,6 +5,7 @@ import binascii
...
@@ -5,6 +5,7 @@ import binascii
import
struct
import
struct
from
time
import
sleep
from
time
import
sleep
from
lib.server_transfer
import
DataTransferWiFi
from
lib.server_transfer
import
DataTransferWiFi
from
lib.rtc_time
import
RTCTime
def
bytes_to_data
(
msg
):
def
bytes_to_data
(
msg
):
...
@@ -35,21 +36,23 @@ def espnow_recv(result):
...
@@ -35,21 +36,23 @@ def espnow_recv(result):
print
(
error
)
print
(
error
)
#
data = DataTransferWiFi()
data
=
DataTransferWiFi
()
#
data.connect("Z", "AbsoluteSandwich")
data
.
connect
(
"
Z
"
,
"
AbsoluteSandwich
"
)
#
data.send(
data
.
send
(
#
"airSensors,sensor_id=TLM0201 temperature=73.97038159354763,humidity=35.23103248356096,co=0.4844531056779361 1661175680\nairSensors,sensor_id=TLM0202 temperature=75.30007505999716,humidity=35.65192991869171,co=0.5141876544505826 1661175680\nairSensors,sensor_id=TLM0202 temperature=75.30007505999756,humidity=35.65192991869171,co=0.5141876544505826 1661175680"
"
airSensors,sensor_id=TLM0201 temperature=73.97038159354763,humidity=35.23103248356096,co=0.4844531056779361 1661175680
\n
airSensors,sensor_id=TLM0202 temperature=75.30007505999716,humidity=35.65192991869171,co=0.5141876544505826 1661175680
\n
airSensors,sensor_id=TLM0202 temperature=75.30007505999756,humidity=35.65192991869171,co=0.5141876544505826 1661175680
"
#
)
)
# data.disconnect()
# data.disconnect()
w
=
WLAN
()
rtc_time
=
RTCTime
()
# w = WLAN()
ESPNOW
.
init
()
#
ESPNOW.init()
p
=
ESPNOW
.
add_peer
(
"
58cf79043c84
"
)
#
p = ESPNOW.add_peer("58cf79043c84")
ESPNOW
.
on_recv
(
espnow_recv
)
#
ESPNOW.on_recv(espnow_recv)
while
True
:
while
True
:
print
(
"
...
"
)
print
(
"
...
"
)
sleep
(
5
)
sleep
(
5
)
print
(
rtc_time
.
get_time
())
pass
pass
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