ArduinoGeneral

Reading SEN0219 on a Raspberry Pi using ADS1115

userHead tony 2020-12-31 01:34:26 1082 Views3 Replies
Hi,

I am having inconsistent weird readings. I modified the code from the Wiki to *what I think* is correct… instead of "float voltage = sensorValue*(5000/1024.0);" I just took the reading from the ADC and divided by 10. The ADC is set to a gain of 1 and that seemed to make it *right* for lack of a better term. I can't seem to find any documentation for connecting this to a Raspberry Pi, so could someone let me know if I am doing this right or help me out please? My Code is below.
Code: Select all
import sys
import Adafruit_DHT
import time
import Adafruit_ADS1x15
import RPi.GPIO as GPIO
adc = Adafruit_ADS1x15.ADS1115()
GAIN = 1
while True:
	values = [0]*4
	for i in range(4):
		values[i] = adc.read_adc(i, gain=GAIN)
	m2_value=values[1]
	CO2_voltage = m2_value*(1/10) 
	if(CO2_voltage == 0): CO2_value = "Fault"
	elif (CO2_voltage < 400): CO2_value = "PreHeating"
	else:
		voltage_dif = CO2_voltage-400
		CO2_value = voltage_dif*50.0/16.0

Thanks!
Tony
2021-01-08 14:07:35 https://github.com/DFRobot/DFRobot_ADS1 ... yPi/Python
In order to download this library, you may need to download the entire ADS1115 Arduino library
userHeadPic 347945801
2021-01-08 00:33:59 Thanks for the response! I have searched around but am unable to find this library, do you have a link? userHeadPic tony
2021-01-05 09:54:56 Hello, the library of this sensor contains the Python code for connecting to the Raspberry Pi. You can find it in the downloaded Arduino library, which may contain the information you want userHeadPic 347945801