Skip to content

Commit

Permalink
Add mcp3221 test script
Browse files Browse the repository at this point in the history
  • Loading branch information
mamin27 committed Jul 11, 2024
1 parent 28ce41a commit 193ba88
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions python_test_scripts/mcp3221/mcp3221_i2c_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

import sys
print (sys.version)
from ecomet_i2c_sensors.mcp3221 import mcp3221
import logging

mcp = mcp3221.MCP3221()

logging.basicConfig(level=logging.DEBUG, # change level looging to (INFO, DEBUG, ERROR)
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename='mcp3221.log',
filemode='w')
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
mcp._logger = logging.getLogger('ecomet.mcp3221')
mcp._logger.info('Start logging ...')

(val,ret) = mcp.to_max_const
mcp._logger.info('Degree: %s',format(round(val,1)))
(val,ret) = mcp.degrees_to_cardinal_calibrated
mcp._logger.info('Cardinal: %s',format(val))

0 comments on commit 193ba88

Please sign in to comment.