├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── feature_request.md └── workflows │ ├── codeql-analysis.yml │ └── python-package-conda.yml ├── .gitignore ├── LICENSE ├── README.md ├── axp209_i2c_test.py ├── bin ├── data │ ├── eeprom_24c01.hex │ ├── eeprom_24c08.hex │ ├── eeprom_24c16.hex │ └── eeprom_24c32.hex ├── eeprom_mng.py ├── emc2301 ├── hdc1080 ├── i2c_ecomet_detect.py └── pca9632 ├── ecomet_i2c_sensors ├── Platform.py ├── __init__.py ├── as3935 │ ├── __init__.py │ ├── as3935.py │ └── as3935_constant.py ├── axp209 │ ├── AXP209.PDF │ ├── __init__.py │ ├── axp209.py │ └── axp209_constant.py ├── axp305 │ ├── AXP209.PDF │ ├── __init__.py │ ├── axp305.py │ └── axp305_constant.py ├── axp805 │ ├── AXP805_Datasheet_V1.0_en.pdf │ ├── __init__.py │ ├── axp805.py │ └── axp805_constant.py ├── ecomet │ ├── ecomet01.py │ └── ecomet01_constant.py ├── eeprom │ ├── __init__.py │ ├── chip_list.py │ ├── documentation │ │ ├── .dnconfig │ │ ├── Schematics.PNG │ │ ├── Schematics_2.PNG │ │ └── eeprom_IIC.md │ ├── eeprom_check.py │ ├── eeprom_read.py │ ├── eeprom_wipe.py │ └── eeprom_write.py ├── emc2301 │ ├── 2poles_dc.png │ ├── __init__.py │ ├── emc2301.py │ ├── emc2301_constant.py │ ├── emc2301_python_IIC.md │ ├── emc2301_python_IID.md │ ├── fan_type.py │ ├── nf-a8.png │ ├── step_1_32.PNG │ └── step_32_63.PNG ├── hdc1080 │ ├── __init__.py │ ├── hdc1080.py │ ├── hdc1080_constant.py │ └── hdc1080_python_IIC.md ├── htu21 │ ├── __init__.py │ ├── htu21.py │ ├── htu21_constant.py │ └── htu21_python_IIC.md ├── i2c.py ├── i2c_command.py ├── ina260 │ ├── __init__.py │ ├── ina260.py │ ├── ina260_constant.py │ ├── ina260_python_IIC.md │ ├── ina260_ui.py │ └── ina260_ui_constant.py ├── isl2802x │ ├── __init__.py │ ├── isl2802x.py │ ├── isl2802x_constant.py │ ├── isl2802x_ui.py │ └── isl2802x_ui_constant.py ├── mcp3221 │ ├── mcp3221.py │ └── mcp3221_constant.py ├── ms5637 │ ├── __init__.py │ ├── ms5637.py │ ├── ms5637_constant.py │ └── ms5637_python.IIC.md ├── pca9557 │ ├── __init__.py │ ├── pca9557.py │ ├── pca9557_constant.py │ └── pca9557_python.IIC.md ├── pca9632 │ ├── __init__.py │ ├── pca9632.py │ ├── pca9632_constant.py │ └── pca_9632_python_IIC.md ├── platform │ ├── __init__.py │ └── i2c_platform.py ├── sgp40 │ ├── sgp40.py │ ├── sgp40_algorithm.py │ └── sgp40_constant.py ├── sn_gcja5 │ ├── __init__.py │ ├── sn_gcja5.py │ └── sn_gcja5_constant.py ├── ssd1306 │ ├── __init__.py │ ├── render.py │ ├── ssd1306.py │ ├── ssd1306_constant.py │ ├── ssd1306_mini.png │ ├── ssd1306_python.IIC.md │ └── zoom_display.mkv └── tsl2591 │ ├── __init__.py │ ├── tsl2591.py │ └── tsl2591_constant.py ├── fonts ├── fpc ├── emc2301 │ ├── creator.lfm │ ├── creator.pas │ ├── emc2301 │ ├── emc2301.ico │ ├── emc2301.lpi │ ├── emc2301.lpr │ ├── emc2301.lps │ ├── emc2301.res │ ├── emc2301_IIC.md │ ├── emc2301_display.lfm │ ├── emc2301_display.pas │ ├── emc2301_graph.lfm │ ├── emc2301_graph.pas │ ├── emc2301_i2c_kick_up.py │ ├── emc2301_i2c_speed_graph.py │ ├── emc2301_i2c_test.py │ ├── emc2301_pyth_util.pas │ ├── emc2301_read.pas │ ├── emc2301_write.pas │ ├── help.lfm │ ├── help.pas │ ├── image │ │ ├── OFF_30x30.png │ │ ├── ON_30x30.png │ │ ├── appl_chip_missing.png │ │ ├── chip_100x100.png │ │ ├── emc2301_gui.png │ │ ├── en_algo.png │ │ ├── missing_chip.png │ │ ├── mode.png │ │ ├── monitor.png │ │ └── src │ │ │ ├── microchip.png │ │ │ ├── microchip.svg │ │ │ ├── smsc.png │ │ │ └── smsc.svg │ ├── missing_chip.lfm │ └── missing_chip.pas ├── hdc1080 │ ├── creator.lfm │ ├── creator.pas │ ├── ecomet_regex.pas │ ├── hdc1080 │ ├── hdc1080.ico │ ├── hdc1080.lpi │ ├── hdc1080.lpr │ ├── hdc1080.lps │ ├── hdc1080.res │ ├── hdc1080_IIC.md │ ├── hdc1080_display.lfm │ ├── hdc1080_display.pas │ ├── hdc1080_pyth_util.pas │ ├── hdc1080_read.pas │ ├── hdc1080_write.pas │ ├── help.lfm │ ├── help.pas │ ├── image │ │ ├── Form_info.txt │ │ ├── OFF_30x30.png │ │ ├── ON_30x30.png │ │ ├── appl_chip_missing.png │ │ ├── appl_work.png │ │ ├── chip_100x100.png │ │ ├── src │ │ │ ├── chip_missing.svg │ │ │ └── ti-logo.svg │ │ └── ti-logo.png │ ├── missing_chip.lfm │ └── missing_chip.pas ├── insert_project.png ├── lazarus.md ├── pca9632 │ ├── creator.lfm │ ├── creator.pas │ ├── help.lfm │ ├── help.pas │ ├── image │ │ ├── BLINK_70x23.png │ │ ├── DIMMING_70x23.png │ │ ├── GRPPWM_70x23.png │ │ ├── Light_off_40x40.png │ │ ├── Light_on_40x40.png │ │ ├── NXP.png │ │ ├── OFF_70x23.png │ │ ├── ON_70x23.png │ │ ├── PWM_70x23.png │ │ └── src │ │ │ ├── BLINKING.svg │ │ │ ├── DIMMING.svg │ │ │ ├── GRPPWM.svg │ │ │ ├── Light.svg │ │ │ ├── OFF.svg │ │ │ ├── ON.svg │ │ │ ├── PWM.svg │ │ │ └── nxp.svg │ ├── missing_chip.lfm │ ├── missing_chip.pas │ ├── pca9632 │ ├── pca9632_IIC.md │ ├── pca9632_console.png │ ├── pca9632_schema.PNG │ ├── pca_9632.ico │ ├── pca_9632.lpi │ ├── pca_9632.lpr │ ├── pca_9632.lps │ ├── pca_9632.res │ ├── pca_display.lfm │ ├── pca_display.pas │ ├── pca_grppwm.pas │ ├── pca_pyth_util.pas │ ├── pca_read.pas │ └── pca_write.pas └── shared │ ├── ecomet_regex.pas │ ├── image │ ├── comet.ico │ └── comet.svg │ ├── proc_py.pas │ ├── rpm_source.pas │ └── universal.pas ├── images ├── projects └── eCScope │ └── bin │ └── ecsope_1.0.0 ├── python └── ecomet_i2c_sensors ├── python_test_scripts ├── as3935 │ ├── AS3935-Datasheet.pdf │ ├── AS3935-austriamicrosystems.pdf │ └── as3935_test_script.py ├── axp209 │ └── axp209_i2c_test.py ├── display │ ├── fonts │ │ └── C&C Red Alert [INET].ttf │ ├── images │ │ ├── code.png │ │ ├── comet_black_white_62x62.png │ │ ├── star.png │ │ └── zoom.png │ └── ssd1306_i2c_test.py ├── ecomet │ └── ecomet01_i2c_test.py ├── emc2301 │ ├── emc2301_i2c_kick_up.py │ ├── emc2301_i2c_speed_graph.py │ ├── emc2301_i2c_speed_graph_led.py │ ├── emc2301_i2c_test.py │ └── emc2301_i2c_test_led.py ├── hdc1080 │ └── hdc1080_i2c_test.py ├── htu21_i2c_test.py ├── ina260 │ ├── i2c_address_search.py │ ├── i2c_address_test.py │ ├── ina260_i2c_calibrate_i.py │ ├── ina260_i2c_calibrate_u.py │ ├── ina260_i2c_i_1.py │ ├── ina260_i2c_i_1_u_2.py │ ├── ina260_i2c_i_2.py │ ├── ina260_i2c_u_1.py │ ├── ina260_i2c_u_2.py │ ├── ina260_i2c_ui.py │ ├── ina260_i2c_ui_1.py │ ├── ina260_i2c_ui_1_i_2.py │ ├── ina260_i2c_ui_1_u_2.py │ └── ina260_i2c_ui_2.py ├── isl28022_i2c_test.py ├── mcp3221 │ └── mcp3221_i2c_test.py ├── ms5637_i2c_test.py ├── pattern │ ├── cpuinfo_RP3 │ └── cpuinfo_RP4_CM4 ├── pca9557_i2c_test.py ├── pca_9632_i2c_rgb.py ├── pca_9632_i2c_rgb_2led.py ├── sgp40 │ ├── sgp40_raw_value.py │ └── sgp40_voc_index.py ├── sn_gcja5 │ └── sn_gcja5_i2c_test.py └── tsl2591 │ └── tsl2591_i2c_test.py ├── requirements.txt ├── test.py └── wiki ├── _i2c_boards ├── _display_curr_board │ ├── display_current.png │ └── display_current_z.png ├── _fan_board │ ├── emc2301.png │ ├── fan_driver_v1.3.png │ ├── fan_driver_v1.5.png │ └── fan_driver_z.png ├── _temp_hmd_board │ └── temp_hmd.png └── _temp_hmd_pressure_board │ └── temp_hmd_pressure.png ├── _support_boards └── hub_mini.png └── common └── support.md /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug or feature** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. step1 '...' 16 | 2. step2 '....' 17 | 3. step3 '....' 18 | 4. log output or error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Version of Raspberry (please complete the following information):** 27 | - Raspberry 3 B+ [uname -a] 28 | 29 | **Additional context** 30 | Add any other context about the problem here. 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Screenshots or sketch** 20 | If applicable, add screenshots or sketch to help explain your problem. 21 | 22 | **Version of Raspberry (please complete the following information):** 23 | - Raspberry 3 B+ [uname -a] 24 | 25 | **Additional context** 26 | Add any other context or screenshots about the feature request here. 27 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '35 6 * * 2' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'python' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 37 | # Learn more: 38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 39 | 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v2 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v1 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v1 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v1 72 | -------------------------------------------------------------------------------- /.github/workflows/python-package-conda.yml: -------------------------------------------------------------------------------- 1 | name: Python Package using Conda 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build-linux: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | max-parallel: 5 10 | 11 | steps: 12 | - uses: actions/checkout@v4 13 | - name: Set up Python 3.10 14 | uses: actions/setup-python@v3 15 | with: 16 | python-version: '3.10' 17 | - name: Add conda to system path 18 | run: | 19 | # $CONDA is an environment variable pointing to the root of the miniconda directory 20 | echo $CONDA/bin >> $GITHUB_PATH 21 | - name: Install dependencies 22 | run: | 23 | conda env update --file environment.yml --name base 24 | - name: Lint with flake8 25 | run: | 26 | conda install flake8 27 | # stop the build if there are Python syntax errors or undefined names 28 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics 29 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 30 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 31 | - name: Test with pytest 32 | run: | 33 | conda install pytest 34 | pytest 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | backup/ 2 | lib/ 3 | *.pyc 4 | *.log 5 | *.data 6 | *.tmp 7 | -------------------------------------------------------------------------------- /axp209_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.axp209 import axp209 6 | import logging 7 | 8 | axp = axp209.AXP209() 9 | 10 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 11 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 12 | datefmt='%m-%d %H:%M', 13 | filename='axp209.log', 14 | filemode='w') 15 | console = logging.StreamHandler() 16 | console.setLevel(logging.DEBUG) 17 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 18 | console.setFormatter(formatter) 19 | logging.getLogger('').addHandler(console) 20 | axp._logger = logging.getLogger('ecomet.axp209') 21 | axp._logger.info('Start logging ...') 22 | 23 | print("internal_temperature: %.2fC" % axp.internal_temperature) 24 | print("battery_exists: %s" % axp.battery_exists) 25 | print("battery_charging: %s" % ("charging" if axp.battery_charging else "done")) 26 | print("battery_current_direction: %s" % ("charging" if axp.battery_current_direction else "discharging")) 27 | print("battery_voltage: %.1fmV" % axp.battery_voltage) 28 | print("battery_discharge_current: %.1fmA" % axp.battery_discharge_current) 29 | print("battery_charge_current: %.1fmA" % axp.battery_charge_current) 30 | print("battery_gauge: %d%%" % axp.battery_gauge) 31 | axp.vbus_current_limit = '500 mA' 32 | print("VBUS current limit: %s" % axp.vbus_current_limit) 33 | print("ADC enable 1:") 34 | print(" Battery voltage ADC Enable: %s" % axp.battery_current_adc_enable) 35 | print(" ACIN Voltage ADC Enable RW: %s" % axp.acin_voltage_adc_enable) 36 | print(" ACIN Current ADC Enable: %s" % axp.acin_current_adc_enable) 37 | print(" VBUS Voltage ADC Enable: %s" % axp.vbus_voltage_adc_enable) 38 | print(" VBUS Current ADC Enable: %s" % axp.vbus_current_adc_enable) 39 | print(" APS Voltage ADC Enable: %s" % axp.aps_voltage_adc_enable) 40 | print(" TS Pin ADC Function is enabled: %s" % axp.ts_pin_adc_function_enable) 41 | print("ADC enable 2:") 42 | print(" APX209 internal temperature monitoring ADC Enable: %s" % axp.apx209_internal_temperature_monitoring_adc_enable) 43 | print(" GPIO0 ADC Function is enabled: %s" % axp.gpio0_adc_function_enable) 44 | print(" GPIO1 ADC Function is enabled: %s" % axp.gpio1_adc_function_enable) 45 | axp.close() 46 | 47 | -------------------------------------------------------------------------------- /bin/data/eeprom_24c01.hex: -------------------------------------------------------------------------------- 1 | 0000: aa ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 2 | 0010: ff ff ff ff ff ff ff ff ff ff ff ff 00 11 22 33 3 | 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 4 | 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 5 | 0040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 6 | 0050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 7 | 0060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 8 | 0070: fc fb fa f0 a3 a2 a1 a0 3a 39 38 37 18 17 16 15 9 | -------------------------------------------------------------------------------- /bin/data/eeprom_24c08.hex: -------------------------------------------------------------------------------- 1 | 0000: aa ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 2 | 0010: ff ff ff ff ff ff ff ff ff ff ff ff 00 11 22 33 3 | 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 4 | 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 5 | 0040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 6 | 0050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 7 | 0060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 8 | 0070: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 9 | 0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 10 | 0090: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 11 | 00a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 12 | 00b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 13 | 00c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 14 | 00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 15 | 00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 16 | 00f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 17 | 0100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 18 | 0110: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 19 | 0120: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 20 | 0130: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 21 | 0140: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 22 | 0150: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 23 | 0160: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 24 | 0170: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 25 | 0180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 26 | 0190: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 27 | 01a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 28 | 01b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 29 | 01c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 30 | 01d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 31 | 01e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 32 | 01f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 33 | 0200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 34 | 0210: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 35 | 0220: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 36 | 0230: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 37 | 0240: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 38 | 0250: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 39 | 0260: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 40 | 0270: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 41 | 0280: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 42 | 0290: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 43 | 02a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 44 | 02b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 45 | 02c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 46 | 02d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 47 | 02e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 48 | 02f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 49 | 0300: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 50 | 0310: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 51 | 0320: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 52 | 0330: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 53 | 0340: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 54 | 0350: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 55 | 0360: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 56 | 0370: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 57 | 0380: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 58 | 0390: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 59 | 03a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 60 | 03b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 61 | 03c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 62 | 03d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 63 | 03e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 64 | 03f0: fc fb fa f0 a3 a2 a1 a0 3a 39 38 37 18 17 16 15 65 | -------------------------------------------------------------------------------- /bin/emc2301: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/bin/emc2301 -------------------------------------------------------------------------------- /bin/hdc1080: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/bin/hdc1080 -------------------------------------------------------------------------------- /bin/i2c_ecomet_detect.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import re 5 | print (sys.version) 6 | from ecomet_i2c_sensors.platform import i2c_platform 7 | import logging 8 | 9 | i2c_count = [ '^RASPBERRY_PI 1\..*$', 10 | '^RASPBERRY_PI 1B\..*$', 11 | '^RASPBERRY_PI 2\..*$', 12 | '^RASPBERRY_PI 3\..*$', 13 | '^RASPBERRY_PI 3B\..*$', 14 | '^RASPBERRY_PI 4B\:.*$', 15 | '^RASPBERRY_PI_\(CM4\).*$', 16 | '^RASPBERRY_PI ZERO 2 W.*$', 17 | '^H616$', 18 | '^A10$', 19 | '^OTHER$' ] 20 | 21 | i2c_count_max = [ 2, 22 | 2, 23 | 2, 24 | 2, 25 | 2, 26 | 2, 27 | 11, 28 | 2, 29 | 4, 30 | 2, 31 | 21 ] 32 | 33 | plat = i2c_platform.Board_plat() 34 | 35 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 36 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 37 | datefmt='%m-%d %H:%M', 38 | filename='i2c_ecomet_detect.log', 39 | filemode='w') 40 | console = logging.StreamHandler() 41 | console.setLevel(logging.DEBUG) 42 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 43 | console.setFormatter(formatter) 44 | logging.getLogger('').addHandler(console) 45 | 46 | plat._logger = logging.getLogger('ecomet.Board_Platform') 47 | plat._logger.info('Start logging ...') 48 | board = plat.board() 49 | plat._logger.info('Board platform: {}'.format(board)) 50 | 51 | idx = 0 52 | for match_str in i2c_count : 53 | match = re.search(match_str, board, flags=re.IGNORECASE) 54 | if match : 55 | max = i2c_count_max[idx] 56 | idx += 1 57 | 58 | plat._logger.info('Number of I2C buses at the board: {}'.format(max)) 59 | 60 | for bus_nm in range(0,max) : 61 | plat = i2c_platform.Board_plat(busnum=bus_nm) 62 | board = plat.board() 63 | bus = plat.bus() 64 | slave = plat.slaves() 65 | 66 | plat._logger.info('>>> Testing at bus: {}'.format(bus_nm)) 67 | if not slave : 68 | plat._logger.info('No Chip connected') 69 | else : 70 | plat._logger.info('Default bus number: {}'.format(bus)) 71 | plat._logger.info('Identified Slaves Chips: {}'.format(slave)) 72 | -------------------------------------------------------------------------------- /bin/pca9632: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/bin/pca9632 -------------------------------------------------------------------------------- /ecomet_i2c_sensors/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/as3935/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/as3935/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/axp209/AXP209.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/axp209/AXP209.PDF -------------------------------------------------------------------------------- /ecomet_i2c_sensors/axp209/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/axp209/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/axp305/AXP209.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/axp305/AXP209.PDF -------------------------------------------------------------------------------- /ecomet_i2c_sensors/axp305/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/axp305/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/axp805/AXP805_Datasheet_V1.0_en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/axp805/AXP805_Datasheet_V1.0_en.pdf -------------------------------------------------------------------------------- /ecomet_i2c_sensors/axp805/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/axp805/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ecomet/ecomet01_constant.py: -------------------------------------------------------------------------------- 1 | ECOMET_ADDR = 0x30 2 | # Register 3 | 4 | REG00 = 0x00 # 1 byte read register 5 | REG01 = 0x01 # 1 byte read register 6 | REG02 = 0x02 # 1 byte read register 7 | REG03 = 0x03 # 2 byte read register 8 | REG04 = 0x04 # 4 byte read register 9 | 10 | 11 | VDD = 5 # Voltage = 5V 12 | MAX_DEGREE = 360 # 360 Degree max position 13 | WEST = 75 14 | SOUTH = 176 15 | EAST = 280 16 | NORTH = 360 17 | NORTH_WEST = 36 18 | SOUTH_WEST = 125 19 | SOUTH_EAST = 225 20 | NORTH_EAST = 330 21 | 22 | MAX_VDD = 4095 23 | 24 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/eeprom/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/eeprom/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/eeprom/chip_list.py: -------------------------------------------------------------------------------- 1 | #chip_list.py 2 | # Author: Marian Minar 3 | # Copyright 2020 4 | 5 | def init(): 6 | global xchip 7 | 8 | xchip = { "24c01":[1,127], # 1-Kbit (128x8) A6 - A0 max 007F 9 | "24c02":[2,255], # 2-Kbit (256x8) A7 - A0 max 00FF 10 | "24c04":[3,511], # 4-Kbit (512x8) A8 - A0 max 01FF 11 | "24c08":[4,1023], # 8-Kbit (1024x8) A9 - A0 max 03FF 12 | "24c16":[5,2047], # 16-Kbit (2048x8) A10 - A0 max 07FF 13 | "24c32":[6,4095], # 32-Kbit (4096x8) A11 - A0 max 0FFF 14 | "24c64":[7,8191], # 64-Kbit (8192x8) A12 - A0 max 1FFF 15 | "24c128":[8,16383], # 128-Kbit (16384x8) A13 - A0 max 3FFF 16 | "24c256":[9,32767], # 256-Kbit (32768x8) A14 - A0 max 7FFF 17 | "24c512":[10,65535], # 512-Kbit (65536x8) A15 - A0 max FFFF 18 | "24c1024":[11,1048575]} # 1024-Kbit (1048576x8) A16 - A0 max FFFFF 19 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/eeprom/documentation/.dnconfig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/eeprom/documentation/.dnconfig -------------------------------------------------------------------------------- /ecomet_i2c_sensors/eeprom/documentation/Schematics.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/eeprom/documentation/Schematics.PNG -------------------------------------------------------------------------------- /ecomet_i2c_sensors/eeprom/documentation/Schematics_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/eeprom/documentation/Schematics_2.PNG -------------------------------------------------------------------------------- /ecomet_i2c_sensors/eeprom/eeprom_check.py: -------------------------------------------------------------------------------- 1 | #eeprom_check.py 2 | # Author: Marian Minar 3 | # Copyright 2020 4 | 5 | # used for comparing two files for testing writing and reading eeprom 6 | 7 | from random import randrange 8 | import time 9 | import sys 10 | import os 11 | from .. import i2c_command,Platform 12 | from ecomet_i2c_sensors.eeprom import chip_list 13 | from ecomet_i2c_sensors.platform import i2c_platform 14 | 15 | plat = i2c_platform.plat_list[Platform.platform_detect()] 16 | if plat == 'H616': 17 | import OPi.GPIO as rGPIO 18 | else: 19 | import RPi.GPIO as rGPIO 20 | 21 | def filecmp (file1,file2,smb,slaveaddr,writestrobe,chip) : 22 | 23 | try: 24 | chip_list.xchip[chip][1] 25 | except: 26 | return 3 27 | 28 | f = open(file1,"w+") 29 | print ("Write ...") 30 | 31 | for addr in range (0,chip_list.xchip[chip][1],16): 32 | 33 | idx = 0 34 | datax = list() 35 | while idx <= 15 : 36 | data = randrange(256) 37 | datax.append(data) 38 | try: 39 | i2c_command.eeprom_write_byte(addr,data,smb,slaveaddr,writestrobe,chip_list.xchip[chip][0]) 40 | except IOError: 41 | return 1 42 | 43 | idx = idx + 1 44 | addr = addr + 1 45 | 46 | f.write("{:04x}: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}\n" 47 | .format((addr-8),datax[0],datax[1],datax[2],datax[3],datax[4],datax[5],datax[6],datax[7],datax[8],datax[9],datax[10],datax[11],datax[12],datax[13],datax[14],datax[15])) 48 | 49 | 50 | rGPIO.cleanup() 51 | f.close() 52 | 53 | f = open(file2,"w+") 54 | print ("Read ...") 55 | 56 | for addr in range (0,chip_list.xchip[chip][1],16): 57 | 58 | idx = 0 59 | datax = list() 60 | while idx <= 15: 61 | try: 62 | data = i2c_command.eeprom_read_byte(addr,smb,slaveaddr,chip_list.xchip[chip][0]) 63 | except IOError: 64 | return 2 65 | datax.append(data) 66 | idx = idx + 1 67 | addr = addr + 1 68 | 69 | f.write("{:04x}: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}\n" 70 | .format((addr-8),datax[0],datax[1],datax[2],datax[3],datax[4],datax[5],datax[6],datax[7],datax[8],datax[9],datax[10],datax[11],datax[12],datax[13],datax[14],datax[15])) 71 | 72 | 73 | rGPIO.cleanup() 74 | f.close() 75 | 76 | with open(file1,"r") as cmp1: 77 | with open(file2,"r") as cmp2: 78 | line1 = cmp1.readlines() 79 | line2 = cmp2.readlines() 80 | if line1 != line2 : 81 | return 4 82 | cmp2.close() 83 | cmp1.close() 84 | 85 | os.remove(file1) 86 | os.remove(file2) 87 | 88 | return 0 89 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/eeprom/eeprom_read.py: -------------------------------------------------------------------------------- 1 | #eeprom_read 2 | # Author: Marian Minar 3 | # Copyright 2020 - 2023 4 | 5 | import time 6 | import sys 7 | import os 8 | from .. import i2c_command,Platform 9 | from ecomet_i2c_sensors.eeprom import chip_list 10 | from ecomet_i2c_sensors.platform import i2c_platform 11 | 12 | plat = i2c_platform.plat_list[Platform.platform_detect()] 13 | if plat == 'H616': 14 | import OPi.GPIO as rGPIO 15 | else: 16 | import RPi.GPIO as rGPIO 17 | 18 | def read_full_to_file (file,smb,slaveaddr,writestrobe,chip) : 19 | 20 | try: 21 | chip_list.xchip[chip][1] 22 | except: 23 | return 2 24 | 25 | f = open(file,"w+") 26 | print ("Read EEprom ...") 27 | 28 | for addr in range (0,chip_list.xchip[chip][1],16): 29 | 30 | idx = 0 31 | datax = list() 32 | while idx <= 15: 33 | try: 34 | data = i2c_command.eeprom_read_byte(addr,smb,slaveaddr,chip_list.xchip[chip][0]) 35 | except IOError: 36 | return 1 37 | datax.append(data) 38 | idx = idx + 1 39 | addr = addr + 1 40 | 41 | f.write("{:04x}: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}\n".format((addr-16),datax[0],datax[1],datax[2],datax[3],datax[4],datax[5],datax[6],datax[7], 42 | datax[8],datax[9],datax[10],datax[11],datax[12],datax[13],datax[14],datax[15])) 43 | 44 | rGPIO.cleanup() 45 | f.close() 46 | 47 | return 0 48 | 49 | def readNBytes(addr_start, addr_end, smb, slaveaddr, writestrobe, chip) : 50 | addr = addr_start 51 | idx = 0 52 | datax = [] 53 | while addr <= addr_end : 54 | try: 55 | datax.append(i2c_command.eeprom_read_byte(addr,smb,slaveaddr,chip_list.xchip[chip][0])) 56 | except IOError: 57 | return 1 58 | 59 | #print("{:04x}: {:02x}".format((addr),datax[idx])) 60 | idx = idx + 1 61 | addr = addr + 1 62 | 63 | return datax 64 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/eeprom/eeprom_wipe.py: -------------------------------------------------------------------------------- 1 | # eeprom_wipe.py package 2 | # Author: Marian Minar 3 | # Copyright 2020 4 | 5 | import time 6 | import sys 7 | import os 8 | from .. import i2c_command,Platform 9 | from ecomet_i2c_sensors.eeprom import chip_list 10 | from ecomet_i2c_sensors.platform import i2c_platform 11 | 12 | plat = i2c_platform.plat_list[Platform.platform_detect()] 13 | if plat == 'H616': 14 | import OPi.GPIO as rGPIO 15 | else: 16 | import RPi.GPIO as rGPIO 17 | 18 | def wipe (smb,slaveaddr,writestrobe,chip) : 19 | 20 | try: 21 | chip_list.xchip[chip][1] 22 | except: 23 | return 2 24 | 25 | print ('Wiping ...') 26 | 27 | for addr in range (0,chip_list.xchip[chip][1],16): 28 | 29 | idx = 0 30 | datax = list() 31 | while idx <= 15 : 32 | data = 0xFF 33 | datax.append(data) 34 | try: 35 | i2c_command.eeprom_write_byte(addr,data,smb,slaveaddr,writestrobe,chip_list.xchip[chip][0]) 36 | except IOError: 37 | return 1 38 | 39 | idx = idx + 1 40 | addr = addr + 1 41 | 42 | # print ("{:04x}: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}" 43 | # .format(addr-16, datax[0],datax[1],datax[2],datax[3],datax[4],datax[5],datax[6],datax[7], 44 | # datax[8],datax[9],datax[10],datax[11],datax[12],datax[13],datax[14],datax[15])) 45 | 46 | rGPIO.cleanup() 47 | 48 | return 0 49 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/eeprom/eeprom_write.py: -------------------------------------------------------------------------------- 1 | #eeprom_write 2 | # Author: Marian Minar 3 | # Copyright 2020 - 2023 4 | 5 | import time 6 | import sys 7 | import os 8 | from .. import i2c_command,Platform 9 | from ecomet_i2c_sensors.eeprom import chip_list 10 | from ecomet_i2c_sensors.platform import i2c_platform 11 | 12 | plat = i2c_platform.plat_list[Platform.platform_detect()] 13 | if plat == 'H616': 14 | import OPi.GPIO as rGPIO 15 | else: 16 | import RPi.GPIO as rGPIO 17 | 18 | def write_full_from_file (file,smb,slaveaddr,writestrobe,chip) : 19 | 20 | try: 21 | chip_list.xchip[chip][1] 22 | except: 23 | return 3 24 | 25 | f = open(file,"r") 26 | print ("Write EEprom ...") 27 | datax = list() 28 | raw_list = list() 29 | addr = 0 30 | 31 | while addr <= chip_list.xchip[chip][1] : 32 | 33 | idx = 0 34 | try: 35 | raw_list = f.readline().replace(' ',' ').split(' ') 36 | except : 37 | return 2 38 | addr = raw_list[0] 39 | datax = raw_list[1:] 40 | addr = addr.replace(':','') 41 | addr = '0x' + addr.strip() 42 | try: 43 | addr = int(addr,0) 44 | except : 45 | return 2 46 | 47 | while idx <= 15 : 48 | datax[idx] = datax[idx].replace(':','') 49 | datax[idx] = '0x' + datax[idx].strip() 50 | data = int(datax[idx],0) 51 | try: 52 | i2c_command.eeprom_write_byte(addr,data,smb,slaveaddr,writestrobe,chip_list.xchip[chip][0]) 53 | except IOError: 54 | return 1 55 | 56 | idx = idx + 1 57 | addr = addr + 1 58 | 59 | # print ("{:04x}: {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}" 60 | # .format(addr-16, int(datax[0],0),int(datax[1],0),int(datax[2],0),int(datax[3],0),int(datax[4],0),int(datax[5],0),int(datax[6],0),int(datax[7],0), 61 | # int(datax[8],0),int(datax[9],0),int(datax[10],0),int(datax[11],0),int(datax[12],0),int(datax[13],0),int(datax[14],0),int(datax[15],0))) 62 | 63 | rGPIO.cleanup() 64 | f.close() 65 | 66 | return 0 67 | 68 | def writeNBytes(addr, datax, smb, slaveaddr, writestrobe, chip) : 69 | try: 70 | chip_list.xchip[chip][1] 71 | except: 72 | return 3 73 | 74 | idx = 0 75 | for i in range(addr,addr + len(datax)) : 76 | try: 77 | i2c_command.eeprom_write_byte(i,datax[idx],smb,slaveaddr,writestrobe,chip_list.xchip[chip][0]) 78 | except IOError: 79 | return 1 80 | idx = idx + 1 81 | return 0 82 | 83 | def split_strg(text): 84 | 85 | # split the text 86 | words = text.split(':') 87 | 88 | # for each word in the line: 89 | for word in words: 90 | #word.strip() 91 | 92 | # print the word 93 | print(words) 94 | 95 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/emc2301/2poles_dc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/emc2301/2poles_dc.png -------------------------------------------------------------------------------- /ecomet_i2c_sensors/emc2301/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/emc2301/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/emc2301/fan_type.py: -------------------------------------------------------------------------------- 1 | # RPM = 1/ * ( ( - 1)/ COUNT * ( 1/) ) * < fan_tachometer > * 60 2 | # internal fan_tachometer = 32768 Hz 3 | 4 | 5 | #NF-8A PWM (Noctua) https://noctua.at/en/nf-a8-pwm/specification 6 | 7 | POLES = 2 # poles 8 | EDGE = 5 # edge_number 9 | MULTIPLIER = 1 # multiplier 10 | FAN_TACH = 32768 # fan_tachometer 11 | RANGE = 0b00 # Min 500 RPM 12 | EDGES = 0b01 # 5 edges, 2 poles, 1 effective tach (default) 13 | 14 | 15 | #Universal 16 | #FAN_CONF1 17 | RANGE_500_1 = 0b00 18 | RANGE_1000_2 = 0b01 19 | RANGE_2000_4 = 0b10 20 | RANGE_4000_8 = 0b11 21 | 22 | EDGES_3_1POLE_05 = 0b00 23 | EDGES_5_2POLE_1 = 0b01 24 | EDGES_7_3POLE_15 = 0b10 25 | EDGES_9_4POLE_2 = 0b11 26 | 27 | UPDATE_100 = 0b000 28 | UPDATE_200 = 0b001 29 | UPDATE_300 = 0b010 30 | UPDATE_400 = 0b011 31 | UPDATE_500 = 0b100 32 | UPDATE_800 = 0b101 33 | UPDATE_1200 = 0b110 34 | UPDATE_1600 = 0b111 35 | 36 | #FAN_CONF2 37 | DER_OPT_NO_DERIVATE = 0b00 38 | DER_OPT_BASIC_DERIVATE = 0b01 39 | DER_OPT_STEP_DERIVATE = 0b10 40 | DER_OPT_BOTH_DERIVATE = 0b11 41 | 42 | ERR_RNG_0RPM = 0b00 43 | ERR_RNG_50RPM = 0b01 44 | ERR_RNG_100RPM = 0b10 45 | ERR_RNG_200RPM = 0b11 46 | 47 | #GAIN 48 | GAIN_GAIND_1x = 0b00 49 | GAIN_GAIND_2x = 0b01 50 | GAIN_GAIND_4x = 0b10 51 | GAIN_GAIND_8x = 0b11 52 | 53 | GAIN_GAINI_1x = 0b00 54 | GAIN_GAINI_2x = 0b01 55 | GAIN_GAINI_4x = 0b10 56 | GAIN_GAINI_8x = 0b11 57 | 58 | GAIN_GAINP_1x = 0b00 59 | GAIN_GAINP_2x = 0b01 60 | GAIN_GAINP_4x = 0b10 61 | GAIN_GAINP_8x = 0b11 62 | 63 | #FAN_SPIN_UP 64 | 65 | FAN_SPIN_UP_TIME1 = 0b00 66 | FAN_SPIN_UP_TIME2 = 0b01 67 | FAN_SPIN_UP_TIME3 = 0b10 68 | FAN_SPIN_UP_TIME4 = 0b11 69 | 70 | FAN_SPIN_UP_LVL1 = 0b000 71 | FAN_SPIN_UP_LVL2 = 0b001 72 | FAN_SPIN_UP_LVL3 = 0b010 73 | FAN_SPIN_UP_LVL4 = 0b011 74 | FAN_SPIN_UP_LVL5 = 0b100 75 | FAN_SPIN_UP_LVL6 = 0b101 76 | FAN_SPIN_UP_LVL7 = 0b110 77 | FAN_SPIN_UP_LVL8 = 0b111 78 | 79 | FAN_SPIN_UP_SPIN = 0b0 80 | FAN_SPIN_UP_NO_SPIN = 0b1 81 | 82 | FAN_SPIN_UP_DF1 = 0b00 83 | FAN_SPIN_UP_DF2 = 0b01 84 | FAN_SPIN_UP_DF3 = 0b10 85 | FAN_SPIN_UP_DF4 = 0b11 86 | 87 | FAN_PWM_BASE1 = 0b00 88 | FAN_PWM_BASE2 = 0b01 89 | FAN_PWM_BASE3 = 0b10 90 | FAN_PWM_BASE4 = 0b11 91 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/emc2301/nf-a8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/emc2301/nf-a8.png -------------------------------------------------------------------------------- /ecomet_i2c_sensors/emc2301/step_1_32.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/emc2301/step_1_32.PNG -------------------------------------------------------------------------------- /ecomet_i2c_sensors/emc2301/step_32_63.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/emc2301/step_32_63.PNG -------------------------------------------------------------------------------- /ecomet_i2c_sensors/hdc1080/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/hdc1080/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/hdc1080/hdc1080_constant.py: -------------------------------------------------------------------------------- 1 | # Address: 2 | 3 | HDC1080_ADDRESS = 0x40 # 8 bit version 4 | 5 | # Register 6 | 7 | TEMP = 0x00 8 | HUMDT = 0x01 9 | CONF = 0x02 10 | SER_ID1 = 0xFB 11 | SER_ID2 = 0xFC 12 | SER_ID3 = 0xFD 13 | MANUF = 0xFE 14 | DEVID = 0xFF 15 | 16 | # CONF 16 Bits allow (MBS): 17 | 18 | HRES = 8 # rw, humidity measurement resolution - 2 bits 19 | TRES = 10 # rw, temperature measurement resolution - 1 bit 20 | BTST = 11 # r, Battery voltage > 2.8V(readonly) -1 bit 21 | MODE = 12 # rw, temperature or humidity is acquired, serial or once - 1 bit 22 | HEAT = 13 # rw, heater bit - 1 bit 23 | RST = 15 # w, software reset 1-bit 24 | 25 | #Status of CONF Bit 26 | MODE_BOTH = 0 27 | MODE_ONLY = 1 28 | HRES_14 = 0b00 # rw, humidity measurement resolution 14 bit 29 | HRES_11 = 0b01 # rw, humidity measurement resolution 11 bit 30 | HRES_08 = 0b11 # rw, humidity measurement resolution 8 bit 31 | TRES_14 = 0 # rw, humidity measurement resolution 14 bit 32 | TRES_11 = 1 # rw, humidity measurement resolution 11 bit 33 | HEAT_DISABLE = 0 # rw, heater disabled 34 | HEAT_ENABLE = 1 # rw, heater enable 35 | RST_ON = 1 # r, software reset enable 36 | 37 | #Status Mask of CONF Bit 38 | MODE_Mask = 0b1 39 | HRES_Mask = 0b11 # rw, humidity measurement resolution 2 bits 40 | TRES_Mask = 0b1 # rw, humidity measurement resolution 1 bit 41 | HEAT_Mask = 0b1 # rw, heater disabled 42 | BTST_Mask = 0b1 43 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/hdc1080/hdc1080_python_IIC.md: -------------------------------------------------------------------------------- 1 | # hdc1080_IIC python3 module 2 | 3 | **Last modification:** 11.07.2020 4 | 5 | ### List of python files: ### 6 | 7 | **Chip description** 8 | The HDC1080 is a digital humidity sensor with integrated temperature sensor that provides excellent measurement accuracy at very low power. 9 | The HDC1080 operates over a wide supply range,and is a low cost,low power alternative to competitive olutions in a wide range of common applications. Thehumidity and temperature sensors are factory calibrated. 10 | 11 | **hdc1080_constant.py** 12 | 13 | * list of hdc1080 chip registers and their statuses 14 | 15 | **hdc1080.py** 16 | 17 | * HDC1080 - main chip class 18 | * HDC1080.read_register - read status of one register 19 | * HDC1080.write_register - write new value to chip register 20 | * HDC1080.write_mert_invoke - touch (TEMP or HUMDT) register (used before reading TEMP or HUMDT value 21 | * HDC1080.both_measurement - read in one sequence TEMP and HUMDT register, CONF file will be pre-set for sequence reading, values are calculated to celsius degrees and humidity percentage 22 | * HDC1080.measure_temp - read only value of TEMP register 23 | * HDC1080.measure_hmdt - read only value of HUMDT register 24 | * HDC1080.sw_reset - software Reset CHIP 25 | * HDC1080.battery - check status of battery or power supply (must by > 2.4V) 26 | * HDC1080.serial - read SERIAL ID of CHIP 27 | * HDC1080.manufacturer - read MANUFACTURER ID 28 | * HDC1080.deviceid - read DEVICE ID 29 | 30 | ### How to call python sub? ### 31 | 32 | see **hdc1080_i2c_test.py** script 33 | 34 | set logging: 35 | ```python 36 | logging.basicConfig(level=logging.INFO 37 | ``` 38 | set for INFO level logging. possible used DEBUG, ERROR loogin 39 | script will produce log hdc1080.log 40 | 41 | initialize chip: 42 | ```python 43 | sens = hdc1080.HDC1080() 44 | ``` 45 | 46 | sw reset & battery test: 47 | ```python 48 | ret = sens.sw_reset() # make sw reset of chip 49 | ret = sens.battery() # will check power_supply status, correct when voltage over than 2.4V 50 | ``` 51 | 52 | write to register: 53 | ```python 54 | ret = sens.write_register ( register = *reg_name*, bits = [*bit1*,*bit2* ...]) 55 | ret = sens.write_register ( register = *reg_name*, bits = [{*bit_name1* : *bit_value1*}, ... ] 56 | ``` 57 | example: 58 | ``` python 59 | ret = sens.write_register( register = "CONF", bits = ['MODE_BOTH','HRES_RES3','TRES_RES1']) 60 | ``` 61 | 62 | read ID: 63 | ```python 64 | (val,ret) = sens.serial() 65 | (val,ret) = sens.manufacturer() 66 | (val,ret) = sens.deviceid() 67 | ``` 68 | read ID values (unique for each Texas Instruments HDC1080 chip 69 | 70 | meausre: 71 | ```python 72 | (temp,hmdt, ret) = sens.both_measurement() 73 | (temp, ret) = sens.measure_temp() 74 | (hmdt, ret) = sens.measure_hmdt() 75 | ``` 76 | measure temperature or humidity sequentially or individually 77 | 78 | ret value: 79 | return value for each procedure (0 - correct, >0 - incorrect) 80 | 81 | output of test script: 82 | ```shell 83 | pi@raspberrypi:~/ecomet_i2c_tools $ python3 hdc1080_i2c_test.py 84 | 3.7.3 (default, Dec 20 2019, 18:57:59) 85 | [GCC 8.3.0] 86 | ecomet.hdc1080: INFO Start logging ... 87 | ecomet.hdc1080: INFO SW Reset correct 88 | ecomet.hdc1080: INFO Battery > 2.4V, correct 89 | ecomet.hdc1080: INFO Write CONF register correct 90 | ecomet.hdc1080: INFO SERIAL Read correct 91 | ecomet.hdc1080: INFO SER ID: 0127:1A13:DC00 92 | ecomet.hdc1080: INFO MANUFACTURER Read correct 93 | ecomet.hdc1080: INFO MAN ID: 5449 94 | ecomet.hdc1080: INFO DEVICE Read correct 95 | ecomet.hdc1080: INFO DEV ID: 1050 96 | ecomet.hdc1080: INFO Measured Temperate BOTH: 26.44 ℃ 97 | ecomet.hdc1080: INFO Measured Humidity BOTH: 57.86 % 98 | ecomet.hdc1080: INFO Write CONF register correct 99 | ecomet.hdc1080: INFO Measured Temperate IND: 26.54 ℃ 100 | ecomet.hdc1080: INFO Measured Humidity IND: 57.76 % 101 | ``` 102 | 103 | **Note:** for more details look into hdc1080_i2c_test.py 104 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/htu21/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/htu21/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/htu21/htu21_constant.py: -------------------------------------------------------------------------------- 1 | # Address: 2 | HTU21_ADDRESS = 0x40 # 8 bit version 3 | 4 | # Register 5 | 6 | TEMP = 0xE3 7 | HUMDT = 0xE5 8 | WRITE_USER = 0xE6 9 | READ_USER = 0xE7 10 | SRESET = 0xFE 11 | 12 | # USER REGISTER 8 Bits: 13 | 14 | MEAS_RES1 = 0x00 # temperature 14 bit, humidity measurement resolution 12 bit 15 | MEAS_RES2 = 0x01 # temperature 12 bit, humidity measurement resolution 8 bit 16 | MEAS_RES3 = 0x80 # temperature 13 bit, humidity measurement resolution 10 bit 17 | MEAS_RES4 = 0x81 # temperature 11 bit, humidity measurement resolution 11 bit 18 | BTST_HI = 0x00 # Battery voltage > 2.25V(readonly) 19 | BTST_LO = 0x40 # Battery voltage < 2.25V(readonly) 20 | HEAT_DISABLE = 0x00 # heater disabled 21 | HEAT_ENABLE = 0x04 # heater enable 22 | OTP_RELOAD_DISABLE = 0x01 # OTP reload disable 23 | OTP_RELOAD_ENABLE = 0x00 # OTP reload enable 24 | 25 | # USER REGISTER 8 Bits clear: 26 | 27 | MEAS_RES1_CLR = 0x7E # temperature & humidity resolution bits clear 28 | MEAS_RES2_CLR = 0x7E # temperature & humidity resolution bits clear 29 | MEAS_RES3_CLR = 0x7E # temperature & humidity resolution bits clear 30 | MEAS_RES4_CLR = 0x7E # temperature & humidity resolution bits clear 31 | BTST_HI_CLR = 0xBF # battery check bit clear 32 | BTST_LO_CLR = 0xBF # battery check bit clear 33 | HEAT_DISABLE_CLR = 0xFB # heater bit clear 34 | HEAT_ENABLE_CLR = 0xFB # heater bit clear 35 | OTP_CLR = 0xFE # OTP bit clear 36 | 37 | # REGISTER Mask bites 38 | REG_MEAS = 0x81 39 | REG_BAT = 0x40 40 | REG_HEAT = 0x04 41 | REG_OTP = 0x02 42 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/htu21/htu21_python_IIC.md: -------------------------------------------------------------------------------- 1 | # htu21_IIC python3 module 2 | 3 | **Last modification:** 31.07.2020 4 | 5 | ### List of python files: ### 6 | 7 | **Chip description** 8 | The HTU21D is a new digital humidity sensor with temperature output. Every sensor is individually calibrated and tested. 9 | 10 | **htu21_constant.py** 11 | 12 | * list of HTU21D chip registers and their statuses 13 | 14 | **htu21.py** 15 | 16 | * HTU21 - main chip class 17 | * HTU21.read_register - read status of one register 18 | * HTU21.write_register - write new value to chip register 19 | * HTU21.measure_temp - read only value of TEMP register 20 | * HTU21.measure_hmdt - read only value of HUMDT register 21 | * HTU21.sw_reset - software Reset CHIP 22 | * HTU21.battery - check status of battery or power supply (must by > 2.25V) 23 | * HTU21.dew_point - temperature at which the water vapor in the air becomes saturated and condensation begins 24 | 25 | ### How to call python sub? ### 26 | 27 | see **htu21_i2c_test.py** script 28 | 29 | set logging: 30 | ```python 31 | logging.basicConfig(level=logging.INFO 32 | ``` 33 | set for INFO level logging. possible used DEBUG, ERROR loogin 34 | script will produce log htu21.log 35 | 36 | initialize chip: 37 | ```python 38 | sens = htu21.HTU21() 39 | ``` 40 | 41 | sw reset & battery test: 42 | ```python 43 | ret = sens.sw_reset() # make sw reset of chip 44 | ret = sens.battery() # will check power_supply status, correct when voltage over than 2.25V 45 | ``` 46 | 47 | write to register: 48 | ```python 49 | ret = sens.write_register ( register = *reg_name*, bits = [*bit1*,*bit2* ...]) 50 | ret = sens.write_register ( register = *reg_name*, bits = [{*bit_name1* : *bit_value1*}, ... ] 51 | ``` 52 | example: 53 | ``` python 54 | ret = sens.write_register( register = "WRITE_USER", bits = ['MEAS_RES1','HEAT_DISABLE']) 55 | 56 | meausre: 57 | ```python 58 | (temp, ret) = sens.measure_temp() 59 | (hmdt, ret) = sens.measure_hmdt() 60 | (hmdt, ret) = sens.dew_point() 61 | ``` 62 | measure temperature, humidity or dew point individually 63 | 64 | ret value: 65 | return value for each procedure (0 - correct, >0 - incorrect) 66 | 67 | output of test script: 68 | ```shell 69 | pi@raspberrypi:~/ecomet_i2c_raspberry_tools $ python3 htu21_i2c_test.py 70 | 3.7.3 (default, Dec 20 2019, 18:57:59) 71 | [GCC 8.3.0] 72 | ecomet.htu21: INFO Start logging ... 73 | ecomet.htu21: INFO SW Reset correct 74 | ecomet.htu21: INFO Battery > 2.4V, correct 75 | ecomet.htu21: INFO Write WRITE_REG register correct 76 | {'REG': {'HRES': '12BIT', 'TRES': '14BIT', 'BAT': 'GOOD', 'HEAT': 'DISABLE', 'OTP': 'DISABLE'}} 77 | ecomet.htu21: INFO Measured Temperate IND: 27.99 ℃ 78 | ecomet.htu21: INFO Measured Humidity IND: 36.62 % 79 | ecomet.htu21: INFO Write WRITE_REG register correct 80 | {'REG': {'HRES': '11BIT', 'TRES': '11BIT', 'BAT': 'GOOD', 'HEAT': 'DISABLE', 'OTP': 'DISABLE'}} 81 | ecomet.htu21: INFO Measured Temperate IND: 28.00 ℃ 82 | ecomet.htu21: INFO Measured Humidity IND: 36.62 % 83 | {'MEASURE': {'TEMP': 27.968281249999997, 'HMDT': 36.6177978515625, 'DEW_POINT': 11.826074255509837}} 84 | ecomet.htu21: INFO Calculated Dew Point IND: 11.85 ℃ 85 | ``` 86 | 87 | **Note:** for more details look into htu21_i2c_test.py 88 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/i2c_command.py: -------------------------------------------------------------------------------- 1 | # i2c_command 2 | # Author: Marian Minar 3 | # Copyright 2020 4 | 5 | import time 6 | from smbus2 import SMBus 7 | from ecomet_i2c_sensors import Platform 8 | from ecomet_i2c_sensors.platform import i2c_platform 9 | 10 | plat = i2c_platform.plat_list[Platform.platform_detect()] 11 | if plat in ['H616','A10']: 12 | import OPi.GPIO as rGPIO 13 | else: 14 | import RPi.GPIO as rGPIO 15 | 16 | 17 | def eeprom_set_addr(addr,smb,slaveaddr,chip) : 18 | 19 | haddr = 0x00 + addr 20 | hslaveaddr = 0x00 + slaveaddr 21 | 22 | if (chip <= 2) : 23 | smb.write_byte(hslaveaddr, addr%256) 24 | elif (chip <= 5) : 25 | if addr//256 > 0 : 26 | hslaveaddr = hslaveaddr | addr//256 27 | smb.write_byte(hslaveaddr, addr%256) 28 | elif (chip <= 10) : 29 | smb.write_byte_data(slaveaddr, addr//256, addr%256) 30 | else : 31 | if addr//65535 > 0 : 32 | hslaveaddr = hslaveaddr | addr//65535 33 | smb.write_byte_data(hslaveaddr, addr//256, addr%256) 34 | 35 | # read by byte mode 36 | def eeprom_read_byte(addr,smb,slaveaddr,chip) : 37 | 38 | haddr = 0x00 + addr 39 | hslaveaddr = 0x00 + slaveaddr 40 | eeprom_set_addr(addr,smb,slaveaddr,chip) 41 | 42 | if (chip > 2 and chip <= 5) : 43 | if addr//256 > 0 : 44 | hslaveaddr = hslaveaddr | addr//256 45 | elif (chip > 11) : 46 | if addr//65535 > 0 : 47 | hslaveaddr = hslaveaddr | addr//65535 48 | 49 | return smb.read_byte(hslaveaddr) 50 | 51 | # write by byte mode 52 | def eeprom_write_byte(addr, byte, smb, slaveaddr, writestrobe, chip) : 53 | 54 | haddr = 0x00 + addr 55 | hslaveaddr = 0x00 + slaveaddr 56 | 57 | if (chip <= 2) : 58 | data = [byte] 59 | try: 60 | if writestrobe != None : 61 | rGPIO.output(writestrobe, rGPIO.LOW) 62 | smb.write_i2c_block_data(hslaveaddr, addr%256, data) 63 | if writestrobe != None : 64 | rGPIO.output(writestrobe, rGPIO.HIGH) 65 | finally: 66 | time.sleep(0.015) 67 | elif (chip > 2 and chip <= 5) : 68 | data = [byte] 69 | hslaveaddr = hslaveaddr | addr//256 70 | try: 71 | if writestrobe != None : 72 | rGPIO.output(writestrobe, rGPIO.LOW) 73 | smb.write_i2c_block_data(hslaveaddr, addr%256, data) 74 | if writestrobe != None : 75 | rGPIO.output(writestrobe, rGPIO.HIGH) 76 | finally: 77 | time.sleep(0.015) # data sheet says 10 msec mac 78 | elif (chip > 5 and chip <= 10) : 79 | data = [addr%256,byte] 80 | try: 81 | if writestrobe != None : 82 | rGPIO.output(writestrobe, rGPIO.LOW) 83 | smb.write_i2c_block_data(slaveaddr, addr//256, data) 84 | if writestrobe != None : 85 | rGPIO.output(writestrobe, rGPIO.HIGH) 86 | finally: 87 | time.sleep(0.015) 88 | else : 89 | data = [addr%256,byte] 90 | hslaveaddr = hslaveaddr | addr//65535 91 | try: 92 | if writestrobe != None : 93 | rGPIO.output(writestrobe, rGPIO.LOW) 94 | smb.write_i2c_block_data(hslaveaddr, addr//256, data) 95 | if writestrobe != None : 96 | rGPIO.outpu(writestrobe, rGPIO.HIGH) 97 | finally: 98 | time.sleep(0.015) 99 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ina260/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/ina260/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ina260/ina260_constant.py: -------------------------------------------------------------------------------- 1 | # Address: 2 | 3 | INA260_ADDRESS = 0x45 # 8 bit version Command Mode 4 | INA260_ADDRESS1 = 0x40 # 8 bit version Command Mode 5 | INA260_ADDRESS2 = 0x45 # 8 bit version Command Mode 6 | 7 | # LED Registers 8 | 9 | class register(object): 10 | # registers INA260 11 | REG_CONFIG = 0x00 # Configuration register 12 | REG_CURRENT = 0x01 # Current measurement register (signed) in mA 13 | REG_BUSVOLTAGE = 0x02 # Bus voltage measurement register in mV 14 | REG_POWER = 0x03 # Power calculation register in mW 15 | REG_MASK_ENABLE = 0x06 # Interrupt/Alert setting and checking register 16 | REG_ALERT_LIMIT = 0x07 # Alert limit value register 17 | REG_MANUFACTURER_ID = 0xFE # Manufacturer ID Register 18 | REG_DIE_UID = 0xFF # Die ID and Revision Register 19 | 20 | # Modes 21 | MODE_SHUTDOWN = 0x00 # SHUTDOWN: Minimize quiescient current and turn off current into the device inputs. Set another mode to exit shutown mode **/ 22 | MODE_SHUNT_CURRENT_TRIG = 0x01 # Shunt Current, Triggered 23 | MODE_BUS_VOLTAGE_TRIG = 0x02 # Bus Voltage, Triggered 24 | MODE_CUR_VOLT_TRIG = 0x03 # TRIGGERED: Trigger a one-shot measurement of current and bus voltage. Set the TRIGGERED mode again to take a new measurement **/ 25 | MODE_SHUNT_CURRENT_CONT = 0x05 26 | MODE_BUS_VOLT_CONT = 0x06 27 | MODE_CUR_VOLT_CONT = 0x07 # CONTINUOUS: (Default) Continuously update 28 | 29 | # Current or voltage conversion time 30 | TIME_140_us = 0x0 #140 us 31 | TIME_204_us = 0x1 #204 us 32 | TIME_332_us = 0x2 #332 us 33 | TIME_558_us = 0x3 #558 us 34 | TIME_1_1_ms = 0x4 #1.1 ms (default) 35 | TIME_2_116_ms = 0x5 #2.115 ms 36 | TIME_4_156_ms = 0x6 #4.156 ms 37 | TIME_8_244_ms = 0x7 #8.244 ms 38 | 39 | # Averaging count 40 | COUNT_1 = 0x0 # 1(default) 41 | COUNT_4 = 0x1 # 4 42 | COUNT_16 = 0x2 # 16 43 | COUNT_64 = 0x3 # 64 44 | COUNT_128 = 0x4 # 128 45 | COUNT_256 = 0x5 # 256 46 | COUNT_512 = 0x6 # 512 47 | COUNT_1024 = 0x7 # 1024 48 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ina260/ina260_ui_constant.py: -------------------------------------------------------------------------------- 1 | from ecomet_i2c_sensors.ina260 import ina260_constant 2 | 3 | class set_measure_0(object): 4 | # set parameters of measure for INA260 chip 0 5 | _mconst = ina260_constant.register 6 | AVGC = _mconst.COUNT_1 # average count 7 | ISHCT = _mconst.TIME_1_1_ms # measure current time 8 | VBUSCT = _mconst.TIME_1_1_ms # measure voltage time 9 | MODE = _mconst.MODE_SHUNT_CURRENT_CONT # measure mode 10 | 11 | class set_measure_1(object): 12 | # set parameters of measure for INA260 chip 1 13 | _mconst = ina260_constant.register 14 | AVGC = _mconst.COUNT_1 # average count 15 | ISHCT = _mconst.TIME_1_1_ms # measure current time 16 | VBUSCT = _mconst.TIME_1_1_ms # measure voltage time 17 | MODE = _mconst.MODE_SHUNT_CURRENT_CONT # measure mode 18 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/isl2802x/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/isl2802x/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/isl2802x/isl2802x_constant.py: -------------------------------------------------------------------------------- 1 | # Address: 2 | 3 | ISL28022_ADDRESS = 0x40 # 8 bit version Command Mode 4 | 5 | # LED Registers 6 | 7 | class register(object): 8 | # registers ISL28022 9 | REG_CONFIG = 0x00 # Power-on reset, bus and shunt ranges, ADC acquisition times, mode configuration 10 | REG_SHUNT_VOLTAGE = 0x01 # Shunt voltage measurement value 11 | REG_BUS_VOLTAGE = 0x02 # Bus voltage measurement value 12 | REG_POWER = 0x03 # Power measurement value 13 | REG_CURRENT = 0x04 # Current measurement value 14 | REG_CALIBRATION_REG = 0x05 # Register used to enable current and power measurements. 15 | REG_SHUNT_VOLTAGE_THRESH = 0x06 # Min/Max shunt thresholds 16 | REG_BUS_VOLTAGE_THRESH = 0x07 # Min/Max VBUS thresholds 17 | REG_DCS_INTERRUPT_STATUS = 0x08 # Threshold interrupts 18 | REG_AUX_CONTROL = 0x09 # Register to control the interrupts and external clock functionality 19 | 20 | # Modes 21 | MODE_POWER_DOWN = 0x00 # Power-down 22 | MODE_SHUNTV_TRIGG = 0x01 # Shunt voltage, triggered 23 | MODE_BUSV_TRIGG = 0x02 # Bus voltage, triggered 24 | MODE_SHUNT_BUSV_TRIGG = 0x03 # Shunt and bus, triggered 25 | MODE_ADC_OFF = 0x04 # ADC off (disabled) 26 | MODE_SHUNTV_CONT = 0x05 # Shunt Voltage, continuous 27 | MODE_BUSV_CONT = 0x06 # Bus voltage, continuous 28 | MODE_SHUNT_BUSV_CONT = 0x07 # Shunt and bus, continuous 29 | 30 | # BRNG 31 | BRNG_16V = 0x00 # BUS_VOLTAGE SCALE RANGE 0..16V 32 | BRNG_32V = 0x01 # 0..32V 33 | BRNG_60V = 0x02 34 | 35 | # ADC 36 | ADC_1_12 = 0x00 # from 72us ... 64.01 ms 37 | ADC_1_13 = 0x01 38 | ADC_1_14 = 0x02 39 | ADC_1_15 = 0x03 40 | ADC_2_15 = 0x09 41 | ADC_4_15 = 0x0a 42 | ADC_8_15 = 0x0b 43 | ADC_16_15 = 0x0c 44 | ADC_32_15 = 0x0d 45 | ADC_64_15 = 0x0e 46 | ADC_128_15 = 0x0f 47 | 48 | # PG 49 | PG_40mV = 0x00 # GAIN 1 +- 40mV 50 | PG_80mV = 0x01 # GAIN 2 +- 80mV 51 | PG_160mV = 0x02 # GAIN 4 +- 160mV 52 | PG_320mV = 0x03 # GAIN 8 +- 320mV 53 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/isl2802x/isl2802x_ui.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | import logging 3 | import time 4 | import random 5 | import os 6 | import pickle 7 | import re 8 | from ecomet_i2c_sensors.ina260 import ina260,ina260_constant,ina260_ui_constant 9 | 10 | class INA260_UI(object): 11 | '''INA260_UI()''' 12 | '''chip=0#0x40''' 13 | 14 | def __init__(self, chip=0, time = 1, i_unit = 'mA', v_unit = 'mV', **kwargs) : 15 | self._logger = logging.getLogger(__name__) 16 | if chip == 0 : 17 | self._address = ina260_constant.INA260_ADDRESS1 18 | _mconst = ina260_ui_constant.set_measure_0 19 | elif chip == 1 : 20 | self._address = ina260_constant.INA260_ADDRESS2 21 | _mconst = ina260_ui_constant.set_measure_1 22 | else : 23 | match = re.search('^(\d+)#(.+)$', chip,re.IGNORECASE) 24 | if match.group(1) == '0' : 25 | self._address = int(match.group(2),16) 26 | _mconst = ina260_ui_constant.set_measure_0 27 | elif match.group(1) == '1' : 28 | self._address = int(match.group(2),16) 29 | _mconst = ina260_ui_constant.set_measure_1 30 | _ina = ina260.INA260(address=self._address) 31 | self._logger.debug("address: %d" % self._address) 32 | self._ina = _ina 33 | self._iunit = i_unit 34 | self._vunit = v_unit 35 | self._measure_avgc = _ina.write_funct('AVGC', value = _mconst.AVGC) 36 | self._measure_ishct = _ina.write_funct('ISHCT', value = _mconst.ISHCT) 37 | self._measure_vbusct = _ina.write_funct('VBUSCT', value = _mconst.VBUSCT) 38 | self._measure_mode = _ina.write_funct('MODE', value = _mconst.MODE) 39 | r = random.randrange(3,999,3) 40 | self._filename = 'ina260_' + str(r) 41 | self._logger.debug("filename: %s" % self._filename) 42 | self._stime = time 43 | 44 | def child(self, vunit=None): 45 | if not vunit: 46 | vunit = self._vunit 47 | fd = open(self._filename,'wb') 48 | self._logger.debug("child: %d" % os.getpid()) 49 | voltage = self._ina.measure_voltage(stime = self._stime, unit = vunit) 50 | pickle.dump(voltage, fd,-1) 51 | fd.close() 52 | os._exit(0) 53 | 54 | def parent(self, stime=None, iunit=None, vunit=None): 55 | if not stime: 56 | stime = self._stime 57 | if not iunit: 58 | iunit = self._iunit 59 | while True: 60 | newpid = os.fork() 61 | if newpid == 0: 62 | self.child( vunit = vunit) 63 | else: 64 | self._logger.debug("parent: %d" % os.getpid()) 65 | current = self._ina.measure_current(stime = stime, unit = iunit ) 66 | os.waitid(os.P_PID,newpid,os.WEXITED) 67 | break 68 | fd = open(self._filename,'rb') 69 | voltage = pickle.load(fd) 70 | fd.close() 71 | os.remove(self._filename) 72 | 73 | multi_measure = [current,voltage] 74 | return (multi_measure) 75 | 76 | def measure_ui (self, iunit=None, vunit=None) : 77 | if not iunit: 78 | iunit = self._iunit 79 | if not vunit: 80 | vunit = self._vunit 81 | data = {} 82 | data = self.parent( iunit = iunit, vunit = vunit) 83 | return data 84 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/isl2802x/isl2802x_ui_constant.py: -------------------------------------------------------------------------------- 1 | from ecomet_i2c_sensors.ina260 import ina260_constant 2 | 3 | class set_measure_0(object): 4 | # set parameters of measure for INA260 chip 0 5 | _mconst = ina260_constant.register 6 | AVGC = _mconst.COUNT_1 # average count 7 | ISHCT = _mconst.TIME_332_us # measure current time 8 | VBUSCT = _mconst.TIME_332_us # measure voltage time 9 | MODE = _mconst.INA260_MODE_CONTINUOUS # measure mode 10 | 11 | class set_measure_1(object): 12 | # set parameters of measure for INA260 chip 0 13 | _mconst = ina260_constant.register 14 | AVGC = _mconst.COUNT_1 # average count 15 | ISHCT = _mconst.TIME_332_us # measure current time 16 | VBUSCT = _mconst.TIME_332_us # measure voltage time 17 | MODE = _mconst.INA260_MODE_CONTINUOUS # measure mode 18 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/mcp3221/mcp3221_constant.py: -------------------------------------------------------------------------------- 1 | MCP_ADDR = 0x4F 2 | 3 | VDD = 5 # Voltage = 5V 4 | MAX_DEGREE = 360 # 360 Degree max position 5 | WEST = 75 6 | SOUTH = 176 7 | EAST = 280 8 | NORTH = 360 9 | NORTH_WEST = 36 10 | SOUTH_WEST = 125 11 | SOUTH_EAST = 225 12 | NORTH_EAST = 330 13 | 14 | MAX_VDD = 4095 15 | 16 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ms5637/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/ms5637/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ms5637/ms5637_constant.py: -------------------------------------------------------------------------------- 1 | # Address: 2 | 3 | MS5637_ADDRESS = 0x76 # 8 bit version 4 | 5 | 6 | # Operation Pressure Range 7 | # MIN = 300 mbar 8 | # MAX = 1200 mbar 9 | 10 | # Command (only write): 11 | # A programmable over sample ratio (OSR) allows users to tune the speed and resolution for a variety of applications. 12 | # accuracy increasing with higher CONV number, also time of measurement is increasing 13 | # See Delta-Sigma ADC info 14 | # https://training.ti.com/delta-sigma-adcs-overview 15 | # 16 | # OSR = fMOD/fDATA 17 | 18 | RESET = 0x1E 19 | D1_CONV_256 = 0x40 # Convert D1 (OSR=256) digital pressure value 20 | D1_CONV_512 = 0x42 # Convert D1 (OSR=512) 21 | D1_CONV_1024 = 0x44 # Convert D1 (OSR=1024) 22 | D1_CONV_2048 = 0x46 # Convert D1 (OSR=2048) 23 | D1_CONV_4096 = 0x48 # Convert D1 (OSR=4096) 24 | D1_CONV_8192 = 0x4A # Convert D1 (OSR=8192) 25 | D2_CONV_256 = 0x50 # Convert D2 (OSR=256) digital temperature value 26 | D2_CONV_512 = 0x52 # Convert D2 (OSR=512) 27 | D2_CONV_1024 = 0x54 # Convert D2 (OSR=1024) 28 | D2_CONV_2048 = 0x56 # Convert D2 (OSR=2048) 29 | D2_CONV_4096 = 0x58 # Convert D2 (OSR=4096) 30 | D2_CONV_8192 = 0x5A # Convert D2 (OSR=8192) 31 | 32 | # conversation time Time for convertion of signal (OSR) 33 | CONV_256_TIME = 0.54 #in ms 34 | CONV_512_TIME = 1.06 35 | CONV_1024_TIME = 2.08 36 | CONV_2048_TIME = 4.13 37 | CONV_4096_TIME = 8.22 38 | CONV_8192_TIME = 16.44 39 | 40 | # onle read 41 | #PROM_READ from 0xA0 - 0xAE (2 bytes) 42 | PROM_PRE_SENS = 0xA2 # Pressure sensitivity SENST1 43 | PROM_PRE_OFFSET = 0xA4 # Pressure offset OFFT1 44 | PROM_TMP_PRE_SENS = 0xA6 # Temperature coefficient of pressure sensitivity | TCS 45 | PROM_TMP_PRE_OFFSET = 0xA8 # Temperature coefficient of pressure offset | TCO 46 | PROM_REF = 0xAA # Reference temperatur | TRef 47 | PROM_TMP_COEF = 0xAC # Temperature coefficient of the temperature | TEMPSE 48 | # (3 bytes) 49 | ADC_READ = 0x00 # ADC Read 50 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/pca9557/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/pca9557/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/pca9557/pca9557_constant.py: -------------------------------------------------------------------------------- 1 | # Address: 2 | 3 | PCA9557_ADDRESS = 0x18 # 8 bit version 4 | 5 | 6 | # Operation Pressure Range 7 | 8 | REGISTER0 = 0x00 # Input Port 9 | REGISTER1 = 0x01 # Output Port 10 | REGISTER2 = 0x02 # Inversion Port I -> Inversion, N -> Normal 11 | REGISTER3 = 0x03 # Setting I/O Port I-> Input, O-> Output 12 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/pca9632/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/pca9632/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/pca9632/pca9632_constant.py: -------------------------------------------------------------------------------- 1 | # Address: 2 | PCA9632_ADDRESS = 0x62 # 8 bit version 0x62 pca9632 3 | PCA9632_SWRESET = 0x06 # Software reset add 0xA5 & 0x5A bytes 4 | PCA9632_LEDALLCALL = 0x70 # LED ALL CALL address 5 | 6 | PCA9632_SUBADR1 = 0x71 7 | PCA9632_SUBADR2 = 0x72 8 | PCA9632_SUBADR3 = 0x74 9 | 10 | # Register 11 | 12 | MODE1 = 0x00 13 | MODE2 = 0x01 14 | PWM0 = 0x02 15 | PWM1 = 0x03 16 | PWM2 = 0x04 17 | PWM3 = 0x05 18 | GRPPWM = 0x06 19 | GRPFREQ = 0x07 20 | LEDOUT = 0x08 21 | SUBADR1 = 0x09 # used as subaddress, when MOD1 SUB1 (1) 22 | SUBADR2 = 0x0A # used as subaddress, when MOD1 SUB2 (1) 23 | SUBADR3 = 0x0B # used as subaddress, when MOD1 SUB3 (1) 24 | ALLCALLADR = 0x0C 25 | 26 | NO_INCREMENT = 0x0 # is used when the same register must be accessed several times during a single I2C-bus communication 27 | SEQ_ACCESS = 0x4 # is used when all the registers must be sequentially accessed 28 | LED_PROG = 0x5 # is used when the four LED drivers must be individually programmed with different values during the same I2C-bus communication 29 | LED_GLOBAL = 0x6 # is used when the LED drivers must be globally programmed with different settings during the same I2C-bus communication 30 | GLOBAL_ALL = 0x7 # is used when individual and global changes must be performed during the same I2C-bus communication 31 | 32 | # MODE 1 Bits allow: 33 | 34 | SLEEP = 0x10 # normal/osciloscop_off 35 | SUB1 = 0x08 # allow/disable SUBADDR1 36 | SUB2 = 0x04 # allow/disable SUBADDR2 37 | SUB3 = 0x02 # allow/disable SUBADDR3 38 | ALLCALL = 0x01 # does_not/respond to ALLCALL_I2C address 39 | 40 | # MODE 1 Bits disable: 41 | 42 | SLEEP_N = 0x0F 43 | SUB1_N = 0x17 44 | SUB2_N = 0x1B 45 | SUB3_N = 0x1D 46 | ALLCALL_N = 0x1E 47 | 48 | # MODE2 Bits allow: 49 | 50 | DMBLNK = 0x10 51 | DMBLNK_DIMMING = 0x10 52 | INVRT = 0x08 # set output parameter 53 | OCH = 0x04 54 | OUTDRV = 0x02 # set output parameter 55 | 56 | # MODE2 Bits disable: 57 | 58 | DMBLNK_BLINKING = 0x0F 59 | INVRT_N = 0x17 60 | OCH_N = 0x1B 61 | OUTDRV_N = 0x1D 62 | 63 | # DBMLNK Status: 64 | DIMMING = 0x00 # 0 - DIMMING 65 | BLINING = 0x01 # 1 - BLINKING 66 | 67 | # LEDOUT Bits: 68 | 69 | LDR0 = 0x03 70 | LDR1 = 0x0C 71 | LDR2 = 0x30 72 | LDR3 = 0xC0 73 | 74 | # LEDOUT Bits Write: 75 | 76 | LDR0_W = 0xFC 77 | LDR1_W = 0xF3 78 | LDR2_W = 0xCF 79 | LDR3_W = 0x3F 80 | 81 | # LEDOUT Mode: 82 | 83 | OFF = 0x00 # LED driver x is off 84 | ON = 0x01 # LED driver x is fully on 85 | PWM = 0x02 # LED driver x individual brightness can be controlled through its PWMx register. 86 | PWM_GRPPWM = 0x03 # LED driver x individual brightness and group dimming/blinking can be controlled through its PWMx register and the GRPPWM registers. 87 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/pca9632/pca_9632_python_IIC.md: -------------------------------------------------------------------------------- 1 | # pca9632_IIC python3 module 2 | 3 | **Last modification:** 29.03.2020 4 | 5 | ### List of python files: ### 6 | 7 | **pca9632_constant.py** 8 | 9 | * list of pca9632 chip registers and their statuses 10 | 11 | **pca9632.py** 12 | 13 | * read_pca9632 - read all registers from chip 14 | * software_reset - make software reset of chip 15 | * ledout_clean - set all LEDRx to OFF status 16 | * PCA9362 - main chip class 17 | * PCA9632.read_register - read status of one register 18 | * PCA9632.write_register - write new value to chip register 19 | 20 | ### How to call python sub? ### 21 | 22 | see **pca_6532_i2c_test.py** script 23 | 24 | initialization: 25 | ```python 26 | pwm = pca9632.PCA9632() 27 | 28 | read all registers: 29 | ```python 30 | reg_view = pca9632.read_pca9632(); 31 | ``` 32 | 33 | write to register: 34 | ```python 35 | ret = pwm.write_register ( register = *reg_name*, bits = [*bit1*,*bit2* ...]) 36 | ret = pwm.write_register ( register = *reg_name*, bits = [{*bit_name1* : *bit_value1*}, ... ] 37 | ``` 38 | example: 39 | ``` 40 | ret = pwm.write_register( register = "MODE2", bits = ['INVRT_N']) 41 | 42 | ret = pwm.write_register( register = 'LEDOUT', bits = [{'LDR0' : 'ON' }, {'LDR1' : 'PWM_GRPPWM'}, {'LDR2' : 'OFF'}, {'LDR3' : 'PWM'}]) 43 | ``` 44 | 45 | Register status value: 46 | 47 | * INVERT - ON INVERT status 48 | * INVERT_N - OFF INVERT status 49 | see **pca9632_constat.py** -------------------------------------------------------------------------------- /ecomet_i2c_sensors/platform/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/platform/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/platform/i2c_platform.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | import logging 3 | import re 4 | import Adafruit_PureIO 5 | 6 | # Platform identification constants. 7 | plat_list = { 0 : 'UNKONWN', 8 | 1 : 'RASPBERRY_PI', 9 | 2 : 'BEAGLEBONE_BLACK', 10 | 3 : 'MINNOWBOARD', 11 | 4 : 'JETSON_NANO', 12 | 5 : 'H616', 13 | 6 : 'A10', 14 | } 15 | 16 | class Board_plat(object): 17 | 18 | def __init__(self, address=None, busnum=None, arange=None, i2c=None, **kwargs) : 19 | # Setup I2C interface for the device. 20 | if i2c is None: 21 | import ecomet_i2c_sensors.i2c as I2C 22 | import ecomet_i2c_sensors.Platform as Platform 23 | i2c = I2C 24 | plat = Platform 25 | self._logger = logging.getLogger(__name__) 26 | self._plat = plat.platform_detect() 27 | if plat_list[self._plat] == 'RASPBERRY_PI' : 28 | self._pi_ver = plat.pi_version() 29 | self._pi_rev = plat.pi_revision() 30 | self._bus = i2c.get_default_bus() 31 | self._busnum = busnum 32 | self._slaves = '' 33 | if arange is None: 34 | arange = [0x00,0x77]; 35 | for addr in range(arange[0],arange[1]) : 36 | ret = 0 37 | try : 38 | self._device = i2c.get_i2c_device(address=addr,busnum=self._busnum, **kwargs) 39 | except : 40 | ret = 1 41 | if addr == 0x76 : #special detection for ms5637 chip 42 | try : 43 | self._device.writeRaw8(0x1E) 44 | except : 45 | ret = 3 46 | else: 47 | try : 48 | self._device.readRaw8() 49 | except : 50 | ret = 2 51 | if ret == 0 : 52 | self._slaves = self._slaves + str(hex(addr)) + ':' 53 | self._slaves = self._slaves[:-1] 54 | def board (self) : 55 | version = plat_list[self._plat] 56 | if version == 'RASPBERRY_PI' : 57 | if re.search('\.',self.pi_ver()) : 58 | version = version + self.pi_ver() 59 | else : 60 | version = version + self.pi_ver() + '.' + self.pi_rev() 61 | return version 62 | def pi_ver (self) : 63 | return str(self._pi_ver) 64 | def pi_rev (self) : 65 | return str(self._pi_rev) 66 | def bus (self) : 67 | return str(self._bus) 68 | def slaves (self) : 69 | return self._slaves 70 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/sgp40/sgp40_constant.py: -------------------------------------------------------------------------------- 1 | SGP40_ADDR = 0x59 2 | 3 | 4 | #Registers 5 | TEST_OK = 0xD400 6 | HEATER_OFF = 0x3615 7 | MEASURE_TEST = 0x280E 8 | SOFT_RESET = 0x0006 9 | MEASURE_RAW = 0x260F 10 | 11 | DURATION_READ_RAW_VOC = 0.03 12 | DURATION_WAIT_MEASURE_TEST = 0.25 13 | OFFSET = 0x00 14 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/sn_gcja5/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/sn_gcja5/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/sn_gcja5/sn_gcja5_constant.py: -------------------------------------------------------------------------------- 1 | # Address: 2 | SN_GCJA5_ADDRESS = 0x33 # 8 bit version 3 | 4 | # Register 5 | # On the mass-density valu, update each 1s 6 | # PM1.0 7 | PM1_0_LL = 0x00 # LL Byte 8 | PM1_0_LH = 0x01 # LH Byte 9 | PM1_0_HL = 0x02 # HL Byte 10 | PM1_0_HH = 0x03 # HH Byte 11 | 12 | # PM2.5 13 | PM2_5_LL = 0x04 # LL Byte 14 | PM2_5_LH = 0x05 # LH Byte 15 | PM2_5_HL = 0x06 # HL Byte 16 | PM2_5_HH = 0x07 # HH Byte 17 | 18 | # PM10 19 | PM10_LL = 0x08 # LL Byte 20 | PM10_LH = 0x09 # LH Byte 21 | PM10_HL = 0x0a # HL Byte 22 | PM10_HH = 0x0b # HH Byte 23 | 24 | # Particle cound, update each 1s 25 | # (0.3-0.5um) 26 | P0_5_L = 0x0c # L Byte 27 | P0_5_H = 0x0d # H Byte 28 | # (0.5-1.0um) 29 | P1_L = 0x0e # L Byte 30 | P1_H = 0x0f # H Byte 31 | # (1.0-2.5um) 32 | P2_5_L = 0x10 # L Byte 33 | P2_5_H = 0x11 # H Byte 34 | # (2.5-5.0um) 35 | P5_L = 0x14 # L Byte 36 | P5_H = 0x15 # H Byte 37 | # (5.0-7.5um) 38 | P7_5_L = 0x16 # L Byte 39 | P7_5_H = 0x17 # H Byte 40 | # (7.5-10.0um) 41 | P10_L = 0x18 # L Byte 42 | P10_H = 0x19 # H Byte 43 | 44 | STATE = 0x26 # Sensor status information 45 | 46 | # STATE (0x26) 8 Bits: 47 | 48 | SENSOR_STAT = 0xC0 # Sensor status 49 | PD_STAT = 0x30 # PD status 50 | LD_STAT = 0x0C # LD operational status 51 | FAN_STAT = 0x03 # FAN operational status 52 | 53 | 54 | # SENSOR_STAT 55 | NULL = 0x00 56 | ANY1 = 0x01 # Any1, nor 2 & 3 57 | ANY2 = 0x02 # Any 2 58 | ANY3 = 0x03 # Any 3, nor 2 59 | 60 | # PD_STAT 61 | PD_NORMAL = 0x00 # Normal status 62 | PD_NORMAL_COR = 0x01 # Normal status (within -80% against initial value), with S/W correction 63 | PD_ABNORM = 0x02 # Abnormal (below -90% against initial value), loss of function 64 | PD_ABNORM_COR = 0x03 # Abnormal (below -80% against initial value), with S/W correct 65 | 66 | # LD_STAT 67 | LD_NORMAL = 0x00 # Normal status 68 | LD_NORMAL_COR = 0x01 # Normal status (within -70% against initial LOP), with S/W correction 69 | LD_ABNORM = 0x02 # Abnormal (below -90% against initial LOP) or no LOP, loss of function 70 | LD_ABNORM_COR = 0x03 # Abnormal (below -70% against initial LOP), with S/W correcti 71 | 72 | # FAN_STAT 73 | FAN_NORMAL = 0x00 # Normal status 74 | FAN_NORMAL_COR = 0x01 # Normal status (1,000rpm or more), with S/W correction 75 | FAN_CALIB = 0x02 # In initial calibration 76 | FAN_ABNORM = 0x03 # Abnormal (below 1,000rpm), out of contr 77 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ssd1306/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/ssd1306/__init__.py -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ssd1306/render.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # The MIT License (MIT) 4 | # 5 | # Copyright (c) 2015 Richard Hull 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | 26 | # Example usage: 27 | # 28 | # from oled.device import ssd1306, sh1106 29 | # from oled.render import canvas 30 | # from PIL import ImageFont, ImageDraw 31 | # 32 | # font = ImageFont.load_default() 33 | # device = sh1106(port=1, address=0x3C) 34 | # 35 | # with canvas(device) as draw: 36 | # draw.rectangle((0, 0, device.width, device.height), outline=0, fill=0) 37 | # draw.text(30, 40, "Hello World", font=font, fill=255) 38 | # 39 | # As soon as the with-block scope level is complete, the graphics primitives 40 | # will be flushed to the device. 41 | # 42 | # Creating a new canvas is effectively 'carte blanche': If you want to retain 43 | # an existing canvas, then make a reference like: 44 | # 45 | # c = canvas(device) 46 | # for X in ...: 47 | # with c as draw: 48 | # draw.rectangle(...) 49 | # 50 | # As before, as soon as the with block completes, the canvas buffer is flushed 51 | # to the device 52 | 53 | from PIL import Image, ImageDraw 54 | 55 | 56 | class canvas(object): 57 | """ 58 | A canvas returns a properly-sized `ImageDraw` object onto which the caller 59 | can draw upon. As soon as the with-block completes, the resultant image is 60 | flushed onto the device. 61 | """ 62 | def __init__(self, device): 63 | self.draw = None 64 | self.image = Image.new('1', (device.width, device.height)) 65 | self.device = device 66 | 67 | def __enter__(self): 68 | self.draw = ImageDraw.Draw(self.image) 69 | return self.draw 70 | 71 | def __exit__(self, type, value, traceback): 72 | if type is None: 73 | # do the drawing onto the device 74 | self.device.display(self.image) 75 | 76 | del self.draw # Tidy up the resources 77 | return False # Never suppress exceptions 78 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ssd1306/ssd1306_constant.py: -------------------------------------------------------------------------------- 1 | # Address: 2 | 3 | SSD1306_ADDRESS_CMD = 0x3C # 8 bit version Command Mode 4 | 5 | 6 | # LED Registers 7 | 8 | class register(object): 9 | SET_COLUMN_LO = 0x00 # 0x00 - 0x0F (0 - 131) 132 columns 10 | SET_COLUMN_HI = 0x10 # 0x10 - 0x1F 11 | SET_MEMORY_MODE = 0x20 # Set Memory address mode 12 | SET_COLUMN_ADDRESS = 0x21 # Set Column Address 13 | SET_PAGE_ADDR = 0x22 14 | SET_START_LINE = 0x40 # 0x40 - 0x7F (0 - 63) 64 lines 15 | SET_CONTRAST = 0x81 # Data byte (0x00 - 0xFF) 16 | CHARGEPUMP = 0x8D # Charge Pump Setting 17 | SET_REMAP_RIGHT = 0xA0 # Segment ReMap Right 18 | SET_REMAP_LEFT = 0xA1 # Segment ReMap Left 19 | SET_VERTICAL_SCROLL = 0xA3 # Set Vertical Scroll Area 20 | SET_ENTIRE_DISP = 0xA4 # Set Entire Display RAM Displayed 21 | SET_ENTIRE_DISP_IGN = 0xA5 # Set Entire Display RAM Ignored 22 | SET_NORMAL_DISP = 0xA6 # Set Normal Display 23 | SET_REVERSE_DISP = 0xA7 # Set Reverse Display 24 | SET_MULTIPLEX_RATION= 0xA8 # Set Multiplex Ration Data (0x00 - 0x3F) 64 Multiplex ration modes 25 | DC_DC_CONTROL_MODE = 0xAD # Control DC-DC converter + (Data are next) 26 | DATA_DC_DC_OFF = 0x8A # DC-DC OFF (sleep mode) 27 | DATA_DC_DC_ON = 0x8B # DC-DC ON (External Vpp or Internal DC-DC) 28 | SET_SEGM_REMAP_0 = 0xA0 # Set Segment Remap, column address 0 to SEG0 29 | SET_SEGM_REMAP_127 = 0xA1 # Set Segment Remap, column address 127 to SEG0 30 | DISPLAY_OFF = 0xAE # Display ON 31 | DISPLAY_ON = 0xAF # Display OFF 32 | SET_PAGE_ADDR = 0xB0 # Set Page Address (0xB0 - 0xB7) 8 Pages 33 | SET_OUTPUT_SCAN_UP = 0xC0 # Scan common output allowing layout flexible, (from COM0 -> COM[n-1]) 34 | SET_OUTPUT_SCAN_DOWN= 0xC8 # Scan common output allowing layout flexible, (from COM[n-1] -> COM0) 35 | SET_DISPLAY_OFFSET = 0xD3 # Mapping of display start line to one of COM0-63 (Data 0x00 - 0x3F) 64 offsets 36 | SET_DISPLAY_CLOCK = 0xD5 # Set frequency of internal display clock (Data 0x00 - 0xFF) Divider bit[4-0] Freq bit[7-4] 37 | SET_CHARGE_PERIOD = 0xD9 # Duration of pre-charged period (Data 0x00 - 0xFF) Pre-Charget_Period_adjust bit[4-0] Dis-Charget_Period_adjustFreq bit[7-4] 38 | SET_HW_CONF_MODE = 0xDA # Common Pads Hardware Configuration Mode Set 39 | SET_VCOM = 0xDB # Set the common pad output voltage level (data 0x00 - 0xFF) 40 | READ_MODIFY_WRITE = 0xE0 # Automatic write 41 | END_RMW = 0xEE # End Read_Modify_Write automatic write 42 | NOP = 0xE3 # NOP command 43 | 44 | -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ssd1306/ssd1306_mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/ssd1306/ssd1306_mini.png -------------------------------------------------------------------------------- /ecomet_i2c_sensors/ssd1306/zoom_display.mkv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/ssd1306/zoom_display.mkv -------------------------------------------------------------------------------- /ecomet_i2c_sensors/tsl2591/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/ecomet_i2c_sensors/tsl2591/__init__.py -------------------------------------------------------------------------------- /fonts: -------------------------------------------------------------------------------- 1 | python_test_scripts/display/fonts -------------------------------------------------------------------------------- /fpc/emc2301/creator.lfm: -------------------------------------------------------------------------------- 1 | object Form_creator: TForm_creator 2 | Left = 690 3 | Height = 186 4 | Top = 221 5 | Width = 349 6 | Caption = 'Creator' 7 | ClientHeight = 186 8 | ClientWidth = 349 9 | LCLVersion = '2.0.0.4' 10 | object Label_creator: TLabel 11 | Left = 32 12 | Height = 75 13 | Top = 88 14 | Width = 182 15 | Caption = 'https://github.com/mamin27'#10'ecomet_i2c_raspberry_tools'#10#10'Marian Minar (c) 2021'#10'GPL-3.0 License' 16 | Font.Height = -12 17 | Font.Name = 'DejaVu Sans Mono' 18 | ParentColor = False 19 | ParentFont = False 20 | end 21 | object Label_project_name: TLabel 22 | Left = 32 23 | Height = 36 24 | Top = 24 25 | Width = 279 26 | Caption = 'EMC2301'#10'RPM-Based PWM Fan Controller' 27 | Font.Color = clBlue 28 | Font.Height = -15 29 | Font.Name = 'DejaVu Sans Mono' 30 | Font.Style = [fsBold] 31 | ParentColor = False 32 | ParentFont = False 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /fpc/emc2301/creator.pas: -------------------------------------------------------------------------------- 1 | unit creator; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; 9 | 10 | type 11 | 12 | { TForm_creator } 13 | 14 | TForm_creator = class(TForm) 15 | Label_creator: TLabel; 16 | Label_project_name: TLabel; 17 | private 18 | public 19 | end; 20 | 21 | var 22 | Form_creator: TForm_creator; 23 | 24 | implementation 25 | 26 | {$R *.lfm} 27 | 28 | { TForm_creator } 29 | 30 | end. 31 | 32 | -------------------------------------------------------------------------------- /fpc/emc2301/emc2301: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/emc2301 -------------------------------------------------------------------------------- /fpc/emc2301/emc2301.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/emc2301.ico -------------------------------------------------------------------------------- /fpc/emc2301/emc2301.lpr: -------------------------------------------------------------------------------- 1 | program emc2301; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | uses 6 | {$IFDEF UNIX}{$IFDEF UseCThreads} 7 | cthreads, 8 | {$ENDIF}{$ENDIF} 9 | Interfaces, // this includes the LCL widgetset 10 | Forms, emc2301_display, emc2301_read, emc2301_graph, 11 | creator, help, missing_chip 12 | { you can add units after this }; 13 | 14 | {$R *.res} 15 | 16 | begin 17 | RequireDerivedFormResource:=True; 18 | Application.Scaled:=True; 19 | Application.Initialize; 20 | Application.CreateForm(TForm_emc2301, Form_emc2301); 21 | Application.CreateForm(TForm_graph, Form_graph); 22 | Application.CreateForm(TForm_help, Form_help); 23 | Application.Run; 24 | end. 25 | 26 | -------------------------------------------------------------------------------- /fpc/emc2301/emc2301.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/emc2301.res -------------------------------------------------------------------------------- /fpc/emc2301/emc2301_IIC.md: -------------------------------------------------------------------------------- 1 | # emc2301_IIC module 2 | 3 | **Last modification:** 6.03.2021 4 | 5 | **Modul board:** 6 | - ![#1589F0](https://via.placeholder.com/15/1589F0/000000?text=+) **!NEW!** Currently in development process 7 | 8 | **Reconnection with Raspberry PI 3+:** 9 | 10 | * Configuration for /dev/i2c-1 11 | * port 2 (SDA), port 3 (SCL) 12 | * pull-up resistor for this module was set to 2.2 kΩ 13 | 14 | ### How to install? ### 15 | Install Lazarus-ide at raspberry [FPC & Lazarus Installation](../lazarus.md) 16 | Install Python3 and next modules for hdc1080 [Python3 & modules](../../ecomet_i2c_sensors/hdc1080/hdc1080_python_IIC.md) 17 | 18 | (optional when you have only lite linux version) 19 | ```console 20 | sudo apt-get install gtk2-engines libgtk2.0-dev 21 | ``` 22 | 23 | ### Run application: ### 24 | ```console 25 | ecomet_i2c_raspberry_tools/emc2301 26 | ``` 27 | 28 | **Features:** 29 | 30 | * Set fan control in 2 modes: 31 | * Direct Setting Mode - Manual setting of fan parameters, speed and measure by tachometer 32 | * FSC Mode (Fan Speed Controll Mode) - Automatic setting target speed a feed back speed control by in-build tachometer 33 | * Setting Software Lock Register for store of settings of status the some chip registers Unlock only after power off chip. 34 | * Update data from registers: 35 | * Toogle the button: ![ON button](./image/ON_30x30.png) 36 | 37 | * Setting auto update ![Monitor Windos](./image/monitor.png) 38 | * possible time update [off,1s,3s,5s,10s,20s] 39 | * Application GUI could run independently under chip control. You could run GUI and in other termina run test scripts working with chip. 40 | * Setting automatical update at Monitor Window you could monitor current fan speed or other changes. 41 | * ID of the chip (ID Window) 42 | * Conf Reg Window: 43 | * Seting fan parameters, clock input, watchdog, set mode 44 | * Gain Window ony in (FSC Mode): 45 | * The Gain register stores the gain terms used by the proportional and integral portions of the RPM 46 | * Spin Up Window: 47 | * Setting Spin, slope of the running curve during speed change 48 | * Fan Stat Window (Reading): 49 | * See current status of fan [Stall, WatchDog, Drive_Fail, Reaching Spin] 50 | * Setting ALARM interupt on/off 51 | * Software Lock for selected Registers 52 | * PWM Window: 53 | * Setting parameters of PWM [frequency, signal inversion, pwm output] 54 | * Tachometer Window: 55 | * Read or Write Tachometer parameters 56 | * Monitor Window: 57 | * Setting time offest for reading chip registers 58 | * Could be used for automatick update or manual 59 | 60 | TABS: 61 | ~ Graph: Currently not developed, just init preparation 62 | ~ Help: Short help for GUI 63 | ~ Creator: Creator information 64 | 65 | Limitations: 66 | ~ Graph feature currently not developed 67 | **Application pictures:** 68 | 69 | ![GUI](./image/emc2301_gui.png) 70 | 71 | When EMC2301 Chip is not responding at I2C lines you see: 72 | 73 | ![Chip_missing](./image/missing_chip.png) 74 | 75 | **Source Code (FPC):** 76 | * Path: ~/ecomet_i2c_raspberry_tools/fpc/emc2301 77 | 78 | **Test python scripts** 79 | * Path: !/ecomet_i2c_raspberry_tools/python_test_scripts 80 | 81 | scripts copy to /ecomet_i2c_raspberry_tools path and then run 82 | -------------------------------------------------------------------------------- /fpc/emc2301/emc2301_graph.lfm: -------------------------------------------------------------------------------- 1 | object Form_graph: TForm_graph 2 | Left = 272 3 | Height = 321 4 | Top = 265 5 | Width = 1149 6 | Caption = 'Form_graph' 7 | ClientHeight = 321 8 | ClientWidth = 1149 9 | LCLVersion = '2.0.0.4' 10 | object Chart_emc2301_RPM: TChart 11 | Left = 32 12 | Height = 248 13 | Top = 40 14 | Width = 984 15 | AxisList = < 16 | item 17 | Marks.LabelBrush.Style = bsClear 18 | Minors = <> 19 | Title.LabelFont.Orientation = 900 20 | Title.LabelBrush.Style = bsClear 21 | end 22 | item 23 | Alignment = calBottom 24 | Marks.LabelBrush.Style = bsClear 25 | Minors = <> 26 | Title.LabelBrush.Style = bsClear 27 | end> 28 | Foot.Brush.Color = clBtnFace 29 | Foot.Font.Color = clBlue 30 | Title.Brush.Color = clBtnFace 31 | Title.Font.Color = clBlue 32 | Title.Text.Strings = ( 33 | 'TAChart' 34 | ) 35 | object RPM: TLineSeries 36 | end 37 | end 38 | object UserDefinedChartSource_RPM: TUserDefinedChartSource 39 | left = 1080 40 | top = 256 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /fpc/emc2301/emc2301_graph.pas: -------------------------------------------------------------------------------- 1 | unit emc2301_graph; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, TAGraph, TASources, 9 | TASeries; 10 | 11 | type 12 | 13 | { TForm_graph } 14 | 15 | TForm_graph = class(TForm) 16 | Chart_emc2301_RPM: TChart; 17 | RPM: TLineSeries; 18 | UserDefinedChartSource_RPM: TUserDefinedChartSource; 19 | private 20 | 21 | public 22 | 23 | end; 24 | 25 | var 26 | Form_graph: TForm_graph; 27 | 28 | implementation 29 | 30 | {$R *.lfm} 31 | 32 | end. 33 | 34 | -------------------------------------------------------------------------------- /fpc/emc2301/emc2301_i2c_speed_graph.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from i2c_pkg.emc2301_pkg import emc2301 4 | from i2c_pkg.emc2301_pkg import fan_type 5 | import logging 6 | import statistics 7 | 8 | fan_list = emc2301.fan_list 9 | sens = emc2301.EMC2301() 10 | 11 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 12 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 13 | datefmt='%m-%d %H:%M', 14 | filename='emc2301.log', 15 | filemode='w') 16 | console = logging.StreamHandler() 17 | console.setLevel(logging.DEBUG) 18 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 19 | console.setFormatter(formatter) 20 | logging.getLogger('').addHandler(console) 21 | sens._logger = logging.getLogger('ecomet.emc2301') 22 | sens._logger.info('Start logging ...') 23 | 24 | (val,ret) = sens.productid() 25 | sens._logger.info('PRODUCT Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 26 | sens._logger.info('PRODUCT ID: %s',format(val)) 27 | 28 | (val,ret) = sens.manufid() 29 | sens._logger.info('MANUFACTURER Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 30 | sens._logger.info('MANUF ID: %s',format(val)) 31 | 32 | (val,ret) = sens.revisionid() 33 | sens._logger.info('REVISION Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 34 | sens._logger.info('REVISION ID: %s',format(val)) 35 | 36 | sens.write_register(register = 'FAN_CONF2', bits = ['EN_RRC']) 37 | 38 | sens.write_register(register = 'FAN_SETTING', value = 0) 39 | sens.write_register(register = 'FAN_CONF1', bits = ['EN_ALGO_CLR']) 40 | ret = sens.write_register(register = 'FAN_CONF1', bits = ['RANGE'], bit = fan_list['RANGE_1000_2'] ) 41 | print ('RET: {}'.format(ret)) 42 | from time import sleep 43 | 44 | speed = 16 45 | while speed <= 255 : 46 | measure = [] 47 | for i in range (10) : 48 | measure.append(sens.speed()[0]) 49 | sleep(0.5) 50 | print ('{}:{}'.format(speed,int(statistics.mean(measure)))) 51 | sens.write_register(register = 'FAN_SETTING', value = speed) 52 | speed = speed + 1 53 | 54 | -------------------------------------------------------------------------------- /fpc/emc2301/emc2301_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | print (sys.version) 5 | from i2c_pkg.emc2301_pkg import emc2301 6 | from i2c_pkg.emc2301_pkg import fan_type 7 | import logging 8 | 9 | fan_list = { 'RANGE' : fan_type.RANGE , 'EDGES' : fan_type.EDGES } 10 | 11 | sens = emc2301.EMC2301() 12 | 13 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 14 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 15 | datefmt='%m-%d %H:%M', 16 | filename='emc2301.log', 17 | filemode='w') 18 | console = logging.StreamHandler() 19 | console.setLevel(logging.DEBUG) 20 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 21 | console.setFormatter(formatter) 22 | logging.getLogger('').addHandler(console) 23 | sens._logger = logging.getLogger('ecomet.emc2301') 24 | sens._logger.info('Start logging ...') 25 | 26 | ret = sens.self_test() 27 | if ret == 0 : 28 | print(":TEST_PASSED:") 29 | else : 30 | print(":MISSING_CHIP:") 31 | 32 | (val,ret) = sens.productid() 33 | sens._logger.info('PRODUCT Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 34 | sens._logger.info('PRODUCT ID: %s',format(val)) 35 | 36 | (val,ret) = sens.manufid() 37 | sens._logger.info('MANUFACTURER Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 38 | sens._logger.info('MANUF ID: %s',format(val)) 39 | 40 | (val,ret) = sens.revisionid() 41 | sens._logger.info('REVISION Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 42 | sens._logger.info('REVISION ID: %s',format(val)) 43 | 44 | sens.write_register(register = 'FAN_CONF2', bits = ['EN_RRC']) 45 | 46 | register = emc2301.conf_register_list() 47 | print ('{}'.format(register)) 48 | 49 | while True : 50 | print ('---------------------------------') 51 | sens.write_register(register = 'FAN_SETTING', value = 0) 52 | sens.write_register(register = 'FAN_CONF1', bits = ['EN_ALGO_CLR']) 53 | sens.write_register(register = 'FAN_CONF1', bits = ['RANGE'], bit = fan_list['RANGE'] ) 54 | #sens.write_register(register = 'FAN_SETTING', bits = [20]) 55 | #sens.write_register(register = 'TACH_TARGET', bits = [33]) 56 | from time import sleep 57 | print('Speed: 0') 58 | for i in range (10) : 59 | register = sens.speed()[0] 60 | print ('{}'.format(register)) 61 | sleep(1) 62 | sens.write_register(register = 'FAN_SETTING', value = 50) 63 | from time import sleep 64 | print ('Speed: 50') 65 | for i in range (20) : 66 | register = sens.speed()[0] 67 | print ('{}'.format(register)) 68 | sleep(1) 69 | sens.write_register(register = 'FAN_SETTING', value = 100) 70 | from time import sleep 71 | print ('Speed: 100') 72 | for i in range (20) : 73 | register = sens.speed()[0] 74 | print ('{}'.format(register)) 75 | sleep(1) 76 | register = emc2301.conf_register_list() 77 | #print ('{}'.format(register)) 78 | sens.write_register(register = 'FAN_SETTING', value = 160) 79 | print('Speed: 160') 80 | for i in range (13) : 81 | register = sens.speed()[0] 82 | print ('{}'.format(register)) 83 | sleep(1) 84 | register = emc2301.conf_register_list() 85 | #print ('{}'.format(register)) 86 | sens.write_register(register = 'FAN_SETTING', value = 200) 87 | print('Speed: 200') 88 | for i in range (20) : 89 | register = sens.speed()[0] 90 | print ('{}'.format(register)) 91 | sleep(1) 92 | register = emc2301.conf_register_list() 93 | #print ('{}'.format(register)) 94 | sens.write_register(register = 'FAN_SETTING', value = 255) 95 | print ('Speed: 255') 96 | for i in range (20) : 97 | sleep(1) 98 | register = sens.speed()[0] 99 | print ('{}'.format(register)) 100 | 101 | print ('---------------------------------') 102 | 103 | -------------------------------------------------------------------------------- /fpc/emc2301/help.pas: -------------------------------------------------------------------------------- 1 | unit help; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls; 9 | 10 | type 11 | 12 | { TForm_help } 13 | 14 | TForm_help = class(TForm) 15 | Image_mode1: TImage; 16 | Image_monitor: TImage; 17 | Image_smsc_logo: TImage; 18 | Image_microchip_logo: TImage; 19 | Image_mode: TImage; 20 | Label1: TLabel; 21 | Label2: TLabel; 22 | Label3: TLabel; 23 | Label4: TLabel; 24 | private 25 | public 26 | end; 27 | 28 | var 29 | Form_help: TForm_help; 30 | 31 | implementation 32 | 33 | {$R *.lfm} 34 | 35 | { TForm_help } 36 | 37 | end. 38 | 39 | -------------------------------------------------------------------------------- /fpc/emc2301/image/OFF_30x30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/OFF_30x30.png -------------------------------------------------------------------------------- /fpc/emc2301/image/ON_30x30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/ON_30x30.png -------------------------------------------------------------------------------- /fpc/emc2301/image/appl_chip_missing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/appl_chip_missing.png -------------------------------------------------------------------------------- /fpc/emc2301/image/chip_100x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/chip_100x100.png -------------------------------------------------------------------------------- /fpc/emc2301/image/emc2301_gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/emc2301_gui.png -------------------------------------------------------------------------------- /fpc/emc2301/image/en_algo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/en_algo.png -------------------------------------------------------------------------------- /fpc/emc2301/image/missing_chip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/missing_chip.png -------------------------------------------------------------------------------- /fpc/emc2301/image/mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/mode.png -------------------------------------------------------------------------------- /fpc/emc2301/image/monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/monitor.png -------------------------------------------------------------------------------- /fpc/emc2301/image/src/microchip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/src/microchip.png -------------------------------------------------------------------------------- /fpc/emc2301/image/src/smsc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/emc2301/image/src/smsc.png -------------------------------------------------------------------------------- /fpc/emc2301/missing_chip.pas: -------------------------------------------------------------------------------- 1 | unit missing_chip; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 | ExtCtrls; 10 | 11 | type 12 | 13 | { TForm_missing_chip } 14 | 15 | TForm_missing_chip = class(TForm) 16 | Image1: TImage; 17 | Timer1: TTimer; 18 | StaticText1: TStaticText; 19 | procedure FormCreate(Sender: TObject); 20 | procedure Timer1Timer(Sender: TObject); 21 | private 22 | Completed: Boolean; 23 | public 24 | 25 | end; 26 | 27 | var 28 | Form_missing_chip: TForm_missing_chip; 29 | 30 | implementation 31 | 32 | {$R *.lfm} 33 | 34 | { TForm_missing_chip } 35 | 36 | procedure TForm_missing_chip.FormCreate(Sender: TObject); 37 | begin 38 | Completed := False; 39 | //writeln('missing form create'); 40 | Timer1.Interval := 20000; // 10s minimum time to show splash screen 41 | Timer1.Enabled := True; 42 | end; 43 | 44 | procedure TForm_missing_chip.Timer1Timer(Sender: TObject); 45 | begin 46 | Timer1.Enabled := False; 47 | Form_missing_chip.Hide; 48 | Completed := True; 49 | Application.Terminate; 50 | Halt; 51 | end; 52 | 53 | end. 54 | 55 | -------------------------------------------------------------------------------- /fpc/hdc1080/creator.lfm: -------------------------------------------------------------------------------- 1 | object Form_creator: TForm_creator 2 | Left = 1031 3 | Height = 186 4 | Top = 135 5 | Width = 312 6 | Caption = 'Creator' 7 | ClientHeight = 186 8 | ClientWidth = 312 9 | OnCreate = FormCreate 10 | LCLVersion = '2.0.0.4' 11 | object Label_creator: TLabel 12 | Left = 32 13 | Height = 75 14 | Top = 88 15 | Width = 182 16 | Caption = 'https://github.com/mamin27'#10'ecomet_i2c_raspberry_tools'#10#10'Marian Minar (c) 2020'#10'GPL-3.0 License' 17 | Font.Height = -12 18 | Font.Name = 'DejaVu Sans Mono' 19 | ParentColor = False 20 | ParentFont = False 21 | end 22 | object Label_project_name: TLabel 23 | Left = 32 24 | Height = 36 25 | Top = 24 26 | Width = 252 27 | Caption = 'HDC1080 '#10'Temperature & Humidity sensor' 28 | Font.Color = clBlue 29 | Font.Height = -15 30 | Font.Name = 'DejaVu Sans Mono' 31 | Font.Style = [fsBold] 32 | ParentColor = False 33 | ParentFont = False 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /fpc/hdc1080/creator.pas: -------------------------------------------------------------------------------- 1 | unit creator; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; 9 | 10 | type 11 | 12 | { TForm_creator } 13 | 14 | TForm_creator = class(TForm) 15 | Label_creator: TLabel; 16 | Label_project_name: TLabel; 17 | procedure FormCreate(Sender: TObject); 18 | private 19 | 20 | public 21 | 22 | end; 23 | 24 | var 25 | Form_creator: TForm_creator; 26 | 27 | implementation 28 | 29 | {$R *.lfm} 30 | 31 | { TForm_creator } 32 | 33 | procedure TForm_creator.FormCreate(Sender: TObject); 34 | begin 35 | sleep(10000); 36 | end; 37 | 38 | end. 39 | 40 | -------------------------------------------------------------------------------- /fpc/hdc1080/ecomet_regex.pas: -------------------------------------------------------------------------------- 1 | unit ecomet_regex; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | type 8 | 9 | TParts = array [1..100] of String; 10 | 11 | function StringPart(Source: string; seperator: char; Index: integer): string; 12 | function StringParts(Source: string; seperator: char): integer; 13 | function StringSplit(Source: string; seperator: char): TParts; 14 | 15 | Implementation 16 | 17 | function StringSplit(Source: string; seperator: char): TParts; 18 | var 19 | Count, counter: integer; 20 | TArray: TParts; 21 | key: String; 22 | begin 23 | //Get parts count. 24 | Count := StringParts(Source, seperator); 25 | 26 | for counter := 0 to Count do 27 | begin 28 | key := StringPart(Source, seperator, counter); 29 | if key = '' then Continue; 30 | TArray[counter] := key; 31 | end; 32 | 33 | //Return array 34 | Result := TArray; 35 | end; 36 | 37 | function StringParts(Source: string; seperator: char): integer; 38 | var 39 | Counter, Count: integer; 40 | begin 41 | 42 | Count := 0; 43 | 44 | if Source = '' then 45 | Result := 0; 46 | 47 | for Counter := 0 to Length(Source) do 48 | begin 49 | if Source[Counter] = seperator then 50 | Inc(Count); 51 | end; 52 | 53 | Result := Count; 54 | end; 55 | 56 | function StringPart(Source: string; seperator: char; Index: integer): string; 57 | var 58 | Counter, j, iLen: integer; 59 | ch: char; 60 | Buffer, Temp: string; 61 | begin 62 | 63 | //Init variables. 64 | Buffer := ''; 65 | ch := #0; 66 | j := 0; 67 | Counter := 0; 68 | 69 | iLen := Length(Source); 70 | Temp := Source; 71 | 72 | if Temp[iLen] <> seperator then 73 | begin 74 | Temp := Temp + seperator; 75 | end; 76 | 77 | for Counter := 1 to iLen + 1 do 78 | begin 79 | //Get char. 80 | ch := Temp[Counter]; 81 | 82 | if (ch <> seperator) then 83 | begin 84 | //build buffer if seperator not found. 85 | Buffer := Buffer + ch; 86 | end 87 | else 88 | begin 89 | //Check if we at the index. 90 | if (j = Index) then 91 | begin 92 | //Return string part. 93 | Result := Buffer; 94 | Exit; 95 | end 96 | else 97 | begin 98 | //INC index counter. 99 | Inc(j, 1); 100 | Buffer := ''; 101 | end; 102 | end; 103 | end; 104 | end; 105 | 106 | end. 107 | -------------------------------------------------------------------------------- /fpc/hdc1080/hdc1080: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/hdc1080/hdc1080 -------------------------------------------------------------------------------- /fpc/hdc1080/hdc1080.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/hdc1080/hdc1080.ico -------------------------------------------------------------------------------- /fpc/hdc1080/hdc1080.lpr: -------------------------------------------------------------------------------- 1 | program hdc1080; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | uses 6 | {$IFDEF UNIX}{$IFDEF UseCThreads} 7 | cthreads, 8 | {$ENDIF}{$ENDIF} 9 | Interfaces, // this includes the LCL widgetset 10 | Forms, hdc1080_display, ecomet_regex, creator, help, missing_chip; 11 | 12 | {$R *.res} 13 | 14 | begin 15 | RequireDerivedFormResource:=True; 16 | Application.Scaled:=True; 17 | Application.Initialize; 18 | Application.ShowMainForm := False; 19 | Application.CreateForm(TForm_hdc1080, Form_hdc1080); 20 | Application.Run; 21 | end. 22 | 23 | -------------------------------------------------------------------------------- /fpc/hdc1080/hdc1080.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/hdc1080/hdc1080.res -------------------------------------------------------------------------------- /fpc/hdc1080/hdc1080_IIC.md: -------------------------------------------------------------------------------- 1 | # hdc1080_IIC module 2 | 3 | **Last modification:** 6.08.2020 4 | 5 | **Modul board:** 6 | [ebay](https://www.ebay.com/itm/HDC1080-module-Low-Power-Temperature-with-Sensor-Humidity-Digital-Accuracy-High/143492459090?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649) 7 | I ordered and tested this modul board 8 | 9 | **Reconnection with Raspberry PI 3+:** 10 | 11 | * Configuration for /dev/i2c-1 12 | * port 2 (SDA), port 3 (SCL) 13 | * pull-up resistor for this module was set to 1.5 kΩ 14 | 15 | ### How to install? ### 16 | 17 | Install Lazarus-ide at raspberry [FPC & Lazarus Installation](../lazarus.md) 18 | Install Python3 and next modules for hdc1080 [Python3 & modules](../../i2c_pkg/hdc1080_pkg/hdc1080_python_IIC.md) 19 | 20 | (optional when you have only lite linux version) 21 | ```console 22 | sudo apt-get install gtk2-engines libgtk2.0-dev 23 | ``` 24 | 25 | ### Run application: ### 26 | ```console 27 | ecomet_i2c_tools/hdc1080 28 | ``` 29 | 30 | **Features:** 31 | 32 | * Read config and measure register of hdc1080 chip and show on concole 33 | * In Accuracy section is possible to set accuracy of measurment for Temperature and Humidity setting of A/D converter 34 | * Heating means (ENABLE/DISABLE) heating chip before measurement 35 | * Chip (MODE) means if measurement will be done by reading temperature and humidity in one cycle or separately: 36 | * Mode Both for measurement in on cycle 37 | * Mode Sequence when each measurement is done individualy 38 | * ID is only readable parameter: 39 | * First number (ID Serial) Unique serial number of chip 40 | * Second number (Manufacturer ID) 41 | * Device Type ID 42 | * Help for quick help 43 | * Self test for I2C connection 44 | * Pushing ![ON button](./image/ON_30x30.png) will be refreshed measurement and read changes of chip setting 45 | 46 | **Application pictures:** 47 | 48 | ![Works](./image/appl_work.png) 49 | 50 | Prepare for measurement 51 | 52 | ![Chip_missing](./image/appl_chip_missing.png) 53 | 54 | Chip I2C Issue 55 | 56 | 57 | 58 | **Source Code (FPC):** 59 | * Path: ~/ecomet_i2c_tools/fpc/hdc1080 60 | -------------------------------------------------------------------------------- /fpc/hdc1080/hdc1080_write.pas: -------------------------------------------------------------------------------- 1 | unit hdc1080_write; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, 9 | hdc1080_pyth_util; 10 | 11 | type 12 | TDict = record 13 | key: String; 14 | kval: String; 15 | end; 16 | 17 | procedure write_reg_hdc (register: String; bits: Array of String); 18 | procedure write_conf_reg (); 19 | function pre_write(cond1:boolean; attr:String): String; 20 | 21 | Implementation 22 | 23 | uses hdc1080_display; 24 | 25 | function pre_write(cond1:boolean; attr:String): String; 26 | begin 27 | if cond1 = true then 28 | Result := attr 29 | else Result := ''; 30 | end; 31 | 32 | procedure write_reg_hdc (register: String; bits: Array of String); 33 | var 34 | Py_S: TStringList; 35 | content: String[100]; 36 | i: Integer; 37 | begin 38 | content := 'register = ' + #39 + register + #39 + ', bits = ['; 39 | i := 0; 40 | repeat 41 | content := content + #39 + bits[i] + #39 + ','; 42 | i := i + 1; 43 | until bits[i] = ''; 44 | 45 | content := Copy(content,0,Length(content)-1); 46 | content := content + ']'; 47 | 48 | Py_S := TStringList.Create; 49 | Py_S.Delimiter := '|'; 50 | Py_S.StrictDelimiter := True; 51 | Py_S.DelimitedText := 'from ecomet_i2c_sensors.hdc1080 import hdc1080|' + 52 | 'sens = hdc1080.HDC1080()|' + 53 | 'ret = sens.write_register(' + content + ')|' + 54 | 'print (":WRITE_REG_CONF:WRITE_CONF")|'; 55 | // 'print (":WRITE_REG_CONF:{}".format(register)) if ret == 0 else print (":WRITE_REG_CONF_ERR:")|'; 56 | 57 | Form_hdc1080.PythonEngine_hdc1080.ExecStrings(Py_S); 58 | Py_S.Free; 59 | end; 60 | 61 | procedure write_conf_reg (); 62 | var 63 | conf_idx: Integer; 64 | conf_cmd: array [1..6] of String; 65 | cmd: String; 66 | begin 67 | 68 | conf_idx:=0; 69 | cmd := pre_write(hdc.attr1.attr_val_obj.attr2.attr_chg, hdc.attr1.attr_val_obj.attr2.attr_new_val); // test change of TEMP bit 70 | if cmd <> '' then begin 71 | conf_idx := conf_idx + 1; 72 | conf_cmd[conf_idx] := cmd; 73 | hdc.attr1.attr_val_obj.attr2.attr_chg := false; 74 | end; 75 | 76 | cmd := pre_write(hdc.attr1.attr_val_obj.attr1.attr_chg, hdc.attr1.attr_val_obj.attr1.attr_new_val); // test change of HMDT bit 77 | if cmd <> '' then begin 78 | conf_idx := conf_idx + 1; 79 | conf_cmd[conf_idx] := cmd; 80 | hdc.attr1.attr_val_obj.attr1.attr_chg := false; 81 | end; 82 | cmd := pre_write(hdc.attr1.attr_val_obj.attr4.attr_chg, hdc.attr1.attr_val_obj.attr4.attr_new_val); // test change of MODE bit 83 | if cmd <> '' then begin 84 | conf_idx := conf_idx + 1; 85 | conf_cmd[conf_idx] := cmd; 86 | hdc.attr1.attr_val_obj.attr4.attr_chg := false; 87 | end; 88 | cmd := pre_write(hdc.attr1.attr_val_obj.attr5.attr_chg, hdc.attr1.attr_val_obj.attr5.attr_new_val); // test change of HEAT bit 89 | if cmd <> '' then begin 90 | conf_idx := conf_idx + 1; 91 | conf_cmd[conf_idx] := cmd; 92 | hdc.attr1.attr_val_obj.attr5.attr_chg := false; 93 | end; 94 | 95 | if conf_idx <> 0 then begin 96 | write_reg_hdc('CONF',conf_cmd); 97 | end; 98 | 99 | end; 100 | 101 | end. 102 | 103 | -------------------------------------------------------------------------------- /fpc/hdc1080/help.pas: -------------------------------------------------------------------------------- 1 | unit help; 2 | 3 | {$mode objfpc} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls; 9 | 10 | type 11 | 12 | { TForm_help } 13 | 14 | TForm_help = class(TForm) 15 | Image_ti_logo: TImage; 16 | Label1: TLabel; 17 | Label2: TLabel; 18 | Label3: TLabel; 19 | Label4: TLabel; 20 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 21 | procedure FormDestroy(Sender: TObject); 22 | procedure Image_ti_logoClick(Sender: TObject); 23 | private 24 | 25 | public 26 | 27 | end; 28 | 29 | var 30 | Form_help: TForm_help; 31 | 32 | implementation 33 | 34 | {$R *.lfm} 35 | 36 | { TForm_help } 37 | 38 | procedure TForm_help.Image_ti_logoClick(Sender: TObject); 39 | begin 40 | sleep(10000); 41 | end; 42 | 43 | procedure TForm_help.FormClose(Sender: TObject; var CloseAction: TCloseAction); 44 | begin 45 | writeln('close'); 46 | end; 47 | 48 | procedure TForm_help.FormDestroy(Sender: TObject); 49 | begin 50 | writeln('destroy'); 51 | end; 52 | 53 | end. 54 | 55 | -------------------------------------------------------------------------------- /fpc/hdc1080/image/Form_info.txt: -------------------------------------------------------------------------------- 1 | TStaticText: font: DejaVu Sans Mono, Book, 9 2 | color: clBlue or clBlack 3 | 4 | TShape: Pen: color: clRed, width: 5, style: psSolid, pecRound 5 | TGroupBox: Caption: name, Color: clSrollBar 6 | TBitBtn: Caption: name 7 | Events: OnClick 8 | TEdit: color: clActiveBorder 9 | TComboBoxEx: Images: EmageList1, 10 | Height: 32 11 | Width: 70 12 | ImageType: itMask 13 | Events: OnChange, 14 | TPythonEngine: DllName: libpython3.8m.so 15 | IO: TPythonInputOutput 16 | Rev ver: 3.8 17 | PyFlag: pfUserClassExceptionsFlag 18 | RedirectIO: True 19 | InitScript: empty 20 | Autoload: True 21 | AutoFinalize: True 22 | Events: IO: PythonInputOutput 23 | TPythonInputOutput: OnSendData: PythonInputOutput1SendData 24 | 25 | Convert svg -> ico 26 | convert -density 384 -background transparent comet.svg -define icon:auto-resize comet.ico 27 | -------------------------------------------------------------------------------- /fpc/hdc1080/image/OFF_30x30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/hdc1080/image/OFF_30x30.png -------------------------------------------------------------------------------- /fpc/hdc1080/image/ON_30x30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/hdc1080/image/ON_30x30.png -------------------------------------------------------------------------------- /fpc/hdc1080/image/appl_chip_missing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/hdc1080/image/appl_chip_missing.png -------------------------------------------------------------------------------- /fpc/hdc1080/image/appl_work.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/hdc1080/image/appl_work.png -------------------------------------------------------------------------------- /fpc/hdc1080/image/chip_100x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/hdc1080/image/chip_100x100.png -------------------------------------------------------------------------------- /fpc/hdc1080/image/ti-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/hdc1080/image/ti-logo.png -------------------------------------------------------------------------------- /fpc/hdc1080/missing_chip.pas: -------------------------------------------------------------------------------- 1 | unit missing_chip; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 | ExtCtrls; 10 | 11 | type 12 | 13 | { TForm_missing_chip } 14 | 15 | TForm_missing_chip = class(TForm) 16 | Image1: TImage; 17 | Timer1: TTimer; 18 | StaticText1: TStaticText; 19 | procedure FormCreate(Sender: TObject); 20 | procedure Timer1Timer(Sender: TObject); 21 | private 22 | Completed: Boolean; 23 | public 24 | 25 | end; 26 | 27 | var 28 | Form_missing_chip: TForm_missing_chip; 29 | 30 | implementation 31 | 32 | {$R *.lfm} 33 | 34 | { TForm_missing_chip } 35 | 36 | procedure TForm_missing_chip.FormCreate(Sender: TObject); 37 | begin 38 | Completed := False; 39 | //writeln('missing form create'); 40 | Timer1.Interval := 20000; // 10s minimum time to show splash screen 41 | Timer1.Enabled := True; 42 | end; 43 | 44 | procedure TForm_missing_chip.Timer1Timer(Sender: TObject); 45 | begin 46 | Timer1.Enabled := False; 47 | Form_missing_chip.Hide; 48 | Completed := True; 49 | Application.Terminate; 50 | Halt; 51 | end; 52 | 53 | end. 54 | 55 | -------------------------------------------------------------------------------- /fpc/insert_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/insert_project.png -------------------------------------------------------------------------------- /fpc/pca9632/creator.lfm: -------------------------------------------------------------------------------- 1 | object Form_creator: TForm_creator 2 | Left = 1031 3 | Height = 186 4 | Top = 135 5 | Width = 455 6 | Caption = 'Creator' 7 | ClientHeight = 186 8 | ClientWidth = 455 9 | OnCreate = FormCreate 10 | LCLVersion = '2.0.0.4' 11 | object Label_creator: TLabel 12 | Left = 32 13 | Height = 75 14 | Top = 88 15 | Width = 182 16 | Caption = 'https://github.com/mamin27'#10'ecomet_i2c_raspberry_tools'#10#10'Marian Minar (c) 2020'#10'GPL-3.0 License' 17 | Font.Height = -12 18 | Font.Name = 'DejaVu Sans Mono' 19 | ParentColor = False 20 | ParentFont = False 21 | end 22 | object Label_project_name: TLabel 23 | Left = 32 24 | Height = 36 25 | Top = 24 26 | Width = 405 27 | Caption = 'PCA9632 '#10'4-bit Fm+ I2C-bus low power LED driver sensor' 28 | Font.Color = clBlue 29 | Font.Height = -15 30 | Font.Name = 'DejaVu Sans Mono' 31 | Font.Style = [fsBold] 32 | ParentColor = False 33 | ParentFont = False 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /fpc/pca9632/creator.pas: -------------------------------------------------------------------------------- 1 | unit creator; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; 9 | 10 | type 11 | 12 | { TForm_creator } 13 | 14 | TForm_creator = class(TForm) 15 | Label_creator: TLabel; 16 | Label_project_name: TLabel; 17 | procedure FormCreate(Sender: TObject); 18 | private 19 | 20 | public 21 | 22 | end; 23 | 24 | var 25 | Form_creator: TForm_creator; 26 | 27 | implementation 28 | 29 | {$R *.lfm} 30 | 31 | { TForm_creator } 32 | 33 | procedure TForm_creator.FormCreate(Sender: TObject); 34 | begin 35 | sleep(10000); 36 | end; 37 | 38 | end. 39 | 40 | -------------------------------------------------------------------------------- /fpc/pca9632/help.pas: -------------------------------------------------------------------------------- 1 | unit help; 2 | 3 | {$mode objfpc} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls; 9 | 10 | type 11 | 12 | { TForm_help } 13 | 14 | TForm_help = class(TForm) 15 | Image_ti_logo: TImage; 16 | Label1: TLabel; 17 | Label2: TLabel; 18 | Label3: TLabel; 19 | Label4: TLabel; 20 | procedure Image_ti_logoClick(Sender: TObject); 21 | procedure Label2Click(Sender: TObject); 22 | private 23 | 24 | public 25 | 26 | end; 27 | 28 | var 29 | Form_help: TForm_help; 30 | 31 | implementation 32 | 33 | {$R *.lfm} 34 | 35 | { TForm_help } 36 | 37 | procedure TForm_help.Image_ti_logoClick(Sender: TObject); 38 | begin 39 | sleep(10000); 40 | end; 41 | 42 | procedure TForm_help.Label2Click(Sender: TObject); 43 | begin 44 | 45 | end; 46 | 47 | end. 48 | 49 | -------------------------------------------------------------------------------- /fpc/pca9632/image/BLINK_70x23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/image/BLINK_70x23.png -------------------------------------------------------------------------------- /fpc/pca9632/image/DIMMING_70x23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/image/DIMMING_70x23.png -------------------------------------------------------------------------------- /fpc/pca9632/image/GRPPWM_70x23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/image/GRPPWM_70x23.png -------------------------------------------------------------------------------- /fpc/pca9632/image/Light_off_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/image/Light_off_40x40.png -------------------------------------------------------------------------------- /fpc/pca9632/image/Light_on_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/image/Light_on_40x40.png -------------------------------------------------------------------------------- /fpc/pca9632/image/NXP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/image/NXP.png -------------------------------------------------------------------------------- /fpc/pca9632/image/OFF_70x23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/image/OFF_70x23.png -------------------------------------------------------------------------------- /fpc/pca9632/image/ON_70x23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/image/ON_70x23.png -------------------------------------------------------------------------------- /fpc/pca9632/image/PWM_70x23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/image/PWM_70x23.png -------------------------------------------------------------------------------- /fpc/pca9632/missing_chip.pas: -------------------------------------------------------------------------------- 1 | unit missing_chip; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 | ExtCtrls; 10 | 11 | type 12 | 13 | { TForm_missing_chip } 14 | 15 | TForm_missing_chip = class(TForm) 16 | Image1: TImage; 17 | Timer1: TTimer; 18 | StaticText1: TStaticText; 19 | procedure FormCreate(Sender: TObject); 20 | procedure Timer1Timer(Sender: TObject); 21 | private 22 | Completed: Boolean; 23 | public 24 | 25 | end; 26 | 27 | var 28 | Form_missing_chip: TForm_missing_chip; 29 | 30 | implementation 31 | 32 | {$R *.lfm} 33 | 34 | { TForm_missing_chip } 35 | 36 | procedure TForm_missing_chip.FormCreate(Sender: TObject); 37 | begin 38 | Completed := False; 39 | //writeln('missing form create'); 40 | Timer1.Interval := 20000; // 10s minimum time to show splash screen 41 | Timer1.Enabled := True; 42 | end; 43 | 44 | procedure TForm_missing_chip.Timer1Timer(Sender: TObject); 45 | begin 46 | Timer1.Enabled := False; 47 | Form_missing_chip.Hide; 48 | Completed := True; 49 | Application.Terminate; 50 | Halt; 51 | end; 52 | 53 | end. 54 | 55 | -------------------------------------------------------------------------------- /fpc/pca9632/pca9632: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/pca9632 -------------------------------------------------------------------------------- /fpc/pca9632/pca9632_IIC.md: -------------------------------------------------------------------------------- 1 | # pca9632_IIC module 2 | 3 | **Last modification:** 10.04.2020 4 | 5 | **Schematics of Module:** 6 | *schematics for testing will be added later* 7 | 8 | ![Schematics](Schematics.PNG) 9 | 10 | **Reconnection with Raspberry PI 3+:** 11 | 12 | ![Interface to PI](pca9632_schema.PNG) 13 | * schematics of PI reconnection* 14 | 15 | * Configuration for /dev/i2c-1 16 | * port 2 (SDA), port 3 (SCL) 17 | * pull-up resistor is used from module board (R2,R3) 18 | 19 | ### How to install? ### 20 | 21 | Install Lazarus-ide at raspberry [FPC & Lazarus Installation](../lazarus.md) 22 | Install Python3 and next modules for pca9632 [Python3 & modules](../../i2c_pkg/pca9632_pkg/pca_9632_python_IIC.md) 23 | 24 | (optional when you have only lite linux version) 25 | ```console 26 | sudo apt-get install gtk2-engines libgtk2.0-dev 27 | ``` 28 | 29 | ### Run application: ### 30 | ```console 31 | ecomet_i2c_tools/pca_9632 32 | ``` 33 | 34 | **Features:** 35 | 36 | * Read status of pca_9632 chip and show on concole 37 | * Click at Enumerated Buttons (as ALLCALL), choice from values for register (MODE1, MODE2, LEDOUT) 38 | * Write to Register - Actually modified value visible by red rectangular 39 | * Apply write changes for all actually selected attributes (buttons) - click at **APPLY** button 40 | * Click at button (with values) changed to color to white. Then able to change value 41 | * PWMx, GRPPWM DutyCycle recalculated to percentage 42 | * GRPFREQ transfered to frequency, time 43 | 44 | **>>Sub Features:** 45 | 46 | * Register MODE1, MODE2 enumerate ON, OFF status 47 | * Register MODE2 (DBMLNK) enumerate DIMMING, BLINKING status 48 | * Register LEDOUT, enumerate ON, OFF, PWM, PWM_GRPPWM status 49 | * Register PWMx, GRPPWN, GRPFREQ (in Hz, in Time) 50 | 51 | **Limitation** 52 | 53 | * TrackBar not used now 54 | * Chip Address currently not able to change 55 | 56 | ![console](pca9632_console.png "Console") 57 | 58 | **Source Code (FPC):** 59 | * Path: ~/ecomet_i2c_tools/fpc/pca9632 60 | -------------------------------------------------------------------------------- /fpc/pca9632/pca9632_console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/pca9632_console.png -------------------------------------------------------------------------------- /fpc/pca9632/pca9632_schema.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/pca9632_schema.PNG -------------------------------------------------------------------------------- /fpc/pca9632/pca_9632.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/pca_9632.ico -------------------------------------------------------------------------------- /fpc/pca9632/pca_9632.lpr: -------------------------------------------------------------------------------- 1 | program pca_9632; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | uses 6 | {$IFDEF UNIX}{$IFDEF UseCThreads} 7 | cthreads, 8 | {$ENDIF}{$ENDIF} 9 | Classes, SysUtils, CustApp, Interfaces, 10 | Forms, pca_display, pca_pyth_util, 11 | pca_read, creator, help, missing_chip; 12 | 13 | {$R *.res} 14 | 15 | begin 16 | RequireDerivedFormResource:=True; 17 | Application.Title:='PCA9632 I2C Tool'; 18 | Application.Scaled:=True; 19 | Application.Initialize; 20 | Application.ShowMainForm := False; 21 | Application.CreateForm(Tpca9632_main, pca9632_main); 22 | Application.Run; 23 | end. 24 | -------------------------------------------------------------------------------- /fpc/pca9632/pca_9632.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/pca9632/pca_9632.res -------------------------------------------------------------------------------- /fpc/shared/ecomet_regex.pas: -------------------------------------------------------------------------------- 1 | unit ecomet_regex; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | type 8 | 9 | TParts = array [1..100] of String; 10 | 11 | function StringPart(Source: string; seperator: char; Index: integer): string; 12 | function StringParts(Source: string; seperator: char): integer; 13 | function StringSplit(Source: string; seperator: char): TParts; 14 | 15 | Implementation 16 | 17 | function StringSplit(Source: string; seperator: char): TParts; 18 | var 19 | Count, counter: integer; 20 | TArray: TParts; 21 | key: String; 22 | begin 23 | //Get parts count. 24 | Count := StringParts(Source, seperator); 25 | 26 | for counter := 0 to Count do 27 | begin 28 | key := StringPart(Source, seperator, counter); 29 | if key = '' then Continue; 30 | TArray[counter] := key; 31 | end; 32 | 33 | //Return array 34 | Result := TArray; 35 | end; 36 | 37 | function StringParts(Source: string; seperator: char): integer; 38 | var 39 | Counter, Count: integer; 40 | begin 41 | 42 | Count := 0; 43 | 44 | if Source = '' then 45 | Result := 0; 46 | 47 | for Counter := 0 to Length(Source) do 48 | begin 49 | if Source[Counter] = seperator then 50 | Inc(Count); 51 | end; 52 | 53 | Result := Count; 54 | end; 55 | 56 | function StringPart(Source: string; seperator: char; Index: integer): string; 57 | var 58 | Counter, j, iLen: integer; 59 | ch: char; 60 | Buffer, Temp: string; 61 | begin 62 | 63 | //Init variables. 64 | Buffer := ''; 65 | ch := #0; 66 | j := 0; 67 | Counter := 0; 68 | 69 | iLen := Length(Source); 70 | Temp := Source; 71 | 72 | if Temp[iLen] <> seperator then 73 | begin 74 | Temp := Temp + seperator; 75 | end; 76 | 77 | for Counter := 1 to iLen + 1 do 78 | begin 79 | //Get char. 80 | ch := Temp[Counter]; 81 | 82 | if (ch <> seperator) then 83 | begin 84 | //build buffer if seperator not found. 85 | Buffer := Buffer + ch; 86 | end 87 | else 88 | begin 89 | //Check if we at the index. 90 | if (j = Index) then 91 | begin 92 | //Return string part. 93 | Result := Buffer; 94 | Exit; 95 | end 96 | else 97 | begin 98 | //INC index counter. 99 | Inc(j, 1); 100 | Buffer := ''; 101 | end; 102 | end; 103 | end; 104 | end; 105 | 106 | end. 107 | -------------------------------------------------------------------------------- /fpc/shared/image/comet.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/fpc/shared/image/comet.ico -------------------------------------------------------------------------------- /fpc/shared/proc_py.pas: -------------------------------------------------------------------------------- 1 | unit proc_py; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | SysUtils, 9 | PythonEngine; 10 | 11 | type 12 | TStringDecodeRecW = record 13 | SFrom, STo: WideString; 14 | end; 15 | 16 | procedure Py_SetSysPath(const Dirs: array of string; DoAdd: boolean); 17 | 18 | function SBegin(const s, sub: string): boolean; 19 | function SDecodeW(const S: WideString; const Decode: array of TStringDecodeRecW): WideString; 20 | function SWideStringToPythonString(const Str: Widestring): string; 21 | 22 | const 23 | cDefFixedFontName = {$ifdef windows} 'Consolas' {$else} {$ifdef linux} 'Ubuntu Mono' {$else} 'Monaco' {$endif} {$endif}; 24 | cDefFixedFontSize = {$ifdef windows} 9 {$else} 11 {$endif}; 25 | 26 | cDefVarFontName = {$ifdef windows} 'Tahoma' {$else} {$ifdef linux} 'Ubuntu' {$else} 'default' {$endif} {$endif}; 27 | cDefVarFontSize = {$ifdef windows} 9 {$else} 10 {$endif}; 28 | 29 | 30 | implementation 31 | 32 | function SDecodeW(const S: WideString; const Decode: array of TStringDecodeRecW): WideString; 33 | var 34 | i, j: Integer; 35 | DoDecode: Boolean; 36 | begin 37 | Result := ''; 38 | i := 1; 39 | repeat 40 | if i > Length(S) then Break; 41 | DoDecode := False; 42 | for j := Low(Decode) to High(Decode) do 43 | with Decode[j] do 44 | if (SFrom <> '') and (SFrom = Copy(S, i, Length(SFrom))) then 45 | begin 46 | DoDecode := True; 47 | Result := Result + STo; 48 | Inc(i, Length(SFrom)); 49 | Break 50 | end; 51 | if DoDecode then Continue; 52 | Result := Result + S[i]; 53 | Inc(i); 54 | until False; 55 | end; 56 | 57 | function SWideStringToPythonString(const Str: Widestring): string; 58 | const 59 | Decode: array[0..0] of TStringDecodeRecW = 60 | ((SFrom: '"'; STo: '"+''"''+"')); 61 | begin 62 | Result:= UTF8Encode(SDecodeW(Str, Decode)); 63 | Result:= 'r"'+Result+'"'; 64 | end; 65 | 66 | function SBegin(const s, sub: string): boolean; 67 | begin 68 | Result:= Copy(s, 1, Length(sub))=sub; 69 | end; 70 | 71 | procedure Py_SetSysPath(const Dirs: array of string; DoAdd: boolean); 72 | var 73 | Str, Sign: string; 74 | i: Integer; 75 | begin 76 | Str:= ''; 77 | for i:= 0 to Length(Dirs)-1 do 78 | Str:= Str + 'r"' + Dirs[i] + '"' + ','; 79 | if DoAdd then 80 | Sign:= '+=' 81 | else 82 | Sign:= '='; 83 | Str:= Format('sys.path %s [%s]', [Sign, Str]); 84 | GetPythonEngine.ExecString(Str); 85 | end; 86 | 87 | 88 | 89 | end. 90 | 91 | -------------------------------------------------------------------------------- /fpc/shared/rpm_source.pas: -------------------------------------------------------------------------------- 1 | unit rpm_source; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Math; 9 | 10 | type 11 | 12 | TRPMRecord = record 13 | Sample: Integer; 14 | Time: Double; 15 | RPM1: Integer; 16 | RPM2: Integer; 17 | RPM3: Integer; 18 | end; 19 | 20 | type 21 | TRPMArray = array of TRPMRecord; 22 | 23 | procedure LoadRPMData(const AFileName: String; var Data: TRPMArray); 24 | 25 | implementation 26 | 27 | procedure LoadRPMData(const AFileName: String; var Data: TRPMArray); 28 | 29 | var 30 | List1, List2: TStringList; 31 | i, j, n: Integer; 32 | s: String; 33 | ds: char; 34 | begin 35 | ds := FormatSettings.DecimalSeparator; 36 | List1 := TStringList.Create; 37 | try 38 | List1.LoadFromFile(AFileName); 39 | n := List1.Count; 40 | SetLength(Data, n); 41 | FormatSettings.DecimalSeparator := '.'; 42 | List2 := TStringList.Create; 43 | try 44 | List2.Delimiter := ':'; 45 | List2.StrictDelimiter := true; 46 | j := 0; 47 | for i:=0 to n-1 do begin 48 | List2.DelimitedText := List1[i]; 49 | s := List1[i]; 50 | with Data[j] do begin 51 | Sample := StrToInt(trim(List2[0])); 52 | Time := RoundTo(StrToFloat(trim(List2[2])),-3); 53 | RPM1 := StrToInt(trim(List2[1])); 54 | end; 55 | inc(j,1); 56 | end; 57 | finally 58 | List2.Free; 59 | end; 60 | finally 61 | FormatSettings.DecimalSeparator := ds; 62 | List1.Free; 63 | end; 64 | end; 65 | 66 | end. 67 | 68 | -------------------------------------------------------------------------------- /fpc/shared/universal.pas: -------------------------------------------------------------------------------- 1 | unit universal; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils; 9 | 10 | function PChatToReal (in_str : PChar; limit : Integer) : Real; 11 | 12 | implementation 13 | 14 | function PChatToReal (in_str : PChar; limit : Integer) : Real; 15 | var 16 | filter: String; 17 | test_n: Real; 18 | const 19 | ALLOWED = ['0'..'9',' ','.',',']; 20 | Function Valid: Boolean; 21 | var 22 | i: Integer; 23 | begin 24 | Result := Length(filter) > 0; 25 | i := 1; 26 | while Result and (i <= Length(filter)) do 27 | begin 28 | Result := Result AND (filter[i] in ALLOWED); 29 | inc(i); 30 | end; 31 | if Length(filter) = 0 then Result := true; 32 | end; 33 | begin 34 | 35 | filter := StringReplace(in_str,' ','',[rfReplaceAll]); 36 | filter := StringReplace(filter,',','.',[rfReplaceAll]); 37 | 38 | if Valid then begin 39 | test_n := StrToFloat(filter); 40 | if (test_n <= limit) then 41 | Result := test_n 42 | else begin 43 | writeln('Number exceed ', limit); 44 | Result := limit; 45 | end; 46 | end 47 | else begin 48 | writeln('Wrong Input please fix'); 49 | Result := -1; 50 | end; 51 | end; 52 | 53 | end. 54 | 55 | -------------------------------------------------------------------------------- /images: -------------------------------------------------------------------------------- 1 | python_test_scripts/display/images -------------------------------------------------------------------------------- /projects/eCScope/bin/ecsope_1.0.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/projects/eCScope/bin/ecsope_1.0.0 -------------------------------------------------------------------------------- /python/ecomet_i2c_sensors: -------------------------------------------------------------------------------- 1 | ../ecomet_i2c_sensors/ -------------------------------------------------------------------------------- /python_test_scripts/as3935/AS3935-Datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/python_test_scripts/as3935/AS3935-Datasheet.pdf -------------------------------------------------------------------------------- /python_test_scripts/as3935/AS3935-austriamicrosystems.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/python_test_scripts/as3935/AS3935-austriamicrosystems.pdf -------------------------------------------------------------------------------- /python_test_scripts/as3935/as3935_test_script.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import sys 4 | #print (sys.version) 5 | from time import sleep 6 | from ecomet_i2c_sensors.as3935 import as3935,as3935_constant 7 | import OPi.GPIO as GPIO 8 | import logging 9 | from datetime import datetime 10 | 11 | #I2C address 12 | AS3935_I2C_ADDR1 = 0X01 13 | AS3935_I2C_ADDR2 = 0X02 14 | AS3935_I2C_ADDR3 = 0X03 15 | 16 | #Antenna tuning capcitance (must be integer multiple of 8, 8 - 120 pf) 17 | AS3935_CAPACITANCE = 96 18 | IRQ_PIN = 7 19 | 20 | GPIO.setmode(GPIO.BOARD) 21 | 22 | sens = as3935.AS3935(AS3935_I2C_ADDR3) 23 | 24 | logging.basicConfig(level=logging.DEBUG, # change level looging to (INFO, DEBUG, ERROR) 25 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 26 | datefmt='%m-%d %H:%M', 27 | filename='as3935.log', 28 | filemode='w') 29 | console = logging.StreamHandler() 30 | console.setLevel(logging.DEBUG) 31 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 32 | console.setFormatter(formatter) 33 | logging.getLogger('').addHandler(console) 34 | sens._logger = logging.getLogger('ecomet.as3935') 35 | sens._logger.info('Start logging ...') 36 | 37 | if (sens.reset == 0): 38 | print("init sensor sucess.") 39 | else: 40 | print("init sensor fail") 41 | while True: 42 | pass 43 | 44 | #Configure sensor 45 | sens.power_up() 46 | #Clear statistics 47 | sens.clear_statistics() 48 | sens._logger.info('Clear statistics') 49 | 50 | #set indoors or outdoors models 51 | #sens.set_indoors() 52 | sens.set_outdoors() 53 | 54 | #disturber detection 55 | sens.disturber_en() 56 | #sens.disturber_dis() 57 | 58 | sens.set_irq_output_source(0) 59 | sleep(0.5) 60 | #set capacitance 61 | sens.set_tuning_caps(AS3935_CAPACITANCE) 62 | 63 | # Connect the IRQ and GND pin to the oscilloscope. 64 | # uncomment the following sentences to fine tune the antenna for better performance. 65 | # This will dispaly the antenna's resonance frequency/16 on IRQ pin (The resonance frequency will be divided by 16 on this pin) 66 | # Tuning AS3935_CAPACITANCE to make the frequency within 500/16 kHz plus 3.5% to 500/16 kHz minus 3.5% 67 | # 68 | # sens.set_lco_fdiv(0) 69 | # sens.set_irq_output_source(as3935_constant.SET_IRQ_SIGNAL_FLAGS.irq_lco) 70 | 71 | #Set the noise level,use a default value greater than 7 72 | sens.set_noise_floor_lv1(as3935_constant.STAT_REG_1_FLAGS.nfl_in_2) 73 | #noiseLv = sens.get_noise_floor_lv1() 74 | #sens._logger.info('Noise Floor Level: %02x'%noiseLv) 75 | 76 | #used to modify WDTH,alues should only be between 0x00 and 0x0F (0 and 7) 77 | sens.set_watchdog_threshold(as3935_constant.STAT_REG_1_FLAGS.wdth_2) 78 | #wtdgThreshold = sens.get_watchdog_threshold() 79 | #sens._logger.info('Threshold Level: %02x'%wtdgThreshold) 80 | 81 | #used to modify SREJ (spike rejection),values should only be between 0x00 and 0x0F (0 and 7) 82 | sens.set_spike_rejection(as3935_constant.STAT_REG_2_FLAGS.srej_2) 83 | #spikeRejection = sens.get_spike_rejection() 84 | #sens._logger.info('Spike Rejection: %02x'%spikeRejection) 85 | 86 | #view all register data 87 | sens.print_all_regs() 88 | 89 | #def callback_handle(channel): 90 | def callback_handle(): 91 | global sens 92 | sleep(0.005) 93 | intSrc = sens.get_interrupt_src() 94 | print (intSrc) 95 | if intSrc == 1: 96 | lightning_distKm = sens.get_lightning_distKm() 97 | print('Lightning occurs!') 98 | print('Distance: %dkm'%lightning_distKm) 99 | 100 | lightning_energy_val = sens.get_strike_energy_raw() 101 | print('Intensity: %d '%lightning_energy_val) 102 | elif intSrc == 2: 103 | print('Disturber discovered!') 104 | elif intSrc == 3: 105 | print('Noise level too high!') 106 | else: 107 | pass 108 | #Set to input mode 109 | #GPIO.setup(IRQ_PIN, GPIO.IN) 110 | #Set the interrupt pin, the interrupt function, rising along the trigger 111 | #GPIO.add_event_detect(IRQ_PIN, GPIO.RISING, callback = callback_handle) 112 | 113 | callback_handle() 114 | print("start lightning detect.") 115 | 116 | while True: 117 | sleep(1.0) 118 | 119 | 120 | -------------------------------------------------------------------------------- /python_test_scripts/axp209/axp209_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.axp209 import axp209 6 | import logging 7 | 8 | axp = axp209.AXP209() 9 | 10 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 11 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 12 | datefmt='%m-%d %H:%M', 13 | filename='axp209.log', 14 | filemode='w') 15 | console = logging.StreamHandler() 16 | console.setLevel(logging.DEBUG) 17 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 18 | console.setFormatter(formatter) 19 | logging.getLogger('').addHandler(console) 20 | axp._logger = logging.getLogger('ecomet.axp209') 21 | axp._logger.info('Start logging ...') 22 | 23 | print("internal_temperature: %.2fC" % axp.internal_temperature) 24 | print("battery_exists: %s" % axp.battery_exists) 25 | print("battery_charging: %s" % ("charging" if axp.battery_charging else "done")) 26 | print("battery_current_direction: %s" % ("charging" if axp.battery_current_direction else "discharging")) 27 | print("battery_voltage: %.1fmV" % axp.battery_voltage) 28 | print("battery_discharge_current: %.1fmA" % axp.battery_discharge_current) 29 | print("battery_charge_current: %.1fmA" % axp.battery_charge_current) 30 | print("battery_gauge: %d%%" % axp.battery_gauge) 31 | axp.vbus_current_limit = '500 mA' 32 | print("VBUS current limit: %s" % axp.vbus_current_limit) 33 | print("ADC enable 1:") 34 | print(" Battery voltage ADC Enable: %s" % axp.battery_current_adc_enable) 35 | print(" ACIN Voltage ADC Enable RW: %s" % axp.acin_voltage_adc_enable) 36 | print(" ACIN Current ADC Enable: %s" % axp.acin_current_adc_enable) 37 | print(" VBUS Voltage ADC Enable: %s" % axp.vbus_voltage_adc_enable) 38 | print(" VBUS Current ADC Enable: %s" % axp.vbus_current_adc_enable) 39 | print(" APS Voltage ADC Enable: %s" % axp.aps_voltage_adc_enable) 40 | print(" TS Pin ADC Function is enabled: %s" % axp.ts_pin_adc_function_enable) 41 | print("ADC enable 2:") 42 | print(" APX209 internal temperature monitoring ADC Enable: %s" % axp.apx209_internal_temperature_monitoring_adc_enable) 43 | print(" GPIO0 ADC Function is enabled: %s" % axp.gpio0_adc_function_enable) 44 | print(" GPIO1 ADC Function is enabled: %s" % axp.gpio1_adc_function_enable) 45 | axp.close() 46 | 47 | -------------------------------------------------------------------------------- /python_test_scripts/display/fonts/C&C Red Alert [INET].ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/python_test_scripts/display/fonts/C&C Red Alert [INET].ttf -------------------------------------------------------------------------------- /python_test_scripts/display/images/code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/python_test_scripts/display/images/code.png -------------------------------------------------------------------------------- /python_test_scripts/display/images/comet_black_white_62x62.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/python_test_scripts/display/images/comet_black_white_62x62.png -------------------------------------------------------------------------------- /python_test_scripts/display/images/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/python_test_scripts/display/images/star.png -------------------------------------------------------------------------------- /python_test_scripts/display/images/zoom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/python_test_scripts/display/images/zoom.png -------------------------------------------------------------------------------- /python_test_scripts/display/ssd1306_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | print (sys.version) 5 | from PIL import ImageFont, Image 6 | from ecomet_i2c_sensors.ssd1306 import ssd1306,render 7 | from ecomet_i2c_sensors.pca9557 import pca9557 # could be skipped 8 | from time import sleep 9 | import qrcode 10 | import logging 11 | 12 | disp = ssd1306.SSD1306() 13 | io = pca9557.PCA9557() # could be skipped 14 | 15 | dconst = disp._const 16 | 17 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 18 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 19 | datefmt='%m-%d %H:%M', 20 | filename='ssd1306.log', 21 | filemode='w') 22 | console = logging.StreamHandler() 23 | console.setLevel(logging.DEBUG) 24 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 25 | console.setFormatter(formatter) 26 | logging.getLogger('').addHandler(console) 27 | 28 | # this code could be skipped if you control Reset PIN at ssd1306 different way 29 | io.sw_reset() 30 | io.set_io('OOIIIIOO') 31 | io.set_invert('NNNNNNNN') 32 | io.set_io_name(port_arr = [[0,'LED1'],[1,'LED2'],[2,'BUT_RIG_DWN'],[3,'BUT_RIG_UP'], 33 | [4,'BUT_LFT_DWN'],[5,'BUT_LFT_UP'],[6,'D/C'],[7,'DIS_RET']]) 34 | io.write_output_port (status = pca9557.High, pin = 'LED1') 35 | io.write_output_port (status = pca9557.High, pin = 'LED2') 36 | io.write_output_port (status = pca9557.Low, pin = 'DIS_RST') 37 | io.write_output_port (status = pca9557.High, pin = 'D/C') 38 | # end of skip 39 | disp.sw_reset() 40 | disp.setup() 41 | 42 | qr = qrcode.QRCode( 43 | version=2, 44 | error_correction=qrcode.constants.ERROR_CORRECT_L, 45 | box_size=2, 46 | border=2, 47 | ) 48 | qr.add_data('https://github.com/mamin27/ecomet_i2c_raspberry_tools') 49 | qr.make(fit=True) 50 | img = qr.make_image() 51 | img.save('./images/code.png') 52 | font = ImageFont.truetype('./fonts/C&C Red Alert [INET].ttf', 12) 53 | 54 | # draw Logo 55 | #disp.sw_reset() 56 | with render.canvas(disp) as draw: 57 | zoom = Image.open('images/zoom.png') 58 | draw.bitmap((0, 0), zoom, fill=1) 59 | zoom.close() 60 | del draw 61 | 62 | with render.canvas(disp) as draw: 63 | sleep(5) 64 | logo = Image.open('images/comet_black_white_62x62.png') 65 | draw.bitmap((0, 0), logo, fill=1) 66 | draw.text((75, 20), 'eComet', font=font, fill=1) 67 | draw.text((90, 32 ), 'Slovakia', font=font, fill=1) 68 | logo.close() 69 | del draw 70 | 71 | # draw QR Code 72 | with render.canvas(disp) as draw: 73 | sleep(5) 74 | code = Image.open('images/code.png') 75 | draw.bitmap((0, 0), code, fill=1) 76 | draw.text((80, 20), 'QR Code', font=font, fill=1) 77 | code.close() 78 | del draw 79 | 80 | # Clean Display 81 | with render.canvas(disp) as draw: 82 | sleep(5) 83 | draw.rectangle((0, 0, disp.width, disp.height), fill=0) #clear display 84 | 85 | -------------------------------------------------------------------------------- /python_test_scripts/ecomet/ecomet01_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys,os 4 | sys.path.append(os.getenv("HOME") + '/ecomet_i2c_raspberry_tools/ecomet_i2c_sensors') 5 | from ecomet import ecomet01, ecomet01_constant 6 | import time 7 | #from hdc1080 import hdc1080 8 | 9 | import logging 10 | 11 | logging.basicConfig(level=logging.DEBUG, # change level looging to (INFO, DEBUG, ERROR) 12 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 13 | datefmt='%m-%d %H:%M', 14 | filename='ecomet01.log', 15 | filemode='a') 16 | console = logging.StreamHandler() 17 | console.setLevel(logging.DEBUG) 18 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 19 | console.setFormatter(formatter) 20 | logging.getLogger('').addHandler(console) 21 | 22 | sens = ecomet01.ECOMET01(busnum = 0) 23 | sens._logger = logging.getLogger('ecomet.ecomet01') 24 | sens._logger.info('Start logging ...') 25 | 26 | value = 0x10 27 | while (1): 28 | data = sens.read_register ( register = 'REG00' ) 29 | time.sleep(5) 30 | data = sens.read_register ( register = 'REG01' ) 31 | time.sleep(5) 32 | data = sens.read_register ( register = 'REG02' ) 33 | time.sleep(5) 34 | data = sens.read_register ( register = 'REG03' ) 35 | time.sleep(5) 36 | data = sens.read_register ( register = 'REG04' ) 37 | time.sleep(5) 38 | data = sens.read_register ( register = 'REG01' ) 39 | time.sleep(5) 40 | data = sens.write_register (register = 'REG02', value = [value]) 41 | time.sleep(5) 42 | data = sens.write_register (register = 'REG03', value = [0x54,value]) 43 | time.sleep(5) 44 | data = sens.write_register (register = 'REG04', value = [0x55,0x01,0x02,value]) 45 | value = value + 1 46 | time.sleep(5) 47 | if (value > 0xFF): 48 | value = 0x00 49 | data = sens.read_register ( register = 'REG_UNI' ) 50 | time.sleep(5) 51 | data = sens.read_register ( register = 'REG03' ) 52 | time.sleep(5) 53 | -------------------------------------------------------------------------------- /python_test_scripts/emc2301/emc2301_i2c_speed_graph.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.emc2301 import emc2301, fan_type 4 | import logging 5 | import statistics 6 | 7 | fan_list = emc2301.fan_list 8 | sens = emc2301.EMC2301() 9 | 10 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 11 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 12 | datefmt='%m-%d %H:%M', 13 | filename='emc2301.log', 14 | filemode='w') 15 | console = logging.StreamHandler() 16 | console.setLevel(logging.DEBUG) 17 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 18 | console.setFormatter(formatter) 19 | logging.getLogger('').addHandler(console) 20 | sens._logger = logging.getLogger('ecomet.emc2301') 21 | sens._logger.info('Start logging ...') 22 | 23 | (val,ret) = sens.productid() 24 | sens._logger.info('PRODUCT Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 25 | sens._logger.info('PRODUCT ID: %s',format(val)) 26 | 27 | (val,ret) = sens.manufid() 28 | sens._logger.info('MANUFACTURER Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 29 | sens._logger.info('MANUF ID: %s',format(val)) 30 | 31 | (val,ret) = sens.revisionid() 32 | sens._logger.info('REVISION Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 33 | sens._logger.info('REVISION ID: %s',format(val)) 34 | 35 | sens.write_register(register = 'FAN_CONF2', bits = ['EN_RRC']) 36 | 37 | sens.write_register(register = 'FAN_SETTING', value = 0) 38 | sens.write_register(register = 'FAN_CONF1', bits = ['EN_ALGO_CLR']) 39 | ret = sens.write_register(register = 'FAN_CONF1', bits = ['RANGE'], bit = fan_list['RANGE_500_1'] ) 40 | ret = sens.write_register(register = 'FAN_CONF1', bits = ['EDGES'], bit = fan_list['EDGES_5_2POLE_1'] ) 41 | print ('RET: {}'.format(ret)) 42 | from time import sleep 43 | 44 | speed = 0 #16 45 | while speed <= 255 : 46 | measure = [] 47 | for i in range (10) : 48 | measure.append(sens.speed()[0]) 49 | sleep(0.5) 50 | print ('{}:{}'.format(speed,int(statistics.mean(measure)))) 51 | sens.write_register(register = 'FAN_SETTING', value = speed) 52 | speed = speed + 1 53 | 54 | -------------------------------------------------------------------------------- /python_test_scripts/emc2301/emc2301_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.emc2301 import emc2301, fan_type 6 | import logging 7 | 8 | fan_list = { 'RANGE' : fan_type.RANGE , 'EDGES' : fan_type.EDGES } 9 | 10 | sens = emc2301.EMC2301() 11 | 12 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 13 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 14 | datefmt='%m-%d %H:%M', 15 | filename='emc2301.log', 16 | filemode='w') 17 | console = logging.StreamHandler() 18 | console.setLevel(logging.DEBUG) 19 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 20 | console.setFormatter(formatter) 21 | logging.getLogger('').addHandler(console) 22 | sens._logger = logging.getLogger('ecomet.emc2301') 23 | sens._logger.info('Start logging ...') 24 | 25 | ret = sens.self_test() 26 | if ret == 0 : 27 | print(":TEST_PASSED:") 28 | else : 29 | print(":MISSING_CHIP:") 30 | 31 | (val,ret) = sens.productid() 32 | sens._logger.info('PRODUCT Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 33 | sens._logger.info('PRODUCT ID: %s',format(val)) 34 | 35 | (val,ret) = sens.manufid() 36 | sens._logger.info('MANUFACTURER Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 37 | sens._logger.info('MANUF ID: %s',format(val)) 38 | 39 | (val,ret) = sens.revisionid() 40 | sens._logger.info('REVISION Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 41 | sens._logger.info('REVISION ID: %s',format(val)) 42 | 43 | sens.write_register(register = 'FAN_CONF2', bits = ['EN_RRC']) 44 | 45 | register = emc2301.conf_register_list() 46 | print ('{}'.format(register)) 47 | 48 | while True : 49 | print ('---------------------------------') 50 | sens.write_register(register = 'FAN_SETTING', value = 0) 51 | sens.write_register(register = 'FAN_CONF1', bits = ['EN_ALGO_CLR']) 52 | sens.write_register(register = 'FAN_CONF1', bits = ['RANGE'], bit = fan_list['RANGE'] ) 53 | #sens.write_register(register = 'FAN_SETTING', bits = [20]) 54 | #sens.write_register(register = 'TACH_TARGET', bits = [33]) 55 | from time import sleep 56 | print('Speed: 0') 57 | for i in range (10) : 58 | register = sens.speed()[0] 59 | print ('{}'.format(register)) 60 | sleep(1) 61 | sens.write_register(register = 'FAN_SETTING', value = 50) 62 | from time import sleep 63 | print ('Speed: 50') 64 | for i in range (20) : 65 | register = sens.speed()[0] 66 | print ('{}'.format(register)) 67 | sleep(1) 68 | sens.write_register(register = 'FAN_SETTING', value = 100) 69 | from time import sleep 70 | print ('Speed: 100') 71 | for i in range (20) : 72 | register = sens.speed()[0] 73 | print ('{}'.format(register)) 74 | sleep(1) 75 | register = emc2301.conf_register_list() 76 | #print ('{}'.format(register)) 77 | sens.write_register(register = 'FAN_SETTING', value = 160) 78 | print('Speed: 160') 79 | for i in range (13) : 80 | register = sens.speed()[0] 81 | print ('{}'.format(register)) 82 | sleep(1) 83 | register = emc2301.conf_register_list() 84 | #print ('{}'.format(register)) 85 | sens.write_register(register = 'FAN_SETTING', value = 200) 86 | print('Speed: 200') 87 | for i in range (20) : 88 | register = sens.speed()[0] 89 | print ('{}'.format(register)) 90 | sleep(1) 91 | register = emc2301.conf_register_list() 92 | #print ('{}'.format(register)) 93 | sens.write_register(register = 'FAN_SETTING', value = 255) 94 | print ('Speed: 255') 95 | for i in range (20) : 96 | sleep(1) 97 | register = sens.speed()[0] 98 | print ('{}'.format(register)) 99 | 100 | print ('---------------------------------') 101 | 102 | -------------------------------------------------------------------------------- /python_test_scripts/hdc1080/hdc1080_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.hdc1080 import hdc1080 6 | import logging 7 | 8 | sens = hdc1080.HDC1080(busnum=0) 9 | 10 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 11 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 12 | datefmt='%m-%d %H:%M', 13 | filename='hdc1080.log', 14 | filemode='w') 15 | console = logging.StreamHandler() 16 | console.setLevel(logging.DEBUG) 17 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 18 | console.setFormatter(formatter) 19 | logging.getLogger('').addHandler(console) 20 | sens._logger = logging.getLogger('ecomet.hdc1080') 21 | sens._logger.info('Start logging ...') 22 | 23 | ret = sens.sw_reset() 24 | sens._logger.info('SW Reset correct') if ret == 0 else sens._logger.error('SW Reset error %s'.format(ret)) 25 | 26 | ret = sens.battery() 27 | sens._logger.info('Battery > 2.4V, correct') if ret == 0 else sens._logger.error('Battery < 2.4V, error') 28 | 29 | (val,ret) = sens.serial() 30 | sens._logger.info('SERIAL Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 31 | sens._logger.info('SER ID: %s',format(val)) 32 | 33 | (val,ret) = sens.manufacturer() 34 | sens._logger.info('MANUFACTURER Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 35 | sens._logger.info('MAN ID: %s',format(val)) 36 | 37 | (val,ret) = sens.deviceid() 38 | sens._logger.info('DEVICE Read correct') if ret == 0 else sens._logger.error('Read error %s'.format(ret)) 39 | sens._logger.info('DEV ID: %s',format(val)) 40 | 41 | ret = sens.write_register( register = 'CONF', bits = [{'MODE':'BOTH'},{'HRES':'14'},{'TRES':'14'}]) 42 | sens._logger.info('Write CONF register correct') if ret == 0 else sens._logger.error('Write error %s'.format(ret)) 43 | 44 | register = hdc1080.register_list() 45 | print ('{}'.format(register)) 46 | 47 | (temp,hmdt, ret) = sens.both_measurement() 48 | if ret == 0 : 49 | sens._logger.info('Measured Temperate BOTH: %s \u2103','{0:10.2f}'.format(temp)) 50 | sens._logger.info('Measured Humidity BOTH: %s %s','{0:10.2f}'.format(hmdt),'%') 51 | else : 52 | sens._logger.error('Read error %s'.format(ret)) 53 | 54 | ret = sens.sw_reset() 55 | sens._logger.info('SW Reset correct') if ret == 0 else sens._logger.error('SW Reset error %s'.format(ret)) 56 | ret = sens.write_register( register = 'CONF', bits = [{'MODE':'ONLY'},{'HRES':'11'},{'TRES':'11'}]) 57 | sens._logger.info('Write CONF register correct') if ret == 0 else sens._logger.error('Write error %s'.format(ret)) 58 | register = hdc1080.register_list() 59 | print ('{}'.format(register)) 60 | 61 | (temp, ret) = sens.measure_temp() 62 | if ret == 0 : 63 | sens._logger.info('Measured Temperate IND: %s \u2103','{0:10.2f}'.format(temp)) 64 | else : 65 | sens._logger.error('Read error %s'.format(ret)) 66 | 67 | ret = sens.write_register( register = 'CONF', bits = [{'MODE':'BOTH'},{'HRES':'11'},{'TRES':'11'}]) 68 | (hmdt, ret) = sens.measure_hmdt() 69 | if ret == 0 : 70 | sens._logger.info('Measured Humidity IND: %s %s','{0:10.2f}'.format(hmdt),'%') 71 | else : 72 | sens._logger.error('Read error %s'.format(ret)) 73 | 74 | ########################################################## 75 | ret = sens.sw_reset() 76 | sens._logger.info('SW Reset correct') if ret == 0 else sens._logger.error('SW Reset error %s'.format(ret)) 77 | 78 | ret = sens.battery() 79 | sens._logger.info('Battery > 2.4V, correct') if ret == 0 else sens._logger.error('Battery < 2.4V, error') 80 | ret = sens.write_register( register = 'CONF', bits = [{'TRES':'11'},{'HRES':'08'},{'MODE':'ONLY'},{'HEAT':'ENABLE'}]) 81 | register = hdc1080.register_list() 82 | print ('{}'.format(register)) 83 | (measure,ret) = hdc1080.measure_list() 84 | 85 | if ret == 0 : 86 | print('{}'.format(measure)) 87 | else : 88 | sens._logger.error('Measure Read error %s'.format(ret)) 89 | -------------------------------------------------------------------------------- /python_test_scripts/htu21_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.htu21 import htu21 6 | import logging 7 | 8 | sens = htu21.HTU21() 9 | 10 | logging.basicConfig(level=logging.DEBUG, # change level looging to (INFO, DEBUG, ERROR) 11 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 12 | datefmt='%m-%d %H:%M', 13 | filename='htu21.log', 14 | filemode='w') 15 | console = logging.StreamHandler() 16 | console.setLevel(logging.DEBUG) 17 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 18 | console.setFormatter(formatter) 19 | logging.getLogger('').addHandler(console) 20 | sens._logger = logging.getLogger('ecomet.htu21') 21 | sens._logger.info('Start logging ...') 22 | 23 | ret = sens.sw_reset() 24 | sens._logger.info('SW Reset correct') if ret == 0 else sens._logger.error('SW Reset error %s'.format(ret)) 25 | 26 | ret = sens.battery() 27 | sens._logger.info('Battery > 2.4V, correct') if ret == 0 else sens._logger.error('Battery < 2.4V, error') 28 | 29 | ret = sens.write_register( register = 'WRITE_USER', bits = ['MEAS_RES1','HEAT_DISABLE']) 30 | sens._logger.info('Write WRITE_REG register correct') if ret == 0 else sens._logger.error('Write error %s'.format(ret)) 31 | 32 | register = htu21.register_list() 33 | print ('{}'.format(register)) 34 | 35 | (temp, ret) = sens.measure_temp() 36 | if ret == 0 : 37 | sens._logger.info('Measured Temperate IND: %s \u2103','{0:10.2f}'.format(temp)) 38 | else : 39 | sens._logger.error('Read error %s'.format(ret)) 40 | (hmdt, ret) = sens.measure_hmdt() 41 | if ret == 0 : 42 | sens._logger.info('Measured Humidity IND: %s %s','{0:10.2f}'.format(hmdt),'%') 43 | else : 44 | sens._logger.error('Read error %s'.format(ret)) 45 | 46 | ############################################################## 47 | 48 | ret = sens.write_register( register = 'WRITE_USER', bits = ['MEAS_RES4','HEAT_DISABLE']) 49 | sens._logger.info('Write WRITE_REG register correct') if ret == 0 else sens._logger.error('Write error %s'.format(ret)) 50 | 51 | register = htu21.register_list() 52 | print ('{}'.format(register)) 53 | 54 | (temp, ret) = sens.measure_temp() 55 | if ret == 0 : 56 | sens._logger.info('Measured Temperate IND: %s \u2103','{0:10.2f}'.format(temp)) 57 | else : 58 | sens._logger.error('Read error %s'.format(ret)) 59 | (hmdt, ret) = sens.measure_hmdt() 60 | if ret == 0 : 61 | sens._logger.info('Measured Humidity IND: %s %s','{0:10.2f}'.format(hmdt),'%') 62 | else : 63 | sens._logger.error('Read error %s'.format(ret)) 64 | 65 | ############################################################## 66 | 67 | (measure,ret) = htu21.measure_list() 68 | 69 | if ret == 0 : 70 | print('{}'.format(measure)) 71 | else : 72 | sens._logger.error('Measure Read error %s'.format(ret)) 73 | 74 | ############################################################### 75 | 76 | (dew_point,ret) = sens.dew_point() 77 | 78 | if ret == 0 : 79 | sens._logger.info('Calculated Dew Point IND: %s \u2103','{0:10.2f}'.format(dew_point)) 80 | else : 81 | sens._logger.error('Dew_point Read error %s'.format(ret)) 82 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/i2c_address_search.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.platform import i2c_platform 4 | 5 | plat = i2c_platform.Board_plat(busnum=1,arange=[0x40,0x4F]) 6 | board = plat.board() 7 | bus = plat.bus() 8 | slave = plat.slaves() 9 | 10 | if not slave : 11 | print (':ERROR::No I2C Address found') 12 | else : 13 | print (':SEARCH::Address::size:{}::address:{}'.format(len(slave.split(':')),slave)) 14 | 15 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/i2c_address_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260 4 | 5 | try: 6 | inaA = ina260.INA260(address=0x40,busnum=1) 7 | chip0 = inaA.self_test() 8 | 9 | if not chip0 == 0 : 10 | statA = 'NOK' 11 | else : 12 | statA = 'OK' 13 | 14 | except: 15 | statA = 'NCON' 16 | try: 17 | inaB = ina260.INA260(address=0x46,busnum=1) 18 | chip1 = inaB.self_test() 19 | 20 | if not chip1 == 0 : 21 | statB = 'NOK' 22 | else : 23 | statB = 'OK' 24 | 25 | except: 26 | statB = 'NCON' 27 | 28 | print (':TEST::Address::#A:{}::#B:{}'.format(statA,statB)) 29 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_calibrate_i.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | 5 | buf_current_1 = {} 6 | 7 | chip0 = ina260_ui.INA260_UI(chip = '0#0x45', time = 0.2, i_unit = 'mA', mode = ina260_constant.register.MODE_SHUNT_CURRENT_CONT, 8 | avgc = ina260_constant.register.COUNT_4, ishct = ina260_constant.register.TIME_204_us) 9 | 10 | ((size_current_1,unit_current_1,buf_current_1)) = chip0.measure_i() 11 | 12 | avrg = 0 13 | for key, value in buf_current_1.items(): 14 | # print ('{}'.format(value)) 15 | avrg = avrg + value 16 | 17 | final = round(avrg/size_current_1,2) 18 | print (':READ::Calibrate::i1::{}::{}'.format(unit_current_1,final)) 19 | 20 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_calibrate_u.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | 5 | buf_voltage_1 = {} 6 | 7 | chip0 = ina260_ui.INA260_UI(chip = '0#0x47', time = 0.2, u_unit = 'mV', mode = ina260_constant.register.MODE_BUS_VOLT_CONT, 8 | avgc = ina260_constant.register.COUNT_4, vbusct = ina260_constant.register.TIME_204_us) 9 | 10 | ((size_voltage_1,unit_voltage_1,buf_voltage_1)) = chip0.measure_u() 11 | 12 | avrg = 0 13 | for key, value in buf_voltage_1.items(): 14 | avrg = avrg + value 15 | 16 | final = round(avrg/size_voltage_1,3) 17 | print (':READ::Calibrate::i1::{}::{}'.format(unit_voltage_1,final)) 18 | 19 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_i_1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | from time import sleep 5 | import pickle 6 | import os 7 | import json 8 | 9 | buf_current_1 = {} 10 | 11 | chip0 = ina260_ui.INA260_UI(chip = '0#0x46', time = 1, i_unit = 'mA', mode = ina260_constant.register.MODE_SHUNT_CURRENT_CONT, 12 | avgc = ina260_constant.register.COUNT_4, ishct = ina260_constant.register.TIME_204_us) 13 | sens0 = ina260.conf_register_list(address = 0x46) 14 | print ('Reg:{}',format(sens0)) 15 | 16 | ((size_current_1,unit_current_1,buf_current_1)) = chip0.measure_i() 17 | 18 | arr_current_1 = () 19 | 20 | arr_current_1 = [value for (key,value) in buf_current_1.items()] 21 | 22 | data_curr1 = {'current_size_1' : size_current_1,'unit_current_1' : unit_current_1,'arr_current_1' : arr_current_1,} 23 | 24 | json_curr1 = json.dumps(data_curr1) 25 | 26 | file = 'ina260.data' 27 | fd = open(file,'w') 28 | fd.writelines([json_curr1,'\n']) 29 | fd.close() 30 | sleep(0.5) 31 | 32 | print (':READ::Measure1::{}'.format(file)) 33 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_i_1_u_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | from time import sleep 5 | import pickle 6 | import os 7 | import json 8 | 9 | base_data = 'ina260.data' 10 | file_data = '/tmp/' + base_data 11 | 12 | def child (): 13 | fd = open(file_data,'wb') 14 | data = chip1.measure_u() 15 | pickle.dump(data, fd,-1) 16 | fd.close() 17 | os._exit(0) 18 | 19 | buf_current_1 = {} 20 | buf_voltage_2 = {} 21 | 22 | chip0 = ina260_ui.INA260_UI(chip = '0#0x46', time = 1, i_unit = 'mA', mode = ina260_constant.register.MODE_SHUNT_CURRENT_CONT, 23 | avgc = ina260_constant.register.COUNT_1, ishct = ina260_constant.register.TIME_558_us) 24 | chip1 = ina260_ui.INA260_UI(chip = '1#0x47', time = 1, u_unit = 'mV',mode = ina260_constant.register.MODE_BUS_VOLT_CONT, 25 | avgc = ina260_constant.register.COUNT_1, vbusct = ina260_constant.register.TIME_558_us) 26 | sens0 = ina260.conf_register_list(address = 0x46) 27 | sens1 = ina260.conf_register_list(address = 0x47) 28 | print ('Reg:{}',format(sens0)) 29 | print ('Reg:{}',format(sens1)) 30 | 31 | 32 | while True: 33 | newpid = os.fork() 34 | if newpid == 0: 35 | child() 36 | else: 37 | ((size_current_1,unit_current_1,buf_current_1)) = chip0.measure_i() 38 | os.waitid(os.P_PID,newpid,os.WEXITED) 39 | break 40 | fd = open(file_data,'rb') 41 | ((size_voltage_2,unit_voltage_2,buf_voltage_2)) = pickle.load(fd) 42 | fd.close() 43 | 44 | os.remove(file_data) 45 | 46 | arr_current_1 = () 47 | arr_voltage_2 = () 48 | 49 | arr_current_1 = [value for (key,value) in buf_current_1.items()] 50 | arr_voltage_2 = [value for (key,value) in buf_voltage_2.items()] 51 | 52 | data_curr1 = {'current_size_1' : size_current_1,'unit_current_1' : unit_current_1,'arr_current_1' : arr_current_1,} 53 | data_voltage2 = {'voltage_size_2' : size_voltage_2,'unit_voltage_2' : unit_voltage_2,'arr_voltage_2' :arr_voltage_2,} 54 | 55 | json_curr1 = json.dumps(data_curr1) 56 | json_voltage2 = json.dumps(data_voltage2) 57 | fd = open(file_data,'w') 58 | fd.writelines([json_curr1,'\n']) 59 | fd.writelines([json_voltage2,'\n']) 60 | fd.close() 61 | sleep(0.5) 62 | 63 | print (':READ::Measure::{}'.format(base_data)) 64 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_i_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | from time import sleep 5 | import pickle 6 | import os 7 | import json 8 | 9 | base_data = 'ina260.data' 10 | file_data = '/tmp/' + base_data 11 | 12 | def child (): 13 | fd = open(file_data,'wb') 14 | data = chip1.measure_i() 15 | pickle.dump(data, fd,-1) 16 | fd.close() 17 | os._exit(0) 18 | 19 | buf_current_1 = {} 20 | buf_current_2 = {} 21 | 22 | chip0 = ina260_ui.INA260_UI(chip = '0#0x46', time = 1, i_unit = 'mA', mode = ina260_constant.register.MODE_SHUNT_CURRENT_CONT, 23 | avgc = ina260_constant.register.COUNT_1, ishct = ina260_constant.register.TIME_204_us) 24 | chip1 = ina260_ui.INA260_UI(chip = '1#0x47', time = 1, i_unit = 'mA', mode = ina260_constant.register.MODE_SHUNT_CURRENT_CONT, 25 | avgc = ina260_constant.register.COUNT_1, ishct = ina260_constant.register.TIME_204_us) 26 | 27 | sens0 = ina260.conf_register_list(address = 0x46) 28 | sens1 = ina260.conf_register_list(address = 0x47) 29 | print ('Reg:{}',format(sens0)) 30 | print ('Reg:{}',format(sens1)) 31 | 32 | while True: 33 | newpid = os.fork() 34 | if newpid == 0: 35 | child() 36 | else: 37 | ((size_current_1,unit_current_1,buf_current_1)) = chip0.measure_i( ioffset = 4.1 ) 38 | os.waitid(os.P_PID,newpid,os.WEXITED) 39 | break 40 | fd = open(file_data,'rb') 41 | ((size_current_2,unit_current_2,buf_current_2)) = pickle.load(fd) 42 | fd.close() 43 | 44 | os.remove(file_data) 45 | 46 | arr_current_1 = () 47 | arr_current_2 = () 48 | 49 | arr_current_1 = [value for (key,value) in buf_current_1.items()] 50 | arr_current_2 = [value for (key,value) in buf_current_2.items()] 51 | 52 | data_curr1 = {'current_size_1' : size_current_1,'unit_current_1' : unit_current_1,'arr_current_1' : arr_current_1,} 53 | data_curr2 = {'current_size_2' : size_current_2,'unit_current_2' : unit_current_2,'arr_current_2' : arr_current_2,} 54 | 55 | json_curr1 = json.dumps(data_curr1) 56 | json_curr2 = json.dumps(data_curr2) 57 | fd = open(file_data,'w') 58 | fd.writelines([json_curr1,'\n']) 59 | fd.writelines([json_curr2,'\n']) 60 | fd.close() 61 | sleep(0.5) 62 | 63 | print (':READ::Measure::{}'.format(base_data)) 64 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_u_1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | from time import sleep 5 | import pickle 6 | import os 7 | import json 8 | 9 | base_data = 'ina260.data' 10 | file_data = '/tmp/' + base_data 11 | 12 | buf_voltage_1 = {} 13 | 14 | chip0 = ina260_ui.INA260_UI(chip = '0#0x46', time = 1, u_unit = 'mV', mode = ina260_constant.register.MODE_BUS_VOLT_CONT, 15 | avgc = ina260_constant.register.COUNT_4, vbusct = ina260_constant.register.TIME_204_us) 16 | sens0 = ina260.conf_register_list(address = 0x46) 17 | print ('Reg:{}',format(sens0)) 18 | 19 | ((size_voltage_1,unit_voltage_1,buf_voltage_1)) = chip0.measure_u() 20 | 21 | arr_voltage_1 = () 22 | 23 | arr_voltage_1 = [value for (key,value) in buf_voltage_1.items()] 24 | 25 | data_voltage1 = {'voltage_size_1' : size_voltage_1,'unit_voltage_1' : unit_voltage_1,'arr_voltage_1' :arr_voltage_1,} 26 | 27 | json_voltage1 = json.dumps(data_voltage1) 28 | 29 | fd = open(file_data,'w') 30 | fd.writelines([json_voltage1,'\n']) 31 | fd.close() 32 | sleep(3.5) 33 | 34 | print (':READ::Measure1::{}'.format(base_data)) 35 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_u_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | from time import sleep 5 | import pickle 6 | import os 7 | import json 8 | 9 | base_data = 'ina260.data' 10 | file_data = '/tmp/' + base_data 11 | 12 | def child (): 13 | fd = open(file_data,'wb') 14 | data = chip1.measure_u() 15 | pickle.dump(data, fd,-1) 16 | fd.close() 17 | os._exit(0) 18 | 19 | buf_voltage_1 = {} 20 | buf_voltage_2 = {} 21 | 22 | chip0 = ina260_ui.INA260_UI(chip = '0#0x46', time = 1, u_unit = 'mV', mode = ina260_constant.register.MODE_BUS_VOLT_CONT, 23 | avgc = ina260_constant.register.COUNT_1, vbusct = ina260_constant.register.TIME_204_us) 24 | chip1 = ina260_ui.INA260_UI(chip = '1#0x47', time = 1, u_unit = 'mV', mode = ina260_constant.register.MODE_BUS_VOLT_CONT, 25 | avgc = ina260_constant.register.COUNT_1, vbusct = ina260_constant.register.TIME_204_us) 26 | sens0 = ina260.conf_register_list(address = 0x46) 27 | sens1 = ina260.conf_register_list(address = 0x47) 28 | print ('Reg:{}',format(sens0)) 29 | print ('Reg:{}',format(sens1)) 30 | 31 | 32 | while True: 33 | newpid = os.fork() 34 | if newpid == 0: 35 | child() 36 | else: 37 | ((size_voltage_1,unit_voltage_1,buf_voltage_1)) = chip0.measure_u() 38 | os.waitid(os.P_PID,newpid,os.WEXITED) 39 | break 40 | fd = open(file_data,'rb') 41 | ((size_voltage_2,unit_voltage_2,buf_voltage_2)) = pickle.load(fd) 42 | fd.close() 43 | os.remove(file_data) 44 | 45 | arr_voltage_1 = () 46 | arr_voltage_2 = () 47 | 48 | arr_voltage_1 = [value for (key,value) in buf_voltage_1.items()] 49 | arr_voltage_2 = [value for (key,value) in buf_voltage_2.items()] 50 | 51 | data_voltage1 = {'voltage_size_1' : size_voltage_1,'unit_voltage_1' : unit_voltage_1,'arr_voltage_1' :arr_voltage_1,} 52 | data_voltage2 = {'voltage_size_2' : size_voltage_2,'unit_voltage_2' : unit_voltage_2,'arr_voltage_2' :arr_voltage_2,} 53 | 54 | json_voltage1 = json.dumps(data_voltage1) 55 | json_voltage2 = json.dumps(data_voltage2) 56 | fd = open(file_data,'w') 57 | fd.writelines([json_voltage1,'\n']) 58 | fd.writelines([json_voltage2,'\n']) 59 | fd.close() 60 | sleep(0.5) 61 | 62 | print (':READ::Measure::{}'.format(base_data)) 63 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_ui.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui 4 | from time import sleep 5 | import pickle 6 | import os 7 | import json 8 | 9 | base_data = 'ina260.data' 10 | file_data = '/tmp/' + base_data 11 | 12 | def child (): 13 | fd = open(file_data,'wb') 14 | data = chip1.measure_ui() 15 | pickle.dump(data, fd,-1) 16 | fd.close() 17 | os._exit(0) 18 | 19 | buf_voltage_1 = {} 20 | buf_current_1 = {} 21 | buf_voltage_2 = {} 22 | buf_current_2 = {} 23 | 24 | chip0 = ina260_ui.INA260_UI(chip = '0#0x46', time = 0.01, i_unit = 'mA', u_unit = 'V') 25 | chip1 = ina260_ui.INA260_UI(chip = '1#0x47', time = 0.01, i_unit = 'mA', u_unit = 'V') 26 | 27 | while True: 28 | newpid = os.fork() 29 | if newpid == 0: 30 | child() 31 | else: 32 | ((size_current_1,unit_current_1,buf_current_1),(size_voltage_1,unit_voltage_1,buf_voltage_1)) = chip0.measure_ui() 33 | os.waitid(os.P_PID,newpid,os.WEXITED) 34 | break 35 | fd = open(file_data,'rb') 36 | ((size_current_2,unit_current_2,buf_current_2),(size_voltage_2,unit_voltage_2,buf_voltage_2)) = pickle.load(fd) 37 | fd.close() 38 | 39 | os.remove(file_data) 40 | 41 | arr_current_1 = () 42 | arr_current_2 = () 43 | arr_voltage_1 = () 44 | arr_voltage_2 = () 45 | 46 | arr_current_1 = [value for (key,value) in buf_current_1.items()] 47 | arr_current_2 = [value for (key,value) in buf_current_2.items()] 48 | arr_voltage_1 = [value for (key,value) in buf_voltage_1.items()] 49 | arr_voltage_2 = [value for (key,value) in buf_voltage_2.items()] 50 | 51 | data_curr1 = {'current_size_1' : size_current_1,'unit_current_1' : unit_current_1,'arr_current_1' : arr_current_1,} 52 | data_voltage1 = {'voltage_size_1' : size_voltage_1,'unit_voltage_1' : unit_voltage_1,'arr_voltage_1' :arr_voltage_1,} 53 | data_curr2 = {'current_size_2' : size_current_2,'unit_current_2' : unit_current_2,'arr_current_2' : arr_current_2,} 54 | data_voltage2 = {'voltage_size_2' : size_voltage_2,'unit_voltage_2' : unit_voltage_2,'arr_voltage_2' :arr_voltage_2,} 55 | 56 | json_curr1 = json.dumps(data_curr1) 57 | json_voltage1 = json.dumps(data_voltage1) 58 | json_curr2 = json.dumps(data_curr2) 59 | json_voltage2 = json.dumps(data_voltage2) 60 | 61 | fd = open(file_data,'w') 62 | fd.writelines([json_curr1,'\n']) 63 | fd.writelines([json_voltage1,'\n']) 64 | fd.writelines([json_curr2,'\n']) 65 | fd.writelines([json_voltage2,'\n']) 66 | fd.close() 67 | sleep(3.5) 68 | 69 | print (':READ::Measure::{}'.format(base_data)) 70 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_ui_1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | from time import sleep 5 | import pickle 6 | import os 7 | import json 8 | 9 | base_data = 'ina260.data' 10 | file_data = '/tmp/' + base_data 11 | 12 | buf_voltage_1 = {} 13 | buf_current_1 = {} 14 | 15 | chip0 = ina260_ui.INA260_UI(chip = '0#0x46', time = 1, u_unit = 'mV', i_unit = 'mA', mode = ina260_constant.register.MODE_CUR_VOLT_CONT, 16 | avgc = ina260_constant.register.COUNT_1, vbusct = ina260_constant.register.TIME_558_us, ishct = ina260_constant.register.TIME_558_us) 17 | sens0 = ina260.conf_register_list(address = 0x46) 18 | print ('Reg:{}',format(sens0)) 19 | 20 | ((size_current_1,unit_current_1,buf_current_1),(size_voltage_1,unit_voltage_1,buf_voltage_1)) = chip0.measure_ui() 21 | 22 | arr_current_1 = () 23 | arr_voltage_1 = () 24 | 25 | arr_current_1 = [value for (key,value) in buf_current_1.items()] 26 | arr_voltage_1 = [value for (key,value) in buf_voltage_1.items()] 27 | 28 | data_curr1 = {'current_size_1' : size_current_1,'unit_current_1' : unit_current_1,'arr_current_1' : arr_current_1,} 29 | data_voltage1 = {'voltage_size_1' : size_voltage_1,'unit_voltage_1' : unit_voltage_1,'arr_voltage_1' :arr_voltage_1,} 30 | 31 | json_curr1 = json.dumps(data_curr1) 32 | json_voltage1 = json.dumps(data_voltage1) 33 | 34 | fd = open(file_data,'w') 35 | fd.writelines([json_curr1,'\n']) 36 | fd.writelines([json_voltage1,'\n']) 37 | fd.close() 38 | sleep(0.5) 39 | 40 | print (':READ::Measure1::{}'.format(base_data)) 41 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_ui_1_i_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | from time import sleep 5 | import pickle 6 | import os 7 | import json 8 | 9 | base_data = 'ina260.data' 10 | file_data = '/tmp/' + base_data 11 | 12 | def child (): 13 | fd = open(file_data,'wb') 14 | data = chip1.measure_i() 15 | pickle.dump(data, fd,-1) 16 | fd.close() 17 | os._exit(0) 18 | 19 | buf_voltage_1 = {} 20 | buf_current_1 = {} 21 | buf_current_2 = {} 22 | 23 | chip0 = ina260_ui.INA260_UI(chip = '0#0x46', time = 1, u_unit = 'mV', i_unit = 'mA', mode = ina260_constant.register.MODE_CUR_VOLT_CONT, 24 | avgc = ina260_constant.register.COUNT_1, vbusct = ina260_constant.register.TIME_1_1_ms, ishct = ina260_constant.register.TIME_1_1_ms) 25 | chip1 = ina260_ui.INA260_UI(chip = '1#0x47', time = 1, i_unit = 'mA', mode = ina260_constant.register.MODE_SHUNT_CURRENT_CONT, 26 | avgc = ina260_constant.register.COUNT_1, ishct = ina260_constant.register.TIME_1_1_ms) 27 | sens0 = ina260.conf_register_list(address = 0x46) 28 | sens1 = ina260.conf_register_list(address = 0x47) 29 | print ('Reg:{}',format(sens0)) 30 | print ('Reg:{}',format(sens1)) 31 | 32 | 33 | while True: 34 | newpid = os.fork() 35 | if newpid == 0: 36 | child() 37 | else: 38 | ((size_current_1,unit_current_1,buf_current_1),(size_voltage_1,unit_voltage_1,buf_voltage_1)) = chip0.measure_ui() 39 | os.waitid(os.P_PID,newpid,os.WEXITED) 40 | break 41 | fd = open(file_data,'rb') 42 | ((size_current_2,unit_current_2,buf_current_2)) = pickle.load(fd) 43 | fd.close() 44 | 45 | os.remove(file_data) 46 | 47 | arr_current_1 = () 48 | arr_current_2 = () 49 | arr_voltage_1 = () 50 | 51 | arr_current_1 = [value for (key,value) in buf_current_1.items()] 52 | arr_current_2 = [value for (key,value) in buf_current_2.items()] 53 | arr_voltage_1 = [value for (key,value) in buf_voltage_1.items()] 54 | 55 | data_curr1 = {'current_size_1' : size_current_1,'unit_current_1' : unit_current_1,'arr_current_1' : arr_current_1,} 56 | data_voltage1 = {'voltage_size_1' : size_voltage_1,'unit_voltage_1' : unit_voltage_1,'arr_voltage_1' :arr_voltage_1,} 57 | data_curr2 = {'current_size_2' : size_current_2,'unit_current_2' : unit_current_2,'arr_current_2' : arr_current_2,} 58 | 59 | json_curr1 = json.dumps(data_curr1) 60 | json_voltage1 = json.dumps(data_voltage1) 61 | json_curr2 = json.dumps(data_curr2) 62 | 63 | fd = open(file_data,'w') 64 | fd.writelines([json_curr1,'\n']) 65 | fd.writelines([json_voltage1,'\n']) 66 | fd.writelines([json_curr2,'\n']) 67 | fd.close() 68 | sleep(0.5) 69 | 70 | print (':READ::Measure::{}'.format(base_data)) 71 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_ui_1_u_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | from time import sleep 5 | import pickle 6 | import os 7 | import json 8 | 9 | base_data = 'ina260.data' 10 | file_data = '/tmp/' + base_data 11 | 12 | def child (): 13 | fd = open(file_data,'wb') 14 | data = chip1.measure_u() 15 | pickle.dump(data, fd,-1) 16 | fd.close() 17 | os._exit(0) 18 | 19 | buf_voltage_1 = {} 20 | buf_current_1 = {} 21 | buf_voltage_2 = {} 22 | 23 | chip0 = ina260_ui.INA260_UI(chip = '0#0x46', time = 1, u_unit = 'mV', i_unit = 'mA', mode = ina260_constant.register.MODE_CUR_VOLT_CONT, 24 | avgc = ina260_constant.register.COUNT_1, vbusct = ina260_constant.register.TIME_204_us, ishct = ina260_constant.register.TIME_204_us) 25 | chip1 = ina260_ui.INA260_UI(chip = '1#0x47', time = 1, u_unit = 'mV', mode = ina260_constant.register.MODE_BUS_VOLT_CONT, 26 | avgc = ina260_constant.register.COUNT_1, vbusct = ina260_constant.register.TIME_204_us) 27 | sens0 = ina260.conf_register_list(address = 0x46) 28 | sens1 = ina260.conf_register_list(address = 0x47) 29 | print ('Reg:{}',format(sens0)) 30 | print ('Reg:{}',format(sens1)) 31 | 32 | 33 | while True: 34 | newpid = os.fork() 35 | if newpid == 0: 36 | child() 37 | else: 38 | ((size_current_1,unit_current_1,buf_current_1),(size_voltage_1,unit_voltage_1,buf_voltage_1)) = chip0.measure_ui() 39 | os.waitid(os.P_PID,newpid,os.WEXITED) 40 | break 41 | fd = open(file_data,'rb') 42 | ((size_voltage_2,unit_voltage_2,buf_voltage_2)) = pickle.load(fd) 43 | fd.close() 44 | 45 | os.remove(file_data) 46 | 47 | arr_current_1 = () 48 | arr_voltage_1 = () 49 | arr_voltage_2 = () 50 | 51 | arr_current_1 = [value for (key,value) in buf_current_1.items()] 52 | arr_voltage_1 = [value for (key,value) in buf_voltage_1.items()] 53 | arr_voltage_2 = [value for (key,value) in buf_voltage_2.items()] 54 | 55 | data_curr1 = {'current_size_1' : size_current_1,'unit_current_1' : unit_current_1,'arr_current_1' : arr_current_1,} 56 | data_voltage1 = {'voltage_size_1' : size_voltage_1,'unit_voltage_1' : unit_voltage_1,'arr_voltage_1' :arr_voltage_1,} 57 | data_voltage2 = {'voltage_size_2' : size_voltage_2,'unit_voltage_2' : unit_voltage_2,'arr_voltage_2' :arr_voltage_2,} 58 | 59 | json_curr1 = json.dumps(data_curr1) 60 | json_voltage1 = json.dumps(data_voltage1) 61 | json_voltage2 = json.dumps(data_voltage2) 62 | 63 | fd = open(file_data,'w') 64 | fd.writelines([json_curr1,'\n']) 65 | fd.writelines([json_voltage1,'\n']) 66 | fd.writelines([json_voltage2,'\n']) 67 | fd.close() 68 | sleep(0.5) 69 | 70 | print (':READ::Measure::{}'.format(base_data)) 71 | -------------------------------------------------------------------------------- /python_test_scripts/ina260/ina260_i2c_ui_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 4 | from time import sleep 5 | import pickle 6 | import os 7 | import json 8 | 9 | base_data = 'ina260.data' 10 | file_data = '/tmp/' + base_data 11 | 12 | def child (): 13 | fd = open(file_data,'wb') 14 | data = chip1.measure_ui() 15 | pickle.dump(data, fd,-1) 16 | fd.close() 17 | os._exit(0) 18 | 19 | buf_voltage_1 = {} 20 | buf_current_1 = {} 21 | buf_voltage_2 = {} 22 | buf_current_2 = {} 23 | 24 | chip0 = ina260_ui.INA260_UI(chip = '0#0x46', time = 1, u_unit = 'mV', i_unit = 'mA', mode = ina260_constant.register.MODE_CUR_VOLT_CONT, 25 | avgc = ina260_constant.register.COUNT_1, vbusct = ina260_constant.register.TIME_1_1_ms, ishct = ina260_constant.register.TIME_1_1_ms) 26 | chip1 = ina260_ui.INA260_UI(chip = '1#0x47', time = 1, u_unit = 'mV', i_unit = 'mA', mode = ina260_constant.register.MODE_CUR_VOLT_CONT, 27 | avgc = ina260_constant.register.COUNT_1, vbusct = ina260_constant.register.TIME_1_1_ms, ishct = ina260_constant.register.TIME_1_1_ms) 28 | sens0 = ina260.conf_register_list(address = 0x46) 29 | sens1 = ina260.conf_register_list(address = 0x47) 30 | print ('Reg:{}',format(sens0)) 31 | print ('Reg:{}',format(sens1)) 32 | 33 | 34 | while True: 35 | newpid = os.fork() 36 | if newpid == 0: 37 | child() 38 | else: 39 | ((size_current_1,unit_current_1,buf_current_1),(size_voltage_1,unit_voltage_1,buf_voltage_1)) = chip0.measure_ui() 40 | os.waitid(os.P_PID,newpid,os.WEXITED) 41 | break 42 | fd = open(file_data,'rb') 43 | ((size_current_2,unit_current_2,buf_current_2),(size_voltage_2,unit_voltage_2,buf_voltage_2)) = pickle.load(fd) 44 | fd.close() 45 | 46 | os.remove(file_data) 47 | 48 | arr_current_1 = () 49 | arr_current_2 = () 50 | arr_voltage_1 = () 51 | arr_voltage_2 = () 52 | 53 | arr_current_1 = [value for (key,value) in buf_current_1.items()] 54 | arr_current_2 = [value for (key,value) in buf_current_2.items()] 55 | arr_voltage_1 = [value for (key,value) in buf_voltage_1.items()] 56 | arr_voltage_2 = [value for (key,value) in buf_voltage_2.items()] 57 | 58 | data_curr1 = {'current_size_1' : size_current_1,'unit_current_1' : unit_current_1,'arr_current_1' : arr_current_1,} 59 | data_voltage1 = {'voltage_size_1' : size_voltage_1,'unit_voltage_1' : unit_voltage_1,'arr_voltage_1' :arr_voltage_1,} 60 | data_curr2 = {'current_size_2' : size_current_2,'unit_current_2' : unit_current_2,'arr_current_2' : arr_current_2,} 61 | data_voltage2 = {'voltage_size_2' : size_voltage_2,'unit_voltage_2' : unit_voltage_2,'arr_voltage_2' :arr_voltage_2,} 62 | 63 | json_curr1 = json.dumps(data_curr1) 64 | json_voltage1 = json.dumps(data_voltage1) 65 | json_curr2 = json.dumps(data_curr2) 66 | json_voltage2 = json.dumps(data_voltage2) 67 | 68 | fd = open(file_data,'w') 69 | fd.writelines([json_curr1,'\n']) 70 | fd.writelines([json_voltage1,'\n']) 71 | fd.writelines([json_curr2,'\n']) 72 | fd.writelines([json_voltage2,'\n']) 73 | fd.close() 74 | sleep(0.5) 75 | 76 | print (':READ::Measure::{}'.format(base_data)) 77 | -------------------------------------------------------------------------------- /python_test_scripts/mcp3221/mcp3221_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.mcp3221 import mcp3221 6 | import logging 7 | 8 | mcp = mcp3221.MCP3221() 9 | 10 | logging.basicConfig(level=logging.DEBUG, # change level looging to (INFO, DEBUG, ERROR) 11 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 12 | datefmt='%m-%d %H:%M', 13 | filename='mcp3221.log', 14 | filemode='w') 15 | console = logging.StreamHandler() 16 | console.setLevel(logging.DEBUG) 17 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 18 | console.setFormatter(formatter) 19 | logging.getLogger('').addHandler(console) 20 | mcp._logger = logging.getLogger('ecomet.mcp3221') 21 | mcp._logger.info('Start logging ...') 22 | 23 | (val,ret) = mcp.to_max_const 24 | mcp._logger.info('Degree: %s',format(round(val,1))) 25 | (val,ret) = mcp.degrees_to_cardinal_calibrated 26 | mcp._logger.info('Cardinal: %s',format(val)) 27 | -------------------------------------------------------------------------------- /python_test_scripts/ms5637_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.ms5637 import ms5637 6 | import logging 7 | 8 | sens = ms5637.MS5637() 9 | 10 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 11 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 12 | datefmt='%m-%d %H:%M', 13 | filename='ms5637.log', 14 | filemode='w') 15 | console = logging.StreamHandler() 16 | console.setLevel(logging.DEBUG) 17 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 18 | console.setFormatter(formatter) 19 | logging.getLogger('').addHandler(console) 20 | sens._logger = logging.getLogger('ecomet.ms5637') 21 | sens._logger.info('Start logging ...') 22 | 23 | ret = sens.sw_reset() 24 | sens._logger.info('SW Reset correct') if ret == 0 else sens._logger.error('SW Reset error %s'.format(ret)) 25 | 26 | #C1 = sens.read_register('PROM_PRE_SENS') first possibility how to read C1 27 | #C1 = sens.c1[0] second possbility how to read C1 28 | 29 | # first way to calculate temperature 30 | #sens.write_register('D2_CONV_256', stime = sens.d1_time) 31 | #D2 = sens.read_register('ADC_READ')[0] 32 | #dT = D2 - C5 * 2**8 33 | #temp = 2000 + dT * C6 / 2**23 34 | #print ("d2 = {}".format(D2)) 35 | #print ("dT = {}".format(dT)) 36 | #print ("TEMP = {}".format(temp)) 37 | 38 | data = sens.measure (accuracy = 6) 39 | temp = data[0] 40 | temp_f = data[1] 41 | pressure = data[2] 42 | if data[3] == 0 : 43 | sens._logger.info('Pressure = %s mbar','{0:10.2f}'.format(pressure)) 44 | sens._logger.info('Temperature in Celsius = %s \u2103','{0:10.2f}'.format(temp)) 45 | sens._logger.info('Temperature in Fahrenheit = %s F','{0:10.2f}'.format(temp_f)) 46 | else : 47 | sens._logger.error('Pressure out of range') 48 | -------------------------------------------------------------------------------- /python_test_scripts/pattern/cpuinfo_RP3: -------------------------------------------------------------------------------- 1 | processor : 0 2 | model name : ARMv7 Processor rev 4 (v7l) 3 | BogoMIPS : 38.40 4 | Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 5 | CPU implementer : 0x41 6 | CPU architecture: 7 7 | CPU variant : 0x0 8 | CPU part : 0xd03 9 | CPU revision : 4 10 | 11 | processor : 1 12 | model name : ARMv7 Processor rev 4 (v7l) 13 | BogoMIPS : 38.40 14 | Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 15 | CPU implementer : 0x41 16 | CPU architecture: 7 17 | CPU variant : 0x0 18 | CPU part : 0xd03 19 | CPU revision : 4 20 | 21 | processor : 2 22 | model name : ARMv7 Processor rev 4 (v7l) 23 | BogoMIPS : 38.40 24 | Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 25 | CPU implementer : 0x41 26 | CPU architecture: 7 27 | CPU variant : 0x0 28 | CPU part : 0xd03 29 | CPU revision : 4 30 | 31 | processor : 3 32 | model name : ARMv7 Processor rev 4 (v7l) 33 | BogoMIPS : 38.40 34 | Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 35 | CPU implementer : 0x41 36 | CPU architecture: 7 37 | CPU variant : 0x0 38 | CPU part : 0xd03 39 | CPU revision : 4 40 | 41 | Hardware : BCM2835 42 | Revision : a020d3 43 | Serial : 0000000082a5497c 44 | Model : Raspberry Pi 3 Model B Plus Rev 1.3 45 | -------------------------------------------------------------------------------- /python_test_scripts/pattern/cpuinfo_RP4_CM4: -------------------------------------------------------------------------------- 1 | processor : 0 2 | BogoMIPS : 108.00 3 | Features : fp asimd evtstrm crc32 cpuid 4 | CPU implementer : 0x41 5 | CPU architecture: 8 6 | CPU variant : 0x0 7 | CPU part : 0xd08 8 | CPU revision : 3 9 | processor : 1 10 | BogoMIPS : 108.00 11 | Features : fp asimd evtstrm crc32 cpuid 12 | 13 | CPU implementer : 0x41 14 | CPU architecture: 8 15 | CPU variant : 0x0 16 | CPU part : 0xd08 17 | CPU revision : 3 18 | processor : 2 19 | BogoMIPS : 108.00 20 | Features : fp asimd evtstrm crc32 cpuid 21 | 22 | CPU implementer : 0x41 23 | CPU architecture: 8 24 | CPU variant : 0x0 25 | CPU part : 0xd08 26 | CPU revision : 3 27 | processor : 3 28 | BogoMIPS : 108.00 29 | Features : fp asimd evtstrm crc32 cpuid 30 | 31 | CPU implementer : 0x41 32 | CPU architecture: 8 33 | CPU variant : 0x0 34 | CPU part : 0xd08 35 | CPU revision : 3 36 | Hardware : BCM2835 37 | Revision : b03140 38 | Serial : 10000000780db69c 39 | Model : Raspberry Pi Compute Module 4 Rev 1.0 40 | -------------------------------------------------------------------------------- /python_test_scripts/pca9557_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.pca9557 import pca9557 6 | import logging 7 | 8 | sens = pca9557.PCA9557() 9 | 10 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 11 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 12 | datefmt='%m-%d %H:%M', 13 | filename='pca9557.log', 14 | filemode='w') 15 | console = logging.StreamHandler() 16 | console.setLevel(logging.DEBUG) 17 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 18 | console.setFormatter(formatter) 19 | logging.getLogger('').addHandler(console) 20 | sens._logger = logging.getLogger('ecomet.pca9557') 21 | sens._logger.info('Start logging ...') 22 | 23 | sens.sw_reset() 24 | 25 | #sens.write_register(register = 'REGISTER3', value = 60) 26 | sens.set_io('OOIIIIOO') 27 | sens.set_invert('NNNNNNNN') 28 | sens.set_io_name(port_arr = [[0,'LED1'],[1,'LED2'],[2,'BUT_RIG_DWN'],[3,'BUT_RIG_UP'], 29 | [4,'BUT_LFT_DWN'],[5,'BUT_LFT_UP'],[6,'DIS_RST'],[7,'D/C']]) 30 | show = sens.port_show_name(setting = 'io') 31 | sens._logger.info('Show Ports:') 32 | for i in range(8) : 33 | sens._logger.info('PIN{}: {} : {} : {}'.format(i,show[0][i][0],show[0][i][1],show[0][i][2])) 34 | 35 | 36 | sens._logger.info('Push 10 times any Button ....') 37 | for j in range (1) : 38 | interrupt = sens.read_input_port(thr = 'Unset', mtime = 6, offset = 0.5) 39 | if ( interrupt[1] == 0 ) : 40 | #sens._logger.info('Input signal detected:') 41 | for i in range(8) : 42 | sens._logger.info('PIN{}: {} : {} : {}'.format(i,interrupt[0][i][0],interrupt[0][i][1],interrupt[0][i][2])) 43 | if ( interrupt[0][i][1] == pca9557.Threshold ) : 44 | sens._logger.info('Loop:{} -> PIN{}: {} ... pushed'.format(j,interrupt[0][i][0],interrupt[0][i][2])) 45 | else : 46 | sens._logger.info('Loop:{} -> No Input signal, threshold time reached'.format(j)) 47 | 48 | sens.reset_outputs() 49 | sens.port_display() 50 | 51 | 52 | sens.write_output_port (status = pca9557.Low, pin = 'LED1') 53 | sens.write_output_port (status = pca9557.High, pin = 'LED2') 54 | sens.port_display() 55 | 56 | from time import sleep 57 | sleep(5) 58 | sens.write_output_port (status = pca9557.High, pin = 'LED1') 59 | sens.write_output_port (status = pca9557.Low, pin = 'LED2') 60 | sens.port_display() 61 | 62 | sleep(5) 63 | sens.write_output_port (status = pca9557.High, pin = 'LED1') 64 | sens.write_output_port (status = pca9557.High, pin = 'LED2') 65 | sens.port_display() 66 | 67 | R0 = sens.read_register('REGISTER0')[0] 68 | R1 = sens.read_register('REGISTER1')[0] 69 | R2 = sens.read_register('REGISTER2')[0] 70 | R3 = sens.read_register('REGISTER3')[0] 71 | 72 | #sens.write_register(register = 'REGISTER2', value = 240) 73 | #R2 = sens.read_register('REGISTER2')[0] 74 | #sens.write_register(register = 'REGISTER1', value = 0) 75 | #R1 = sens.read_register('REGISTER1')[0] 76 | print ("R0 = {}".format(R0)) 77 | print ("R1 = {}".format(R1)) 78 | print ("R2 = {}".format(R2)) 79 | print ("R3 = {}".format(R3)) 80 | 81 | -------------------------------------------------------------------------------- /python_test_scripts/pca_9632_i2c_rgb.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # test script for RGB LED testing, in loop color will be rotated in palette and dimmed 3 | 4 | import sys 5 | import time 6 | import logging 7 | print (sys.version) 8 | from ecomet_i2c_sensors.pca9632 import pca9632 9 | 10 | pwm1 = pca9632.PCA9632(address=0x60) 11 | pwm2 = pca9632.PCA9632(address=0x62) 12 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 13 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 14 | datefmt='%m-%d %H:%M', 15 | filename='pca9632.log', 16 | filemode='w') 17 | console = logging.StreamHandler() 18 | console.setLevel(logging.DEBUG) 19 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 20 | console.setFormatter(formatter) 21 | logging.getLogger('').addHandler(console) 22 | pwm1._logger = logging.getLogger('ecomet.pca9632') 23 | pwm1._logger.info('Start logging ...') 24 | 25 | #reg_view = pca9632.read_pca9632(); 26 | ret = pca9632.software_reset() 27 | ret = pca9632.ledout_clear() 28 | ret = pwm1.write_register( register = 'MODE1', bits = ['ALLCALL','SLEEP_N']) 29 | ret = pwm1.write_register( register = 'MODE2', bits = ['DMBLNK_BLINKING']) 30 | ret = pwm1.write_register( register = 'LEDOUT', bits = [{'LDR0' : 'PWM' }, {'LDR1' : 'PWM'}, {'LDR2' : 'PWM'}, {'LDR3' : 'OFF'}]) 31 | 32 | ret = pwm2.write_register( register = 'MODE1', bits = ['ALLCALL','SLEEP_N']) 33 | ret = pwm2.write_register( register = 'MODE2', bits = ['DMBLNK_BLINKING']) 34 | ret = pwm2.write_register( register = 'LEDOUT', bits = [{'LDR0' : 'PWM' }, {'LDR1' : 'PWM'}, {'LDR2' : 'PWM'}, {'LDR3' : 'OFF'}]) 35 | 36 | # RGB led connected to PWM1, PWM2, PWM3 37 | # PWM1 = BLUE, PWM2 = GREEN, PWM3 = RED 38 | 39 | blue = { 'R': 0, 40 | 'G': 0, 41 | 'B': 255 } 42 | violet = { 'R': 128, 43 | 'G': 0, 44 | 'B': 255 } 45 | magenta = { 'R': 255, 46 | 'G': 0, 47 | 'B': 255 } 48 | rose = { 'R': 255, 49 | 'G': 0, 50 | 'B': 128 } 51 | red = { 'R': 255, 52 | 'G': 0, 53 | 'B': 0 } 54 | orange = { 'R': 255, 55 | 'G': 128, 56 | 'B': 0 } 57 | yellow = { 'R': 255, 58 | 'G': 255, 59 | 'B': 0 } 60 | chartre = { 'R': 128, 61 | 'G': 255, 62 | 'B': 0 } 63 | green = { 'R': 0, 64 | 'G': 255, 65 | 'B': 0 } 66 | springg = { 'R': 0, 67 | 'G': 255, 68 | 'B': 128 } 69 | cyan = { 'R': 0, 70 | 'G': 255, 71 | 'B': 255 } 72 | azure = { 'R': 0, 73 | 'G': 128, 74 | 'B': 255 } 75 | 76 | der = [1,2,4,8,10,12,14,16,18,20] 77 | 78 | 79 | palette = [blue,violet,magenta,rose,red,orange,yellow,chartre,green,springg,cyan,azure] 80 | from time import sleep 81 | for loop in range (1,10) : 82 | for i in palette : 83 | 84 | pwm1.write_register( register = 'PWM2', bits = [{'PWM' : int(i['R'] / der[loop]) }]) 85 | pwm1.write_register( register = 'PWM1', bits = [{'PWM' : int(i['G'] / der[loop]) }]) 86 | pwm1.write_register( register = 'PWM0', bits = [{'PWM' : int(i['B'] / der[loop]) }]) 87 | 88 | pwm2.write_register( register = 'PWM2', bits = [{'PWM' : int(i['R'] / der[loop]) }]) 89 | pwm2.write_register( register = 'PWM1', bits = [{'PWM' : int(i['G'] / der[loop]) }]) 90 | pwm2.write_register( register = 'PWM0', bits = [{'PWM' : int(i['B'] / der[loop]) }]) 91 | sleep(0.1) 92 | 93 | pwm1.write_register( register = 'PWM2', bits = [{'PWM' : '0' }]) 94 | pwm1.write_register( register = 'PWM1', bits = [{'PWM' : '0' }]) 95 | pwm1.write_register( register = 'PWM0', bits = [{'PWM' : '0' }]) 96 | 97 | pwm2.write_register( register = 'PWM2', bits = [{'PWM' : '0' }]) 98 | pwm2.write_register( register = 'PWM1', bits = [{'PWM' : '0' }]) 99 | pwm2.write_register( register = 'PWM0', bits = [{'PWM' : '0' }]) 100 | 101 | 102 | -------------------------------------------------------------------------------- /python_test_scripts/pca_9632_i2c_rgb_2led.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # test script for RGB LED testing, in loop color will be rotated in palette and dimmed 3 | 4 | import sys 5 | import time 6 | import logging 7 | print (sys.version) 8 | from ecomet_i2c_sensors.pca9632 import pca9632 9 | 10 | pwm1 = pca9632.PCA9632(address=0x60) 11 | pwm2 = pca9632.PCA9632(address=0x62) 12 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 13 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 14 | datefmt='%m-%d %H:%M', 15 | filename='pca9632.log', 16 | filemode='w') 17 | console = logging.StreamHandler() 18 | console.setLevel(logging.DEBUG) 19 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 20 | console.setFormatter(formatter) 21 | logging.getLogger('').addHandler(console) 22 | pwm1._logger = logging.getLogger('ecomet.pca9632') 23 | pwm1._logger.info('Start logging ...') 24 | 25 | #reg_view = pca9632.read_pca9632(); 26 | ret = pca9632.software_reset() 27 | ret = pca9632.ledout_clear() 28 | ret = pwm1.write_register( register = 'MODE1', bits = ['ALLCALL','SLEEP_N']) 29 | ret = pwm1.write_register( register = 'MODE2', bits = ['DMBLNK_BLINKING']) 30 | ret = pwm1.write_register( register = 'LEDOUT', bits = [{'LDR0' : 'PWM' }, {'LDR1' : 'PWM'}, {'LDR2' : 'PWM'}, {'LDR3' : 'OFF'}]) 31 | 32 | ret = pwm2.write_register( register = 'MODE1', bits = ['ALLCALL','SLEEP_N']) 33 | ret = pwm2.write_register( register = 'MODE2', bits = ['DMBLNK_BLINKING']) 34 | ret = pwm2.write_register( register = 'LEDOUT', bits = [{'LDR0' : 'PWM' }, {'LDR1' : 'PWM'}, {'LDR2' : 'PWM'}, {'LDR3' : 'OFF'}]) 35 | 36 | # RGB led connected to PWM1, PWM2, PWM3 37 | # PWM1 = BLUE, PWM2 = GREEN, PWM3 = RED 38 | 39 | blue = { 'R': 0, 40 | 'G': 0, 41 | 'B': 255 } 42 | violet = { 'R': 128, 43 | 'G': 0, 44 | 'B': 255 } 45 | magenta = { 'R': 255, 46 | 'G': 0, 47 | 'B': 255 } 48 | rose = { 'R': 255, 49 | 'G': 0, 50 | 'B': 128 } 51 | red = { 'R': 255, 52 | 'G': 0, 53 | 'B': 0 } 54 | orange = { 'R': 255, 55 | 'G': 128, 56 | 'B': 0 } 57 | yellow = { 'R': 255, 58 | 'G': 255, 59 | 'B': 0 } 60 | chartre = { 'R': 128, 61 | 'G': 255, 62 | 'B': 0 } 63 | green = { 'R': 0, 64 | 'G': 255, 65 | 'B': 0 } 66 | springg = { 'R': 0, 67 | 'G': 255, 68 | 'B': 128 } 69 | cyan = { 'R': 0, 70 | 'G': 255, 71 | 'B': 255 } 72 | azure = { 'R': 0, 73 | 'G': 128, 74 | 'B': 255 } 75 | 76 | der = [1,2,4,8,10,12,14,16,18,20] 77 | 78 | 79 | palette = [blue,violet,magenta,rose,red,orange,yellow,chartre,green,springg,cyan,azure] 80 | #palette = [blue,red,green] 81 | from time import sleep 82 | for loop in range (1,2) : 83 | for i in palette : 84 | 85 | pwm1.write_register( register = 'PWM2', bits = [{'PWM' : int(i['B'] / der[loop]) }]) 86 | pwm1.write_register( register = 'PWM1', bits = [{'PWM' : int(i['R'] / der[loop]) }]) 87 | pwm1.write_register( register = 'PWM0', bits = [{'PWM' : int(i['G'] / der[loop]) }]) 88 | 89 | pwm2.write_register( register = 'PWM2', bits = [{'PWM' : int(i['B'] / der[loop]) }]) 90 | pwm2.write_register( register = 'PWM1', bits = [{'PWM' : int(i['R'] / der[loop]) }]) 91 | pwm2.write_register( register = 'PWM0', bits = [{'PWM' : int(i['G'] / der[loop]) }]) 92 | print ('palette: %s',i) 93 | sleep(2) 94 | 95 | pwm1.write_register( register = 'PWM2', bits = [{'PWM' : '0' }]) 96 | pwm1.write_register( register = 'PWM1', bits = [{'PWM' : '0' }]) 97 | pwm1.write_register( register = 'PWM0', bits = [{'PWM' : '0' }]) 98 | 99 | pwm2.write_register( register = 'PWM2', bits = [{'PWM' : '0' }]) 100 | pwm2.write_register( register = 'PWM1', bits = [{'PWM' : '0' }]) 101 | pwm2.write_register( register = 'PWM0', bits = [{'PWM' : '0' }]) 102 | 103 | 104 | -------------------------------------------------------------------------------- /python_test_scripts/sgp40/sgp40_raw_value.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.sgp40 import sgp40 6 | from ecomet_i2c_sensors.hdc1080 import hdc1080 7 | import logging 8 | from time import sleep 9 | 10 | #set IICbus elativeHumidity(0-100%RH) temperature(-10~50 centigrade) 11 | sgp40=sgp40.SGP40() 12 | sens = hdc1080.HDC1080() 13 | 14 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 15 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 16 | datefmt='%m-%d %H:%M', 17 | filename='sgp40.log', 18 | filemode='w') 19 | console = logging.StreamHandler() 20 | console.setLevel(logging.DEBUG) 21 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 22 | console.setFormatter(formatter) 23 | logging.getLogger('').addHandler(console) 24 | sgp40._logger = logging.getLogger('ecomet.spg40') 25 | sgp40._logger.info('Start logging ...') 26 | 27 | (temp,hmdt, ret) = sens.both_measurement() 28 | 29 | #If you want to modify the environment parameters, you can do so 30 | #elativeHumidity(0-100%RH) temperature(-10~50 centigrade) 31 | sgp40.set_envparams(relative_humidity = hmdt,temperature_c = temp) 32 | sgp40._logger.info('temp: %.2f hmdt: %.2f'%(temp,hmdt)) 33 | 34 | while True: 35 | # get raw vlaue 36 | sgp40._logger.info('Raw vlaue: %d'%(sgp40.measure_raw())) 37 | sleep(1) 38 | -------------------------------------------------------------------------------- /python_test_scripts/sgp40/sgp40_voc_index.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.sgp40 import sgp40 6 | from ecomet_i2c_sensors.hdc1080 import hdc1080 7 | import logging 8 | from time import sleep 9 | 10 | #set IICbus elativeHumidity(0-100%RH) temperature(-10~50 centigrade) 11 | sgp = sgp40.SGP40() 12 | sens = hdc1080.HDC1080() 13 | 14 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 15 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 16 | datefmt='%m-%d %H:%M', 17 | filename='sgp40.log', 18 | filemode='w') 19 | console = logging.StreamHandler() 20 | console.setLevel(logging.DEBUG) 21 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 22 | console.setFormatter(formatter) 23 | logging.getLogger('').addHandler(console) 24 | sgp._logger = logging.getLogger('ecomet.spg40') 25 | sgp._logger.info('Start logging ...') 26 | 27 | (temp,hmdt, ret) = sens.both_measurement() 28 | 29 | #set Warm-up time 30 | sgp._logger.info('Please wait 10 seconds...') 31 | sgp.begin(10) 32 | 33 | #If you want to modify the environment parameters, you can do so 34 | #elativeHumidity(0-100%RH) temperature(-10~50 centigrade) 35 | sgp.set_envparams(relative_humidity = hmdt,temperature_c = temp) 36 | sgp._logger.info('temp: %.2f hmdt: %.2f'%(temp,hmdt)) 37 | 38 | while True: 39 | idx = sgp.get_voc_index() 40 | sgp._logger.info('Voc index : %d [%s]'%(idx, sgp.index_to_explanation(index = idx))) 41 | sleep(1) 42 | -------------------------------------------------------------------------------- /python_test_scripts/sn_gcja5/sn_gcja5_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | print (sys.version) 5 | from ecomet_i2c_sensors.sn_gcja5 import sn_gcja5 6 | import logging 7 | 8 | sens = sn_gcja5.SN_GCJA5() 9 | 10 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 11 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 12 | datefmt='%m-%d %H:%M', 13 | filename='sn-gcja5.log', 14 | filemode='w') 15 | console = logging.StreamHandler() 16 | console.setLevel(logging.DEBUG) 17 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 18 | console.setFormatter(formatter) 19 | logging.getLogger('').addHandler(console) 20 | sens._logger = logging.getLogger('ecomet.sn-gcja5') 21 | sens._logger.info('Start logging ...') 22 | 23 | ret = sens.self_test() 24 | if ret == 0 : 25 | print(":TEST_PASSED:") 26 | else : 27 | print(":MISSING_CHIP:") 28 | 29 | register = sn_gcja5.conf_register_list() 30 | print ('{}'.format(register)) 31 | -------------------------------------------------------------------------------- /python_test_scripts/tsl2591/tsl2591_i2c_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys,os 4 | sys.path.append(os.getenv("HOME") + '/ecomet_i2c_raspberry_tools/ecomet_i2c_sensors') 5 | from tsl2591 import tsl2591,tsl2591_constant 6 | #from ecomet_i2c_sensors.tsl2591 import tsl2591 7 | import logging 8 | 9 | logging.basicConfig(level=logging.INFO, # change level looging to (INFO, DEBUG, ERROR) 10 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 11 | datefmt='%m-%d %H:%M', 12 | filename='tsl2591.log', 13 | filemode='a') 14 | console = logging.StreamHandler() 15 | console.setLevel(logging.DEBUG) 16 | formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') 17 | console.setFormatter(formatter) 18 | logging.getLogger('').addHandler(console) 19 | 20 | sens = tsl2591.TSL2591() 21 | sens._logger = logging.getLogger('ecomet.tsl2591') 22 | sens._logger.info('Start logging ...') 23 | 24 | #sens.reset_ic make throuble 25 | 26 | sens._logger.info('Manual Setting of Gain and Integral Time.') 27 | sens._logger.info('<--------------------------------------->') 28 | 29 | data = sens.Read_FullSpectrum () 30 | data2 = sens.Read_Infrared () 31 | data3 = sens.Read_Visible () 32 | lux = sens.Lux() 33 | 34 | sens._logger.info('Lux: (%s)',lux[0]) 35 | sens._logger.info('Infrared light: (%s)', data2[0]) 36 | sens._logger.info('Visible light: (%s)',data3[0]) 37 | sens._logger.info('Full spectrum (IR + visible) light: (%s)',data[0]) 38 | sens._logger.info('Measure Gain: (%s) IntegralTime: (%s)',lux[1],lux[2]) 39 | 40 | sens.reset_ic 41 | sens.set_gain('GAIN_MED') 42 | sens.set_IntegralTime('TIME_300MS') 43 | 44 | data = sens.Read_FullSpectrum () 45 | data2 = sens.Read_Infrared () 46 | data3 = sens.Read_Visible () 47 | lux = sens.Lux() 48 | 49 | sens._logger.info('Lux: (%s)',lux[0]) 50 | sens._logger.info('Infrared light: (%s)', data2[0]) 51 | sens._logger.info('Visible light: (%s) ',data3[0]) 52 | sens._logger.info('Full spectrum (IR + visible) light: (%s)',data[0]) 53 | sens._logger.info('Measure Gain: (%s) IntegralTime: (%s)',lux[1],lux[2]) 54 | 55 | sens.reset_ic 56 | sens.set_gain('GAIN_HIGH') 57 | sens.set_IntegralTime('TIME_500MS') 58 | 59 | data = sens.Read_FullSpectrum () 60 | data2 = sens.Read_Infrared () 61 | data3 = sens.Read_Visible () 62 | lux = sens.Lux() 63 | 64 | sens._logger.info('Lux: (%s)',lux[0]) 65 | sens._logger.info('Infrared light: (%s)', data2[0]) 66 | sens._logger.info('Visible light: (%s)',data3[0]) 67 | sens._logger.info('Full spectrum (IR + visible) light: (%s)',data[0]) 68 | sens._logger.info('Measure Gain: (%s) IntegralTime: (%s)',lux[1],lux[2]) 69 | 70 | sens.reset_ic 71 | sens._logger.info('Calibration') 72 | sens._logger.info('<--------------------------------------->') 73 | 74 | lux = sens.SelfCalibrate 75 | data = sens.Read_FullSpectrum (calibrate = 1) 76 | data2 = sens.Read_Infrared (calibrate = 1) 77 | data3 = sens.Read_Visible (calibrate = 1) 78 | 79 | sens._logger.info('Lux: (%s)',lux) 80 | sens._logger.info('Infrared light: (%s)', data2[0]) 81 | sens._logger.info('Measure Gain: (%s) IntegralTime: (%s)',data2[1],data2[2]) 82 | sens._logger.info('Visible light: (%s)',data3[0]) 83 | sens._logger.info('Measure Gain: (%s) IntegralTime: (%s)',data3[1],data3[2]) 84 | sens._logger.info('Full spectrum (IR + visible) light: (%s)',data[0]) 85 | sens._logger.info('Measure Gain: (%s) IntegralTime: (%s)',data[1],data[2]) 86 | 87 | sens._logger.info('Set Interrupt') 88 | sens._logger.info('<--------------------------------------->') 89 | sens.SET_InterruptThreshold(HIGH = 0xff00, LOW = 0x0010) 90 | sens._logger.info('List of Registers') 91 | sens._logger.info('<--------------------------------------->') 92 | sens._logger.info (tsl2591.conf_register_list()) 93 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | logging 2 | time 3 | math 4 | division 5 | re 6 | platform 7 | mraa 8 | subprocess 9 | Adafruit_PureIO 10 | RPi.GPIO 11 | randrange 12 | sys 13 | os 14 | pil 15 | -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | from ecomet_i2c_sensors.ina260 import ina260, ina260_ui, ina260_constant 2 | 3 | buf = {} 4 | sens0 = ina260.INA260(address = 0x40) 5 | (size,unit,buf) = sens0.measure_current(stime=0.1,unit='mA') 6 | print ('Size: ',format(size)) 7 | print ('Units: ', format(unit)) 8 | print ('Values: ', format(buf)) 9 | -------------------------------------------------------------------------------- /wiki/_i2c_boards/_display_curr_board/display_current.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/wiki/_i2c_boards/_display_curr_board/display_current.png -------------------------------------------------------------------------------- /wiki/_i2c_boards/_display_curr_board/display_current_z.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/wiki/_i2c_boards/_display_curr_board/display_current_z.png -------------------------------------------------------------------------------- /wiki/_i2c_boards/_fan_board/emc2301.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/wiki/_i2c_boards/_fan_board/emc2301.png -------------------------------------------------------------------------------- /wiki/_i2c_boards/_fan_board/fan_driver_v1.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/wiki/_i2c_boards/_fan_board/fan_driver_v1.3.png -------------------------------------------------------------------------------- /wiki/_i2c_boards/_fan_board/fan_driver_v1.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/wiki/_i2c_boards/_fan_board/fan_driver_v1.5.png -------------------------------------------------------------------------------- /wiki/_i2c_boards/_fan_board/fan_driver_z.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/wiki/_i2c_boards/_fan_board/fan_driver_z.png -------------------------------------------------------------------------------- /wiki/_i2c_boards/_temp_hmd_board/temp_hmd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/wiki/_i2c_boards/_temp_hmd_board/temp_hmd.png -------------------------------------------------------------------------------- /wiki/_i2c_boards/_temp_hmd_pressure_board/temp_hmd_pressure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/wiki/_i2c_boards/_temp_hmd_pressure_board/temp_hmd_pressure.png -------------------------------------------------------------------------------- /wiki/_support_boards/hub_mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mamin27/ecomet_i2c_raspberry_tools/ad8fd33fb7b361ea5bf360b0bc3e02a4981cff77/wiki/_support_boards/hub_mini.png -------------------------------------------------------------------------------- /wiki/common/support.md: -------------------------------------------------------------------------------- 1 | Dear enthusiast 2 | 3 | If you are on this page, it means that you are interested in a special part of my project. Looking for documentation, a special implementation, or adding a new feature to the driver? If so, you are in the right place. What you are looking for is currently not ready and is waiting for your support and donation. Behind every toy of this project, there is a lot of research, designing, testing... If you want to move and you don't have time to develop it yourself, write to my email and explain to me what you need to add to the project. Simple support is to add a ![/python_test_script/display/images/star.png](https://github.com/mamin27/ecomet_i2c_raspberry_tools/blob/master/python_test_scripts/display/images/star.png) to my GitHub project. If you need more, there is a way to donate my work and I will add your request to the project. 4 | 5 | 6 | 7 | 8 | 9 | Sincerely 10 | 11 | Designer Marian 12 | 13 | email: mminar7@gmail.com 14 | --------------------------------------------------------------------------------