<jupyter_start><jupyter_text>Atlas Scientific pH  pH Sensor for measuring acidity (hydrogen ion concentration) of liquids  Manufacturer Link: https://www.atlas-scientific.com/ph.html<jupyter_code>import matplotlib.pyplot as plt

from meerkat.base import time
from meerkat import atlas, parser
# instance device and set output format to .csv (which is default)
dev = atlas.pH(bus_n=1, output='csv')<jupyter_output><empty_output><jupyter_text>Configuration<jupyter_code># device information: device type, firmware version
time.sleep(0.5)
dev.info()
# status of device power: restart code, input voltage Vcc
time.sleep(0.5)
dev.status()
# set current temperature for compensation
time.sleep(0.5)
dev.temp_set(24.4)
time.sleep(0.5)
dev.temp_get()<jupyter_output><empty_output><jupyter_text>Calibration<jupyter_code># Three point calibration
dev.cal_set_mid(7.00)
time.sleep(1)
dev.cal_set_low(3.00)
time.sleep(1)
dev.cal_set_high(10.09)
time.sleep(1)
dev.cal_get()
# clear calibration
time.sleep(1)
dev.cal_clear()
time.sleep(1)
dev.cal_get()
# response breakdown of calibration
time.sleep(0.5)
dev.cal_slope()<jupyter_output><empty_output><jupyter_text>Measurement<jupyter_code># single pH measurement
time.sleep(0.5)
dev.measure()
# get one sample without a description
dev.get('test_1')
# get 5 samples with a description
dev.get('test_2', n=5)<jupyter_output><empty_output><jupyter_text>JSON Data Publishing<jupyter_code># set the metadata publishing interval to every third sample
dev.json_writer.metadata_interval = 3
dev.publish(description='test_3', n=5)<jupyter_output><empty_output><jupyter_text>CSV Writer Output<jupyter_code># write 5 samples to .csv file with description
dev.write(description='test_4', n=5)
# name of file written
dev.csv_writer.path
# load .csv data written with dev.write
m, df = parser.csv_resource(dev.csv_writer.path)
df
df.datetime64_ns = df.datetime64_ns.dt.tz_localize('UTC')  # Pandas 0.24.1 hack
df[["datetime64_ns", "pH"]].plot(x="datetime64_ns", style='-x');<jupyter_output><empty_output><jupyter_text>JSON Writer Output<jupyter_code>dev.writer_output = "json"
# get 7 samples with a description
dev.write(description='test_5', n=7)
# name of file written
dev.json_writer.path
!head $dev.json_writer.path<jupyter_output>{"description": "test_5", "sample_n": 0, "pH": 0.0, "std_time_ms": "2020-12-10 19:47:48.004082"}
{"description": "test_5", "sample_n": 1, "pH": 0.0, "std_time_ms": "2020-12-10 19:47:50.458519"}
{"description": "test_5", "sample_n": 2, "pH": 0.0, "std_time_ms": "2020-12-10 19:47:52.913051", "encoding": "utf-8", "format": "text/json", "standard": "RFC 8259", "line_terminator": "\n", "quote_char": "\"", "double_quote": true, "escape_char": "\\", "null_sequence": "NA", "comment": "#", "metadata": {"name": "atlas_ph", "urls": "www.atlas-scientific.com/ph.html", "manufacturer": "Atlas Scientific", "header": ["description", "sample_n", "pH"], "dtype": ["str", "int", "float"], "units": [null, "count", "pH units"], "accuracy": [null, 1, "+/-0.002"], "precision": [null, 1, 0.001], "bus_n": 1, "bus_addr": 99, "description": "Atlas pH"}, "path": "2020_12_10_19_47_48_atlas_ph.jsontxt", "time_format": "std_time_ms", "strfmtime": "%Y-%m-%d %H:%M:%S.%f", "metadata_interval": 3}
{"description": "test_5[...]
StarcoderdataJupyterStructuredCleanDedup