reef-pi / drivers

Various sensors, controller and IC drivers for reef-pi
Other
5 stars 17 forks source link

(feat)add initial implementation of ph board #10

Closed ranjib closed 5 years ago

ranjib commented 5 years ago

@robertobuti @theatrus review please

ranjib commented 5 years ago

Found an example, periph.io driver: https://github.com/MichaelS11/go-ads

theatrus commented 5 years ago

For reference, here is my test Python for the Pico adapter. I don't set the gain register in this example (writes to register 1)

import smbus
import struct
import time

def signed(number):
     return struct.unpack('h', struct.pack('>H', number))

bus = smbus.SMBus(1)
addr = 0x48

while True:
     data = bus.read_word_data(addr, 0x0)
     print signed(data)
     time.sleep(1.0)
ranjib commented 5 years ago

ph Conversion logic:

phValue= adcValue*5.0/1024/6; //convert the analog into millivolt
phValue=3.5*phValue+Offset;             //convert the millivolt into pH value
theatrus commented 5 years ago

Any value to millivolts instead of just calibrating on ADC counts directly? In the end it won't matter.

(The Pico board ADC uses a 2.5V reference, the reference is halved to drive the common signal)