Skip to content
Snippets Groups Projects
Commit 225fa471 authored by Bilal Hassan's avatar Bilal Hassan
Browse files

setup multiple dendrometer on a single client, new setup with 2 dendrometer is...

setup multiple dendrometer on a single client, new setup with 2 dendrometer is on the desk of room 3N10
parent 6893f05a
No related branches found
No related tags found
4 merge requests!39Merge Develop into Main,!19development into master,!17Inital Host, initial Client,!6Espnow
......@@ -3,9 +3,14 @@
void ForteDR26 ::setup()
{
Wire.begin(6, 7);
ads.setGain(GAIN_ONE);
ads.begin() ? Serial.println("ADS initialized") : Serial.println("failed to initialize ADS");
// ads.setGain(GAIN_ONE);
// ads.begin() ? Serial.println("ADS initialized") : Serial.println("failed to initialize ADS");
ads1.setGain(GAIN_ONE);
ads1.begin() ? Serial.println("ADS initialized") : Serial.println("failed to initialize ADS");
delay(100);
channel=0;
}
float ForteDR26 ::readData()
......@@ -16,8 +21,8 @@ float ForteDR26 ::readData()
float volt = 0;
try
{
adc = ads.readADC_SingleEnded(0);
volt = ads.computeVolts(adc);
adc = ads1.readADC_SingleEnded(channel);
volt = ads1.computeVolts(adc);
}
catch(NoDataAvailableException& e)
{
......@@ -50,6 +55,11 @@ void ForteDR26 ::changeGain(adsGain_t gain)
ads.setGain(gain);
}
void ForteDR26 ::setChannel(int c)
{
channel=c;
}
std::list<Message> ForteDR26::buildMessages()
{
std::list<Message> messages;
......@@ -62,3 +72,6 @@ SensorInformation ForteDR26::getSensorInformation() const
{
return sensorInformation;
}
Adafruit_ADS1115 ForteDR26::ads1=ads1;
\ No newline at end of file
......@@ -14,12 +14,15 @@ class ForteDR26 : public ForteSensor<float> {
void setup() override;
float readData() override;
void changeGain(adsGain_t gain);
void setChannel(int channel);
std::list<Message> buildMessages() override;
[[nodiscard]] SensorInformation getSensorInformation() const override;
static Adafruit_ADS1115 ads1;
private:
Adafruit_ADS1115 ads;
const SensorInformation sensorInformation{"DR26", Protocol::Analog};
int channel;
};
#endif
\ No newline at end of file
......@@ -11,7 +11,9 @@
static const std::string TAG = "MAIN";
ForteDR26 dr26;
ForteDR26 dr26_channel0;
ForteDR26 dr26_channel1;
void setup()
{
Serial.begin(115200);
......@@ -20,27 +22,27 @@ void setup()
DeepSleep::bootCount++;
ESP_LOGD(TAG.c_str(), "Boot number: %d", DeepSleep::bootCount);
// drs26.setup();
dr26.setup();
dr26_channel1.setup();
dr26_channel0.setChannel(0);
dr26_channel1.setChannel(1);
espnow_setup();
// log_e("Setup complete.");
}
void loop()
{
float data= dr26.readData();
Serial.printf("data circumfrence");
Serial.printf(String(dr26.readData()).c_str());
Serial.println("***********************1-DRS26**********************************");
Serial.println(dr26_channel0.readData(),5);
Serial.println("***********************2-DRS26**********************************");
Serial.println(dr26_channel1.readData(),5);
try {
// out_data_drs26 data= dr26.readData();
// Serial.printf("data circumfrence");
// Serial.printf(String( data.circumferenceIncrement).c_str());
//auto messages = drs26.buildMessages();
auto messages = dr26.buildMessages();
// auto scdMessages = scd30.buildmessages();
auto messages = dr26_channel0.buildMessages();
messages=dr26_channel1.buildMessages();
for (const Message &message : messages) {
if(message.send() != ESP_OK){
......@@ -56,14 +58,9 @@ void loop()
std::cerr << e.what() << '\n';
}
// ESP_LOGE(TAG.c_str(), "Sensor Circumference: ");
// log_e("Temperature: ");
// log_e("Id: ");
Serial.print("This device: ");
// Serial.println(WiFi.macAddress());
Serial.println("\n");
delay(10000);
delay(5000);
DeepSleep::deep_sleep(5);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment