Mihai Popa
Published © LGPL

Indoor multi-screen air quality measurement

This is a multi-screen device used for indoor air quality measurements.

Things used in this project

Hardware components

Infineon CY8PROTO-062-4343W PSoC6
×1
Infineon PASCO2
×1
Infineon S2GO PRESSURE DPS368
×1
Bosch bme280 (generic module)
×1
Gravity: I2C HUB
DFRobot Gravity: I2C HUB
×1
Maxim Integrated DS3231 RTC
×1
Nokia 5110 blue
×12
PCB for LCD displays
×1
Hexagonal Plastic Pillar M2 12mm
×48
Plastic Round Head Screw M2 5mm
×96
Jumper wires (generic)
Jumper wires (generic)
×1
5V power supply generic
×1
DC-DC 3V-6V to 12V 3A
×1

Software apps and online services

Infineon MicroPython for PSoC6
MicroPython
MicroPython
MicroPython for PSoC6 repository
Tinkercad
Autodesk Tinkercad
EasyEDA
JLCPCB EasyEDA
Thonny - IDE for Python

Hand tools and fabrication machines

solder iron generic
screwdriver, tweezers, patent, other tools used in electronic lab
Drilling machine (generic) with 2 mm drill bit

Story

Read more

Custom parts and enclosures

3D printed support

This is an 3D printed support for the PCB with LCD displays, PSoC 6 board and all sensors used.

Schematics

Electronic schematic

This is the electronic schematic for this project. Contain only the power supply part, LCD Nokia 5110 connection and connectors with MCU.

Gerber files

Gerber files used to create PCB for LCD driver

BOM file for LCD driver board

BOM file containing all components used to create the LCD driver PCB

Graphics on Nokia 5110 LCD

It is an excel file that I used to create craracters displayed on Nokia 5110 LCDs

Code

dps310.py

MicroPython
This library is used to comunicate with Infineon DPS368 pressure sensor using I2C and microPython
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
"""
`dps310`
================================================================================
MicroPython Driver for the DP310 Barametric Sensor
* Author: Jose D. Montoya
Implementation Notes
**Software and Dependencies:**

This library depends on Micropython
"""
# pylint: disable=line-too-long

import time
import math
import struct
from micropython import const
from lib.i2c_helpers import CBits, RegisterStruct

__version__ = "0.1.3"
__repo__ = "https://github.com/jposada202020/MicroPython_DPS310.git"

_DEVICE_ID = const(0x0D)
_PRS_CFG   = const(0x06)
_TMP_CFG   = const(0x07)
_MEAS_CFG  = const(0x08)
_CFGREG    = const(0x09)
_RESET     = const(0x0C)

_TMPCOEFSRCE = const(0x28)  # Temperature calibration src

# DPS310 Pressure Oversampling Rate
SAMPLE_PER_SECOND_1   = const(0b000)  # 1 time (Pressure Low Precision)
SAMPLE_PER_SECOND_2   = const(0b001)  # 2 times (Pressure Low Power)
SAMPLE_PER_SECOND_4   = const(0b010)  # 4 times
SAMPLE_PER_SECOND_8   = const(0b011)  # 8 times
SAMPLE_PER_SECOND_16  = const(0b100)  # 16 times (Pressure Standard).**
SAMPLE_PER_SECOND_32  = const(0b101)  # 32 times **
SAMPLE_PER_SECOND_64  = const(0b110)  # 64 times (Pressure High Precision) **
SAMPLE_PER_SECOND_128 = const(0b111)  # 128 times **
oversamples_values = (
    SAMPLE_PER_SECOND_1,
    SAMPLE_PER_SECOND_2,
    SAMPLE_PER_SECOND_4,
    SAMPLE_PER_SECOND_8,
    SAMPLE_PER_SECOND_16,
    SAMPLE_PER_SECOND_32,
    SAMPLE_PER_SECOND_64,
    SAMPLE_PER_SECOND_128,
)

# DPS310 Pressure Sample Rate
RATE_1_HZ   = const(0b000)
RATE_2_HZ   = const(0b001)
RATE_4_HZ   = const(0b010)
RATE_8_HZ   = const(0b011)
RATE_16_HZ  = const(0b100)
RATE_32_HZ  = const(0b101)
RATE_64_HZ  = const(0b110)
RATE_128_HZ = const(0b111)
rates_values = (
    RATE_1_HZ,
    RATE_2_HZ,
    RATE_4_HZ,
    RATE_8_HZ,
    RATE_16_HZ,
    RATE_32_HZ,
    RATE_64_HZ,
    RATE_128_HZ,
)

IDLE            = const(0b000)
ONE_PRESSURE    = const(0b001)
ONE_TEMPERATURE = const(0b010)
CONT_PRESSURE   = const(0b101)
CONT_TEMP       = const(0b110)
CONT_PRESTEMP   = const(0b111)
mode_values     = (IDLE, ONE_PRESSURE, ONE_TEMPERATURE, CONT_PRESSURE, CONT_TEMP, CONT_PRESTEMP)


class DPS310:
    """Main class for the Sensor
    :param ~machine.I2C i2c: The I2C bus the DPS310 is connected to.
    :param int address: The I2C device address. Defaults to :const:`0x77`
    :raises RuntimeError: if the sensor is not found
    **Quickstart: Importing and using the device**
    Here is an example of using the :class:`micropython_dps310.DPS310` class.
    First you will need to import the libraries to use the sensor
    .. code-block:: python
        from machine import Pin, I2C
        import micropython_dps310.dps310 as dps310
    Once this is done you can define your `machine.I2C` object and define your sensor object
    .. code-block:: python
        i2c = I2C(1, sda=Pin(2), scl=Pin(3))
        dps = dps310.DPS310(i2c)
    Now you have access to the :attr:`pressure` attribute
    .. code-block:: python
        press = dps.pressure 
    """

    # Register definitions
    _device_id = RegisterStruct(_DEVICE_ID, ">B")
    _reset_register = RegisterStruct(_RESET, ">B")
    _press_conf_reg = RegisterStruct(_PRS_CFG, ">B")
    _temp_conf_reg = RegisterStruct(_TMP_CFG, ">B")
    _sensor_operation_mode = RegisterStruct(_MEAS_CFG, ">B")

    # Register 0x06 Pressure Configuration
    # | ---- | PM_RATE(2) |  PM_RATE(1)| PM_RATE(0) | PM_PRC(3) | PM_PRC(2) | PM_PRC(1) | PM_PRC(0) |
    _pressure_oversample = CBits(4, _PRS_CFG, 0)
    _pressure_rate = CBits(3, _PRS_CFG, 4)
    
    # Register 0x07 Temperature Configuration
    # | TMP_EXT | PM_RATE(2) |  PM_RATE(1)| PM_RATE(0) | PM_PRC(3) | PM_PRC(2) | PM_PRC(1) | PM_PRC(0) |
    _temperature_oversample = CBits(4, _TMP_CFG, 0)
    _temperature_rate = CBits(3, _TMP_CFG, 4)
    _temperature_external_source = CBits(0, _TMP_CFG, 7) 

    # Register 0x08 Sensor Operating Mode and Status
    # | COEF_RDY | SENSOR_RDY |  TMP_RDY | PRS_RDY | ---- | MEAS_CTRL(2) | MEAS_CTRL(1) | MEAS_CTRL(0) |
    _sensor_mode = CBits(3, _MEAS_CFG, 0)
    _pressure_ready = CBits(1, _MEAS_CFG, 4)
    _sensor_ready = CBits(1, _MEAS_CFG, 6)
    _temp_ready = CBits(1, _MEAS_CFG, 5)
    _coefficients_ready = CBits(1, _MEAS_CFG, 7)

    # Register 0x09 Sensor interreupts
    # | INT_HL | INT_FIFO | INT_TMP | INT_PRS | T_SHIFT | P_SHIFT | FIFO_EN | SPI_MODE |
    _t_shift = CBits(1, _CFGREG, 3)
    _p_shift = CBits(1, _CFGREG, 2)

    _raw_pressure = CBits(24, 0x00, 0, 3, False)
    _raw_temperature = CBits(24, 0x03, 0, 3, False)

    _calib_coeff_temp_src_bit = CBits(1, _TMPCOEFSRCE, 7) 

    _reg0e = CBits(8, 0x0E, 0)
    _reg0f = CBits(8, 0x0F, 0)
    _reg62 = CBits(8, 0x62, 0)

    _measurement_times_table = {
        0: 3.6,
        1: 5.2,
        2: 8.4,
        3: 14.8,
        4: 27.6,
        5: 53.2,
        6: 104.4,
        7: 206.8,
    }

    _calib_coeff_temp_src_bit = CBits(1, _TMPCOEFSRCE, 7)

    _soft_reset = CBits(4, 0x0C, 0)

    def __init__(self, i2c, address=0x77) -> None:
        self._i2c = i2c
        self._address = address

        if self._device_id != 0x10:
            raise RuntimeError("Failed to find the DPS310 sensor!")

        self._pressure_scale = None
        self._temp_scale = None

        self._oversample_scalefactor = (
            524288.0,
            1572864.0,
            3670016.0,
            7864320.0,
            253952.0,
            516096.0,
            1040384.0,
            2088960.0,
        )
        self._sea_level_pressure = 1013.25

        self._correct_temp()
        self._read_calibration()
        self._temp_measurement_src_bit = self._calib_coeff_temp_src_bit

        self.pressure_oversample = RATE_64_HZ
        self.temperature_oversample = RATE_64_HZ
        self._sensor_mode = CONT_PRESTEMP

        self._wait_temperature_ready()
        self._wait_pressure_ready()

    @property
    def pressure_oversample(self) -> str:
        values = (
            "SAMPLE_PER_SECOND_1",
            "SAMPLE_PER_SECOND_2",
            "SAMPLE_PER_SECOND_4",
            "SAMPLE_PER_SECOND_8",
            "SAMPLE_PER_SECOND_16",
            "SAMPLE_PER_SECOND_32",
            "SAMPLE_PER_SECOND_64",
            "SAMPLE_PER_SECOND_128",
        )
        return values[self._pressure_oversample]

    @pressure_oversample.setter
    def pressure_oversample(self, value: int) -> None:
        if value not in oversamples_values:
            raise ValueError("Value must be a valid oversample setting")
        self._pressure_oversample = value
        self._p_shift = value > SAMPLE_PER_SECOND_8
        self._pressure_scale = self._oversample_scalefactor[value]

    @property
    def pressure_rate(self) -> str:
        values = (
            "RATE_1_HZ",
            "RATE_2_HZ",
            "RATE_4_HZ",
            "RATE_8_HZ",
            "RATE_16_HZ",
            "RATE_32_HZ",
            "RATE_64_HZ",
            "RATE_128_HZ",
        )
        return values[self._pressure_rate]

    @pressure_rate.setter
    def pressure_rate(self, value: int) -> None:
        if value not in rates_values:
            raise ValueError("Value must be a valid rate setting")
        self._pressure_rate = value

    @property
    def temperature_oversample(self) -> str:
        values = (
            "SAMPLE_PER_SECOND_1",
            "SAMPLE_PER_SECOND_2",
            "SAMPLE_PER_SECOND_4",
            "SAMPLE_PER_SECOND_8",
            "SAMPLE_PER_SECOND_16",
            "SAMPLE_PER_SECOND_32",
            "SAMPLE_PER_SECOND_64",
            "SAMPLE_PER_SECOND_128",
        )
        return values[self._temperature_oversample]

    @temperature_oversample.setter
    def temperature_oversample(self, value: int) -> None:
        if value not in oversamples_values:
            raise ValueError("Value must be a valid oversample setting")
        self._temperature_oversample = value
        self._temp_scale = self._oversample_scalefactor[value]
        self._t_shift = value > SAMPLE_PER_SECOND_8

    @property
    def temperature_rate(self) -> str:
        values = (
            "RATE_1_HZ",
            "RATE_2_HZ",
            "RATE_4_HZ",
            "RATE_8_HZ",
            "RATE_16_HZ",
            "RATE_32_HZ",
            "RATE_64_HZ",
            "RATE_128_HZ",
        )

        return values[self._temperature_rate]

    @temperature_rate.setter
    def temperature_rate(self, value: int) -> None:
        if value not in rates_values:
            raise ValueError("Value must be a valid rate setting")
        self._temperature_rate = value

    @property
    def sensor_mode(self) -> str:

        values = (IDLE, ONE_PRESSURE, ONE_TEMPERATURE, CONT_PRESSURE, CONT_TEMP, CONT_PRESTEMP)
        return values[self._sensor_mode]

