sensors = get_sensors(config, status_logger)
# Join the LoRa network
# lora = False
# if (True in sensors.values() or gps_on) and config.get_config("LORA") == "ON": #TODO: lorawan disabled here
# lora = LoRaWAN(status_logger)
## Ring buffer
message_limit_count = 5 # buffer size?
cell_size_bytes = 100 # all buffer slots are a fixed size ! so waste space, but dont make this smaller that a max message!
msgBuffer = RingBuffer(
RING_BUFFER_DIR,
RING_BUFFER_FILE,
message_limit_count,
cell_size_bytes,
config,
status_logger,
) # processing_path, lora_file_name, 31 * self.message_limit, 100)
msgBuffer.push([1, secOfTheMonth()]) # port 1 , reboot 1
## Pybytes
try:
# Start PM sensor thread
pyBytesThreadId = _thread.start_new_thread(
PybytesTransmit.pybytes_thread, (msgBuffer, config, status_logger)
)
status_logger.info("THREAD - Pybytes initialised")
# trunk-ignore(flake8/F841)
except Exception as e:
status_logger.info("Failed to initialise Pybytes thread ")
# raise e
# Initialise temperature and humidity sensor thread with id: TEMP
status_logger.info("Starting Temp logger...")
if sensors[TEMP]:
TEMP_logger = SensorLogger(sensor_name=TEMP, terminal_out=True)
if config.get_config(TEMP) == "SHT35":
temp_sensor = TempSHT35(config, TEMP_logger, status_logger)
status_logger.info("Temperature and humidity sensor initialised")
# Initialise PM power circuitry
PM_transistor = Pin("P20", mode=Pin.OUT)
if (
config.get_config(PM1) == "OFF" and config.get_config(PM2) == "OFF"
): # Turn on sensors (power)
PM_transistor.value(0) # TODO: Somehow make this clear that it disables BOTH???
else:
PM_transistor.value(1)
status_logger.info("Enable power on for BOTH PM sensors")
# Initialise PM sensor threads
if sensors[PM1]:
init.initialise_pm_sensor(
sensor_name=PM1, pins=("P3", "P17"), serial_id=1, msgBuffer=msgBuffer
)
if sensors[PM2]:
init.initialise_pm_sensor(
sensor_name=PM2, pins=("P11", "P18"), serial_id=2, msgBuffer=msgBuffer
)
# Blink green three times to identify that the device has been initialised
for val in range(3):
lorawan disabled here
lora = LoRaWAN(status_logger)
raise e
Initialise temperature and humidity sensor thread with id: TEMP
https://github.com/pyonair/PyonAir-pycom/blob/9b8cd7f8cb06d958981c1841ca740c9ae1cf723d/code/main.py#L242
fb2a9f7cee3ac0c7caa02384d5c52899dd8eb901