Skip to content
Permalink
Browse files

Slight application namespace refactoring

  • Loading branch information...
amotl committed Mar 17, 2019
1 parent 4508407 commit d50e46e6326fcd88fef50cb47cb666519dfd3d70
Showing with 23 additions and 73 deletions.
  1. 0 main-ttn.py → examples/ttn-example.py
  2. +0 −1 hiveeyes/__init__.py
  3. +0 −22 hiveeyes/datalogger.py
  4. +10 −40 main.py
  5. +13 −2 terkin/datalogger.py
  6. +0 −8 terkin/sensor.py
File renamed without changes.
@@ -1 +0,0 @@
__version__ = b"0.0.0"

This file was deleted.

Oops, something went wrong.
50 main.py
@@ -3,27 +3,25 @@
# Hiveeyes MicroPython Datalogger
# https://github.com/hiveeyes/hiveeyes-micropython-firmware
#
# Conceived for the Bee Observer (BOB) project.
# https://community.hiveeyes.org/c/bee-observer
#
# (c) 2019 Richard Pobering <richard@hiveeyes.org>
# (c) 2019 Andreas Motl <andreas@hiveeyes.org>
# License: GNU General Public License, Version 3
#
"""
Convenient data logger framework conceived for the Bee Observer (BOB) project.
https://community.hiveeyes.org/c/bee-observer
"""
import time
import settings
from hiveeyes.datalogger import HiveeyesDatalogger
from terkin.datalogger import TerkinDatalogger
from hiveeyes.sensor_hx711 import HX711Sensor


class BobDatalogger(HiveeyesDatalogger):
class HiveeyesDatalogger(TerkinDatalogger):
"""
Yet another data logger. This time for MicroPython.
"""

# Naming things.
name = 'BOB MicroPython Datalogger'
name = 'Hiveeyes MicroPython Datalogger'

def register_sensors(self):
"""
@@ -33,8 +31,8 @@ def register_sensors(self):
# First, spin up the built-in sensors.
super().register_sensors()

# Add some sensors for the Bee Observer (BOB) project.
self.device.tlog('Registering BOB sensors')
# Add some sensors for the Hiveeyes project.
self.device.tlog('Registering Hiveeyes sensors')

# Setup the HX711.
try:
@@ -72,43 +70,15 @@ def loop(self):
"""

# It's your turn.
self.device.tlog('BOB loop')

# TODO: Send real measurement data to TTN.
if self.settings.get('networking.lora.antenna_attached'):
self.ttn_test()
self.device.tlog('Hiveeyes loop')

# Finally, schedule other system tasks.
super().loop()

def read_sensors(self):
# CayenneLPP example

# Payload Base64: AWf8sABnAag=
# Payload Hex: 0167FCB0006701A8
data = {
'temperature_0': 42.42,
'temperature_1': -84.84,
}
return data

def ttn_test(self):
"""
Send dummy payload to TTN over LoRaWAN, without taking too much Airtime.
"""
for i in range(1, 39):
j = i % 10
if j == 0 or i == 1:
payload = "ff"
success = self.device.networking.lora_send(payload)
if success:
print("[LoRa] send:", payload)
time.sleep(1)


def main():
"""Start the data logger application."""
datalogger = BobDatalogger(settings)
datalogger = HiveeyesDatalogger(settings)
datalogger.start()


@@ -5,13 +5,19 @@
import utime
import machine

from terkin import __version__
from terkin.configuration import TerkinConfiguration
from terkin.device import TerkinDevice
from terkin.sensor import MemoryFree


# Maybe refactor to TerkinCore.
class TerkinDatalogger:

# Application metadata.
name = 'Terkin MicroPython Datalogger'
version = __version__

def __init__(self, settings):
self.settings = TerkinConfiguration()
self.settings.add(settings)
@@ -42,13 +48,18 @@ def start(self):
self.start_mainloop()

def register_sensors(self):
self.device.tlog('Registering Terkin sensors')
"""
Add baseline sensors.
TODO: Add more sensors.
- Metadata from NetworkManager.station
- Device stats, see Microhomie
"""
pass

self.device.tlog('Registering Terkin sensors')

memfree = MemoryFree()
self.register_sensor(memfree)

def register_sensor(self, sensor):
self.sensors.append(sensor)
@@ -4,14 +4,6 @@
# License: GNU General Public License, Version 3


class DummySensor:

def read(self):
# Fake measurement.
data = {"temperature": 42.84, "humidity": 83}
return data


class MemoryFree:

def read(self):

0 comments on commit d50e46e

Please sign in to comment.
You can’t perform that action at this time.