#    @mode.setter
    def mode(self, value: int) -> None:
        self._sensor_mode = value

    def _wait_pressure_ready(self) -> None:
        """Wait until a pressure measurement is available. To avoid waiting indefinitely
        this function raises an error if the sensor isn't configured for pressure measurements,

        """
        if self.mode in (IDLE, ONE_TEMPERATURE, CONT_TEMP):
            raise RuntimeError(
                "Sensor mode is set to idle or temperature measurement, can't wait for a pressure measurement"
            )
        while self._pressure_ready is False:
            time.sleep(0.001)

    def _wait_temperature_ready(self) -> None:
        """Wait until a temperature measurement is available.
        To avoid waiting indefinitely this function raises an
        error if the sensor isn't configured for temperate measurements,
        """
        if self.mode in (IDLE, ONE_PRESSURE, CONT_PRESSURE):
            raise RuntimeError(
                "Sensor mode is set to idle or pressure measurement, can't wait for a temperature measurement"
            )
        while self._temp_ready is False:
            time.sleep(0.001)

    def _read_calibration(self) -> None:
        """
        Read the calibration data from the sensor
        """
        while not self._coefficients_ready:
            time.sleep(0.001)

        coeffs = [None] * 18
        for offset in range(18):
            register = 0x10 + offset
            coeffs[offset] = struct.unpack(
                "B", self._i2c.readfrom_mem(self._address, register, 1)
            )[0]

        self._c0 = (coeffs[0] << 4) | ((coeffs[1] >> 4) & 0x0F)
        self._c0 = self._twos_complement(self._c0, 12)

        self._c1 = self._twos_complement(((coeffs[1] & 0x0F) << 8) | coeffs[2], 12)

        self._c00 = (coeffs[3] << 12) | (coeffs[4] << 4) | ((coeffs[5] >> 4) & 0x0F)
        self._c00 = self._twos_complement(self._c00, 20)

        self._c10 = ((coeffs[5] & 0x0F) << 16) | (coeffs[6] << 8) | coeffs[7]
        self._c10 = self._twos_complement(self._c10, 20)

        self._c01 = self._twos_complement((coeffs[8] << 8) | coeffs[9], 16)
        self._c11 = self._twos_complement((coeffs[10] << 8) | coeffs[11], 16)
        self._c20 = self._twos_complement((coeffs[12] << 8) | coeffs[13], 16)
        self._c21 = self._twos_complement((coeffs[14] << 8) | coeffs[15], 16)
        self._c30 = self._twos_complement((coeffs[16] << 8) | coeffs[17], 16)

    @staticmethod
    def _twos_complement(val: int, bits: int) -> int:
        if val & (1 << (bits - 1)):
            val -= 1 << bits

        return val

    def _correct_temp(self) -> None:
        """Correct temperature readings on ICs with a fuse bit problem"""
        self._reg0e = 0xA5
        self._reg0f = 0x96
        self._reg62 = 0x02
        self._reg0e = 0
        self._reg0f = 0

        _unused = self._raw_temperature

    @property
    def pressure(self) -> float:
        """Returns the current pressure reading in hectoPascals (hPa)"""

        temp_reading = self._raw_temperature

        raw_temperature = self._twos_complement(temp_reading, 24) 

        pressure_reading = self._raw_pressure

        raw_pressure = self._twos_complement(pressure_reading, 24)

        scaled_rawtemp = raw_temperature / self._temp_scale
        scaled_rawpres = raw_pressure / self._pressure_scale

        pres_calc = (
            self._c00
            + scaled_rawpres
            * (self._c10 + scaled_rawpres * (self._c20 + scaled_rawpres * self._c30))
            + scaled_rawtemp
            * (self._c01 + scaled_rawpres * (self._c11 + scaled_rawpres * self._c21))
        )

        final_pressure = pres_calc / 100

        return final_pressure

    @property
    def altitude(self) -> float:
        """
        The altitude in meters based on the sea level pressure
        (:attr:`sea_level_pressure`) - which you must enter ahead of time
        """
        return 44330.0 * (
            1.0 - math.pow(self.pressure / self._sea_level_pressure, 0.1903)
        )

    @altitude.setter
    def altitude(self, value: float) -> None:
        self.sea_level_pressure = self.pressure / (1.0 - value / 44330.0) ** 5.255

    @property
    def temperature(self) -> float:
        """The current temperature reading in Celsius"""
        scaled_rawtemp = self._raw_temperature / self._temp_scale
        temp = scaled_rawtemp * self._c1 + self._c0 / 2.0
        return temp

    @property
    def sea_level_pressure(self) -> float:
        """The local sea level pressure in hectoPascals (aka millibars). This is used
        for calculation of :attr:`altitude`. Values are typically in the range
        980 - 1030."""
        return self._sea_level_pressure

    @sea_level_pressure.setter
    def sea_level_pressure(self, value: float) -> None:
        self._sea_level_pressure = value

pasco2.py

MicroPython
This library is used to comunicate with Infineon PAS CO2 sensor using I2C and microPython.
# Infineon XENSIV PAS CO2 sensor driver for MicroPython

from machine import I2C
from utime import sleep, sleep_ms

# Sensor Register Address Stack
_PASCO2_REG_SENS_STS    = const(0x01)  # Sensor status register address
_PASCO2_REG_MEAS_RATE_H = const(0x02)  # Measurement period MSB configuration register address
_PASCO2_REG_MEAS_CFG    = const(0x04)  # Measurement mode configuration register address
_PASCO2_REG_CO2PPM_H    = const(0x05)  # CO2 concentration result MSB register address
_PASCO2_REG_MEAS_STS    = const(0x07)  # Measurement status register address
_PASCO2_REG_SENS_RST    = const(0x10)  # Soft reset register address
_PASCO2_REG_PROD_ID     = const(0x00)  # Product and revision ID register address

# Error codes
_PASCO2_SUCCESS = 0
_PASCO2_ERROR = -1

addr = 0
mask = 1


class PASCO2:
    """IFX - XENSIV PAS CO2 sensor driver"""

    # RegAddr, Mask, <Later extend with register access type, bit position etc.>
    regMap = {
        "REG_SENS_STS_BITF_SENS_RDY" : [_PASCO2_REG_SENS_STS, 0x80],  # Sensor status bit
        "REG_MEAS_CFG_BITF_OP_MODE"  : [_PASCO2_REG_MEAS_CFG, 0x03],  # Operation Mode type bit
        "REG_MEAS_STS_BITF_DATA_RDY" : [_PASCO2_REG_MEAS_STS, 0x10],  # Data ready status bit
        "REG_CO2PPM_H_BITF_CO2_PPM_H": [_PASCO2_REG_CO2PPM_H, 0xFF],  # Stored CO2 value bit
        "REG_PROD_ID_BITF_PROD"      : [_PASCO2_REG_PROD_ID, 0xE0],   # Product id bit
        "REG_PROD_ID_BITF_REV"       : [_PASCO2_REG_PROD_ID, 0x1F],   # Revision id bit
    }

    def __init__(self, bus, measInterval=10, sensorAddr=0x28):
        """ " Intialize the sensor and required dependencies"""
        self.bus = bus
        self.sensorAddr = sensorAddr
        self.measInterval = measInterval
        self.softResetCode = b"\xa3"

    def _read_reg(self, regAddr, bytesToRead=1):
        """Internal function to read data from the sensor register and returns it raw"""
        readVal = self.bus.readfrom_mem(self.sensorAddr, regAddr, bytesToRead)
        return readVal

    def _write_reg(self, regAddr, writeData):
        """Internal function to write data to sensor register"""
        self.bus.writeto_mem(self.sensorAddr, regAddr, writeData)

    def _is_sensor_ready(self):
        """Helper function to check the sensor status"""
        reg = self.regMap["REG_SENS_STS_BITF_SENS_RDY"]
        return self._read_reg(reg[addr])[0] & reg[mask]

    def _soft_reset(self):
        """Helper function to perform soft reset of the sensor"""
        self._write_reg(_PASCO2_REG_SENS_RST, self.softResetCode)

    def _set_mode(self, mode):
        """Helper function to set the mode of sensor. Currently supported modes:
        1. Idle
        2. Continuous
        """
        if mode == "idle":
            modeVal = 0x00
        if mode == "continuous":
            modeVal = 0x02

        reg = self.regMap["REG_MEAS_CFG_BITF_OP_MODE"]
        readData = self._read_reg(reg[addr])[0]
        writeData = bytes([(readData & ~(reg[mask])) | modeVal])
        self._write_reg(_PASCO2_REG_MEAS_CFG, writeData)

    def initialize(self):
        """Public function to initialize the sensor"""
        try:
            # wait for sensor to be ready
            sensor_ready = self._is_sensor_ready()
            while not sensor_ready:
                sleep(1)
                sensor_ready = self._is_sensor_ready()

            # soft reset sensor register
            self._soft_reset()
            sleep_ms(800)

            # set measure rate
            buf = bytes([(self.measInterval >> 8) & 0xFF, self.measInterval & 0xFF])
            self._write_reg(_PASCO2_REG_MEAS_RATE_H, buf)

            # reset operation mode to idle mode
            self._set_mode("idle")

            # start continuous mode
            self._set_mode("continuous")

            return _PASCO2_SUCCESS

        except:
            return _PASCO2_ERROR

    def get_co2_value(self):
        """Public function to get the CO2 value"""
        while True:
            try:
                # get meas status
                reg = self.regMap["REG_MEAS_STS_BITF_DATA_RDY"]
                readStatus = self._read_reg(reg[addr])
                data_ready = readStatus[0] & reg[mask]

                if data_ready:
                    # get CO2 value
                    reg = self.regMap["REG_CO2PPM_H_BITF_CO2_PPM_H"]
                    readVal = self._read_reg(reg[addr], 2)
                    co2_value = (readVal[0] << 8) | readVal[1]
                    return co2_value
            except:
                return _PASCO2_ERROR

    def get_prod_id(self):
        """Public function to get the sensor product id"""
        try:
            reg = self.regMap["REG_PROD_ID_BITF_PROD"]
            readID = (self._read_reg(reg[addr])[0] & 0xE0) >> 5
            return readID

        except:
            return _PASCO2_ERROR

    def get_rev_id(self):
        """Public function to get the sensor revision id"""
        try:
            reg = self.regMap["REG_PROD_ID_BITF_REV"]
            readID = (self._read_reg(reg[addr])[0] & 0x1F) >> 0
            return readID

        except:
            return _PASCO2_ERROR

pcd8544_mod.py

