GY-63_MS5611/libraries/DMM/README.md

153 lines
4.0 KiB
Markdown
Raw Normal View History

2022-12-21 15:16:14 -05:00
[![Arduino CI](https://github.com/RobTillaart/DMM/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/DMM/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/DMM/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/DMM/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/DMM/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/DMM/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/DMM.svg?maxAge=3600)](https://github.com/RobTillaart/DMM/releases)
# DMM = Digital MultiMeter.
2023-02-04 08:10:04 -05:00
Arduino library for a DMM (digital multimeter) class.
2022-12-21 15:16:14 -05:00
## Description
DMM is a class that uses the Arduino analogRead to make measurements.
It is based upon the UNO but will work on some other boards too.
The first version only works as a voltmeter, DC only.
It is meant to be extended in the future to be a complete Digital MultiMeter class.
that includes amps ohms, diode testing etc.
2023-02-04 08:10:04 -05:00
This is an old 'toy' project, wrapped into a class.
Do not expect high precision or accuracy.
2022-12-21 15:16:14 -05:00
2023-02-04 08:10:04 -05:00
#### Related
2022-12-21 15:16:14 -05:00
- https://github.com/RobTillaart/ACS712 (current measurement).
## Interface
2023-02-04 08:10:04 -05:00
```cpp
#include "DMM.h"
```
#### Constructor
2022-12-21 15:16:14 -05:00
- **DMM()** constructor.
#### Configuration
2023-02-04 08:10:04 -05:00
- **begin(uint8_t analogPin, float volts = 5.0, uint16_t maxADC = 1023)** configuration.
Note these are the specifications of the ADC used.
2022-12-21 15:16:14 -05:00
- **void setMaxVoltage(float maxVoltage)**
- **float getMaxVoltage()**
- **void setGain(float factor = 1.0)** GAIN e.g. due to voltage divider.
2023-02-04 08:10:04 -05:00
A 25V to 5V divider has a factor = 5.
2022-12-21 15:16:14 -05:00
- **float getGain()** returns the set gain.
2023-02-04 08:10:04 -05:00
#### ReadVolts
One must connect GND of Arduino to the GND of the device.
```
[A0]---- V unknown
[GND]---- GND
or with a divider => setGain(x)
[A0]----[divider]---- V unknown
[GND]----[divider]---- GND
```
- **float readVolts(uint8_t times = 1)** read voltage.
2022-12-21 15:16:14 -05:00
Times can be set to average multiple measurements.
- **float readMilliVolts(uint8_t times = 1)** convenience wrapper.
2023-02-04 08:10:04 -05:00
- **float readNoise(uint8_t times = 1)** measure the noise on the wire.
Assumes connected to constant voltage e.g. GND.
#### ReadOhm
The schema for measuring resistors is based on a simple voltage divider.
See below. This schema can be extended with a selector switch that can
switch between different reference resistors.
```
[GND] ----[ R reference ]----[A0]----[ R unknown ]----[+5V]
```
- **void setReferenceR(uint32_t ohm = 1000)** set the reference resistor.
units are Ohm, default = 1K.
- **uint32_t readOhm(uint8_t times = 1)** read ohm.
Times can be set to average multiple measurements.
- **uint32_t readKiloOhm(uint8_t times = 1)** read ohm.
Times can be set to average multiple measurements.
Character ohm = Ω (ALT-234 or ALT-0216 might work)
2022-12-21 15:16:14 -05:00
#### Calibration
2023-02-04 08:10:04 -05:00
2022-12-21 15:16:14 -05:00
- **float readNoise(uint8_t times = 1)** get noise level for accuracy.
2023-02-04 08:10:04 -05:00
2022-12-21 15:16:14 -05:00
## Operation
2023-02-04 08:10:04 -05:00
Basic operation is to connect the Arduino GND to the projects GND (or - )
and use the configured analog pin to measure a (positive) voltage.
2022-12-21 15:16:14 -05:00
By adding a voltage divider one can measure larger voltages.
The divider factor can be set with **setGain(factor)**.
To elaborate.
- GND, VCC
## Future
#### Functional
2023-02-04 08:10:04 -05:00
2022-12-21 15:16:14 -05:00
- AMPS (how -> measure voltage over a known resistor)
- CAPS (how -> RC timing)
2023-02-04 08:10:04 -05:00
- RC (load 5 seconds)
- disconnect
- measure drop rate / time in micros.
- DIODE (how -> 5V or 0V)
- DigitalRead(INPUT PULLUP) => HIGH or LOW
- or 0.7 volt drop from 5V
2022-12-21 15:16:14 -05:00
#### Must
2023-02-04 08:10:04 -05:00
2022-12-21 15:16:14 -05:00
- update documentation
- update examples
2023-02-04 08:10:04 -05:00
- add use of AREF
2022-12-21 15:16:14 -05:00
- external or internal 1.1 Volt
2023-02-04 08:10:04 -05:00
- **float setOffset(float offset)** adjust the voltage used.
- this is not the voltage the ADC uses internally.
2022-12-21 15:16:14 -05:00
#### Should
2023-02-04 08:10:04 -05:00
2022-12-21 15:16:14 -05:00
- investigate noise
- analogReference(EXTERNAL) for external voltage for build in ADC
- support external ADC e.g. ADS1115 for 16 bit resolution.
#### Could
2023-02-04 08:10:04 -05:00
2022-12-21 15:16:14 -05:00
- multichannel compare
2023-02-04 08:10:04 -05:00
- schema for
2022-12-21 15:16:14 -05:00
- scope functionality?
#### Won't