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

adding the missing libary folder

parent 6b486952
No related branches found
No related tags found
5 merge requests!39Merge Develop into Main,!19development into master,!17Inital Host, initial Client,!10merge serial comm and sd write into espnow,!2Draft: Read Sensors on ESP32 Client device
#include <drs26.hpp>
/*
It happens for some reason that the sensor cant get reached every 2 time
Because the sensor use sdi12 protocoll we have to wait aproxemettly 1 secound between the commands
It is not known how lond the response takes so we use a while loop which can be a risk wehre the programm can get stuck
*/
void Forte_DRS26 ::setup()
{
drs26.begin(SDI_DATA);
}
out_data_drs26 *Forte_DRS26 ::read_data()
{
String sdiResponse = "";
String measurement_command="1M!"; //The drs26 sensor uses the sdi12 protocoll , in the sdi12 protocoll is the measurement command is specified as 1M!=Sebsir measurement request at adress 1
String data_command="1D0!"; //and the followed data command 1D0! = Sensor data request at adress 1
drs26.sendCommand(measurement_command);
delay(1000);
drs26.sendCommand(data_command);
while (drs26.available())
{
char next_character = drs26.read();
if ((next_character != '\n') && (next_character != '\r'))
{
sdiResponse += next_character;
delay(10); // 1 character ~ 7.5ms
}
}
if (sdiResponse.length() > 1)
{
data.id = sdiResponse.substring(0, 8).toInt();
data.circumference = sdiResponse.substring(9, 15).toFloat();
data.temperatur = sdiResponse.substring(16, 22).toFloat();
return &data;
}
return 0;
}
\ No newline at end of file
#ifndef _DRS26
#define _DRS26
#include <forte_sensor.hpp>
#include <SDI12.h>
#include <pinout.hpp>
#include "Wire.h"
struct out_data_drs26 {
int id;
float circumference;
float temperatur;
};
class Forte_DRS26 : public Forte_Sensor{
public:
void setup();
out_data_drs26* read_data();
private:
SDI12 drs26;
out_data_drs26 data;
};
#endif
\ No newline at end of file
#ifndef _FORTE_SENSOR
#define _FORTE_SENSOR
class Forte_Sensor {
public:
virtual void* read_data() = 0;
virtual void setup() = 0;
private:
};
#endif
\ No newline at end of file
#ifndef _FORTE_PINOUT
#define _FORTE_PINOUT
// Pins for SDI12
#define SDI_DATA 8
#endif
\ No newline at end of file
#ifndef _FORTE_SENSOR
#define _FORTE_SENSOR
class Forte_Sensor {
public:
virtual void* read_data() = 0;
virtual void setup() = 0;
private:
};
#endif
\ No newline at end of file
#include "ina219.hpp"
void Forte_INA219 :: setup(){
Wire.begin(I2C_SDA, I2C_SCL);
if(!ina219.init()){
// Sensor init went wrong
return;
}
}
out_data_ina219* Forte_INA219 :: read_data(){
if(!ina219.getOverflow())
{
data.shuntVoltage_mV = ina219.getShuntVoltage_mV();
data.busVoltage_V= ina219.getBusVoltage_V();
data.current_mA= ina219.getCurrent_mA();
data.power_mW= ina219.getBusPower();
data.loadVoltage_V = data.busVoltage_V + (data.shuntVoltage_mV/1000);
data.ina219_overflow=ina219.getOverflow();
return &data;
}
else
return 0;
}
\ No newline at end of file
#ifndef _INA219
#define _INA219
#include <forte_sensor.hpp>
#include <pinout.hpp>
#include <INA219_WE.h>
#include "Wire.h"
struct out_data_ina219 {
float shuntVoltage_mV = 0.0;
float loadVoltage_V = 0.0;
float busVoltage_V = 0.0;
float current_mA = 0.0;
float power_mW = 0.0;
bool ina219_overflow = false;
};
class Forte_INA219 : public Forte_Sensor{
public:
void setup();
out_data_ina219* read_data();
private:
INA219_WE ina219;
out_data_ina219 data;
};
#endif
\ No newline at end of file
#ifndef _FORTE_PINOUT
#define _FORTE_PINOUT
// Pins for I2C
#define I2C_SDA 5
#define I2C_SCL 4
#endif
\ No newline at end of file
#ifndef _FORTE_SENSOR
#define _FORTE_SENSOR
class Forte_Sensor {
public:
virtual void* read_data() = 0;
virtual void setup() = 0;
private:
};
#endif
\ No newline at end of file
#ifndef _FORTE_PINOUT
#define _FORTE_PINOUT
// Pins for I2C
#define I2C_SDA 18
#define I2C_SCL 19
#endif
\ No newline at end of file
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