MicroPython
This library is used to comunicate with Nokia 5110 LCD using SPI and MicroPython
"""
MicroPython Nokia 5110 PCD8544 84x48 LCD driver
https://github.com/mcauser/micropython-pcd8544

MIT License
Copyright (c) 2016-2018 Mike Causer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

from micropython import const
from ustruct     import pack
from utime       import sleep_us

# Function set 0010 0xxx
FUNCTION_SET     = const(0x20)
POWER_DOWN       = const(0x04)
ADDRESSING_VERT  = const(0x02)
EXTENDED_INSTR   = const(0x01)

# Display control 0000 1x0x
DISPLAY_BLANK    = const(0x08)
DISPLAY_ALL      = const(0x09)
DISPLAY_NORMAL   = const(0x0c)
DISPLAY_INVERSE  = const(0x0d)

# Temperature control 0000 01xx
TEMP_COEFF_0     = const(0x04)
TEMP_COEFF_1     = const(0x05)
TEMP_COEFF_2     = const(0x06) # default
TEMP_COEFF_3     = const(0x07)

# Bias system 0001 0xxx
BIAS_1_100       = const(0x10)
BIAS_1_80        = const(0x11)
BIAS_1_65        = const(0x12)
BIAS_1_48        = const(0x13)
BIAS_1_40        = const(0x14) # default
BIAS_1_24        = const(0x15)
BIAS_1_18        = const(0x16)
BIAS_1_10        = const(0x17)

# Set operation voltage
SET_VOP          = const(0x80)

# DDRAM addresses
COL_ADDR         = const(0x80) # x pos (0~83)
BANK_ADDR        = const(0x40) # y pos, in banks of 8 rows (0~5)

class PCD8544:
#	def __init__(self, spi, cs, dc, rst=None):
#	def __init__(self, spi, cs, dc):        
    def __init__(self, spi, dc):   
        self.width  = 84
        self.height = 48

        self.spi    = spi
#		self.cs     = cs   # chip enable, active LOW
        self.dc     = dc   # data HIGH, command LOW
#		self.rst    = rst  # reset, active LOW

#		self.cs.init(self.cs.OUT, value=1)
        self.dc.init(self.dc.OUT, value=0)

#		if self.rst:
#			self.rst.init(self.rst.OUT, value=1)
#		self.reset()
#		self.init()

    def init(self, horizontal=True, contrast=0x3f, bias=BIAS_1_40, temp=TEMP_COEFF_2):
		# power up, horizontal addressing, basic instruction set
        self.fn = FUNCTION_SET

		# switch to vertical addressing
        if not horizontal:
            self.fn |= ADDRESSING_VERT

        self.contrast(contrast, bias, temp)
        self.cmd(DISPLAY_NORMAL)
        self.clear()

#	def reset(self):
		# issue reset impulse to reset the display
#		self.rst(1)
#		sleep_us(100)
#		self.rst(0)
#		sleep_us(100) # reset impulse has to be >100 ns and <100 ms
#		self.rst(1)
#		sleep_us(100)

    def power_on(self):
#		self.cs(1)
        self.fn &= ~POWER_DOWN
        self.cmd(self.fn)

    def power_off(self):
        self.fn |= POWER_DOWN
        self.cmd(self.fn)

    def contrast(self, contrast=0x3f, bias=BIAS_1_40, temp=TEMP_COEFF_2):
        for cmd in (
			# extended instruction set is required to set temp, bias and vop
            self.fn | EXTENDED_INSTR,
			# set temperature coefficient
            temp,
			# set bias system (n=3 recommended mux rate 1:40/1:34)
            bias,
			# set contrast with operating voltage (0x00~0x7f)
			# 0x00 = 3.00V, 0x3f = 6.84V, 0x7f = 10.68V
			# starting at 3.06V, each bit increments voltage by 0.06V at room temperature
            SET_VOP | contrast,
			# revert to basic instruction set
            self.fn & ~EXTENDED_INSTR):
            self.cmd(cmd)

    def invert(self, invert):
        self.cmd(DISPLAY_INVERSE if invert else DISPLAY_NORMAL)

    def clear(self):
		# clear DDRAM, reset x,y position to 0,0
        self.data([0] * (self.height * self.width // 8))
        self.position(0, 0)

    def position(self, x, y):
		# set cursor to column x (0~83), bank y (0~5)
        self.cmd(COL_ADDR | x) # set x pos (0~83)
        self.cmd(BANK_ADDR | y) # set y pos (0~5)

    def cmd(self, command):
        self.dc(0)
#		self.cs(0)
        self.spi.write(bytearray([command]))
#		self.cs(1)

    def data(self, data):
        self.dc(1)
#		self.cs(0)
        self.spi.write(pack('B'*len(data), *data))
#		self.cs(1)

bme280.py

MicroPython
This library is used to comunicate with Bosh BME280 sensor using I2C and MicroPython
# Authors: Paul Cunnane 2016, Peter Dahlebrg 2016
#
# This module borrows from the Adafruit BME280 Python library. Original
# Copyright notices are reproduced below.
#
# Those libraries were written for the Raspberry Pi. This modification is
# intended for the MicroPython and esp8266 boards.
#
# Copyright (c) 2014 Adafruit Industries
# Author: Tony DiCola
#
# Based on the BMP280 driver with BME280 changes provided by
# David J Taylor, Edinburgh (www.satsignal.eu)
#
# Based on Adafruit_I2C.py created by Kevin Townsend.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.


import time
from ustruct import unpack, unpack_from
from array import array

# BME280 default address.
BME280_I2CADDR = 0x76

# Operating Modes
BME280_OSAMPLE_1 = 1
BME280_OSAMPLE_2 = 2
BME280_OSAMPLE_4 = 3
BME280_OSAMPLE_8 = 4
BME280_OSAMPLE_16 = 5

BME280_REGISTER_CONTROL_HUM = 0xF2
BME280_REGISTER_CONTROL = 0xF4


class BME280:

    def __init__(self,
                 mode=BME280_OSAMPLE_1,
                 address=BME280_I2CADDR,
                 i2c=None,
                 **kwargs):
        # Check that mode is valid.
        if mode not in [BME280_OSAMPLE_1, BME280_OSAMPLE_2, BME280_OSAMPLE_4,
                        BME280_OSAMPLE_8, BME280_OSAMPLE_16]:
            raise ValueError(
                'Unexpected mode value {0}. Set mode to one of '
                'BME280_ULTRALOWPOWER, BME280_STANDARD, BME280_HIGHRES, or '
                'BME280_ULTRAHIGHRES'.format(mode))
        self._mode = mode
        self.address = address
        if i2c is None:
            raise ValueError('An I2C object is required.')
        self.i2c = i2c

        # load calibration data
        dig_88_a1 = self.i2c.readfrom_mem(self.address, 0x88, 26)
        dig_e1_e7 = self.i2c.readfrom_mem(self.address, 0xE1, 7)
        self.dig_T1, self.dig_T2, self.dig_T3, self.dig_P1, \
            self.dig_P2, self.dig_P3, self.dig_P4, self.dig_P5, \
            self.dig_P6, self.dig_P7, self.dig_P8, self.dig_P9, \
            _, self.dig_H1 = unpack("<HhhHhhhhhhhhBB", dig_88_a1)

        self.dig_H2, self.dig_H3 = unpack("<hB", dig_e1_e7)
        e4_sign = unpack_from("<b", dig_e1_e7, 3)[0]
        self.dig_H4 = (e4_sign << 4) | (dig_e1_e7[4] & 0xF)

        e6_sign = unpack_from("<b", dig_e1_e7, 5)[0]
        self.dig_H5 = (e6_sign << 4) | (dig_e1_e7[4] >> 4)

        self.dig_H6 = unpack_from("<b", dig_e1_e7, 6)[0]

        self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL,
                             bytearray([0x3F]))
        self.t_fine = 0

        # temporary data holders which stay allocated
        self._l1_barray = bytearray(1)
        self._l8_barray = bytearray(8)
        self._l3_resultarray = array("i", [0, 0, 0])

    def read_raw_data(self, result):
        """ Reads the raw (uncompensated) data from the sensor.

            Args:
                result: array of length 3 or alike where the result will be
                stored, in temperature, pressure, humidity order
            Returns:
                None
        """

        self._l1_barray[0] = self._mode
        self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL_HUM,
                             self._l1_barray)
        self._l1_barray[0] = self._mode << 5 | self._mode << 2 | 1
        self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL,
                             self._l1_barray)

        sleep_time = 1250 + 2300 * (1 << self._mode)
        sleep_time = sleep_time + 2300 * (1 << self._mode) + 575
        sleep_time = sleep_time + 2300 * (1 << self._mode) + 575
        time.sleep_us(sleep_time)  # Wait the required time

        # burst readout from 0xF7 to 0xFE, recommended by datasheet
        self.i2c.readfrom_mem_into(self.address, 0xF7, self._l8_barray)
        readout = self._l8_barray
        # pressure(0xF7): ((msb << 16) | (lsb << 8) | xlsb) >> 4
        raw_press = ((readout[0] << 16) | (readout[1] << 8) | readout[2]) >> 4
        # temperature(0xFA): ((msb << 16) | (lsb << 8) | xlsb) >> 4
        raw_temp = ((readout[3] << 16) | (readout[4] << 8) | readout[5]) >> 4
        # humidity(0xFD): (msb << 8) | lsb
        raw_hum = (readout[6] << 8) | readout[7]

        result[0] = raw_temp
        result[1] = raw_press
        result[2] = raw_hum

    def read_compensated_data(self, result=None):
        """ Reads the data from the sensor and returns the compensated data.

            Args:
                result: array of length 3 or alike where the result will be
                stored, in temperature, pressure, humidity order. You may use
                this to read out the sensor without allocating heap memory

            Returns:
                array with temperature, pressure, humidity. Will be the one from
                the result parameter if not None
        """
        self.read_raw_data(self._l3_resultarray)
        raw_temp, raw_press, raw_hum = self._l3_resultarray
        # temperature
        var1 = ((raw_temp >> 3) - (self.dig_T1 << 1)) * (self.dig_T2 >> 11)
        var2 = (((((raw_temp >> 4) - self.dig_T1) *
                  ((raw_temp >> 4) - self.dig_T1)) >> 12) * self.dig_T3) >> 14
        self.t_fine = var1 + var2
        temp = (self.t_fine * 5 + 128) >> 8

        # pressure
        var1 = self.t_fine - 128000
        var2 = var1 * var1 * self.dig_P6
        var2 = var2 + ((var1 * self.dig_P5) << 17)
        var2 = var2 + (self.dig_P4 << 35)
        var1 = (((var1 * var1 * self.dig_P3) >> 8) +
                ((var1 * self.dig_P2) << 12))
        var1 = (((1 << 47) + var1) * self.dig_P1) >> 33
        if var1 == 0:
            pressure = 0
        else:
            p = 1048576 - raw_press
            p = (((p << 31) - var2) * 3125) // var1
            var1 = (self.dig_P9 * (p >> 13) * (p >> 13)) >> 25
            var2 = (self.dig_P8 * p) >> 19
            pressure = ((p + var1 + var2) >> 8) + (self.dig_P7 << 4)

        # humidity
        h = self.t_fine - 76800
        h = (((((raw_hum << 14) - (self.dig_H4 << 20) -
                (self.dig_H5 * h)) + 16384)
              >> 15) * (((((((h * self.dig_H6) >> 10) *
                            (((h * self.dig_H3) >> 11) + 32768)) >> 10) +
                          2097152) * self.dig_H2 + 8192) >> 14))
        h = h - (((((h >> 15) * (h >> 15)) >> 7) * self.dig_H1) >> 4)
        h = 0 if h < 0 else h
        h = 419430400 if h > 419430400 else h
        humidity = h >> 12

        if result:
            result[0] = temp
            result[1] = pressure
            result[2] = humidity
            return result

        return array("i", (temp, pressure, humidity))

    @property
    def values(self):
        """ human readable values """

        t, p, h = self.read_compensated_data()

        p = p // 256
        pi = p // 100
        pd = p - pi * 100

        hi = h // 1024
        hd = h * 100 // 1024 - hi * 100
        return ("{}C".format(t / 100), "{}.{:02d}hPa".format(pi, pd),
                "{}.{:02d}%".format(hi, hd))

ds3231.py

MicroPython
This library is used to comunicate with DS3231 RTC using I2C and MicroPython
#source code is from here:
# https://www.instructables.com/Pi-Pico-Real-Time-Clock-DS3231-Workout/
# file name is: ds3231Modifies.py
#then I saved the most part (initialization and read/write) into a device library


#!/usr/bin/python
# -*- coding: utf-8 -*-
from machine import Pin, I2C
import utime
import binascii


#    the new version use i2c0,if it dont work,try to uncomment the line 14 and comment line 17
#    it should solder the R3 with 0R resistor if want to use alarm function,please refer to the Sch file on waveshare Pico-RTC-DS3231 wiki
#    https://www.waveshare.net/w/upload/0/08/Pico-RTC-DS3231_Sch.pdf
#I2C_PORT = 0
#I2C_SDA = 0
#I2C_SCL = 1

#i2c = I2C(0, sda = Pin(0), scl = Pin(1), freq = 100000)

ALARM_PIN = 3


class ds3231(object):
#            13:45:00 Mon 24 May 2021
#  the register value is the binary-coded decimal (BCD) format
#               sec min hour week day month year
    NowTime = b'\x00\x45\x13\x02\x24\x05\x21'
    w  = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
    address = 0x68
    start_reg = 0x00
    alarm1_reg = 0x07
    control_reg = 0x0e
    status_reg = 0x0f


#    def __init__(self,i2c_port,i2c_scl,i2c_sda, i2c=None):
    def __init__(self,i2c=None):
#        print("Port: ", i2c_port)
#        print("I2C SCL: ", i2c_scl)
#        print("I2C SDA: ", i2c_sda)
#        self.bus = I2C(i2c_port,scl=Pin(i2c_scl),sda=Pin(i2c_sda))
#        self.bus = I2C(i2c_port,scl=i2c_scl,sda=i2c_sda)
        self.bus = i2c

    def set_time(self,new_time):
        hour = new_time[0] + new_time[1]
        minute = new_time[3] + new_time[4]
        second = new_time[6] + new_time[7]
        week = "0" + str(self.w.index(new_time.split(",",2)[1])+1)
        year = new_time.split(",",2)[2][2] + new_time.split(",",2)[2][3]
        month = new_time.split(",",2)[2][5] + new_time.split(",",2)[2][6]
        day = new_time.split(",",2)[2][8] + new_time.split(",",2)[2][9]
        now_time = binascii.unhexlify((second + " " + minute + " " + hour + " " + week + " " + day + " " + month + " " + year).replace(' ',''))
        #print(binascii.unhexlify((second + " " + minute + " " + hour + " " + week + " " + day + " " + month + " " + year).replace(' ','')))
        #print(self.NowTime)
        self.bus.writeto_mem(int(self.address),int(self.start_reg),now_time)
    
    def read_time(self):
        t = self.bus.readfrom_mem(int(self.address),int(self.start_reg),7)
        a = t[0]&0x7F  #second
        b = t[1]&0x7F  #minute
        c = t[2]&0x3F  #hour
        d = t[3]&0x07  #week
        e = t[4]&0x3F  #day
        f = t[5]&0x1F  #month
#        print("20%x/%02x/%02x %02x:%02x:%02x %s" %(t[6],t[5],t[4],t[2],t[1],t[0],self.w[t[3]-1]))
        
    def year(self):
        t = self.bus.readfrom_mem(int(self.address),int(self.start_reg),7)
        hi = int((t[6]&0x70)/16) * 10
        lo = t[6]&0x0F
        return hi + lo
        
    def sec(self):
        t = self.bus.readfrom_mem(int(self.address),int(self.start_reg),7)
        hi = int((t[0]&0x70)/16) * 10
        lo = t[0]&0x0F
        return hi + lo
    
    def minute(self):
        t = self.bus.readfrom_mem(int(self.address),int(self.start_reg),7)
        hi = int((t[1]&0x70)/16) * 10
        lo = t[1]&0x0F
        return hi + lo
    
    def hour(self):
        t = self.bus.readfrom_mem(int(self.address),int(self.start_reg),7)
        hi = int((t[2]&0x30)/16) * 10
        lo = t[2]&0x0F
        return hi + lo
    
    def week(self):
        t = self.bus.readfrom_mem(int(self.address),int(self.start_reg),7)
        lo = t[3]&0x07
        return lo
    
    def day(self):
        t = self.bus.readfrom_mem(int(self.address),int(self.start_reg),7)
        hi = int((t[4]&0x30)/16) * 10
        lo = t[4]&0x0F
        return hi + lo
    
    def month(self):
        t = self.bus.readfrom_mem(int(self.address),int(self.start_reg),7)
        hi = int((t[5]&0x10)/16) * 10
        lo = t[5]&0x0F
        return hi + lo
    
    def day_name(self):
        t = self.bus.readfrom_mem(int(self.address),int(self.start_reg),7)
        return(self.w[t[3]-1])
    
    def set_alarm_time(self,alarm_time):
        #    init the alarm pin
        self.alarm_pin = Pin(ALARM_PIN,Pin.IN,Pin.PULL_UP)
        #    set alarm irq
        self.alarm_pin.irq(lambda pin: print("alarm1 time is up"), Pin.IRQ_FALLING)
        #    enable the alarm1 reg
        self.bus.writeto_mem(int(self.address),int(self.control_reg),b'\x05')
        #    convert to the BCD format
        hour = alarm_time[0] + alarm_time[1]
        minute = alarm_time[3] + alarm_time[4]
        second = alarm_time[6] + alarm_time[7]
        date = alarm_time.split(",",2)[2][8] + alarm_time.split(",",2)[2][9]
        now_time = binascii.unhexlify((second + " " + minute + " " + hour +  " " + date).replace(' ',''))
        #    write alarm time to alarm1 reg
        self.bus.writeto_mem(int(self.address),int(self.alarm1_reg),now_time)
        
    def temperature(self):
        t = self.bus.readfrom_mem(int(self.address),int(self.start_reg),19)
        whole = t[17]&0xFF        
#modificare sa afiseje doar partea intreaga a temperaturii,  nu si cea zecimala:
#        decimal = ((t[18]& 192)/64) *0.25
        temp = whole # + decimal
        if (t[17]&0xFF) > 127:
            temp = temp * -1
        return temp

##########################################################################
# All the reading and writing procedures:
##########################################################################
#Initialisation of RTC reading:    
#rtc = ds3231(I2C_PORT,I2C_SCL,I2C_SDA)
#set RTC data:
#rtc.set_time('15:19:0,Tuesday,2023-08-3')

#rtc.set_alarm_time('13:34:15,Monday,2021-05-24')

#for reading and displaying data:
#    rtc.read_time()
#rtc.set_alarm_time('13:34:15,Monday,2021-05-24')
#    print(rtc.sec())
#    print(rtc.minute())
#    print(rtc.hour())
#    print(rtc.week())
#    print(rtc.day())
#    print(rtc.year())
#    print(rtc.month())
#    print(rtc.day_name())
#    print(rtc.temperature())
#    utime.sleep(1)
    

i2c_helpers.py

MicroPython
This library is used by the dps310 library to comunicate using I2C and MicroPython.
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
"""
`i2c_helpers`
================================================================================

I2C Communications helpers


* Author(s): Jose D. Montoya

Based on
* adafruit_register.i2c_struct. Author(s): Scott Shawcroft
* adafruit_register.i2c_bits.  Author(s): Scott Shawcroft

MIT License

Copyright (c) 2016 Adafruit Industries

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

