Skip to content
Snippets Groups Projects
Commit fd2ee8b2 authored by User expired's avatar User expired
Browse files

Combining the code fro the sensor_station and esp_now client

parent 1063ce5e
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
Showing
with 5370 additions and 37 deletions
,Shunt Voltage [mV],Bus Voltage [V].Load Voltage [V],Current[mA],Bus Power [mW],Overflow
0.28,1.8,1.8,2.7,4.0,0
0.27,1.8,1.8,2.9,6.0,0
0.28,1.8,1.8,2.8,6.0,0
0.3,1.8,1.8,3.0,6.0,0
0.29,1.8,1.8,2.9,6.0,0
0.3,1.8,1.8,2.9,6.0,0
0.29,1.8,1.8,3.0,6.0,0
0.27,1.8,1.8,2.7,4.0,0
0.26,1.8,1.8,2.6,4.0,0
0.25,1.8,1.8,2.6,4.0,0
0.26,1.8,1.8,2.6,4.0,0
0.27,1.8,1.8,2.8,6.0,0
0.28,1.8,1.8,2.8,6.0,0
0.27,1.8,1.8,2.9,6.0,0
0.27,1.8,1.8,2.9,6.0,0
0.31,1.8,1.8,2.9,6.0,0
0.27,1.8,1.8,2.8,6.0,0
0.28,1.8,1.8,2.8,6.0,0
0.26,1.8,1.8,2.6,4.0,0
0.28,1.8,1.8,2.9,6.0,0
0.28,1.8,1.8,2.7,4.0,0
0.28,1.8,1.8,2.9,6.0,0
0.3,1.8,1.8,2.7,4.0,0
0.27,1.8,1.8,2.8,6.0,0
0.29,1.8,1.8,2.7,4.0,0
0.27,1.8,1.8,2.9,6.0,0
0.29,1.8,1.8,2.9,6.0,0
0.3,1.8,1.8,2.7,4.0,0
0.28,1.8,1.8,2.9,6.0,0
0.28,1.8,1.8,2.9,6.0,0
0.28,1.8,1.8,2.7,4.0,0
0.28,1.8,1.8,2.8,6.0,0
0.26,1.8,1.8,3.0,6.0,0
0.28,1.8,1.8,2.9,6.0,0
0.29,1.8,1.8,2.7,4.0,0
0.27,1.8,1.8,2.9,6.0,0
0.29,1.8,1.8,2.7,4.0,0
0.27,1.8,1.8,2.9,6.0,0
0.26,1.8,1.8,2.7,4.0,0
0.29,1.8,1.8,2.7,4.0,0
0.28,1.8,1.8,2.8,6.0,0
0.27,1.8,1.8,3.0,6.0,0
0.27,1.8,1.8,2.8,6.0,0
0.27,1.8,1.8,2.8,6.0,0
0.29,1.8,1.8,2.9,6.0,0
0.26,1.8,1.8,3.0,6.0,0
0.29,1.8,1.8,2.9,6.0,0
0.23,1.8,1.8,2.7,4.0,0
0.28,1.8,1.8,2.9,6.0,0
0.27,1.8,1.8,2.9,6.0,0
import serial.tools.list_ports
ports = serial.tools.list_ports.comports()
serialInst= serial.Serial()
portList = []
for onePort in ports:
portList.append(str(onePort))
print(str(onePort))
serialInst.port = "/dev/ttyUSB0"
serialInst.baudrate=9600
serialInst.open()
f= open('readmee.txt', 'w')
f.write("shajfksad\n")
f.writelines("hsjdhsjhd")
f.writelines("hsjdhsjhd")
while True:
if serialInst.in_waiting:
packet=serialInst.readline()
# print(packet.decode('utf'))
f.writelines(packet.decode('utf'))
f= open('readmee.txt', 'w')
f.write("shajfksad\n")
f.writelines("hsjdhsjhd")
f.writelines("hsjdhsjhd")
\ No newline at end of file
Shunt Voltage [mV],Bus Voltage [V].Load Voltage [V],Current[mA],Bus Power [mW],Overflow
0.28,1.80,1.80,2.70,4.00,0
0.27,1.80,1.80,2.90,6.00,0
0.28,1.80,1.80,2.80,6.00,0
0.30,1.80,1.80,3.00,6.00,0
0.29,1.80,1.80,2.90,6.00,0
0.30,1.80,1.80,2.90,6.00,0
0.29,1.80,1.80,3.00,6.00,0
0.27,1.80,1.80,2.70,4.00,0
0.26,1.80,1.80,2.60,4.00,0
0.25,1.80,1.80,2.60,4.00,0
0.26,1.80,1.80,2.60,4.00,0
0.27,1.80,1.80,2.80,6.00,0
0.28,1.80,1.80,2.80,6.00,0
0.27,1.80,1.80,2.90,6.00,0
0.27,1.80,1.80,2.90,6.00,0
0.31,1.80,1.80,2.90,6.00,0
0.27,1.80,1.80,2.80,6.00,0
0.28,1.80,1.80,2.80,6.00,0
0.26,1.80,1.80,2.60,4.00,0
0.28,1.80,1.80,2.90,6.00,0
0.28,1.80,1.80,2.70,4.00,0
0.28,1.80,1.80,2.90,6.00,0
0.30,1.80,1.80,2.70,4.00,0
0.27,1.80,1.80,2.80,6.00,0
0.29,1.80,1.80,2.70,4.00,0
0.27,1.80,1.80,2.90,6.00,0
0.29,1.80,1.80,2.90,6.00,0
0.30,1.80,1.80,2.70,4.00,0
0.28,1.80,1.80,2.90,6.00,0
0.28,1.80,1.80,2.90,6.00,0
0.28,1.80,1.80,2.70,4.00,0
0.28,1.80,1.80,2.80,6.00,0
0.26,1.80,1.80,3.00,6.00,0
0.28,1.80,1.80,2.90,6.00,0
0.29,1.80,1.80,2.70,4.00,0
0.27,1.80,1.80,2.90,6.00,0
0.29,1.80,1.80,2.70,4.00,0
0.27,1.80,1.80,2.90,6.00,0
0.26,1.80,1.80,2.70,4.00,0
0.29,1.80,1.80,2.70,4.00,0
0.28,1.80,1.80,2.80,6.00,0
0.27,1.80,1.80,3.00,6.00,0
0.27,1.80,1.80,2.80,6.00,0
0.27,1.80,1.80,2.80,6.00,0
0.29,1.80,1.80,2.90,6.00,0
0.26,1.80,1.80,3.00,6.00,0
0.29,1.80,1.80,2.90,6.00,0
0.23,1.80,1.80,2.70,4.00,0
0.28,1.80,1.80,2.90,6.00,0
0.27,1.80,1.80,2.90,6.00,0
\ No newline at end of file
import pandas as pd
read_file=pd.read_csv(r'/home/hassan/Documents/TEAM/sensor-system/code-snippets/client/INA219_POWER_MEASURMENT_STATION/Example_forte_libary/client/python_txt_to_csv/raw_data.txt')
read_file.to_csv(r'/home/hassan/Documents/TEAM/sensor-system/code-snippets/client/INA219_POWER_MEASURMENT_STATION/Example_forte_libary/client/python_txt_to_csv/ example.csv')
read_file.to_excel(r'/home/hassan/Documents/TEAM/sensor-system/code-snippets/client/INA219_POWER_MEASURMENT_STATION/Example_forte_libary/client/python_txt_to_csv/ example.csv')
\ No newline at end of file
hsjdhsjhdhsjdhsjhd
\ No newline at end of file
......@@ -36,25 +36,38 @@ void loop()
}
delay(5000);
int samples = 50;
int samples = 5000;
out_data *data_raw = (out_data *)malloc(samples * sizeof(out_data));
Serial.println("if you want to start the sensor mesaurment type 'y' ");
while (Serial.read() != 'y') {
/* while (Serial.read() != 'y') {
delay(1000);
}
*/
Serial.println("Measuring..");
for (int i = 0; i < samples; i++) {
data_raw[i] = *sensor1.read_data();
Serial.println(sensor1.read_data()->current_mA);
// Serial.println(sensor1.read_data()->current_mA);
delay(1);
}
Serial.println("Finished Mesasrument.");
delay(1000);
Serial.println("Output data");
Serial.println();
Serial.println();
Serial.println();
Serial.println();
Serial.println();
Serial.println();
Serial.println();
Serial.println();
Serial.println();
Serial.println();
Serial.println();
/*
for (int i = 0; i < samples; i++) {
if (&data_raw[i] == 0) {
......@@ -76,6 +89,14 @@ void loop()
Serial.println();
}
}
*/
Serial.print("Shunt Voltage [mV],");
Serial.print("Bus Voltage [V].");
Serial.print("Load Voltage [V],");
Serial.print("Current[mA],");
Serial.print("Bus Power [mW],");
Serial.println("Overflow");
for (int i = 0; i < samples; i++) {
......@@ -93,7 +114,7 @@ void loop()
Serial.print(",");
Serial.print(data_raw[i].power_mW);
Serial.print(",");
data_raw[i].ina219_overflow == false ? Serial.println("0/") : Serial.println("1/");
data_raw[i].ina219_overflow == false ? Serial.println("0") : Serial.println("1");
}
}
......
,hassan,hassan-Lifebook-U7411,17.08.2022 16:52,file:///home/hassan/.config/libreoffice/4;
\ No newline at end of file
......@@ -10,42 +10,18 @@ Forte_DRS26 drs26;
void setup() {
Serial.begin(9600);
scd30.setup();
ina219.setup();
drs26.setup();
}
void loop() {
//***********************************************************DATA for scd30**************************
out_data_scd30* data_scd30;
data_scd30 = scd30.read_data();
Serial.println("******************************SCD0********************CO2/TEMP/HUM**********************************");
if(data_scd30==0)
{
Serial.println("Waiting for data!");
Serial.println();
}
else{
Serial.print("Sensor CO2 "); Serial.println(data_scd30->C02);
Serial.print("Humidity "); Serial.println(data_scd30->Humidity);
Serial.print("Temperature "); Serial.println(data_scd30->Temperature);
Serial.println();
}
delay(1000);
//***********************************************************DATA for ins219**************************
out_data_ina219* data_ina219;
data_ina219 = ina219.read_data();
// Serial.println("******************************INA219********************Power-Consumption**********************************");
Serial.println("******************************INA219********************Power--Consumption**********************************");
if(data_ina219==0)
{
Serial.println("Waiting for data!");
......@@ -62,12 +38,6 @@ void loop() {
}
delay(1000);
//***********************************************************DATA for drs26*************************
out_data_drs26* data;
drs26.read_data();
......
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
#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
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
lib_deps = sparkfun/SparkFun SCD30 Arduino Library@^1.0.18
Wire
wollewald/INA219_WE@^1.3.1
envirodiy/SDI-12@^2.1.4
fbiego/ESP32Time@^1.1.0
#include <Arduino.h>
#include <scd30.hpp>
#include <ina219.hpp>
#include <drs26.hpp>
#include "espnow.hpp"
#include "ram_caching.hpp"
#include <stdio.h>
#include <f_deep_sleep.h>
Forte_SCD30 scd30;
Forte_INA219 ina219;
Forte_DRS26 drs26;
void setup() {
Serial.begin(9600);
Serial.println();
Serial.println("Weak up from deep sleep");
ina219.setup();
drs26.setup();
esp_err_t result = espnow_setup();
}
void loop() {
//*****Data from the Sensor INA219
out_data_ina219* data_ina219;
data_ina219 = ina219.read_data();
ina219.print(data_ina219);
//*****Data from the Sensor DRS26
out_data_drs26* data_drs26;
data_drs26 = drs26.read_data();
drs26.print(data_drs26);
//temperatur 0
//cicumfence 1
//load voltage 2
//crrent 3
Message* new_data = new Message();
new_data->add_data(data_drs26->temperatur, 0);
new_data->add_data(data_drs26->circumference, 1);
new_data->add_data(data_ina219->loadVoltage_V, 2);
new_data->add_data(data_ina219->current_mA,3);
new_data->send();
delete new_data;
Serial.println("Going to sleep");
deep_sleep(1);
}
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
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