Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:16 12 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : ads1115 library.

Author Message
crez

Senior Member

Joined: 24/10/2012
Location: Australia
Posts: 152
Posted: 04:41am 03 Feb 2019
Copy link to clipboard 
Print this post

I recall reading that one existed for the micromite for this A/D chip. Can someone please point me to it.

David
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 600
Posted: 09:12am 03 Feb 2019
Copy link to clipboard 
Print this post


I do recall something but don't remember as it was awhile back.
Here is a test setup I did with the ADS1115. The jest of it was from
some python code from Adafruit.


Option explicit

Dim float adc01,adc23,adc0,adc1,adc2,adc3,getvolts,tmp,ofs=-2.67
Dim startime$
RTC gettime
RTC SETREG &h07,&h92
startime$=Time$
Dim fs=2,p=0
I2C open 100,5000

Box 0, 0, MM.HRes-1, MM.VRes-1, 8, , RGB(yellow)

PWM 2,1000,50
'

'SetTick 3600000,settime,1 'update time from RTC hourly


SetTick 750,ADC,4 'periodical reading

clr

Do

locate 5,1
Print startime$;" ";Time$;" "
Print "Volts A01 is "; adc01
Print "Volts A23 is "; adc23
Print "----------------------"
Print "Volts A0 is "; adc0
Print ((adc0-.4)/0.2925);"pH "
Print
Print "Volts A1 is "; adc1
Print (adc1-2.7315)*100
Print
Print "Volts A2 is "; adc2
Print
Print "Temp ";Str$((adc2-2.7315)*100,0,3);"C "
Print "Temp ";Str$((adc2-2.7315)*100*(9/5)+32,0,3);"F "
'Print Str$((adc2-2.7315)*100*(9/5)+32+ofs,0,4);" F "
Print "Volts A3 is "; adc3
Print "--------------------"
tmp=TEMPR(16)
Print "The temp ";Str$(tmp,0,3);" C ",Str$(tmp*1.8+32,0,3);" F "


Text MM.HRes/2,30,Date$+" "+Time$,cm,1,fs,RGB(red),RGB(yellow)
Text 10,40,"A01 is "+Str$(adc01,2,5),,1,fs,RGB(blue),RGB(yellow)
Text 10,65,"A23 is "+Str$(adc23,2,5),,1,fs,RGB(blue),RGB(yellow)
Text 10,90,"A0 is "+Str$(adc0,2,5),,1,fs,RGB(blue),RGB(yellow)
Text 10,115,"A1 is "+Str$(adc1,2,5),,1,fs,RGB(blue),RGB(yellow)
Text 10,140,"A2 is "+Str$(adc2,2,5),,1,fs,RGB(blue),RGB(yellow)
Text 10,165,"A3 is "+Str$(adc3,2,5),,1,fs,RGB(blue),RGB(yellow)
Text 10,190,"Tmp is "+Str$(tmp*1.8+32),,1,fs,RGB(blue),RGB(yellow)
Loop

Sub ADC ' ADC reading
Local cfreg,cnv,cfhi,cflo

cfreg = &h01: cnv =&h00 ' rate 128 sps no comp operations

cfhi = &h83 : cflo= &h81 'reading Dif Ain0 , Ain1,FS= +/- 4.096 , 128 sps
I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg
I2C write &h48,0,1,cnv ' adr 48 point to conversion reg
getadc
adc01 = getvolts
'
cfhi = &hB3 : cflo= &h81 ' reading Dif Ain2 , Ain3,FS= +/- 4.096 , 128 sps
I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg
I2C write &h48,0,1,cnv ' adr 48 point to conversion reg
getadc
adc23 = getvolts
'
cfhi = &hC3 : cflo= &h81 ' reading single Ain0,FS= +/- 4.096 , 128 sps
I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg
I2C write &h48,0,1,cnv ' adr 48 point to conversion reg
getadc
adc0 = getvolts
'
cfhi = &hD3 : cflo= &h81 ' reading single Ain1,FS= +/- 4.096 , 128 sps
I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg
I2C write &h48,0,1,cnv ' adr 48 point to conversion reg
getadc
adc1 = getvolts
'
cfhi = &hE3 : cflo= &h81 ' reading single Ain2,FS= +/- 4.096 , 128 sps
I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg
I2C write &h48,0,1,cnv ' adr 48 point to conversion reg
getadc
adc2 = getvolts
'
cfhi = &hf3 : cflo= &h81 ' reading single Ain1,FS= +/- 4.096 , 128 sps
I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg
I2C write &h48,0,1,cnv ' adr 48 point to conversion reg
getadc
adc3 = getvolts

End Sub

Sub getadc
Local adcv
Local integer adcrd(2) 'to receive 2 bytes

Pause 100
I2C read &h48,0,2,adcrd()

adcv= (adcrd(0)<<8) Or adcrd(1)
If adcv > &H7fff Then adcv = adcv - &HFFFF
getvolts = adcv *(4.096/32768)

End Sub

Sub settime
RTC gettime
Pause 50

End Sub

Sub clr
Print Chr$(27)+"[f" : Print Chr$(27)+"[2J"
End Sub

Sub locate x,y
Print Chr$(27)+"["+Str$(X)+";"+Str$(Y)+"f";
End Sub
 
crez

Senior Member

Joined: 24/10/2012
Location: Australia
Posts: 152
Posted: 10:59am 03 Feb 2019
Copy link to clipboard 
Print this post

Thanks very much for that. There are enough comments to make my job pretty easy.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025