[riot-notifications] [RIOT-OS/RIOT] Driver ph oem (#10983)

Igor Knippenberg notifications at github.com
Mon Feb 11 01:23:26 CET 2019


This request adds support for the [Atlas Scientific pH OEM circuit](https://www.atlas-scientific.com/product_pages/oem/oem_ph.html). The sensor can accurately measure the pH level in a range of 0.001 - 14.000 with any commercially available pH electrode (with or without BNC, depending on the custom PCB). It doesn't integrate a temperature sensor, so an external sensor needs to provide the temperature in celcius. The device supports speeds of 10-100 kHz so the board I2C speed needs to be set <= I2C_SPEED_NORMAL

**Driver features:**
- Turning internal LED off/on for lower power consumption
- Changing the I2C device address in the sensor as well as in the device descriptor at runtime
- 1/2/3 point calibration of the electrode (including clearing and checking current calibration state)
- Set the temperature compensation of the sensor for error compensation 
- Read the compensation to verify at which temperature a reading was taken
- Device enable/disable functionality which turns the device on/off by setting a defined GPIO pin high/low. This is a custom PCB feature and not part of the sensor itself. The PCB needs some form of power switch for this feature. PH value is highly inaccurate after powering the device on, so unfortunately one needs to wait arround 2 minutes for it to stabilize. The enable pin is undefined by default.
- Interrupt capability via a dedicated pin which fires when a reading was taken (can be set to rising, falling or both). Pin is undefined by default. The alternative approach when the interrupt pin is undefined is to poll the sensor every 20ms till a reading was taken (around 420ms)
- Support for SAUL with reading the pH value and writing the temperature compensation.

**TODO:**
- Make the reading of the pH via SAUL possible when enable and/or interrupt pin are/is defined


Log output with enable and interrupt pin defined (without calibration process, because that resets the previous calibrations):

```
2019-02-11 00:47:24,167 - INFO # main(): This is RIOT! (Version: 2019.04-devel-161-gd1412-driver_ph_oem)
2019-02-11 00:47:24,168 - INFO # Atlas Scientific pH OEM sensor driver test application
2019-02-11 00:47:24,168 - INFO # 
2019-02-11 00:47:24,169 - INFO # Initializing pH OEM sensor at I2C_0, address 0x65...[OK]
2019-02-11 00:47:24,170 - INFO # Turning LED off... [OK]
2019-02-11 00:47:25,723 - INFO # Turning LED on... [OK]
2019-02-11 00:47:25,727 - INFO # Setting device address to 0x66... [OK]
2019-02-11 00:47:25,742 - INFO # Setting device address back to the default address 0x65... [OK]
2019-02-11 00:47:25,743 - INFO # Setting interrupt pin to option 8...[OK]
2019-02-11 00:47:25,744 - INFO # Enabling interrupt pin... [OK]
2019-02-11 00:47:25,744 - INFO # Enabling device... [OK]
2019-02-11 00:47:27,196 - INFO # 
2019-02-11 00:47:27,197 - INFO # [IRQ - Reading done]
2019-02-11 00:47:27,202 - INFO # pH value raw: 6972
2019-02-11 00:47:27,202 - INFO # pH reading was taken at 2200 Celsius
2019-02-11 00:47:33,200 - INFO # 
2019-02-11 00:47:33,200 - INFO # [IRQ - Reading done]
2019-02-11 00:47:33,206 - INFO # pH value raw: 7148
2019-02-11 00:47:33,206 - INFO # pH reading was taken at 2200 Celsius
2019-02-11 00:47:39,203 - INFO # 
2019-02-11 00:47:39,204 - INFO # [IRQ - Reading done]
2019-02-11 00:47:39,208 - INFO # pH value raw: 7213
2019-02-11 00:47:39,209 - INFO # pH reading was taken at 2200 Celsius
```

Log output with SAUL example:

```
2019-02-11 00:57:51,382 - INFO # main(): This is RIOT! (Version: 2019.04-devel-161-gd1412-driver_ph_oem)
2019-02-11 00:57:51,383 - INFO # Welcome to RIOT!
2019-02-11 00:57:51,383 - INFO # 
2019-02-11 00:57:51,385 - INFO # Type `help` for help, type `saul` to see all SAUL devices
2019-02-11 00:57:51,385 - INFO # 
> saul
2019-02-11 00:57:56,076 - INFO #  saul
2019-02-11 00:57:56,077 - INFO # ID	Class		Name
2019-02-11 00:57:56,077 - INFO # #0	SENSE_ANALOG	ADC1
2019-02-11 00:57:56,078 - INFO # #1	SENSE_ANALOG	ADC2
2019-02-11 00:57:56,078 - INFO # #2	SENSE_ANALOG	ADC3
2019-02-11 00:57:56,079 - INFO # #3	ACT_SWITCH	LED(red)
2019-02-11 00:57:56,079 - INFO # #4	ACT_SWITCH	LED(green)
2019-02-11 00:57:56,080 - INFO # #5	ACT_SWITCH	LED(blue)
2019-02-11 00:57:56,080 - INFO # #6	SENSE_BTN	Button(User)
2019-02-11 00:57:56,081 - INFO # #7	SENSE_PH	pH OEM sensor
> saul read 7
2019-02-11 00:58:02,534 - INFO #  saul read 7
2019-02-11 00:58:03,038 - INFO # Reading from #7 (pH OEM sensor|SENSE_PH)
2019-02-11 00:58:03,038 - INFO # Data:	       7082 mpH
> saul write 7 2155
2019-02-11 00:58:19,133 - INFO #  saul write 7 2155
2019-02-11 00:58:19,133 - INFO # Writing to device #7 - pH OEM sensor
2019-02-11 00:58:19,134 - INFO # Data:	       2155
2019-02-11 00:58:19,135 - INFO # data successfully written to device #7
> 
```
You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/10983

-- Commit Summary --

  * drivers/ph_oem: Initial implementation of the pH OEM sensor
  * drivers/saul: Added pH
  * sys/phydat: Added unit for pH
  * tests/driver_ph_oem: Added a test application for the pH OEM driver
  * sys/auto_init: Added auto initialization for pH OEM driver

-- File Changes --

    M drivers/Makefile.dep (6)
    M drivers/Makefile.include (4)
    A drivers/include/ph_oem.h (385)
    M drivers/include/saul.h (1)
    A drivers/ph_oem/Makefile (1)
    A drivers/ph_oem/include/ph_oem_params.h (79)
    A drivers/ph_oem/include/ph_oem_regs.h (61)
    A drivers/ph_oem/ph_oem.c (449)
    A drivers/ph_oem/ph_oem_saul.c (68)
    M drivers/saul/saul_str.c (1)
    M sys/auto_init/auto_init.c (4)
    A sys/auto_init/saul/auto_init_ph_oem.c (76)
    M sys/include/phydat.h (2)
    M sys/phydat/phydat_str.c (1)
    A tests/driver_ph_oem/Makefile (17)
    A tests/driver_ph_oem/README.md (18)
    A tests/driver_ph_oem/main.c (301)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/10983.patch
https://github.com/RIOT-OS/RIOT/pull/10983.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10983
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190210/e0bffec2/attachment.html>


More information about the notifications mailing list