Commit 1ce5c77f authored by Ravindu Dolawatta's avatar Ravindu Dolawatta

Final Sync

parent 998170e5
:Author: radixdol
:Email:
:Date: 05/08/2023
:Revision: version#
:License: Public Domain
= Project: {Project}
Describe your project
== Step 1: Installation
Please describe the steps to install this project.
For example:
1. Open this file
2. Edit as you like
3. Release to the World!
== Step 2: Assemble the circuit
Assemble the circuit following the diagram layout.png attached to the sketch
== Step 3: Load the code
Upload the code contained in this sketch on to your board
=== Folder structure
....
sketch123 => Arduino sketch folder
├── sketch123.ino => main Arduino file
├── schematics.png => (optional) an image of the required schematics
├── layout.png => (optional) an image of the layout
└── ReadMe.adoc => this file
....
=== License
This project is released under a {License} License.
=== Contributing
To contribute to this project please contact:
=== BOM
Add the bill of the materials you need for this project.
|===
| ID | Part name | Part number | Quantity
| R1 | 10k Resistor | 1234-abcd | 10
| L1 | Red LED | 2345-asdf | 5
| A1 | Arduino Zero | ABX00066 | 1
|===
=== Help
This document is written in the _AsciiDoc_ format, a markup language to describe documents.
If you need help you can search the http://www.methods.co.nz/asciidoc[AsciiDoc homepage]
or consult the http://powerman.name/doc/asciidoc[AsciiDoc cheatsheet]
#define SECRET_SSID ""
#define SECRET_OPTIONAL_PASS ""
#define SECRET_DEVICE_KEY ""
{
"cpu": {
"fqbn": "esp8266:esp8266:nodemcuv2:baud=115200,dbg=Disabled,eesz=4M,exception=disabled,ip=lm2f,lvl=None____,vt=flash,wipe=none,xtal=80",
"name": "NodeMCU 1.0 (ESP-12E Module)",
"type": "serial"
},
"secrets": [
{
"name": "SECRET_DEVICE_KEY",
"value": ""
},
{
"name": "SECRET_OPTIONAL_PASS",
"value": ""
},
{
"name": "SECRET_SSID",
"value": ""
}
],
"included_libs": []
}
\ No newline at end of file
// Code generated by Arduino IoT Cloud, DO NOT EDIT.
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
const char DEVICE_LOGIN_NAME[] = "16ab09cb-ce60-4240-bbe6-4ea702ff8365";
const char SSID[] = SECRET_SSID; // Network SSID (name)
const char PASS[] = SECRET_OPTIONAL_PASS; // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[] = SECRET_DEVICE_KEY; // Secret device password
void onCChange();
void onCCIChange();
void onCDiffChange();
void onCurrentBChange();
void onCurrentCAPChange();
void onCurrentI650Change();
void onCurrentI940Change();
void onCurrentTChange();
void onDHT11HChange();
void onDHT11TChange();
void onDiffBChange();
void onDiffCAPChange();
void onDiffTChange();
void onLdrChange();
void onNNIChange();
void onSoilmChange();
void onTchlChange();
void onThicknessChange();
void onThicknessDiffChange();
void onTnitChange();
void onVSPADChange();
void onZUNOFeedChange();
float C;
float CCI;
float C_diff;
float current_B;
float current_CAP;
float current_I_650;
float current_I_940;
float current_T;
float DHT11_H;
float DHT11_T;
float diff_B;
float diff_CAP;
float diff_T;
float ldr;
float NNI;
float soilm;
float tchl;
float thickness;
float thickness_diff;
float tnit;
float V_SPAD;
bool z_UNO_feed;
void initProperties(){
ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
ArduinoCloud.addProperty(C, READWRITE, 30 * SECONDS, onCChange);
ArduinoCloud.addProperty(CCI, READWRITE, 30 * SECONDS, onCCIChange);
ArduinoCloud.addProperty(C_diff, READWRITE, 30 * SECONDS, onCDiffChange);
ArduinoCloud.addProperty(current_B, READWRITE, 30 * SECONDS, onCurrentBChange);
ArduinoCloud.addProperty(current_CAP, READWRITE, 30 * SECONDS, onCurrentCAPChange);
ArduinoCloud.addProperty(current_I_650, READWRITE, 30 * SECONDS, onCurrentI650Change);
ArduinoCloud.addProperty(current_I_940, READWRITE, 30 * SECONDS, onCurrentI940Change);
ArduinoCloud.addProperty(current_T, READWRITE, 30 * SECONDS, onCurrentTChange);
ArduinoCloud.addProperty(DHT11_H, READWRITE, 30 * SECONDS, onDHT11HChange);
ArduinoCloud.addProperty(DHT11_T, READWRITE, 60 * SECONDS, onDHT11TChange);
ArduinoCloud.addProperty(diff_B, READWRITE, 30 * SECONDS, onDiffBChange);
ArduinoCloud.addProperty(diff_CAP, READWRITE, 30 * SECONDS, onDiffCAPChange);
ArduinoCloud.addProperty(diff_T, READWRITE, 30 * SECONDS, onDiffTChange);
ArduinoCloud.addProperty(ldr, READWRITE, 30 * SECONDS, onLdrChange);
ArduinoCloud.addProperty(NNI, READWRITE, 30 * SECONDS, onNNIChange);
ArduinoCloud.addProperty(soilm, READWRITE, 30 * SECONDS, onSoilmChange);
ArduinoCloud.addProperty(tchl, READWRITE, 30 * SECONDS, onTchlChange);
ArduinoCloud.addProperty(thickness, READWRITE, 30 * SECONDS, onThicknessChange);
ArduinoCloud.addProperty(thickness_diff, READWRITE, 30 * SECONDS, onThicknessDiffChange);
ArduinoCloud.addProperty(tnit, READWRITE, 30 * SECONDS, onTnitChange);
ArduinoCloud.addProperty(V_SPAD, READWRITE, 30 * SECONDS, onVSPADChange);
ArduinoCloud.addProperty(z_UNO_feed, READWRITE, ON_CHANGE, onZUNOFeedChange);
}
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);
/*
Coded by Ravindu Dolawatta
Leaf Thickness Meter (LTM)
*/
#include "A_LTM.h"
A_LTM::A_LTM(int inputPIN_in, float RefVolt, int BitPrecision, float sensorSensitivity_in){
predefinedMagneticFluxDensity = 1700; //Gauss
predefinedThickness = 0.4284; //mm
initialMagneticFluxDensity = 1700; //Gauss
initialThickness = 0.4284; //mm
finalMagneticFluxDensity = 0; //Gauss
finalThickness = 0; //mm
initialMillis = 0;
finalMillis = 0;
inputPIN = 0;
sensorSensitivity = 1.9;
sensitivityCoefficient = 2.56;
zeroGaussPoint_ADC = 511;
zeroGaussPoint_Volt = 2.5;
count=1; val =0.0;
inputPIN = inputPIN_in;
sensorSensitivity = sensorSensitivity_in;
sensitivityCoefficient = 1/(((sensorSensitivity_in/1000)/RefVolt)*pow(2,BitPrecision));
zeroGaussPoint_ADC = (pow(2,BitPrecision)/2)-1;
roofCurtainStatus = 0;
}
void A_LTM::calcLTM_adcval(float val_in, int rounds){
val += val_in;
if (count>=rounds){
val = val/(float)rounds;
initialMagneticFluxDensity = finalMagneticFluxDensity;
finalMagneticFluxDensity = sensitivityCoefficient * (val-zeroGaussPoint_ADC);
convertMagneticFluxDensityToThickness();
count =1; val =0.0;
return;
}
count++;
return;
}
void A_LTM::calcLTM_voltage(float val_in){
initialMagneticFluxDensity = finalMagneticFluxDensity;
if(val_in > zeroGaussPoint_Volt) finalMagneticFluxDensity = (1000/sensorSensitivity) * (val_in-zeroGaussPoint_Volt);
else finalMagneticFluxDensity = (1000/sensorSensitivity) * (zeroGaussPoint_Volt-val_in);
convertMagneticFluxDensityToThickness();
}
void A_LTM::calcLTM_voltage(float val_in, int rounds){
val += val_in;
if (count>=rounds){
val /= (float)rounds;
initialMagneticFluxDensity = finalMagneticFluxDensity;
if(val > zeroGaussPoint_Volt) finalMagneticFluxDensity = (1000/sensorSensitivity) * (val-zeroGaussPoint_Volt);
else finalMagneticFluxDensity = (1000/sensorSensitivity) * (zeroGaussPoint_Volt-val);
convertMagneticFluxDensityToThickness();
count =1; val =0;
return;
}
count++;
return;
}
void A_LTM::calcLTM_voltage(float val_in, int rounds, float zeroGaussPoint_Volt_in){
zeroGaussPoint_Volt = zeroGaussPoint_Volt_in;
val += val_in;
if (count>=rounds){
val /= (float)rounds;
initialMagneticFluxDensity = finalMagneticFluxDensity;
if(val > zeroGaussPoint_Volt) finalMagneticFluxDensity = (1000/sensorSensitivity) * (val-zeroGaussPoint_Volt);
else finalMagneticFluxDensity = (1000/sensorSensitivity) * (zeroGaussPoint_Volt-val);
convertMagneticFluxDensityToThickness();
count =1; val =0;
return;
}
count++;
return;
}
void A_LTM::convertMagneticFluxDensityToThickness(){
initialThickness = finalThickness;
finalThickness = 61.625 * exp(-0.003 * finalMagneticFluxDensity);
}
void A_LTM::calcRoofCurtainStatus(){
if(getCurrentThickness() > 0.6){
roofCurtainStatus = 0; //full shade
} else roofCurtainStatus = 1; //no shade
}
//getters
float A_LTM::getCurrentMagneticFluxDensity(){
return finalMagneticFluxDensity;
}
float A_LTM::getCurrentThickness(){
return finalThickness;
}
float A_LTM::getRelativeChangeInThickness(){
return finalThickness-predefinedThickness;
}
float A_LTM::getRateOfChangeInThickness(){
initialMillis = finalMillis;
finalMillis = millis();
return ((finalThickness-initialThickness)/((finalMillis-initialMillis)/1000));
}
int A_LTM::getRoofCurtainStatus(){
calcRoofCurtainStatus();
return roofCurtainStatus;
}
#ifndef A_LTM_h
#define A_LTM_h
#include <Arduino.h>
#include <math.h>
//Prototypes
class A_LTM{
private:
float predefinedMagneticFluxDensity;
float predefinedThickness;
float initialMagneticFluxDensity;
float initialThickness;
float finalMagneticFluxDensity;
float finalThickness;
int initialMillis;
int finalMillis;
int inputPIN;
float sensorSensitivity;
float sensitivityCoefficient;
float zeroGaussPoint_ADC;
float zeroGaussPoint_Volt;
int count; float val;
int roofCurtainStatus;
public:
A_LTM(int inputPIN_in, float RefVolt, int BitPrecision, float sensorSensitivity_in);
void calcLTM_adcval(float val_in, int rounds);
void calcLTM_voltage(float val_in);
void calcLTM_voltage(float val_in, int rounds);
void calcLTM_voltage(float val_in, int rounds, float zeroGaussPoint_Volt_in);
void convertMagneticFluxDensityToThickness();
void calcRoofCurtainStatus();
//getters
float getCurrentMagneticFluxDensity();
float getCurrentThickness();
float getRelativeChangeInThickness();
float getRateOfChangeInThickness();
int getRoofCurtainStatus();
};
#endif
/*
Coded by Janinda Induwara
Leaf Nitrogen and Chlorophyll Meter (LNCM)
*/
#include "B_LNCM.h"
B_LNCM::B_LNCM(int PIN_OPT101_in, float RefVolt_in, int BitResolution_in, int POUT_LED940_in, int POUT_LED650_in){
referenceInitialIntensityIR = 71.9965; //62.729166;
referenceInitialIntensityRED = 106.1693; //41.458033;
critNitConc = 2.9;
refSPAD = 50.00;
predefinedNNI = 0.22;
initialIntensityIR = 71.9965;
initialIntensityRED = 106.1693;
finalIntensityIR = 0.0;
finalIntensityRED = 0.0;
initialCCI = 0.0;
initialNNI = 0.0;
initialSPAD = 0.0;
finalCCI = 0.0;
finalNNI = 0.0;
finalSPAD = 0.0;
finalNitConc = 0.0;
finalChlConc = 0.0;
voltageCoefficient = 0.00488;
voltageCoefficient = RefVolt_in/BitResolution_in;
PIN_OPT101 = A1;
POUT_LED940 = 3;
POUT_LED650 = 4;
initialMillis = 0;
finalMillis = 0;
PIN_OPT101 = PIN_OPT101_in;
POUT_LED940 = POUT_LED940_in;
POUT_LED650 = POUT_LED650_in;
pinMode(PIN_OPT101,INPUT);
pinMode(POUT_LED940,OUTPUT);
pinMode(POUT_LED650,OUTPUT);
count = 1; val = 0.0;
FertilizerPumpStatus = 0;
}
//Arduino
void B_LNCM::calcLNCM_arduino(){
initialIntensityIR = finalIntensityIR;
finalIntensityIR = measureIntensity_arduino(POUT_LED940, POUT_LED650);
delay(6000);
initialIntensityRED = finalIntensityRED;
finalIntensityRED = measureIntensity_arduino(POUT_LED650, POUT_LED940);
calcLNCM();
// Serial.print(">IR(mW/cm2):");
// Serial.println(finalIntensityIR,6);
// Serial.print(">RED(mW/cm2):");
// Serial.println(finalIntensityRED,6);
// Serial.print(">CCI:");
// Serial.println(finalCCI,6);
// Serial.print(">SPAD:");
// Serial.println(finalSPAD,6);
// Serial.print(">chl:");
// Serial.println(finalChlConc,6);
// Serial.print(">NNI:");
// Serial.println(finalNNI,6);
// Serial.print(">nit:");
// Serial.println(finalNitConc,6);
delay(6000);
}
float B_LNCM::measureIntensity_arduino(int on_LED_in, int off_LED_in){
int on_LED = on_LED_in;
int off_LED = off_LED_in;
digitalWrite(off_LED,LOW);
digitalWrite(on_LED,HIGH);
delay(1000); //reach photodiode value
int c = 0; /*unsigned long sum = 0;*/ int d =0; float sum_2 = 0;
float val_max = analogRead(PIN_OPT101); float val_min = analogRead(PIN_OPT101);
for(; c < 400; c++){
float reading = analogRead(PIN_OPT101);
if (reading ==0 || reading >=1023) {d++; continue;}
if (reading > val_max) val_max = reading;
if (reading < val_min) val_min = reading;
//Serial.print(">Intensity of Pin "+String(on_LED_in)+":");
//Serial.println(reading,6);
/*sum += reading;*/
}
sum_2 = (val_max + val_min)/2;
/*float cumulative = float(sum/(c-d));*/
digitalWrite(off_LED,LOW);
digitalWrite(on_LED,LOW);
return convertToIntensity(sum_2,'a');
}
//Voltages
void B_LNCM::calcLNCM_voltage(int type, float val_in){
if (type == 940) {
initialIntensityIR = finalIntensityIR;
finalIntensityIR = convertToIntensity(val_in,'v');
} else if (type == 650){
initialIntensityRED = finalIntensityRED;
finalIntensityRED = convertToIntensity(val_in,'v');
}
}
void B_LNCM::calcLNCM_voltage(int type, float val_in, int rounds){
val += val_in;
if (count>=rounds){
if (type == 940) {
initialIntensityIR = finalIntensityIR;
finalIntensityIR = convertToIntensity(val/(float)rounds,'v');
} else if (type == 650){
initialIntensityRED = finalIntensityRED;
finalIntensityRED = convertToIntensity(val/(float)rounds,'v');
}
count =1; val =0;
return;
}
count++;
return;
}
//Conversion
float B_LNCM::convertToIntensity(float input_val, char t){
float y_volt = 0.0;
if (t == 'v'){ //voltage
y_volt = input_val;
} else if (t == 'a'){ //ADC
y_volt = voltageCoefficient * input_val;
//y_volt = (input_val/1024.0)*5.0;
}
float x_irr = 0.0;
if( y_volt >= 0.01 && y_volt < 0.1 )
x_irr = (y_volt - 0.030045)/1.020520;
else if ( y_volt >= 0.1 && y_volt < 1.0 ) {
x_irr = (y_volt - 0.304993)/1.028938;
if (x_irr < 0.0 ) x_irr = (y_volt + 0.610478)/10.185179;
}
else if ( y_volt >= 1.0 && y_volt < 10.0 ) {
x_irr = (y_volt - 3.178953)/1.010221;
if (x_irr < 0.0 ) x_irr = (y_volt + 6.172307)/10.258393;
}
return x_irr*100; //multiplied by 100 to obtain values in mW/cm2
}
void B_LNCM::calcLNCM(){
calcCCI();
calcNNI();
calcNitConc();
calcSPAD();
calcChlConc();
}
//equation chain
void B_LNCM::calcCCI(){
initialCCI = finalCCI;
float irPercentTransmission = (finalIntensityIR/referenceInitialIntensityIR)*100;
float redPercentTransmission = (finalIntensityRED/referenceInitialIntensityRED)*100;
finalCCI = irPercentTransmission/redPercentTransmission;
}
void B_LNCM::calcNNI(){
initialNNI = finalNNI;
finalNNI = 0.0847 * exp(finalSPAD/refSPAD);
}
void B_LNCM::calcNitConc(){
finalNitConc = finalNNI * critNitConc * 10; //T nni in mg/g
//Nitrogen content = NNI x critical nitrogen concentration x 10
//Source: Brassicaceae Plants Response and Tolerance to Nutrient Deficiencies
//critical nit conc = 2.9 mg/g of leaf
}
void B_LNCM::calcSPAD(){
initialSPAD = finalSPAD;
finalSPAD = 60.241 * log(finalCCI) + 12.976;
//SPAD proposed by Design and Implementation of a Low-Cost Chlorophyll Content meter
//finalSPAD = -42.9 + 42.1 * pow(finalCCI,0.215);
//Source: In situ measurement of leaf chlorophyll concentration:analysis of the optical/absolute relationship
//Common Leaf SPAD conversion - Derived by large amount of different leaf species
}
void B_LNCM::calcChlConc(){
finalChlConc = -84.3 + 98.6 * pow(finalCCI,0.505); //T chl in umol/m2 //Common Leaf chl conversion - Derived by large amount of different leaf species
//finalChlConc = -150 + 162 * pow(finalCCI,0.34); //T chl in umol/m2 //Calculation fitted for kohlrabi - a tuber with leaves closely related to Brassica
//Source: In situ measurement of leaf chlorophyll concentration:analysis of the optical/absolute relationship
//finalChlConc = 0.2317 * exp(0.0406 * finalSPAD); //T chl in mg/g
//Soruce: Jian et. el A correlation analysis on chlorophyll content and SPAD value in tomato leaves
}
void B_LNCM::calcFertilizerPumpStatus(){
if(getCurrentNNI() < 0.2){
FertilizerPumpStatus = 1; //pump on
} else FertilizerPumpStatus = 0; //pump off
}
//getters
float B_LNCM::getCurrentRedIntensity(){
return finalIntensityRED;
}
float B_LNCM::getCurrentIRIntensity(){
return finalIntensityIR;
}
float B_LNCM::getCurrentCCI(){
return finalCCI;
}
float B_LNCM::getCurrentNNI(){
return finalNNI;
}
float B_LNCM::getRelativeChangeInNNI(){
return finalNNI - predefinedNNI;
}
float B_LNCM::getRateOfChangeInNNI(){
initialMillis = finalMillis;
finalMillis = millis();
return ((finalNNI-initialNNI)/((finalMillis-initialMillis)/1000));
}
float B_LNCM::getEstimatedNitrogenConcentration(){
return finalNitConc;
}
float B_LNCM::getCurrentSPAD(){
return finalSPAD;
}
float B_LNCM::getRelativeChangeInSPAD(){
return finalSPAD-refSPAD;
}
float B_LNCM::getRateOfChangeInSPAD(){
initialMillis = finalMillis;
finalMillis = millis();
return ((finalSPAD-initialSPAD)/((finalMillis-initialMillis)/1000));
}
float B_LNCM::getEstimatedChlorophyllConcentration(){
return finalChlConc;
}
int B_LNCM::getFertilizerPumpStatus(){
calcFertilizerPumpStatus();
return FertilizerPumpStatus;
}
#ifndef B_LNCM_h
#define B_LNCM_h
#include <Arduino.h>
#include <math.h>
//Prototypes
class B_LNCM {
private:
float referenceInitialIntensityIR;
float referenceInitialIntensityRED;
float critNitConc;
float refSPAD;
float predefinedNNI;
float initialIntensityIR;
float initialIntensityRED;
float finalIntensityIR;
float finalIntensityRED;
float initialCCI;
float initialNNI;
float initialSPAD;
float finalCCI;
float finalNNI;
float finalSPAD;
float finalNitConc;
float finalChlConc;
float voltageCoefficient;
int PIN_OPT101;
int POUT_LED940;
int POUT_LED650;
int initialMillis;
int finalMillis;
int count; float val;
int FertilizerPumpStatus;
public:
B_LNCM(int PIN_OPT101_in, float RefVolt_in, int BitPrecision_in, int POUT_LED940_in, int POUT_LED650_in);
void calcCCI();
void calcNNI();
void calcNitConc();
void calcSPAD();
void calcChlConc();
void calcFertilizerPumpStatus();
void calcLNCM();
float convertToIntensity(float Volt_input, char t);
float measureIntensity_arduino(int on_LED_in, int off_LED_in );
void calcLNCM_arduino();
void calcLNCM_voltage(int type, float val_in);
void calcLNCM_voltage(int type, float val_in, int rounds);
float getCurrentRedIntensity();
float getCurrentIRIntensity();
float getCurrentCCI();
float getCurrentNNI();
float getRelativeChangeInNNI();
float getRateOfChangeInNNI();
float getEstimatedNitrogenConcentration();
float getCurrentSPAD();
float getRelativeChangeInSPAD();
float getRateOfChangeInSPAD();
float getEstimatedChlorophyllConcentration();
int getFertilizerPumpStatus();
};
#endif
/*
Coded by Kavindu Rathnayake
Leaf Capacitance Meter (LCM)
*/
#include "C_LCM.h"
C_LCM::C_LCM(int PIN_CHARGE_in, int PIN_DISCHARGE_in, int MAX_ADC_VALUE_in){
predefinedCapacitance = 500; //pF
initialCapacitance = 0;
finalCapacitance = 0;
initialMillis = 0;
finalMillis = 0;
PIN_CHARGE = PIN_CHARGE_in;
PIN_DISCHARGE = PIN_DISCHARGE_in;
pinMode(PIN_CHARGE, OUTPUT);
pinMode(PIN_DISCHARGE, OUTPUT);
IN_STRAY_CAP_TO_GND = 24.48; //initially this was 30.00
IN_EXTRA_CAP_TO_GND = 0.0;
IN_CAP_TO_GND = IN_STRAY_CAP_TO_GND + IN_EXTRA_CAP_TO_GND;
MAX_ADC_VALUE = MAX_ADC_VALUE_in;
WaterPumpStatus = 0;
}
float C_LCM::measure_LCM(){
pinMode(PIN_DISCHARGE, INPUT);
digitalWrite(PIN_CHARGE, HIGH);
int val = analogRead(PIN_DISCHARGE);
//Clear everything for next measurement
digitalWrite(PIN_CHARGE, LOW);
pinMode(PIN_DISCHARGE, OUTPUT);
//Calculate and print result
float capacitance = ((float)val * IN_CAP_TO_GND / (float)(MAX_ADC_VALUE - val));
float corrected_capacitance = 0.5257 * capacitance - 26.488;
return corrected_capacitance;
}
void C_LCM::calcLCM_arduino(){
float val_max = measure_LCM(); float val_min = measure_LCM();
for(int c = 0; c<400; c++){
float reading = measure_LCM();
if (reading > val_max) val_max = reading;
if (reading < val_min) val_min = reading;
delay(10);
}
initialCapacitance = finalCapacitance;
finalCapacitance = (val_max + val_min)/2;
}
void C_LCM::calcWaterPumpStatus(){
if(getCurrentCapacitance() < 300){
WaterPumpStatus = 1; //pump on
} else WaterPumpStatus = 0; //pump off
}
//getters
float C_LCM::getCurrentCapacitance(){
return finalCapacitance;
}
float C_LCM::getRelativeChangeInCapacitance(){
return finalCapacitance-predefinedCapacitance;
}
float C_LCM::getRateOfChangeInCapacitance(){
initialMillis = finalMillis;
finalMillis = millis();
return ((finalCapacitance-initialCapacitance)/((finalMillis-initialMillis)/1000));
}
int C_LCM::getWaterPumpStatus(){
calcWaterPumpStatus();
return WaterPumpStatus;
}
#ifndef C_LCM_h
#define C_LCM_h
#include <Arduino.h>
#include <math.h>
//Prototypes
class C_LCM {
private:
float predefinedCapacitance;
float initialCapacitance;
float finalCapacitance;
int initialMillis;
int finalMillis;
int PIN_CHARGE;
int PIN_DISCHARGE;
float IN_STRAY_CAP_TO_GND;
float IN_EXTRA_CAP_TO_GND;
float IN_CAP_TO_GND = IN_STRAY_CAP_TO_GND + IN_EXTRA_CAP_TO_GND;
int MAX_ADC_VALUE;
int WaterPumpStatus;
public:
C_LCM(const int PIN_CHARGE_in, const int PIN_DISCHARGE_in, const int MAX_ADC_VALUE_in);
float measure_LCM();
void calcLCM_arduino();
void calcWaterPumpStatus();
//getters
float getCurrentCapacitance();
float getRelativeChangeInCapacitance();
float getRateOfChangeInCapacitance();
int getWaterPumpStatus();
};
#endif
/*
Coded by Shenita Alexander
Leaf Surface Temperature Meter (LSTM)
*/
#include "D_LSTM.h"
D_LSTM::D_LSTM(){
//constructor
predefinedLeafTemperature = 26;
predefinedTemperatureDiff = 1;
initialAirTemperature = 27;
initialLeafTemperature = 26;
initialTemperatureDiff = 1;
finalAirTemperature = 0;
finalLeafTemperature = 0;
finalTemperatureDiff = 0;
initialMillis = 0;
finalMillis = 0;
FansStatus = 0;
}
void D_LSTM::calcLSTM_arduino(float leafTemperature_in, float airTemperature_in){
initialLeafTemperature = finalLeafTemperature;
initialAirTemperature = finalAirTemperature;
initialTemperatureDiff = finalTemperatureDiff;
initialMillis = finalMillis;
finalLeafTemperature = leafTemperature_in;
finalAirTemperature = airTemperature_in;
finalTemperatureDiff = finalAirTemperature-finalLeafTemperature;
finalMillis = millis();
}
void D_LSTM::calcFansStatus(){
if(getRelativeChangeInLeafTemperature() > 1 ){
FansStatus = 1; //fans on
} else FansStatus = 0; //fans off
}
//getters
float D_LSTM::getCurrentLeafTemperature(){
return finalLeafTemperature;
}
float D_LSTM::getRelativeChangeInLeafTemperature(){
return finalLeafTemperature-predefinedLeafTemperature;
}
float D_LSTM::getRateOfChangeInLeafTemperature(){
return (finalLeafTemperature-initialLeafTemperature)/((finalMillis-initialMillis)/1000);
}
float D_LSTM::getTemperatureDiff(){
return finalTemperatureDiff;
}
float D_LSTM::getRelativeChangeInTemperatureDiff(){
return finalTemperatureDiff-predefinedTemperatureDiff;
}
float D_LSTM::getRateOfChangeInTemperatureDiff(){
return (finalTemperatureDiff-initialTemperatureDiff)/((finalMillis-initialMillis)/1000);
}
int D_LSTM::getFansStatus(){
calcFansStatus();
return FansStatus;
}
#ifndef D_LSTM_h
#define D_LSTM_h
#include <Arduino.h>
#include <math.h>
//Prototypes
class D_LSTM {
private:
float predefinedLeafTemperature;
float predefinedTemperatureDiff;
float initialAirTemperature;
float initialLeafTemperature;
float initialTemperatureDiff;
float finalAirTemperature;
float finalLeafTemperature;
float finalTemperatureDiff;
int initialMillis;
int finalMillis;
int FansStatus;
public:
D_LSTM();
void calcLSTM_arduino(float leafTemperature_in, float airTemperature_in);
void calcFansStatus();
//getters
float getCurrentLeafTemperature();
float getRelativeChangeInLeafTemperature();
float getRateOfChangeInLeafTemperature();
float getTemperatureDiff();
float getRelativeChangeInTemperatureDiff();
float getRateOfChangeInTemperatureDiff();
int getFansStatus();
};
#endif
This diff is collapsed.
This diff is collapsed.
//ADS1256 header file
/*
Name: ADS1256.h
Created: 2022/07/14
Author: Curious Scientist
Editor: Notepad++
Comment: Visit https://curiousscientist.tech/blog/ADS1256-custom-library
*/
#ifndef _ADS1256_h
#define _ADS1256_h
//Differential inputs
#define DIFF_0_1 0b00000001 //A0 + A1 as differential input
#define DIFF_2_3 0b00100011 //A2 + A3 as differential input
#define DIFF_4_5 0b01000101 //A4 + A5 as differential input
#define DIFF_6_7 0b01100111 //A6 + A7 as differential input
//Single-ended inputs
#define SING_0 0b00001111 //A0 + GND (common) as single-ended input
#define SING_1 0b00011111 //A1 + GND (common) as single-ended input
#define SING_2 0b00101111 //A2 + GND (common) as single-ended input
#define SING_3 0b00111111 //A3 + GND (common) as single-ended input
#define SING_4 0b01001111 //A4 + GND (common) as single-ended input
#define SING_5 0b01011111 //A5 + GND (common) as single-ended input
#define SING_6 0b01101111 //A6 + GND (common) as single-ended input
#define SING_7 0b01111111 //A7 + GND (common) as single-ended input
//PGA settings
#define PGA_1 0b00000000 //± 5 V
#define PGA_2 0b00000001 // ± 2.5 ±
#define PGA_4 0b00000010 //± 1.25 ±
#define PGA_8 0b00000011 //± 625 mV
#define PGA_16 0b00000100 //± 312.5 mV
#define PGA_32 0b00000101 //+ 156.25 mV
#define PGA_64 0b00000110 // ± 78.125 mV
//Datarate
#define DRATE_30000SPS 0b11110000
#define DRATE_15000SPS 0b11100000
#define DRATE_7500SPS 0b11010000
#define DRATE_3750SPS 0b11000000
#define DRATE_2000SPS 0b10110000
#define DRATE_1000SPS 0b10100001
#define DRATE_500SPS 0b10010010
#define DRATE_100SPS 0b10000010
#define DRATE_60SPS 0b01110010
#define DRATE_50SPS 0b01100011
#define DRATE_30SPS 0b01010011
#define DRATE_25SPS 0b01000011
#define DRATE_15SPS 0b00110011
#define DRATE_10SPS 0b00100011
#define DRATE_5SPS 0b00010011
#define DRATE_2SPS 0b00000011
//Status register
#define BITORDER_MSB 0
#define BITORDER_LSB 1
#define ACAL_DISABLED 0
#define ACAL_ENABLED 1
#define BUFFER_DISABLED 0
#define BUFFER_ENABLED 1
//Register addresses
#define STATUS_REG 0x00
#define MUX_REG 0x01
#define ADCON_REG 0x02
#define DRATE_REG 0x03
#define IO_REG 0x04
#define OFC0_REG 0x05
#define OFC1_REG 0x06
#define OFC2_REG 0x07
#define FSC0_REG 0x08
#define FSC1_REG 0x09
#define FSC2_REG 0x0A
//Command definitions
#define WAKEUP 0b00000000
#define RDATA 0b00000001
#define RDATAC 0b00000011
#define SDATAC 0b00001111
#define RREG 0b00010000
#define WREG 0b01010000
#define SELFCAL 0b11110000
#define SELFOCAL 0b11110001
#define SELFGCAL 0b11110010
#define SYSOCAL 0b11110011
#define SYSGCAL 0b11110100
#define SYNC 0b11111100
#define STANDBY 0b11111101
#define RESET 0b11111110
//----------------------------------------------------------------
class ADS1256
{
public:
int DRDY_pin;
int RESET_pin;
int SYNC_pin;
int CS_pin;
//Constructor
ADS1256(int DRDY_pin, int RESET_pin, int SYNC_pin, int CS_pin, float VREF);
//Initializing function
void InitializeADC();
//ADS1256(int drate, int pga, int byteOrder, bool bufen);
//Read a register
long readRegister(uint8_t registerAddress);
//Write a register
void writeRegister(uint8_t registerAddress, uint8_t registerValueToWrite);
//Individual methods
void setDRATE(int drate);
void setPGA(int pga);
void setMUX(int mux);
void setByteOrder(int byteOrder);
void setBuffer(int bufen);
void setAutoCal(int acal);
void setGPIO(int dir0, int dir1, int dir2, int dir3);
void writeGPIO(int dir0value, int dir1value, int dir2value, int dir3value);
int readGPIO(int gpioPin);
void setCLKOUT(int clkout);
void setSDCS(int sdcs);
void sendDirectCommand(uint8_t directCommand);
//Get a single conversion
long readSingle();
//Single input continuous reading
long readSingleContinuous();
void readBurst(unsigned long numberOfSamples);
//Cycling through the single-ended inputs
long cycleSingle(); //Ax + COM
//Cycling through the differential inputs
long cycleDifferential(); //Ax + Ay
//Converts the reading into a voltage value
float convertToVoltage(int32_t rawData);
void testAcquisitionRate(int drate, long packetSize);
//Stop AD
void stopConversion();
private:
float _VREF; //Value of the reference voltage
//Pins
int _DRDY_pin; //Pin assigned for DRDY
int _RESET_pin; //Pin assigned for RESET
int _SYNC_pin; //Pin assigned for SYNC
int _CS_pin; //Pin assigned for CS
//Register-related variables
int _registerAddress; //Value holding the address of the register we want to manipulate
int _registerValueToWrite; //Value to be written on a selected register
int _registerValuetoRead; //Value read from the selected register
//Register values
byte _DRATE; //Value of the DRATE register
byte _ADCON; //Value of the ADCON register
byte _MUX; //Value of the MUX register
byte _PGA; //Value of the PGA (within ADCON)
byte _GPIO; //Value of the GPIO register
byte _STATUS; //Value of the status register
byte _GPIOvalue; //GPIO value
byte _ByteOrder; //Byte order
unsigned long _numberOfSamples;
byte _outputBuffer[3]; //3-byte (24-bit) buffer for the fast acquisition - Single-channel, continuous
long _outputValue; //Combined value of the _outputBuffer[3]
bool _isAcquisitionRunning; //bool that keeps track of the acquisition (running or not)
int _cycle; //Tracks the cycles as the MUX is cycling through the input channels
};
#endif
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
# - due
# - zero
# - leonardo
- m4
- esp32
# - esp8266
# - mega2560
- rpipico
# These are supported funding model platforms
github: RobTillaart
name: Arduino-lint
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update
compliance: strict
---
name: Arduino CI
on: [push, pull_request]
jobs:
runTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb
name: JSON check
on:
push:
paths:
- '**.json'
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
with:
pattern: "\\.json$"
This diff is collapsed.
#pragma once
//
// FILE: ADS1X15.H
// AUTHOR: Rob Tillaart
// VERSION: 0.3.11
// DATE: 2013-03-24
// PUPROSE: Arduino library for ADS1015 and ADS1115
// URL: https://github.com/RobTillaart/ADS1X15
//
#include "Arduino.h"
#include "Wire.h"
#define ADS1X15_LIB_VERSION (F("0.3.11"))
// allow compile time default address
// address in { 0x48, 0x49, 0x4A, 0x4B }, no test...
#ifndef ADS1015_ADDRESS
#define ADS1015_ADDRESS 0x48
#endif
#ifndef ADS1115_ADDRESS
#define ADS1115_ADDRESS 0x48
#endif
#define ADS1X15_OK 0
#define ADS1X15_INVALID_VOLTAGE -100
#define ADS1X15_INVALID_GAIN 0xFF
#define ADS1X15_INVALID_MODE 0xFE
class ADS1X15
{
public:
void reset();
#if defined (ESP8266) || defined(ESP32)
bool begin(int sda, int scl);
#elif defined (ARDUINO_ARCH_RP2040) && !defined(__MBED__)
bool begin(int sda, int scl);
#endif
bool begin();
bool isConnected();
// GAIN
// 0 = +- 6.144V default
// 1 = +- 4.096V
// 2 = +- 2.048V
// 4 = +- 1.024V
// 8 = +- 0.512V
// 16 = +- 0.256V
void setGain(uint8_t gain = 0); // invalid values are mapped to 0 (default).
uint8_t getGain(); // 0xFF == invalid gain error.
// both may return ADS1X15_INVALID_VOLTAGE if the gain is invalid.
float toVoltage(int16_t value = 1); // converts raw to voltage
float getMaxVoltage(); // -100 == invalid voltage error
// 0 = CONTINUOUS
// 1 = SINGLE default
void setMode(uint8_t mode = 1); // invalid values are mapped to 1 (default)
uint8_t getMode(); // 0xFE == invalid mode error.
// 0 = slowest
// 7 = fastest
// 4 = default
void setDataRate(uint8_t dataRate = 4); // invalid values are mapped on 4 (default)
uint8_t getDataRate(); // actual speed depends on device
int16_t readADC(uint8_t pin = 0);
int16_t readADC_Differential_0_1();
// used by continuous mode and async mode.
int16_t getLastValue() { return getValue(); }; // will be obsolete in the future 0.4.0
int16_t getValue();
// ASYNC INTERFACE
// requestADC(pin) -> isBusy() or isReady() -> getValue();
// see examples
void requestADC(uint8_t pin = 0);
void requestADC_Differential_0_1();
bool isBusy();
bool isReady();
// COMPARATOR
// 0 = TRADITIONAL > high => on < low => off
// else = WINDOW > high or < low => on between => off
void setComparatorMode(uint8_t mode);
uint8_t getComparatorMode();
// 0 = LOW (default)
// else = HIGH
void setComparatorPolarity(uint8_t pol);
uint8_t getComparatorPolarity();
// 0 = NON LATCH
// else = LATCH
void setComparatorLatch(uint8_t latch);
uint8_t getComparatorLatch();
// 0 = trigger alert after 1 conversion
// 1 = trigger alert after 2 conversions
// 2 = trigger alert after 4 conversions
// 3 = Disable comparator = default, also for all other values.
void setComparatorQueConvert(uint8_t mode);
uint8_t getComparatorQueConvert();
void setComparatorThresholdLow(int16_t lo);
int16_t getComparatorThresholdLow();
void setComparatorThresholdHigh(int16_t hi);
int16_t getComparatorThresholdHigh();
int8_t getError();
// EXPERIMENTAL
// see https://github.com/RobTillaart/ADS1X15/issues/22
void setWireClock(uint32_t clockSpeed = 100000);
// proto - getWireClock returns the value set by setWireClock
// not necessary the actual value
uint32_t getWireClock();
protected:
ADS1X15();
// CONFIGURATION
// BIT DESCRIPTION
// 0 # channels 0 == 1 1 == 4;
// 1 0
// 2 # resolution 0 == 12 1 == 16
// 3 0
// 4 has gain 0 = NO 1 = YES
// 5 has comparator 0 = NO 1 = YES
// 6 0
// 7 0
uint8_t _config;
uint8_t _maxPorts;
uint8_t _address;
uint8_t _conversionDelay;
uint8_t _bitShift;
uint16_t _gain;
uint16_t _mode;
uint16_t _datarate;
// COMPARATOR variables
// TODO merge these into one COMPARATOR MASK? (low priority)
// would speed up code in _requestADC() and save 3 bytes RAM.
// TODO boolean flags for first three, or make it mask value that
// can be or-ed. (low priority)
uint8_t _compMode;
uint8_t _compPol;
uint8_t _compLatch;
uint8_t _compQueConvert;
int16_t _readADC(uint16_t readmode);
void _requestADC(uint16_t readmode);
bool _writeRegister(uint8_t address, uint8_t reg, uint16_t value);
uint16_t _readRegister(uint8_t address, uint8_t reg);
int8_t _err = ADS1X15_OK;
TwoWire* _wire;
uint32_t _clockSpeed = 0;
};
///////////////////////////////////////////////////////////////////////////
//
// DERIVED CLASSES from ADS1X15
//
class ADS1013 : public ADS1X15
{
public:
ADS1013(uint8_t Address = ADS1015_ADDRESS, TwoWire *wire = &Wire);
};
class ADS1014 : public ADS1X15
{
public:
ADS1014(uint8_t Address = ADS1015_ADDRESS, TwoWire *wire = &Wire);
};
class ADS1015 : public ADS1X15
{
public:
ADS1015(uint8_t Address = ADS1015_ADDRESS, TwoWire *wire = &Wire);
int16_t readADC_Differential_0_3();
int16_t readADC_Differential_1_3();
int16_t readADC_Differential_2_3();
int16_t readADC_Differential_0_2(); // not possible in async
int16_t readADC_Differential_1_2(); // not possible in async
void requestADC_Differential_0_3();
void requestADC_Differential_1_3();
void requestADC_Differential_2_3();
};
class ADS1113 : public ADS1X15
{
public:
ADS1113(uint8_t address = ADS1115_ADDRESS, TwoWire *wire = &Wire);
};
class ADS1114 : public ADS1X15
{
public:
ADS1114(uint8_t address = ADS1115_ADDRESS, TwoWire *wire = &Wire);
};
class ADS1115 : public ADS1X15
{
public:
ADS1115(uint8_t address = ADS1115_ADDRESS, TwoWire *wire = &Wire);
int16_t readADC_Differential_0_3();
int16_t readADC_Differential_1_3();
int16_t readADC_Differential_2_3();
int16_t readADC_Differential_0_2(); // not possible in async
int16_t readADC_Differential_1_2(); // not possible in async
void requestADC_Differential_0_3();
void requestADC_Differential_1_3();
void requestADC_Differential_2_3();
};
// -- END OF FILE --
# Change Log
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
- update and add examples
## [0.3.11] - 2023-08-31
- update readme.md
- move code from .h to .cpp
- reordered code in .cpp to follow .h
- minor edits
## [0.3.10] - 2023-06-07
- fix NANO RP2040
- update and add examples
- minor edits
## [0.3.9] - 2023-01-21
- update GitHub actions
- update license 2023
- update readme.md
- minor edits
## [0.3.8] - 2022-10-17
- add RP2040 support (kudos to intubun)
- simplified changelog.md
## [0.3.7] - 2022-06-21
- fix ESP32 Wire.begin data type
## [0.3.6] - 2022-03-10
- add CHANGELOG.md: moved history in ADS1x15.cpp to this file.
- add default parameters for single channel devices.
- **readADC(uint8_t pin = 0);**
- **requestADC(uint8_t pin = 0);**
- add two examples for the **ADS1114** (single channel devices)
- update readme.md.
## [0.3.5] - 2022-01-21
- fix #36 support for Nano Every
## [0.3.4] - 2021-12-11
- add unit test constants.
- update library.json, license,
- minor edits including layout
## [0.3.3] - 2021-10-17
- update build-CI (esp32), readme.md, keywords.txt
## [0.3.2] - 2021-10-07
- added examples
- update readme
- fix build-CI;
## [0.3.1] - 2021-04-25
- add get/setClock() for Wire speed
- add reset()
- fix issue #22
## [0.3.0] - 2021-03-29
- add Wire parameter to constructors.
----
### 0.2.7 - 2020-09-27
- redo readRegister()
- getValue()
- getError()
### [0.2.6] - 2020-09-01
- fix #12
- fix getMaxVoltage
- refactor
### [0.2.5] - 2020-08-26
- add missing readADC_Differential_X_X()
### [0.2.4] - 2020-08-26
- check readme.md and minor fixes
### [0.2.3] - 2020-08-20
- add comparator code
- add async mode
### [0.2.2] - 2020-08-18
- add begin(sda, scl) for ESP32
### [0.2.1] - 2020-08-15
- fix issue #2 gain
### [0.2.0] - 2020-04-08
- initial release;
- refactor ad fundum;
----
### [0.1.0] - 2017-07-31
- removed pre 1.0 support;
- added getVoltage
### [0.0.1] - 2013-03-24
- first working version
### [0.0.0] - 2013-03-24
- initial version
MIT License
Copyright (c) 2013-2023 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This diff is collapsed.
//
// FILE: ADS_1114_four.ino
// AUTHOR: Rob.Tillaart
// PURPOSE: demo reading four ADS1114 modules in parallel
// URL: https://github.com/RobTillaart/ADS1X15
// Note all IO with the sensors are guarded by an isConnected()
// this is max robust, in non critical application one may either
// cache the value or only verify it in setup (least robust).
// Less robust may cause the application to hang - watchdog reset ?
#include "ADS1X15.h"
ADS1114 ADS[4];
uint16_t val[4];
uint32_t last = 0, now = 0;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("ADS1X15_LIB_VERSION: ");
Serial.println(ADS1X15_LIB_VERSION);
for (uint8_t i = 0; i < 4; i++)
{
uint8_t address = 0x48 + i;
ADS[i] = ADS1114(address);
Serial.print(address, HEX);
Serial.print(" ");
Serial.println(ADS[i].begin() ? "connected" : "not connected");
ADS[i].setDataRate(4); // 0 = slow 4 = medium 7 = fast, but more noise
}
ADS_request_all();
}
void loop()
{
// Serial.println(__FUNCTION__);
// wait until all is read...
while(ADS_read_all());
// we have all values, so process (print) them
ADS_print_all();
delay(1000); // wait a second, comment this line for more samples.
ADS_request_all();
}
void ADS_request_all()
{
// Serial.println(__FUNCTION__);
for (int i = 0; i < 4; i++)
{
if (ADS[i].isConnected()) ADS[i].requestADC(0);
delayMicroseconds(200); // get them evenly spaced in time ...
}
}
bool ADS_read_all()
{
// Serial.println(__FUNCTION__);
for (int i = 0; i < 4; i++)
{
if (ADS[i].isConnected() && ADS[i].isBusy()) return true;
}
// Serial.print("IDX:\t");
// Serial.println(idx);
for (int i = 0; i < 4; i++)
{
if (ADS[i].isConnected())
{
val[i] = ADS[i].getValue();
}
}
ADS_request_all();
return false;
}
void ADS_print_all()
{
// Serial.println(__FUNCTION__);
// print duration since last print.
now = millis();
Serial.print(now - last);
last = now;
Serial.println();
// PRINT ALL VALUES
for (int i = 0; i < 4; i++)
{
Serial.print(val[i]);
Serial.print("\t");
}
Serial.println();
}
// -- END OF FILE --
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
# - uno
# - due
# - zero
# - leonardo
# - m4
# - esp32
# - esp8266
# - mega2560
- rpipico
\ No newline at end of file
//
// FILE: ADS_RP2040_WIRE1.ino
// AUTHOR: Rob.Tillaart / Intubun
// PURPOSE: read analog input
// URL: https://github.com/RobTillaart/ADS1X15
// test
// connect 1 potmeter
//
// GND ---[ x ]------ 5V
// |
//
// measure at x (connect to AIN0).
#include "ADS1X15.h"
// choose your sensor
// ADS1013 ADS(0x48);
// ADS1014 ADS(0x48);
// ADS1015 ADS(0x48);
// ADS1113 ADS(0x48);
// ADS1114 ADS(0x48);
ADS1115 ADS(0x48, &Wire1);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("ADS1X15_LIB_VERSION: ");
Serial.println(ADS1X15_LIB_VERSION);
ADS.begin(26, 27); // SDA (Pin 26), SCL(Pin 27)
ADS.setGain(0); // 6.144 volt
ADS.setDataRate(7); // 0 = slow 4 = medium 7 = fast
ADS.setMode(0); // continuous mode
ADS.readADC(0); // first read to trigger
}
void loop()
{
Serial.println(ADS.getValue());
// optional other code here
}
// -- END OF FILE --
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment