Hi there,
If anyone can help me on this, I'd be very grateful.
I want to get pressure data from two transducers from an ESP32 through Bluetooth, and print the data on PLX-DAQ spreadsheet. The bluetooth connection works well, but the printed data doesn't seem to change, even though the pressure in my system does. Here's my code
#include "BluetoothSerial.h" //Header File for Serial Bluetooth, will be added by default into Arduino
BluetoothSerial ESP_BT; //Object for Bluetooth
float press_in;
float press_out;
float press_1;
float press_2;
float V;
float U;
int i = 0;
int tmpo;
void setup() {
ESP_BT.begin("ESP32_Pressure_Sensor"); //Name of your Bluetooth Signal
delay(10000);
ESP_BT.println("CLEARDATA");
ESP_BT.println("LABEL,Time,Tempo(s),Pressao de Entrada (Bar),Pressao de Saida (Bar)");
pinMode(A12, INPUT);
pinMode(A13, INPUT);
}
void loop() {
V = analogRead(A13);
U = analogRead(A12);
press_1 = (V - 102) * 30 / 819;
press_2 = (U - 102) * 30 / 819;
press_in = press_1 * 0.0689476; //unit conversion
press_out = press_2 * 0.0689476; //unit conversion
tmpo = i*5;
i++;
delay(5000);
ESP_BT.print("DATA,TIME,");//
ESP_BT.print(tmpo);
ESP_BT.print(",");//
ESP_BT.print(press_in);
ESP_BT.print(",");
ESP_BT.println(press_out);
}
delay(5000);
ESP_BT.print("DATA,TIME,");//
ESP_BT.print(tmpo);
ESP_BT.print(",");//
ESP_BT.print(press_in);
ESP_BT.print(",");
ESP_BT.println(press_out);
Are you sure that you want to waste five seconds between measuring the pressures and printing them out?
Where do you print U and V so that you can debug this issue?
vaj4088:
Are you sure that you want to waste five seconds between measuring the pressures and printing them out?
Where do you print U and V so that you can debug this issue?
Hi there, thanks for the reply
I changed a bit the code as you suggested.
So now, U and V are always printing the value 4095 on the spreadsheet.
#include "BluetoothSerial.h" //Header File for Serial Bluetooth, will be added by default into Arduino
BluetoothSerial ESP_BT; //Object for Bluetooth
float pressao_in;
float pressao_out;
float pressao_1;
float pressao_2;
float V;
float U;
int i = 0;
int tmpo;
void setup() {
pinMode(27, INPUT);
pinMode(34, INPUT);
ESP_BT.begin("ESP32_Pressure_Sensor"); //Name of your Bluetooth Signal
//Serial.begin(9600);
delay(30000);
ESP_BT.println("CLEARDATA");
ESP_BT.println("LABEL,Time,Tempo(s), U, V, Pressao de Entrada (Bar), Pressao de Saida (Bar)");
}
void loop() {
V = analogRead(27);
delay(1000);
U = analogRead(34);
pressao_1 = (V - 409) * 30 / (4095 - 409);
pressao_2 = (U - 409) * 30 / (4095 - 409);
pressao_in = pressao_1 * 0.0689476;
pressao_out = pressao_2 * 0.0689476;
tmpo = i*5;
i++;
ESP_BT.print("DATA,TIME,");//
ESP_BT.print(tmpo); //Imprime na serial o valor da vazão
ESP_BT.print(",");
ESP_BT.print(U);
ESP_BT.print(",");
ESP_BT.print(V);
ESP_BT.print(",");//
ESP_BT.print(pressao_in); //Imprime a contagem i (segundos)
ESP_BT.print(",");
ESP_BT.println(pressao_out);
delay(5000);
Are you certain that your sensors are connected to pins 34 and 27 ?
It appears that either your sensors are not connected to the pins that you expect, or there is something wrong with your wiring, or your sensors do not (or cannot) work as expected.
I have not seen anything about the wiring.
You need to get one (and only one) sensor working correctly first.
Then, you can add a second sensor and get it working.
Then, you can have any unit conversions you want.
Then, you can try using Bluetooth.
You need to approach this in small steps.