Commit ab00e633 authored by Rousseau Vincent's avatar Rousseau Vincent
Browse files

add ads1115 sensor

parent ec27febb
No related merge requests found
Showing with 53 additions and 1 deletion
+53 -1
......@@ -33,3 +33,13 @@ services:
depends_on:
- influxdb
- grafana
ads1115:
build: ./sensors/ads1115
devices:
- "/dev/i2c-1"
restart: always
environment:
- INFLUX_HOST=influxdb
depends_on:
- influxdb
- grafana
FROM python:3
RUN mkdir -p /usr/src/app
COPY *.py /usr/src/app
COPY requirements.txt /usr/src/app
WORKDIR /usr/src/app
RUN python3 -m pip install -r requirements.txt
CMD ["python3", "/usr/src/app/ads1115_influx.py"]
\ No newline at end of file
import time
import os
import ADS1115 as ads1115_lib
from influxdb import InfluxDBClient
influx_host = os.getenv('INFLUX_HOST', 'localhost')
influx_dbname = os.getenv('INFLUX_DBNAME', 'multi-sense')
influx_client = InfluxDBClient(host=influx_host, database=influx_dbname)
influx_client.create_database(influx_dbname)
adc = ads1115_lib.ADS1115()
# Add timestamp to measurement
# Accumulate measurement to write multiples points
while True:
measurement = [
{
'measurement': 'ads1115',
'fields': {
'ain0': adc.readADCSingleEnded(),
'ain1': adc.readADCSingleEnded(1),
'ain2': adc.readADCSingleEnded(channel=2, sps=16),
'ain3': adc.readADCSingleEnded(channel=3, pga=1024, sps=16)
}
}
]
influx_client.write_points(measurement)
time.sleep(1)
influxdb==5.2.1
ADS1115==0.2.1
FROM python:3
RUN mkdir -p /usr/src/app
COPY cpu_load.py /usr/src/app
COPY *.py /usr/src/app
COPY requirements.txt /usr/src/app
WORKDIR /usr/src/app
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment