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

update on analog drs26 lib

parent f25a1acf
No related branches found
No related tags found
4 merge requests!39Merge Develop into Main,!19development into master,!17Inital Host, initial Client,!6Espnow
{
"files.associations": {
"optional": "cpp"
}
}
\ No newline at end of file
......@@ -2,26 +2,32 @@
void ForteDR26 ::setup()
{
Wire.begin(I2C_SDA, I2C_SCL);
// ads.setGain(0);
if (ads.begin()) {
ESP_LOGI(sensorInformation.getSensorName().c_str(), "ADS initialized.");
} else {
ESP_LOGW(sensorInformation.getSensorName().c_str(), "ADS initialization failed.");
}
delay(100);
Wire.begin(6, 7);
ads.setGain(GAIN_ONE);
ads.begin() ? Serial.println("ADS initialized") : Serial.println("failed to initialize ADS");
delay(100);
}
float ForteDR26 ::readData()
{
float volts = 0;
for (int i = 0; i < 10; i++) {
int16_t adc = ads.readADC_SingleEnded(0);
float volt = ads.computeVolts(adc);
volts += volt;
}
volts /= 10;
return volts;
float volts=0;
for(int i=0; i<10; i++){
int16_t adc = 0;
float volt = 0;
try
{
adc = ads.readADC_SingleEnded(0);
volt = ads.computeVolts(adc);
}
catch(NoDataAvailableException& e)
{
throw NoDataAvailableException(); //propagate exception
}
volts += volt;
}
volts /= 10;
return volts;
}
// The following functions change the ADC input range: be careful
......
......@@ -7,6 +7,7 @@
#include "Pinout.hpp"
#include "esp_log.h"
#include <Wire.h>
#include "NoDataAvailableException.hpp"
class ForteDR26 : public ForteSensor<float> {
public:
......
......@@ -10,8 +10,8 @@
// #include "esp32-hal-log.h"
static const std::string TAG = "MAIN";
ForteDRS26 drs26;
ForteDR26 dr26;
void setup()
{
Serial.begin(115200);
......@@ -20,17 +20,27 @@ void setup()
DeepSleep::bootCount++;
ESP_LOGD(TAG.c_str(), "Boot number: %d", DeepSleep::bootCount);
drs26.setup();
// drs26.setup();
dr26.setup();
espnow_setup();
// log_e("Setup complete.");
}
void loop()
{
float data= dr26.readData();
Serial.printf("data circumfrence");
Serial.printf(String(dr26.readData()).c_str());
try {
auto messages = drs26.buildMessages();
// 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();
for (const Message &message : messages) {
if(message.send() != ESP_OK){
......@@ -51,7 +61,8 @@ void loop()
// log_e("Id: ");
Serial.print("This device: ");
Serial.println(WiFi.macAddress());
// Serial.println(WiFi.macAddress());
Serial.println("\n");
delay(10000);
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