"""
# pylint: disable=too-many-arguments
import struct


class CBits:
    """
    Changes bits from a byte register
    """

    def __init__(
        self,
        num_bits: int,
        register_address: int,
        start_bit: int,
        register_width=1,
        lsb_first=True,
    ) -> None:
        self.bit_mask = ((1 << num_bits) - 1) << start_bit
        self.register = register_address
        self.star_bit = start_bit
        self.lenght = register_width
        self.lsb_first = lsb_first

    def __get__(
        self,
        obj,
        objtype=None,
    ) -> int:
        mem_value = obj._i2c.readfrom_mem(obj._address, self.register, self.lenght)

        reg = 0
        order = range(len(mem_value) - 1, -1, -1)
        if not self.lsb_first:
            order = reversed(order)
        for i in order:
            reg = (reg << 8) | mem_value[i]

        reg = (reg & self.bit_mask) >> self.star_bit

        return reg

    def __set__(self, obj, value: int) -> None:
        memory_value = obj._i2c.readfrom_mem(obj._address, self.register, self.lenght)

        reg = 0
        order = range(len(memory_value) - 1, -1, -1)
        if not self.lsb_first:
            order = range(0, len(memory_value))
        for i in order:
            reg = (reg << 8) | memory_value[i]
        reg &= ~self.bit_mask

        value <<= self.star_bit
        reg |= value
        reg = reg.to_bytes(self.lenght, "big")

        obj._i2c.writeto_mem(obj._address, self.register, reg)


class RegisterStruct:
    """
    Register Struct
    """

    def __init__(self, register_address: int, form: str) -> None:
        self.format = form
        self.register = register_address
        self.lenght = struct.calcsize(form)

    def __get__(
        self,
        obj,
        objtype=None,
    ):
        if self.lenght <= 2:
            value = struct.unpack(
                self.format,
                memoryview(
                    obj._i2c.readfrom_mem(obj._address, self.register, self.lenght)
                ),
            )[0]
        else:
            value = struct.unpack(
                self.format,
                memoryview(
                    obj._i2c.readfrom_mem(obj._address, self.register, self.lenght)
                ),
            )
        return value

    def __set__(self, obj, value):
        mem_value = struct.pack(self.format, value)
        obj._i2c.writeto_mem(obj._address, self.register, mem_value)


def twos_complement(val: int, bits: int) -> int:
    """
    Two complements
    """
    if val & (1 << (bits - 1)):
        val -= 1 << bits

    return val

Program.py

MicroPython
Main program
#Statie pentru masurarea calitatii aerului la interior
import socket
import network
import time
import utime as time

from machine import I2C
from machine import Pin

from utime import sleep_us
from time  import sleep

from A_Definitions import *
from B_Backlight import *
from C_Display_small_big_numbers import *
from E_Display_text_fix import *
from F_Web_site import *

from bme280 import BME280
from ds3231 import ds3231
from lib    import dps310
import pasco2 as sensor

#constant used to calcul the relative altitude with BME280 sensor:
pressure_sea_level=1013.25

#configure I2C interface between sensord and PSoC6:
i2c = I2C(0, scl='P6_0', sda='P6_1', freq=100000)
#configure I2C for BME280:
bme = BME280(i2c = i2c)
#configure I2C for DS3231 RTC:
rtc = ds3231(i2c = i2c)
#configure I2C for DPS310 sensor (used with DPS 368 sensor):
dps = dps310.DPS310(i2c)
#configure I2C for PAS CO2 sensor:
bus = i2c
pasco2 = sensor.PASCO2(bus)
init_status = pasco2.initialize()

num = None #variable used for display results on LCD Nokia 5110

#74HC595: set pins to output PIN objects for reset all 74HC505:
ResetPin_b = Pin('P6_2', Pin.OUT, None, value=Pin.STATE_HIGH)
ResetPin_d = Pin('P8_0', Pin.OUT, None, value=Pin.STATE_HIGH)

### Initializing all 74HC595 at startup
ResetPin_d.value(0); sleep_us(1);
ResetPin_d.value(1); sleep_us(1);

#reset 74HC595 backlight at startup:
ResetPin_b.value(0); sleep_us(1);
ResetPin_b.value(1); sleep_us(1);

#setup and activate network wlan:
ap = network.WLAN(network.AP_IF)
ap.active(True)            #activating
ap.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
ap.config(essid=ssid, password=password)

while ap.active() == False:
  pass
print('Connection is successful')
print(ap.ifconfig())

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #creating socket object
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('', 80)) # Legarea serverului la adresa i portul specificate
s.listen(1)      # Ateptarea pentru conexiune
s.settimeout(5) # Setarea unui timeout pentru accept() (de exemplu, 5 secunde)

### Functions used to in initialize the LCDs Nokia 5110:
def initialize_display_01():
    init_display(enabling_display_01,reseting_display_01,0x3c)
def initialize_display_02():
    init_display(enabling_display_02,reseting_display_02,0x3c)
def initialize_display_03():
    init_display(enabling_display_03,reseting_display_03,0x3c)
def initialize_display_04():
    init_display(enabling_display_04,reseting_display_04,0x3c)
def initialize_display_05():
    init_display(enabling_display_05,reseting_display_05,0x3c)
def initialize_display_06():
    init_display(enabling_display_06,reseting_display_06,0x3c)  
def initialize_display_07():
    init_display(enabling_display_07,reseting_display_07,0x3c) 
def initialize_display_08():
    init_display(enabling_display_08,reseting_display_08,0x3c)
def initialize_display_09():
    init_display(enabling_display_09,reseting_display_09,0x3c) 
def initialize_display_10():
    init_display(enabling_display_10,reseting_display_10,0x3c)
def initialize_display_11():
    init_display(enabling_display_11,reseting_display_11,0x3c)
def initialize_display_12():
    init_display(enabling_display_12,reseting_display_12,0x3c) 

### Calculus data displayed on each LCD Nokia 5110:
def calcul_temperatura():
    num = round( float(t), 0 )
    impartire_valoare_in_digiti(num)
    afisare_cifre_mari(0,2)
def calcul_umiditate():
    num = round( float(hi), 0 )
    impartire_valoare_in_digiti(num)
    afisare_cifre_mari(0,2)
def calcul_ITU():
    num = round( float(itu), 0 )
    impartire_valoare_in_digiti(num)
    afisare_cifre_mari(0,2)    
    num = round( float(itu), 0 )
    if num<=65:
        afisare_simbol_ITU_normal(64,2)
    elif 65<num<80:
        afisare_simbol_ITU_alerta(64,2)
    elif num>=80:
        afisare_simbol_ITU_disconfort(64,2)           
def calcul_presiune():    
    num = round( float(press), 0 )
    impartire_valoare_in_digiti(num)
    afisare_cifre_mari(0,2)
def calcul_punct_de_roua():
    num = round( float(Dewpoint), 0 )
    impartire_valoare_in_digiti(num)    
    afisare_cifre_mari(0,2)  
def calcul_altitudine():
    num = round( float(alt), 0 )
    if num<0:
        num=0
        impartire_valoare_in_digiti(num)    
        afisare_cifre_mari(0,2)
    elif num>=0:
        impartire_valoare_in_digiti(num)    
        afisare_cifre_mari(0,2)        
def calcul_data_si_ora():
    rtc.read_time()
    num = round( float(rtc.hour()), 0 )
    impartire_valoare_in_digiti(num)  
    afisare_cifre_mici(24,2)
    lcd.position(36, 2); lcd.data(Semnul_doua_puncte)
    num = round( float(rtc.minute()), 0 )
    impartire_valoare_in_digiti(num)   
    afisare_cifre_mici(44,2)
    num = round( float(rtc.day()), 0 )
    impartire_valoare_in_digiti(num) 
    afisare_cifre_mici(6,3)
    lcd.position(18, 3); lcd.data(Semnul_impartire)
    num = round( float(rtc.month()), 0 )
    impartire_valoare_in_digiti(num)   
    afisare_cifre_mici(26,3)
    lcd.position(38, 3); lcd.data(Semnul_impartire)
    lcd.position(46, 3); lcd.data(Cifra_2)
    lcd.position(52, 3); lcd.data(Cifra_0)
    num = round( float(rtc.year()), 0 )
    impartire_valoare_in_digiti(num) 
    afisare_cifre_mici(58,3)
    num = round( float(rtc.temperature()), 0 )
    impartire_valoare_in_digiti(num)
    afisare_cifre_mici(55,5)
def calcul_barometru():
    num = round( float(press), 0 )
    impartire_valoare_in_digiti(num)   
    if num<750:
        if 740<=num<745:
            num = 00; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,2)
            num = 50; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,3)
            num = 50; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,4)
            afisare_sageata_transparenta(0,2)
            afisare_simbol_sageata(0,3)
            afisare_simbol_sageata(0,4)
            num = round( float(press), 0 )
        elif 745<=num<750:
            num = 00; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,2)
            num = 10; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,3)
            num = 90; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,4)
            afisare_sageata_transparenta(0,2)
            afisare_sageata_transparenta(0,3)
            afisare_simbol_sageata(0,4)
            num = round( float(press), 0 )     
    elif 750<=num<760:
        if 750<=num<752:
            num = 00; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,2)
            num = 90; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,3)
            num = 10; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,4)
            afisare_sageata_transparenta(0,2)
            afisare_simbol_sageata(0,3)
            afisare_sageata_transparenta(0,4)
            num = round( float(press), 0 )
        elif 752<=num<755:
            num = 25; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,2)
            num = 50; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,3)
            num = 25; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,4)
            afisare_sageata_transparenta(0,2)
            afisare_simbol_sageata(0,3)
            afisare_sageata_transparenta(0,4)            
            num = round( float(press), 0 )                
        elif 755<=num<759:
            num = 90; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,2)
            num = 10; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,3)
            num = 00; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,4)
            afisare_simbol_sageata(0,2)
            afisare_sageata_transparenta(0,3)
            afisare_sageata_transparenta(0,4)            
            num = round( float(press), 0 )  
    elif num>=760:
        if 760<=num<765:
            num = 50; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,2)
            num = 50; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,3)
            num = 00; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,4)
            afisare_simbol_sageata(0,2)
            afisare_simbol_sageata(0,3)
            afisare_sageata_transparenta(0,4)            
            num = round( float(press), 0 )
        elif 765<=num:
            num = 90; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,2)
            num = 10; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,3)
            num = 00; impartire_valoare_in_digiti(num); lcd = pcd8544_mod.PCD8544(spi, DC); afisare_cifre_mici(58,4)
            afisare_simbol_sageata(0,2)
            afisare_sageata_transparenta(0,3)
            afisare_sageata_transparenta(0,4)             
            num = round( float(press), 0 ) 
def calcul_atm_press_Infineon():
    num = round( float(dps.pressure*0.75), 0 )
    impartire_valoare_in_digiti(num)
    afisare_cifre_mari(0,2)
def calcul_altitudine_Infineon():
    num = round( float(dps.altitude), 0 )
    impartire_valoare_in_digiti(num)
    afisare_cifre_mari(0,2)    
def calcul_co2_Infineon():
    co2value = co2ppm
    if co2value<0:
        num=000
    else:
        num = co2ppm
    impartire_valoare_in_digiti(num)
    afisare_cifre_mari(0,2)   
def sensor_init(): 
    if init_status != 0:
        print("[co2-module] : Sensor setup failed!")
        return -1
    else:
        print("[co2-module] : Sensor setup done successfully!")
        return pasco2
def read_sensor_data(co2Obj):
    global co2ppm
    co2ppm = co2Obj.get_co2_value()
    if co2ppm == -1:
        print("[co2-module] : Measurement not ready yet")
    else:
        print("[co2-module] : co2 ppm value: ", co2ppm)
           
### Display data in REPL console:  
def afisare_date_in_consola():
    print("Temperature:       {}".format(t), "C")
    print("Humidity:          {}".format(hi), "%")
    print("Indice ITU:        {}".format(itu), "%")
    print("Presiune atm:      {}".format(press), "mmHg")
    print("Punct de roua DEW: {}".format(Dewpoint), "C")
    print("Altitudine:        {}".format(alt), "meters")
    print(rtc.day(),"/",rtc.month(),"/20",rtc.year(),"  ",rtc.hour(),":",rtc.minute(),":",rtc.sec())
    print("RTC temp: ",rtc.temperature(), "C")
    print("Presiune atm Infineon: {}".format(dps.pressure*0.75), "mmHg")
    print("Altitude rel Infineon: {}".format(dps.altitude), "meters")
    print("CO2 Infineon: ", co2ppm, "ppm")    

### Initializare display-uri:
def initializare_display_uri():
    initialize_display_01() #initializa display 01
    initialize_display_02() #initializa display 02
    initialize_display_03() #initializa display 03
    initialize_display_04() #initializa display 04
    initialize_display_05() #initializa display 05
    initialize_display_06() #initializa display 06
    initialize_display_07() #initializa display 07
    initialize_display_08() #initializa display 08
    initialize_display_09() #initializa display 00
    initialize_display_10() #initializa display 10
    initialize_display_11() #initializa display 11
    initialize_display_12() #initializa display 12

### Read all sensors:
def read_all_sensors():
    global t; global p; global h; global hi; global itu; global press; global Dewpoint; global alt; global press_I; global alt_I;
    t,p,h = bme.read_compensated_data()
    t = t / 100
    p = p // 256
    pi = p // 100
    pd = p - pi * 100    
    hi = h // 1024
    hd = h * 100 // 1024 - hi * 100
    itu = (t*1.8 + 32) - (0.55 - 0.0055*hi) * ((t*1.8 + 32)-58)
    itu = round(float(itu), 0 )
    press=pi*0.75 #convert from hPa in mmHg
    Dewpoint = ((t)-(100-hi)/5)
    alt = (153.84*((t)+273.15))*(1-((p/100)/pressure_sea_level)**(1/5.257)) #calculus for relative altitude
    read_sensor_data(co2Obj)
    press_I = dps.pressure*0.75 # for web page display
    alt_I   = dps.altitude      # for web page display

def display_data_on_LCDs():
    select_or_reset_display(enabling_display_01); afisare_text_fix_Temperatura();           calcul_temperatura();         #show data on display 01:        
    select_or_reset_display(enabling_display_02); afisare_text_fix_Umiditate();             calcul_umiditate();           #show data on display 02:
    select_or_reset_display(enabling_display_03); afisare_text_fix_ITU();                   calcul_ITU();                 #show data on display 03:   
    select_or_reset_display(enabling_display_04); afisare_text_fix_Punct_de_roua_DEW();     calcul_punct_de_roua();       #show data on display 04:   
    select_or_reset_display(enabling_display_05); afisare_text_fix_Presiune_atm();          calcul_presiune();            #show data on display 05:      
    select_or_reset_display(enabling_display_06); afisare_text_fix_Altitudine();            calcul_altitudine();          #show data on display 06:     
    select_or_reset_display(enabling_display_07); afisare_text_fix_Barometru();             calcul_barometru();           #show data on display 07:   
    select_or_reset_display(enabling_display_08); afisare_text_fix_DATA_SI_ORA();           calcul_data_si_ora();         #show data on display 08:
    select_or_reset_display(enabling_display_09); afisare_text_fix_Presiune_atm_Infineon(); calcul_atm_press_Infineon();  #show data on display 09:
    select_or_reset_display(enabling_display_10); afisare_text_fix_Altitudine_Infineon();   calcul_altitudine_Infineon(); #show data on display 10:
    select_or_reset_display(enabling_display_11); afisare_text_fix_CO2_Infineon();          calcul_co2_Infineon();        #show data on display 11:
    select_or_reset_display(enabling_display_12); afisare_text_fix_connectivity();                                        #show data on display 12:
    
##################### MAIN PROGRAM: ######################
initializare_display_uri()
backlight_off_at_start()
co2Obj = sensor_init()
joc_la_pornire()

while True:
    try:        
        conn, addr = s.accept()                     # Socket accept() 
        print("Got connection from %s" % str(addr))
        print("Date cu conexiune la wlan AP!")    
        request=conn.recv(1024)                     # Socket receive()
        print("")
        print("Content %s" % str(request))
        request = str(request)                      # Socket send()
        update = request.find('/getData')
        if update == 6:
            read_all_sensors()                      # read all sensord 
            afisare_date_in_consola()               # display data in REPL console
            #create string with data to displat in web page:
            response = str(round(t))+"|"+str(round(hi))+"|"+str(round(itu))+"|"+str(round(Dewpoint))+"|"+str(round(press))+"|"+str(round(alt))+"|"+str(round(press_I))+"|"+str(round(alt_I))+"|"+str(round(co2ppm))
        else:
            response = web_page()       
        # Create a socket reply
        conn.send('HTTP/1.1 200 OK\n')
        conn.send('Content-Type: text/html\n')
        conn.send('Connection: close\n\n')
        conn.sendall(response)    
        conn.close()                                # Socket close()
    except:
        print("Date fara conexiune la wlan AP!")
        read_all_sensors()                          # read all sensord 
        afisare_date_in_consola()                   # display data in REPL console
        display_data_on_LCDs()
        sleep(10)
s.close()

A_Definitions.py

MicroPython
File that contain data used by Nokia 5110 lcd (pcd8544_mod.py) to display graphics
###############################################################
### Numbers, letters and signs that will be displayed on
### Nokia 5110 LCD displays
###############################################################

###############################################################
### SSID and PASS for WiFi AP::
###############################################################
ssid     = 'PSOC6'         #Set access point name 
password = '12345678'      #Set your access point password

###############################################################
### Definition of large numbers, 16 pixels height:
###############################################################
#Number 0:
Cifra_0_0 = bytearray(b'\xFC\xF9\xF3\xE7\x0F\x0F\x0F\x0F\x0F\x0F\xE7\xF3\xF9\xFC\x00\x00')
Cifra_0_1 = bytearray(b'\x7F\x3F\x1F\x0F\x00\x00\x00\x00\x00\x00\x0F\x1F\x3F\x7F\x00\x00')
Cifra_0_2 = bytearray(b'\xFE\xFC\xF8\xF0\x00\x00\x00\x00\x00\x00\xF0\xF8\xFC\xFE\x00\x00')
Cifra_0_3 = bytearray(b'\x3F\x9F\xCF\xE7\xF0\xF0\xF0\xF0\xF0\xF0\xE7\xCF\x9F\x3F\x00\x00')
#Number 1:
Cifra_1_0 = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xE0\xF0\xF8\xFC\x00\x00')
Cifra_1_1 = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\x1F\x3F\x7F\x00\x00')
Cifra_1_2 = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0\xF8\xFC\xFE\x00\x00')
Cifra_1_3 = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x0F\x1F\x3F\x00\x00')
#Number 2:
Cifra_2_0 = bytearray(b'\x00\x01\x03\x07\x0F\x0F\x0F\x0F\x0F\x0F\xE7\xF3\xF9\xFC\x00\x00')
Cifra_2_1 = bytearray(b'\x00\x00\x80\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xCF\x9F\x3F\x7F\x00\x00')
Cifra_2_2 = bytearray(b'\xFE\xFC\xF9\xF3\x03\x03\x03\x03\x03\x03\x03\x01\x00\x00\x00\x00')
Cifra_2_3 = bytearray(b'\x3F\x9F\xCF\xE7\xF0\xF0\xF0\xF0\xF0\xF0\xE0\xE0\xC0\x80\x00\x00')
#Number 3:
Cifra_3_0 = bytearray(b'\x00\x01\x03\x07\x0F\x0F\x0F\x0F\x0F\x0F\xE7\xF3\xF9\xFC\x00\x00')
Cifra_3_1 = bytearray(b'\x00\x00\x80\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xCF\x9F\x3F\x7F\x00\x00')
Cifra_3_2 = bytearray(b'\x00\x00\x01\x03\x03\x03\x03\x03\x03\x03\xF3\xF9\xFC\xFE\x00\x00')
Cifra_3_3 = bytearray(b'\x00\x80\xC0\xE0\xF0\xF0\xF0\xF0\xF0\xF0\xE7\xCF\x9F\x3F\x00\x00')
#Number 4:
Cifra_4_0 = bytearray(b'\xFC\xF8\xF0\xE0\x00\x00\x00\x00\x00\x00\xE0\xF0\xF8\xFC\x00\x00')
Cifra_4_1 = bytearray(b'\x7F\x3F\x9F\xCF\xC0\xC0\xC0\xC0\xC0\xC0\xCF\x9F\x3F\x7F\x00\x00')
Cifra_4_2 = bytearray(b'\x00\x00\x01\x03\x03\x03\x03\x03\x03\x03\xF3\xF9\xFC\xFE\x00\x00')
Cifra_4_3 = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x0F\x1F\x3F\x00\x00')
#Number 5:
Cifra_5_0 = bytearray(b'\xFC\xF9\xF3\xE7\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x07\x03\x01\x00\x00')
Cifra_5_1 = bytearray(b'\x7F\x3F\x9F\xCF\xC0\xC0\xC0\xC0\xC0\xC0\xC0\x80\x00\x00\x00\x00')
Cifra_5_2 = bytearray(b'\x00\x00\x01\x03\x03\x03\x03\x03\x03\x03\xF3\xF9\xFC\xFE\x00\x00')
Cifra_5_3 = bytearray(b'\x00\x80\xC0\xE0\xF0\xF0\xF0\xF0\xF0\xF0\xE7\xCF\x9F\x3F\x00\x00')
#Number 6:
Cifra_6_0 = bytearray(b'\xFC\xF9\xF3\xE7\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x07\x03\x01\x00\x00')
Cifra_6_1 = bytearray(b'\x7F\x3F\x9F\xCF\xC0\xC0\xC0\xC0\xC0\xC0\xC0\x80\x00\x00\x00\x00')
Cifra_6_2 = bytearray(b'\xFE\xFC\xF9\xF3\x03\x03\x03\x03\x03\x03\xF3\xF9\xFC\xFE\x00\x00')
Cifra_6_3 = bytearray(b'\x3F\x9F\xCF\xE7\xF0\xF0\xF0\xF0\xF0\xF0\xE7\xCF\x9F\x3F\x00\x00')
#Number 7:
Cifra_7_0 = bytearray(b'\x00\x01\x03\x07\x0F\x0F\x0F\x0F\x0F\x0F\xE7\xF3\xF9\xFC\x00\x00')
Cifra_7_1 = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\x1F\x3F\x7F\x00\x00')
Cifra_7_2 = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0\xF8\xFC\xFE\x00\x00')
Cifra_7_3 = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x0F\x1F\x3F\x00\x00')
#Number 8:
Cifra_8_0 = bytearray(b'\xFC\xF9\xF3\xE7\x0F\x0F\x0F\x0F\x0F\x0F\xE7\xF3\xF9\xFC\x00\x00')
Cifra_8_1 = bytearray(b'\x7F\x3F\x9F\xCF\xC0\xC0\xC0\xC0\xC0\xC0\xCF\x9F\x3F\x7F\x00\x00')
Cifra_8_2 = bytearray(b'\xFE\xFC\xF9\xF3\x03\x03\x03\x03\x03\x03\xF3\xF9\xFC\xFE\x00\x00')
Cifra_8_3 = bytearray(b'\x3F\x9F\xCF\xE7\xF0\xF0\xF0\xF0\xF0\xF0\xE7\xCF\x9F\x3F\x00\x00')
#Number 9:
Cifra_9_0 = bytearray(b'\xFC\xF9\xF3\xE7\x0F\x0F\x0F\x0F\x0F\x0F\xE7\xF3\xF9\xFC\x00\x00')
Cifra_9_1 = bytearray(b'\x7F\x3F\x9F\xCF\xC0\xC0\xC0\xC0\xC0\xC0\xCF\x9F\x3F\x7F\x00\x00')
Cifra_9_2 = bytearray(b'\x00\x00\x01\x03\x03\x03\x03\x03\x03\x03\xF3\xF9\xFC\xFE\x00\x00')
Cifra_9_3 = bytearray(b'\x00\x80\xC0\xE0\xF0\xF0\xF0\xF0\xF0\xF0\xE7\xCF\x9F\x3F\x00\x00')

Cifra_transparenta = bytearray(b'\x00')


###############################################################
### Definition of small numbers, 8 pixels height:
###############################################################
Cifra_0 = bytearray(b'\x3E\x41\x41\x41\x3E\x00') #Number 0
Cifra_1 = bytearray(b'\x00\x42\x7F\x40\x00\x00') #Number 1
Cifra_2 = bytearray(b'\x42\x61\x51\x49\x46\x00') #Number 2
Cifra_3 = bytearray(b'\x21\x41\x45\x4B\x31\x00') #Number 3
Cifra_4 = bytearray(b'\x18\x14\x12\x7F\x10\x00') #Number 4
Cifra_5 = bytearray(b'\x27\x45\x45\x45\x39\x00') #Number 5
Cifra_6 = bytearray(b'\x3C\x4A\x49\x49\x30\x00') #Number 6
Cifra_7 = bytearray(b'\x01\x71\x09\x05\x03\x00') #Number 7
Cifra_8 = bytearray(b'\x36\x49\x49\x49\x36\x00') #Number 8
Cifra_9 = bytearray(b'\x06\x49\x49\x29\x1E\x00') #Number 9


###############################################################
### Definition of capital letter, 8 pixels height:
###############################################################
Litera_A = bytearray(b'\x7E\x11\x11\x11\x7E\x00') #Letter A
Litera_B = bytearray(b'\x7F\x49\x49\x49\x36\x00') #Letter B
Litera_C = bytearray(b'\x3E\x41\x41\x41\x22\x00') #Letter C
Litera_D = bytearray(b'\x7F\x41\x41\x41\x3E\x00') #Letter D
Litera_E = bytearray(b'\x7f\x49\x49\x49\x41\x00') #Letter E
Litera_F = bytearray(b'\x7F\x09\x09\x09\x01\x00') #Letter F
#Litera_G = bytearray(b'\x7F\x09\x09\x09\x01\x00') #Letter FG
Litera_H = bytearray(b'\x7F\x08\x08\x08\x7F\x00') #Letter H
Litera_I = bytearray(b'\x41\x41\x7F\x41\x41\x00') #Letter I
#Litera_J = bytearray(b'\x41\x41\x7F\x41\x41\x00') #Letter IJ
#Litera_K = bytearray(b'\x41\x41\x7F\x41\x41\x00') #Letter IK
Litera_L = bytearray(b'\x7F\x40\x40\x40\x40\x00') #Letter L
Litera_M = bytearray(b'\x7F\x02\x0C\x02\x7F\x00') #Letter M
Litera_N = bytearray(b'\x7F\x04\x08\x10\x7F\x00') #Letter N
Litera_O = bytearray(b'\x3E\x41\x41\x41\x3E\x00') #Letter O
Litera_P = bytearray(b'\x7F\x09\x09\x09\x06\x00') #Letter P
#Litera_Q = bytearray(b'\x41\x41\x7F\x41\x41\x00') #Letter IQ
Litera_R = bytearray(b'\x7F\x09\x19\x29\x46\x00') #Letter R
Litera_S = bytearray(b'\x26\x49\x49\x49\x32\x00') #Letter S
Litera_T = bytearray(b'\x01\x01\x7F\x01\x01\x00') #Letter T
Litera_U = bytearray(b'\x3F\x40\x40\x40\x3F\x00') #Letter U
Litera_V = bytearray(b'\x1F\x20\x40\x20\x1F\x00') #Letter V
#Litera_X = bytearray(b'\x41\x41\x7F\x41\x41\x00') #Letter IX
Litera_Y = bytearray(b'\x03\x04\x78\x04\x03\x00') #Letter Y
Litera_W = bytearray(b'\x3F\x40\x38\x40\x3F\x00') #Letter W
#Litera_Z = bytearray(b'\x41\x41\x7F\x41\x41\x00') #Letter IZ


###############################################################
### Definition of lowercase letter, 8 pixels height:
###############################################################
Litera_p = bytearray(b'\xF8\x28\x28\x28\x10\x00') #Letter p
Litera_e = bytearray(b'\x38\x54\x54\x54\x18\x00') #Letter e
Litera_b = bytearray(b'\xF8\xA0\xA0\xA0\x40\x00') #Letter b
Litera_m = bytearray(b'\x7C\x04\x18\x04\x78\x00') #Letter m
Litera_g = bytearray(b'\x18\xA4\xA4\xA4\x78\x00') #Letter g
Litera_t = bytearray(b'\x04\x3F\x44\x40\x20\x00') #Letter t

###############################################################
### Definition of special characters, 8 & 16 pixels height:
###############################################################
Semnul_punct          = bytearray(b'\x60\x60') #Semnul "."
Semnul_doua_puncte    = bytearray(b'\x00\x00\x66\x66') #Semnul ":"
Semnul_procent_1      = bytearray(b'\x1E\x3F\x33\x33\x3F\x9E\xC0\x60\x30\x18\x0C\x06\x03\x01\x00') #sign %, upper part
Semnul_procent_2      = bytearray(b'\x30\x18\x0C\x06\x03\x01\x00\x00\x1E\x3F\x33\x33\x3F\x1E\x00') #sign %, lower part
Semn_grad_Celsius     = bytearray(b'\x00\x1E\x3F\x33\x33\x3F\x1E\x00') #Celsius degree sigh:
Semnul_procent        = bytearray(b'\x47\x25\x17\x08\x74\x52\x71\x00') #sigh %, 8 pixel height
Semn_sageata          = bytearray(b'\x08\x08\x08\x08\x08\x3E\x1C\x08') #sign horizontal arrow to right
Sageata_transparenta  = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') #sign transparent arrow
Semnul_impartire      = bytearray(b'\x00\x40\x20\x10\x08\x04\x00\x00') #sign /, 8 pixel height
Semn_grad_Celsius_mic = bytearray(b'\x00\x00\x07\x05\x07\x00')         #sign degreee Celsius, 8 pixel height

Litera_grad_Celsius_1 = bytearray(b'\xFC\xFE\xFF\x0F\x07\x07\x07\x07\x0F\x1F\x1E\x1C') #Letter C, upper part
Litera_grad_Celsius_2 = bytearray(b'\x3F\x7F\xFF\xF0\xE0\xE0\xE0\xE0\xF0\xF8\x78\x38') #Letter C, lower part

Semn_picatura_1       = bytearray(b'\x00\x00\x00\x80\x60\x1C\x03\x1C\x60\x80\x00\x00')
Semn_picatura_2       = bytearray(b'\x00\x1E\x3D\x6C\xDC\xDC\xFC\xFC\xFC\x7C\x3D\x1E')

Semn_termometru_1     = bytearray(b'\x00\x00\xFE\x01\xFD\x01\xFE\x00\x00')
Semn_termometru_2     = bytearray(b'\x38\x44\x83\xB8\x3F\xB8\x83\x44\x38')
 
Semn_ITU_normal_1     = bytearray(b'\xE0\x10\x08\x24\x22\x21\x21\x21\x01\x21\x21\x21\x22\x24\x08\x10\xE0')
Semn_ITU_normal_2     = bytearray(b'\x07\x08\x10\x20\x40\x88\x90\x90\x90\x90\x90\x88\x40\x20\x10\x08\x07')

Semn_ITU_alerta_1     = bytearray(b'\xE0\x10\x08\x64\x92\x91\x61\x01\x01\x01\x61\x91\x92\x64\x08\x10\xE0')
Semn_ITU_alerta_2     = bytearray(b'\x07\x08\x10\x20\x40\x80\x90\x90\x90\x90\x90\x80\x40\x20\x10\x08\x07')

Semn_ITU_disconfort_1 = bytearray(b'\xE0\x10\x08\x44\x22\x11\x09\x01\x01\x01\x09\x11\x22\x44\x08\x10\xE0')
Semn_ITU_disconfort_2 = bytearray(b'\x07\x08\x10\x20\x40\x90\x88\x88\x88\x88\x88\x90\x40\x20\x10\x08\x07')

Semn_presiune_1       = bytearray(b'\x00\x00\xC0\x80\x00\x00\xC4\x4C\x5E\x4C\xC4\x00\x00\x80\xC0\x00')
Semn_presiune_2       = bytearray(b'\x00\x01\x07\x03\x01\x00\x47\x64\xF4\x64\x47\x00\x01\x03\x07\x01')

Semn_altitudine_1     = bytearray(b'\x00\x00\x00\x80\x60\x18\x87\x0C\x10\x60\x80\x00\x00\x00\x00\x04\x06\xFF\x06\x04')
Semn_altitudine_2     = bytearray(b'\xE0\xD8\xC6\xF1\xC8\xC6\xC1\xC3\xC4\xD8\xE0\xC3\xC6\xC8\xF0\xE0\x00\xFF\x00\x00')

Semn_CO2_1            = bytearray(b'\x00\x00\x00\x80\x10\x10\x38\x7C\xFF\x7C\x38\x10\x10\x00\x00\xC0\x00\x00\x00\x00')
Semn_CO2_2            = bytearray(b'\x04\x04\x0E\x3F\x0E\x04\x04\x00\x01\x00\x00\x02\x02\x07\x1F\x07\x02\x02\x00\x00')

###############################################################
### Strings used to enable each LCD display:
###############################################################
enabling_display_01            = "101111111111111111111111"
enabling_display_02            = "111011111111111111111111"
enabling_display_03            = "111110111111111111111111"
enabling_display_04            = "111111101111111111111111"
enabling_display_05            = "111111111011111111111111"
enabling_display_06            = "111111111110111111111111"
enabling_display_07            = "111111111111101111111111"
enabling_display_08            = "111111111111111011111111"
enabling_display_09            = "111111111111111110111111"
enabling_display_10            = "111111111111111111101111"
enabling_display_11            = "111111111111111111111011"
enabling_display_12            = "111111111111111111111110"

###############################################################
### Strings used to reset each LCD display:
###############################################################
reseting_display_01            = "011111111111111111111111"
reseting_display_02            = "110111111111111111111111"
reseting_display_03            = "111101111111111111111111"
reseting_display_04            = "111111011111111111111111"
reseting_display_05            = "111111110111111111111111"
reseting_display_06            = "111111111101111111111111"
reseting_display_07            = "111111111111011111111111"
reseting_display_08            = "111111111111110111111111"
reseting_display_09            = "111111111111111101111111"
reseting_display_10            = "111111111111111111011111"
reseting_display_11            = "111111111111111111110111"
reseting_display_12            = "111111111111111111111101"

enabling_reseting_display_none = "111111111111111111111111"

#variables used for On/Off background (b):
b01 = "0"; b02 = "0"; b03 = "0"; b04 = "0";
b05 = "0"; b06 = "0"; b07 = "0"; b08 = "0";
b09 = "0"; b10 = "0"; b11 = "0"; b12 = "0";

B_Backlight.py

MicroPython
File contains functions used to control backlight of Nokia 5110 LCDs
from machine import Pin
from utime import sleep_us
from time  import sleep

import time

from A_Definitions import *

string_backlight = None


#################### Start 74HC595 pins setup - ######################
dataPIN_b   = Pin('P12_0', Pin.OUT)
latchPIN_b  = Pin('P12_3', Pin.OUT)
clockPIN_b  = Pin('P13_4', Pin.OUT)
enablePIN_b = Pin('P13_6', Pin.OUT)

dataPIN_backlight     = dataPIN_b
latchPIN_backlight    = latchPIN_b
clockPIN_backlight    = clockPIN_b
EnablePin_backlight   = enablePIN_b


#define shift register update function for 74HC595 used for backlight On/Off::
def shift_update_backlight(input_b,data,clock,latch):
#put latch down to start data sending
    clockPIN_backlight.value(0)
    latchPIN_backlight.value(0)
    clockPIN_backlight.value(1)   
#load data in reverse order
    for i in range(11, -1, -1):
        clockPIN_backlight.value(0)
        dataPIN_backlight.value(int(input_b[i]))
        clockPIN_backlight.value(1)
#put latch up to store data on register
    clockPIN_backlight.value(0)
    latchPIN_backlight.value(1)   
    clockPIN_backlight.value(1)   
    return

#function used to create a string for activate backlight:
#def create_string():
#    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])

def backlight_on_off(string_backlight):
#    create_string()
    EnablePin_backlight.value(1)
    shift_update_backlight(string_backlight,dataPIN_b,clockPIN_b,latchPIN_b)
    EnablePin_backlight.value(0)

def backlight_off_at_start():   
    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])
    backlight_on_off(string_backlight)		#apeleaza functia de On/Off backgroung
        
def joc_la_pornire():
    print("Joc la pornire")
    b01 = "1"; b02 = "0"; b03 = "0"; b04 = "0";
    b05 = "0"; b06 = "0"; b07 = "0"; b08 = "0";
    b09 = "0"; b10 = "0"; b11 = "0"; b12 = "0";
    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])
    backlight_on_off(string_backlight)		#apeleaza functia de On/Off backgroung
    time.sleep(0.5)

    b01 = "1"; b02 = "1"; b03 = "0"; b04 = "0";
    b05 = "1"; b06 = "0"; b07 = "0"; b08 = "0";
    b09 = "0"; b10 = "0"; b11 = "0"; b12 = "0";
    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])
    backlight_on_off(string_backlight)		#apeleaza functia de On/Off backgroung
    time.sleep(0.5)

    b01 = "1"; b02 = "1"; b03 = "1"; b04 = "0";
    b05 = "1"; b06 = "1"; b07 = "0"; b08 = "0";
    b09 = "1"; b10 = "0"; b11 = "0"; b12 = "0";
    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])
    backlight_on_off(string_backlight)		#apeleaza functia de On/Off backgroung
    time.sleep(0.5)

    b01 = "0"; b02 = "1"; b03 = "1"; b04 = "1";
    b05 = "1"; b06 = "1"; b07 = "1"; b08 = "0";
    b09 = "1"; b10 = "1"; b11 = "0"; b12 = "0";
    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])
    backlight_on_off(string_backlight)		#apeleaza functia de On/Off backgroung
    time.sleep(0.5)   

    b01 = "0"; b02 = "0"; b03 = "1"; b04 = "1";
    b05 = "0"; b06 = "1"; b07 = "1"; b08 = "1";
    b09 = "1"; b10 = "1"; b11 = "1"; b12 = "0";
    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])
    backlight_on_off(string_backlight)		#apeleaza functia de On/Off backgroung
    time.sleep(0.5)    

    b01 = "0"; b02 = "0"; b03 = "0"; b04 = "1";
    b05 = "0"; b06 = "0"; b07 = "1"; b08 = "1";
    b09 = "0"; b10 = "1"; b11 = "1"; b12 = "1";
    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])
    backlight_on_off(string_backlight)		#apeleaza fucntia de On/Off backgroung
    time.sleep(0.5)   

    b01 = "0"; b02 = "0"; b03 = "0"; b04 = "0";
    b05 = "0"; b06 = "0"; b07 = "0"; b08 = "1";
    b09 = "0"; b10 = "0"; b11 = "1"; b12 = "1";
    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])
    backlight_on_off(string_backlight)		#apeleaza functia de On/Off backgroung
    time.sleep(0.5)    

    b01 = "0"; b02 = "0"; b03 = "0"; b04 = "0";
    b05 = "0"; b06 = "0"; b07 = "0"; b08 = "0";
    b09 = "0"; b10 = "0"; b11 = "0"; b12 = "1";
    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])
    backlight_on_off(string_backlight)		#apeleaza functia de On/Off backgroung
    time.sleep(0.5)    

    b01 = "0"; b02 = "0"; b03 = "0"; b04 = "0";
    b05 = "0"; b06 = "0"; b07 = "0"; b08 = "0";
    b09 = "0"; b10 = "0"; b11 = "0"; b12 = "0";
    string_backlight = "".join([b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12])
    backlight_on_off(string_backlight)		#apeleaza functia de On/Off backgroung
    time.sleep(0.5)
    

C_Display_small_big_numbers.py

MicroPython
File that contains functions used to display big and slamm numbers on Nokia 5110 LCD
from machine import SPI
from machine import Pin
from utime   import sleep_us 

import pcd8544_mod

spi = SPI(0, baudrate = 100000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB, sck='P9_2', mosi='P9_0', miso='P9_1')
spi.init()

DC = Pin('P5_7')     #Data/Commands - specific for LCD Nokia 5110 display
DC.init(Pin.OUT, None, value=Pin.STATE_HIGH)

contrast = 0xff      #used for set contrast for LCD Nokia 5110 display; default value is 0xff

from A_Definitions import *
from D_Format_text_fix import *


#definire variabile folosita la impartirea valorior senzorilor in digiti:
mii     = None #folosita global
sute    = None #folosita global
zeci    = None #folosita global
unitati = None #sfolosita global
#################### Start 74HC595 pins setup - ######################
dataPIN_d   =  Pin('P9_4', Pin.OUT)
latchPIN_d  =  Pin('P9_5', Pin.OUT)
clockPIN_d  =  Pin('P9_6', Pin.OUT)
enablePIN_d =  Pin('P9_7', Pin.OUT)

dataPIN_display     = dataPIN_d
latchPIN_display    = latchPIN_d
clockPIN_display    = clockPIN_d
EnablePin_display   = enablePIN_d

### Impartire in digiti a numerelor de afisat:
def impartire_valoare_in_digiti(num):
    global mii;     mii     = num // 1000
    global sute;    sute    = (num % 1000) // 100
    global zeci;    zeci    = (num % 100) // 10
    global unitati; unitati = (num % 10)
    return

##### Display big numbers on display:  
def afisare_cifre_mari(x_pos, y_pos):
#display digit thousand:
    if (mii == 0):           afiseaza_cifra_zero_transparenta(x_pos+0,y_pos)
    elif mii == 1:           afiseaza_cifra_unu(x_pos+0,y_pos)        
    elif mii == 2:           afiseaza_cifra_doi(x_pos+0,y_pos)    
    elif mii == 3:           afiseaza_cifra_trei(x_pos+0,y_pos)    
    elif mii == 4:           afiseaza_cifra_patru(x_pos+0,y_pos)
    elif mii == 5:           afiseaza_cifra_cinci(x_pos+0,y_pos)        
    elif mii == 6:           afiseaza_cifra_sase(x_pos+0,y_pos)    
    elif mii == 7:           afiseaza_cifra_sapte(x_pos+0,y_pos)
    elif mii == 8:           afiseaza_cifra_opt(x_pos+0,y_pos)    
    elif mii == 9:           afiseaza_cifra_noua(x_pos+0,y_pos)

#display digit hundreds:
    if ( mii > 0):
        if sute == 0:        afiseaza_cifra_zero(x_pos+16,y_pos)
        else:
            if sute == 1:    afiseaza_cifra_unu(x_pos+16,y_pos)     
            elif sute == 2:  afiseaza_cifra_doi(x_pos+16,y_pos)    
            elif sute == 3:  afiseaza_cifra_trei(x_pos+16,y_pos)    
            elif sute == 4:  afiseaza_cifra_patru(x_pos+16,y_pos)
            elif sute == 5:  afiseaza_cifra_cinci(x_pos+16,y_pos)        
            elif sute == 6:  afiseaza_cifra_sase(x_pos+16,y_pos)    
            elif sute == 7:  afiseaza_cifra_sapte(x_pos+16,y_pos)
            elif sute == 8:  afiseaza_cifra_opt(x_pos+16,y_pos)    
            elif sute == 9:  afiseaza_cifra_noua(x_pos+16,y_pos)
    if (mii == 0):
        if (sute == 0):      afiseaza_cifra_zero_transparenta(x_pos+16,y_pos)
        else:
            if sute == 1:    afiseaza_cifra_unu(x_pos+16,y_pos)     
            elif sute == 2:  afiseaza_cifra_doi(x_pos+16,y_pos)    
            elif sute == 3:  afiseaza_cifra_trei(x_pos+16,y_pos)    
            elif sute == 4:  afiseaza_cifra_patru(x_pos+16,y_pos)
            elif sute == 5:  afiseaza_cifra_cinci(x_pos+16,y_pos)        
            elif sute == 6:  afiseaza_cifra_sase(x_pos+16,y_pos)    
            elif sute == 7:  afiseaza_cifra_sapte(x_pos+16,y_pos)
            elif sute == 8:  afiseaza_cifra_opt(x_pos+16,y_pos)    
            elif sute == 9:  afiseaza_cifra_noua(x_pos+16,y_pos)           
#display digit tens:
    if zeci == 0:            afiseaza_cifra_zero(x_pos+32,y_pos) 
    elif zeci == 1:          afiseaza_cifra_unu(x_pos+32,y_pos)        
    elif zeci == 2:          afiseaza_cifra_doi(x_pos+32,y_pos)    
    elif zeci == 3:          afiseaza_cifra_trei(x_pos+32,y_pos)    
    elif zeci == 4:          afiseaza_cifra_patru(x_pos+32,y_pos)
    elif zeci == 5:          afiseaza_cifra_cinci(x_pos+32,y_pos)        
    elif zeci == 6:          afiseaza_cifra_sase(x_pos+32,y_pos)    
    elif zeci == 7:          afiseaza_cifra_sapte(x_pos+32,y_pos)
    elif zeci == 8:          afiseaza_cifra_opt(x_pos+32,y_pos)    
    elif zeci == 9:          afiseaza_cifra_noua(x_pos+32,y_pos)
#display digit units:
    if unitati == 0:         afiseaza_cifra_zero(x_pos+48,y_pos) 
    elif unitati == 1:       afiseaza_cifra_unu(x_pos+48,y_pos)        
    elif unitati == 2:       afiseaza_cifra_doi(x_pos+48,y_pos)    
    elif unitati == 3:       afiseaza_cifra_trei(x_pos+48,y_pos)    
    elif unitati == 4:       afiseaza_cifra_patru(x_pos+48,y_pos)
    elif unitati == 5:       afiseaza_cifra_cinci(x_pos+48,y_pos)        
    elif unitati == 6:       afiseaza_cifra_sase(x_pos+48,y_pos)    
    elif unitati == 7:       afiseaza_cifra_sapte(x_pos+48,y_pos)
    elif unitati == 8:       afiseaza_cifra_opt(x_pos+48,y_pos)    
    elif unitati == 9:       afiseaza_cifra_noua(x_pos+48,y_pos)
    return

### Function used to update data into 74HC595:
def shift_update_display(input_d,data,clock,latch):
#put latch down to start data sending:
    clockPIN_display.value(0)
    latchPIN_display.value(0)
    clockPIN_display.value(1)
#load data in reverse order:
    for j in range(23, -1, -1):
        clockPIN_display.value(0)
        dataPIN_display.value(int(input_d[j]))
        clockPIN_display.value(1)
#put latch up to store data on register:
    clockPIN_display.value(0)
    latchPIN_display.value(1)
    clockPIN_display.value(1)
    return

### Function used to activate, deactivare and/or reset display LCD Nokia 5110:
def select_or_reset_display(string_display):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    EnablePin_display.value(1)    
    shift_update_display(string_display,dataPIN_d,clockPIN_d,latchPIN_d)
    EnablePin_display.value(0)    
    return

### Function used to initialize the display LCD Nokia 5110:
def init_display(enable_disp_nr, reset_disp_nr, contrast):
    select_or_reset_display(reset_disp_nr)
    sleep_us(10)
    select_or_reset_display(enabling_reseting_display_none)
    sleep_us(10)
    select_or_reset_display(enable_disp_nr)
    lcd = pcd8544_mod.PCD8544(spi, DC)      #set comunication between MCU and display using SPI and set DC pin:
    lcd.init(True, contrast, 0x14, 0x06)    #initialize LCD display:
    lcd.clear                               #clear LCD display:
    select_or_reset_display(enable_disp_nr)    
    return

### Display small number on display LCD Nokia 5110:
def afisare_cifre_mici(x_pos,y_pos):
#display digit thousand: nothing special will be displayed; it is hardcoded number 2 RTC, year (from year 20xx)
#display digit hundreds: nothing special will be displayed; it is hardcoded number 0 RTC, year (from year 20xx)

#display digit tens:
    if zeci == 0:
        lcd.position(x_pos+00, y_pos);    lcd.data(Cifra_0)
    elif zeci == 1:
        lcd.position(x_pos+00, y_pos);    lcd.data(Cifra_1)        
    elif zeci == 2:
        lcd.position(x_pos+00, y_pos);    lcd.data(Cifra_2)   
    elif zeci == 3:
        lcd.position(x_pos+00, y_pos);    lcd.data(Cifra_3)    
    elif zeci == 4:
        lcd.position(x_pos+00, y_pos);    lcd.data(Cifra_4)
    elif zeci == 5:
        lcd.position(x_pos+00, y_pos);    lcd.data(Cifra_5)        
    elif zeci == 6:
        lcd.position(x_pos+00, y_pos);    lcd.data(Cifra_6)
    elif zeci == 7:
        lcd.position(x_pos+00, y_pos);    lcd.data(Cifra_7)
    elif zeci == 8:
        lcd.position(x_pos+00, y_pos);    lcd.data(Cifra_8)   
    elif zeci == 9:
        lcd.position(x_pos+00, y_pos);    lcd.data(Cifra_9)

#display digit units:
    if unitati == 0:
        lcd.position(x_pos+06, y_pos);    lcd.data(Cifra_0)
    elif unitati == 1:
        lcd.position(x_pos+06, y_pos);    lcd.data(Cifra_1)
    elif unitati == 2:
        lcd.position(x_pos+06, y_pos);    lcd.data(Cifra_2)
    elif unitati == 3:
        lcd.position(x_pos+06, y_pos);    lcd.data(Cifra_3)
    elif unitati == 4:
        lcd.position(x_pos+06, y_pos);    lcd.data(Cifra_4)
    elif unitati == 5:
        lcd.position(x_pos+06, y_pos);    lcd.data(Cifra_5)
    elif unitati == 6:
        lcd.position(x_pos+06, y_pos);    lcd.data(Cifra_6)
    elif unitati == 7:
        lcd.position(x_pos+06, y_pos);    lcd.data(Cifra_7)
    elif unitati == 8:
        lcd.position(x_pos+06, y_pos);    lcd.data(Cifra_8)
    elif unitati == 9:
        lcd.position(x_pos+06, y_pos);    lcd.data(Cifra_9)    

### Display the big numbers on LCD Nokia 5110 (from four parts):
def afiseaza_cifra_zero(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_0_0)
    lcd.position(x_position, y_position+1);    lcd.data(Cifra_0_1)
    lcd.position(x_position, y_position+2);    lcd.data(Cifra_0_2)
    lcd.position(x_position, y_position+3);    lcd.data(Cifra_0_3)
    return
def afiseaza_cifra_unu(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_1_0)
    lcd.position(x_position, y_position+1);    lcd.data(Cifra_1_1)
    lcd.position(x_position, y_position+2);    lcd.data(Cifra_1_2)
    lcd.position(x_position, y_position+3);    lcd.data(Cifra_1_3)
    return
def afiseaza_cifra_doi(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_2_0)
    lcd.position(x_position, y_position+1);    lcd.data(Cifra_2_1)
    lcd.position(x_position, y_position+2);    lcd.data(Cifra_2_2)
    lcd.position(x_position, y_position+3);    lcd.data(Cifra_2_3)
    return
def afiseaza_cifra_trei(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_3_0)
    lcd.position(x_position, y_position+1);    lcd.data(Cifra_3_1)
    lcd.position(x_position, y_position+2);    lcd.data(Cifra_3_2)
    lcd.position(x_position, y_position+3);    lcd.data(Cifra_3_3)
    return
def afiseaza_cifra_patru(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_4_0)
    lcd.position(x_position, y_position+1);    lcd.data(Cifra_4_1)
    lcd.position(x_position, y_position+2);    lcd.data(Cifra_4_2)
    lcd.position(x_position, y_position+3);    lcd.data(Cifra_4_3)
    return
def afiseaza_cifra_cinci(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_5_0)
    lcd.position(x_position, y_position+1);    lcd.data(Cifra_5_1)
    lcd.position(x_position, y_position+2);    lcd.data(Cifra_5_2)
    lcd.position(x_position, y_position+3);    lcd.data(Cifra_5_3)
    return
def afiseaza_cifra_sase(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_6_0)
    lcd.position(x_position, y_position+1);    lcd.data(Cifra_6_1)
    lcd.position(x_position, y_position+2);    lcd.data(Cifra_6_2)
    lcd.position(x_position, y_position+3);    lcd.data(Cifra_6_3)
    return
def afiseaza_cifra_sapte(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_7_0)
    lcd.position(x_position, y_position+1);    lcd.data(Cifra_7_1)
    lcd.position(x_position, y_position+2);    lcd.data(Cifra_7_2)
    lcd.position(x_position, y_position+3);    lcd.data(Cifra_7_3)
    return
def afiseaza_cifra_opt(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_8_0)
    lcd.position(x_position, y_position+1);    lcd.data(Cifra_8_1)
    lcd.position(x_position, y_position+2);    lcd.data(Cifra_8_2)
    lcd.position(x_position, y_position+3);    lcd.data(Cifra_8_3)
    return
def afiseaza_cifra_noua(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_9_0)
    lcd.position(x_position, y_position+1);    lcd.data(Cifra_9_1)
    lcd.position(x_position, y_position+2);    lcd.data(Cifra_9_2)
    lcd.position(x_position, y_position+3);    lcd.data(Cifra_9_3)
    return
def afiseaza_cifra_zero_transparenta(x_position, y_position):
    lcd = pcd8544_mod.PCD8544(spi, DC)
    lcd.position(x_position, y_position+0);    lcd.data(Cifra_transparenta)
    return

D_Format_text_fix.py

MicroPython
File with function used to format text fix for displaying on Nokia 5110 lcd, at startup
import pcd8544_mod
from C_Display_small_big_numbers import *
lcd = pcd8544_mod.PCD8544(spi, DC) 
##### Format text and simbol for Temperature: 
def afiseaza_text_Temperatura(x_pos, y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_M)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_P)
    lcd.position(x_pos+24,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+30,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+36,y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+42,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+48,y_pos);    lcd.data(Litera_U)
    lcd.position(x_pos+54,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+60,y_pos);    lcd.data(Litera_E)
def afiseaza_semn_grad_celsius(x_pos, y_pos):
    lcd.position(x_pos+0,y_pos+0);   lcd.data(Semn_grad_Celsius)
    lcd.position(x_pos+8,y_pos+0);   lcd.data(Litera_grad_Celsius_1)
    lcd.position(x_pos+8,y_pos+1);   lcd.data(Litera_grad_Celsius_2)
def afiseaza_simbol_termometru(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semn_termometru_1)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semn_termometru_2)
##### Format text si simbol for Humidity:   
def afiseaza_text_Umiditate(x_pos, y_pos): 
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_H)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_U)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_M)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+24,y_pos);    lcd.data(Litera_D)
    lcd.position(x_pos+30,y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+36,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+42,y_pos);    lcd.data(Litera_Y) 
def afiseaza_picatura_umiditate(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semn_picatura_1)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semn_picatura_2)
def afiseaza_procent_RH(x_pos,y_pos):
    lcd.position(x_pos+0,y_pos+0);   lcd.data(Semnul_procent_1)
    lcd.position(x_pos+0,y_pos+1);   lcd.data(Semnul_procent_2)
    lcd.position(x_pos+4,y_pos+3);   lcd.data(Litera_R)
    lcd.position(x_pos+10,y_pos+3);  lcd.data(Litera_H)   
##### Format text and simbol for Atm Presssure:  
def afiseaza_text_Presiune_atm(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_M)
    lcd.position(x_pos+22,y_pos);    lcd.data(Litera_P)
    lcd.position(x_pos+28,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+34,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+40,y_pos);    lcd.data(Litera_S)
    lcd.position(x_pos+46,y_pos);    lcd.data(Litera_S)
    lcd.position(x_pos+52,y_pos);    lcd.data(Litera_U)
    lcd.position(x_pos+58,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+64,y_pos);    lcd.data(Litera_E)  
def afiseaza_text_mmHg(x_pos,y_pos):   
    lcd.position(x_pos+0,y_pos);     lcd.data(Litera_m)
    lcd.position(x_pos+6,y_pos);     lcd.data(Litera_m)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_H)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_g)
def afisare_simbol_presiune(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semn_presiune_1)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semn_presiune_2) 
##### Format text and simbol for DEW point:  
def afiseaza_text_Punct_de_roua_DEW(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_D)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_W)
    lcd.position(x_pos+22,y_pos);    lcd.data(Litera_P)
    lcd.position(x_pos+28,y_pos);    lcd.data(Litera_O)
    lcd.position(x_pos+34,y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+40,y_pos);    lcd.data(Litera_N)
    lcd.position(x_pos+46,y_pos);    lcd.data(Litera_T)
def afiseaza_text_DEW(x_pos,y_pos):   
    lcd.position(x_pos+0,y_pos);     lcd.data(Litera_D)
    lcd.position(x_pos+6,y_pos);     lcd.data(Litera_E)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_W)
##### Format text and simbol for Confort factor:  
def afiseaza_text_Confort_factor(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_C)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_O)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_N)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_F)
    lcd.position(x_pos+24,y_pos);    lcd.data(Litera_O)
    lcd.position(x_pos+30,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+36,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+46,y_pos);    lcd.data(Litera_F)
    lcd.position(x_pos+52,y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+58,y_pos);    lcd.data(Litera_C)
    lcd.position(x_pos+64,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+70,y_pos);    lcd.data(Litera_O)
    lcd.position(x_pos+76,y_pos);    lcd.data(Litera_R)
def afiseaza_indice_ITU(x_pos,y_pos):   
    lcd.position(x_pos+0,y_pos);     lcd.data(Litera_I)
    lcd.position(x_pos+6,y_pos);     lcd.data(Litera_T)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_U)
def afisare_simbol_ITU_normal(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semn_ITU_normal_1)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semn_ITU_normal_2) 
def afisare_simbol_ITU_alerta(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semn_ITU_alerta_1)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semn_ITU_alerta_2)       
def afisare_simbol_ITU_disconfort(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semn_ITU_disconfort_1)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semn_ITU_disconfort_2)       
##### Format text and simbol for Altitudine:  
def afiseaza_text_Altitudine(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_L)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+24,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+30,y_pos);    lcd.data(Litera_U)
    lcd.position(x_pos+36,y_pos);    lcd.data(Litera_D)
    lcd.position(x_pos+42,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+52,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+58,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+64,y_pos);    lcd.data(Litera_L)
    lcd.position(70,5);              lcd.data(Litera_m)
def afisare_simbol_altitudine(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semn_altitudine_1)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semn_altitudine_2)       
##### Format text fix and simbol for Barometer:  
def afiseaza_text_Barometru(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_B)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_O)
    lcd.position(x_pos+24,y_pos);    lcd.data(Litera_M)
    lcd.position(x_pos+30,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+36,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+42,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+48,y_pos);    lcd.data(Litera_R)
def afiseaza_text_Senin(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_C)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_L)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+24,y_pos);    lcd.data(Litera_R)
def afiseaza_text_Ploaie(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_N)
def afiseaza_text_Nori(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_C)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_L)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_O)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_U)
    lcd.position(x_pos+24, y_pos);   lcd.data(Litera_D)
    lcd.position(x_pos+30,y_pos);    lcd.data(Litera_L)
    lcd.position(x_pos+36,y_pos);    lcd.data(Litera_Y)
def afisare_simbol_procent(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semnul_procent)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semnul_procent)
    lcd.position(x_pos,y_pos+2);     lcd.data(Semnul_procent)
def afisare_simbol_sageata(x_pos,y_pos):
    lcd.position(x_pos,y_pos);       lcd.data(Semn_sageata)
def afisare_sageata_transparenta(x_pos,y_pos):
    lcd.position(x_pos,y_pos);       lcd.data(Sageata_transparenta)
##### Format text fix and simbol for Date and Time:  
def afiseaza_text_DATA_SI_ORA(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_D)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+28,y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+34,y_pos);    lcd.data(Litera_N)
    lcd.position(x_pos+40,y_pos);    lcd.data(Litera_D)
    lcd.position(x_pos+50,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+56,y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+62,y_pos);    lcd.data(Litera_M)
    lcd.position(x_pos+68,y_pos);    lcd.data(Litera_E)        
    lcd.position(x_pos+0, y_pos+5);  lcd.data(Litera_R)
    lcd.position(x_pos+6, y_pos+5);  lcd.data(Litera_T)
    lcd.position(x_pos+12,y_pos+5);  lcd.data(Litera_C)
    lcd.position(x_pos+22,y_pos+5);  lcd.data(Litera_t)
    lcd.position(x_pos+28,y_pos+5);  lcd.data(Litera_e)
    lcd.position(x_pos+34,y_pos+5);  lcd.data(Litera_m)
    lcd.position(x_pos+40,y_pos+5);  lcd.data(Litera_p) 
    lcd.position(x_pos+67,y_pos+5);  lcd.data(Semn_grad_Celsius_mic)
    lcd.position(x_pos+73,y_pos+5);  lcd.data(Litera_C)   
##### Format text and simbol for ATM Presssure:  (sensor DPS368 Infineon)  
def afiseaza_text_Presiune_atm_Infineon(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_M)
    lcd.position(x_pos+22,y_pos);    lcd.data(Litera_P)
    lcd.position(x_pos+28,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+34,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+40,y_pos);    lcd.data(Litera_S)
    lcd.position(x_pos+46,y_pos);    lcd.data(Litera_S)
    lcd.position(x_pos+52,y_pos);    lcd.data(Litera_U)
    lcd.position(x_pos+58,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+64,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+74,y_pos);    lcd.data(Litera_I)    
def afiseaza_text_mmHg(x_pos,y_pos):   
    lcd.position(x_pos+0,y_pos);     lcd.data(Litera_m)
    lcd.position(x_pos+6,y_pos);     lcd.data(Litera_m)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_H)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_g)
def afisare_simbol_presiune(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semn_presiune_1)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semn_presiune_2) 
##### Format text and simbol for Altitude : (sensor DPS368 Infineon)
def afiseaza_text_Altitudine_Infineon(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_L)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+24,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+30,y_pos);    lcd.data(Litera_U)
    lcd.position(x_pos+36,y_pos);    lcd.data(Litera_D)
    lcd.position(x_pos+42,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+74,y_pos);    lcd.data(Litera_I) 
    lcd.position(x_pos+52,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+58,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+64,y_pos);    lcd.data(Litera_L)
    lcd.position(70,5);              lcd.data(Litera_m)
def afisare_simbol_altitudine(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semn_altitudine_1)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semn_altitudine_2)       
##### Format text fix and simbol for CO2: (sensor PAS CO2 Infineon) 
def afiseaza_text_CO2_Infineon(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_R)
    lcd.position(x_pos+22,y_pos);    lcd.data(Litera_C)
    lcd.position(x_pos+28,y_pos);    lcd.data(Litera_O)
    lcd.position(x_pos+34,y_pos);    lcd.data(Cifra_2)
    lcd.position(x_pos+74,y_pos);    lcd.data(Litera_I) 
def afiseaza_simbol_CO2_Infineon(x_pos,y_pos):
    lcd.position(x_pos,y_pos+0);     lcd.data(Semn_CO2_1)
    lcd.position(x_pos,y_pos+1);     lcd.data(Semn_CO2_2)     
def afiseaza_text_CO2_ppm_Infineon(x_pos,y_pos):
    lcd.position(x_pos+0,y_pos);     lcd.data(Litera_p)
    lcd.position(x_pos+6,y_pos);     lcd.data(Litera_p)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_m)
##### Format text fix for connectivity display:
def afiseaza_text_connectivity(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_C)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_O)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_N)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_N)
    lcd.position(x_pos+24,y_pos);    lcd.data(Litera_E)
    lcd.position(x_pos+30,y_pos);    lcd.data(Litera_C)
    lcd.position(x_pos+36,y_pos);    lcd.data(Litera_T)
    lcd.position(x_pos+42,y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+48,y_pos);    lcd.data(Litera_V)
    lcd.position(x_pos+54,y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+60,y_pos);    lcd.data(Litera_T) 
    lcd.position(x_pos+66,y_pos);    lcd.data(Litera_Y)    
def afiseaza_text_conectivity_SSID(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_S)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_S)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_D)
    lcd.position(x_pos+24,y_pos);    lcd.data(Semnul_doua_puncte)
    lcd.position(x_pos+34,y_pos);    lcd.data(Litera_P)
    lcd.position(x_pos+40,y_pos);    lcd.data(Litera_S)
    lcd.position(x_pos+46,y_pos);    lcd.data(Litera_O)
    lcd.position(x_pos+52,y_pos);    lcd.data(Litera_C)
    lcd.position(x_pos+58,y_pos);    lcd.data(Cifra_6)
def afiseaza_text_conectivity_PASS(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_P)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_A)
    lcd.position(x_pos+12,y_pos);    lcd.data(Litera_S)
    lcd.position(x_pos+18,y_pos);    lcd.data(Litera_S)
    lcd.position(x_pos+24,y_pos);    lcd.data(Semnul_doua_puncte)
    lcd.position(x_pos+34,y_pos);    lcd.data(Cifra_1)
    lcd.position(x_pos+40,y_pos);    lcd.data(Cifra_2)
    lcd.position(x_pos+46,y_pos);    lcd.data(Cifra_3)
    lcd.position(x_pos+52,y_pos);    lcd.data(Cifra_4)
    lcd.position(x_pos+58,y_pos);    lcd.data(Cifra_5)
    lcd.position(x_pos+64,y_pos);    lcd.data(Cifra_6)
    lcd.position(x_pos+70,y_pos);    lcd.data(Cifra_7)
    lcd.position(x_pos+76,y_pos);    lcd.data(Cifra_8)
def afiseaza_text_conectivity_IP(x_pos,y_pos):
    lcd.position(x_pos+0, y_pos);    lcd.data(Litera_I)
    lcd.position(x_pos+6, y_pos);    lcd.data(Litera_P)
    lcd.position(x_pos+14,y_pos);    lcd.data(Cifra_1)
    lcd.position(x_pos+20,y_pos);    lcd.data(Cifra_9)
    lcd.position(x_pos+26,y_pos);    lcd.data(Cifra_2)
    lcd.position(x_pos+32,y_pos);    lcd.data(Semnul_punct)
    lcd.position(x_pos+34,y_pos);    lcd.data(Cifra_1)
    lcd.position(x_pos+40,y_pos);    lcd.data(Cifra_6)
    lcd.position(x_pos+46,y_pos);    lcd.data(Cifra_8)
    lcd.position(x_pos+52,y_pos);    lcd.data(Semnul_punct)
    lcd.position(x_pos+55,y_pos);    lcd.data(Cifra_0)
    lcd.position(x_pos+61,y_pos);    lcd.data(Semnul_punct)
    lcd.position(x_pos+64,y_pos);    lcd.data(Cifra_4)

E_Display_text_fix.py

MUSHCode
File that contain function used to display text fix on Kihia 5110 lcd
from D_Format_text_fix import *


#############################################################################
##### Afisare text fix pe fiecare display:  
#############################################################################
##### Function used to display text fix on each display:  
def afisare_text_fix_Temperatura():
    afiseaza_text_Temperatura(3,0)
    afiseaza_simbol_termometru(0,2)
    afiseaza_semn_grad_celsius(64,2)    
def afisare_text_fix_Umiditate():
    afiseaza_text_Umiditate(10, 0)
    afiseaza_picatura_umiditate(0,2)
    afiseaza_procent_RH(64,2)
def afisare_text_fix_ITU():
    afiseaza_text_Confort_factor(0,0)
    afiseaza_indice_ITU(64,5)
    afisare_simbol_ITU_normal(64,2)    
def afisare_text_fix_Presiune_atm():  
    afiseaza_text_Presiune_atm(0,0)
    afiseaza_text_mmHg(60,5)
    afisare_simbol_presiune(64,2)
def afisare_text_fix_Punct_de_roua_DEW():
    afiseaza_text_Punct_de_roua_DEW(0,0)
    afiseaza_text_DEW(64,5)
    afiseaza_simbol_termometru(0,2)
    afiseaza_semn_grad_celsius(64,2) 
def afisare_text_fix_Altitudine():
    afiseaza_text_Altitudine(0,0)
    afisare_simbol_altitudine(64,2)
def afisare_text_fix_Barometru():
    afiseaza_text_Barometru(0,0)
    afisare_simbol_procent(72,2)
    afiseaza_text_Senin(8,2)
    afiseaza_text_Nori(8,3)
    afiseaza_text_Ploaie(8,4)
def afisare_text_fix_DATA_SI_ORA():
    afiseaza_text_DATA_SI_ORA(0,0)
def afisare_text_fix_Presiune_atm_Infineon():  
    afiseaza_text_Presiune_atm_Infineon(0,0)
    afiseaza_text_mmHg(60,5)
    afisare_simbol_presiune(64,2)
def afisare_text_fix_Altitudine_Infineon():
    afiseaza_text_Altitudine_Infineon(0,0)
    afisare_simbol_altitudine(64,2)
def afisare_text_fix_CO2_Infineon():
    afiseaza_text_CO2_Infineon(0,0)
    afiseaza_simbol_CO2_Infineon(64,2)
    afiseaza_text_CO2_ppm_Infineon(64,5)
def afisare_text_fix_connectivity():
    afiseaza_text_connectivity(0,0)
    afiseaza_text_conectivity_SSID(0,2)
    afiseaza_text_conectivity_PASS(0,3)
    afiseaza_text_conectivity_IP(0,4)

F_Web_site.py

MicroPython
File that contain web page used to siaplay data over wifi
#****************************************************
# Function for creating the
# web page to be displayed
def web_page():
    html_page = """
<!DOCTYPE html>  
 <html>  
  <head>  
  <meta name='viewport' content='width=device-width, initial-scale=1.0'/>  
  <script>   
   var ajaxRequest = new XMLHttpRequest();  
   
   function ajaxLoad(ajaxURL)  
   {  
    ajaxRequest.open('GET',ajaxURL,true);  
    ajaxRequest.onreadystatechange = function()  
    {  
     if(ajaxRequest.readyState == 4 && ajaxRequest.status==200)  
     {  
      var ajaxResult = ajaxRequest.responseText;  
      var tmpArray = ajaxResult.split("|");  
      document.getElementById('temp').innerHTML    = tmpArray[0];  
      document.getElementById('humi').innerHTML    = tmpArray[1];
      document.getElementById('itu').innerHTML     = tmpArray[2];
      document.getElementById('Dew').innerHTML     = tmpArray[3];
      document.getElementById('press').innerHTML   = tmpArray[4];
      document.getElementById('alt').innerHTML     = tmpArray[5];
      document.getElementById('press_I').innerHTML = tmpArray[6];
      document.getElementById('alt_I').innerHTML   = tmpArray[7];
      document.getElementById('air').innerHTML     = tmpArray[8]; 
     }
    }  
    ajaxRequest.send();  
   }  
     
   function updateSensors()   
   {   
     ajaxLoad('getData');   
   }  
     
   setInterval(updateSensors, 10000);  
    
  </script>  
    
    
  <title>PSoC6 Indoor Weather Station</title>  
  </head>  
    
  <body>  
   <center>  
   <div id='main'>  
    <h1>MicroPython Weather Station</h1>  
    <h4>Web server on PSoC6</h4>
    <h4>Sensor values auto updates using AJAX</h4>  
    <div id='content'>   
     <p>Temperature: <strong><span id='temp'>--.-</span> &deg;C</strong></p>  
     <p>Humidity: <strong><span id='humi'>--.-</span> % </strong></p>
     <p>Confort factor: <strong><span id='itu'>--.-</span> value </strong></p>
     <p>DEW point: <strong><span id='Dew'>--.-</span> &deg;C </strong></p>
     <p>Atmospheric pressure: <strong><span id='press'>--.-</span> mmHg </strong></p>
     <p>Relative altitude: <strong><span id='alt'>--.-</span> meters </strong></p>
     <p>Atmospheric pressure I: <strong><span id='press_I'>--.-</span> mmHg </strong></p>
     <p>Relative altitude I: <strong><span id='alt_I'>--.-</span> meters </strong></p>
     <p>Air CO2: <strong><span id='air'>--.-</span> ppm </strong></p>
    </div>  
   </div>  
   </center>  
  </body>  
 </html>
"""
    return html_page
#****************************************************

Credits

Mihai Popa

Mihai Popa

5 projects • 6 followers
I am working as test engineer for navigation systems in auto industry. I am passionate about science, IoT, ML, MCU programming, SF movies.

Comments