I have removed the ACS712 and just connected the HM-10 to the Arduino Uno. Then I used a simple code where I sent one "Hey" to my smartphone and measured the operation time. I got 4 milliseconds as a result. I measured the operation time again and again and got the same result of 4 milliseconds. Is this way of measuring the operation time correct? Or do I have to keep my full circuit (with ACS712) and my full code (with analogRead(A0) etc)? This is the simple code I used:
#include <SoftwareSerial.h>
SoftwareSerial ble(2, 3); // RX, TX
void setup() {
// Open serial port
Serial.begin(9600);
// begin bluetooth serial port communication
ble.begin(9600);
long int t1 = millis();
ble.write("Hey!");
long int t2 = millis();
Serial.print("Time taken by the task: "); Serial.print(t2-t1); Serial.println(" milliseconds");
}
// Now for the loop
void loop() {
}
Ok, so one single data session's duration is 4 ms. As told, one wireless data transmission has a weird shape, for example:
Let's say we want to take 5 power measurements of 1 ms each to be able to encompass 1 whole data session: mA_total = mA1 + mA2 + mA3 + mA4 + mA5
So, do we need a for-loop like this?:
for(int i = 0; i < 5; i++) {
Vout = (Vout + (resADC * analogRead(A0)));
delay(1);
}
And where exactly do I have to put my sigle data transmission code?:
ble.write("Hey!");
In the for-loop? Before the for-loop? After the for-loop?
If I put it before the for-loop (and thus before the measurement: analogRead(A0)), doesn't this mean that the measurement will start when the data transmission will have ended? That doesn't make sense I think.
If I put it after the for-loop, then the data will be sent after the measurement will have finished. That doesn't make sense either; I will be measuring void in both cases.
Putting the ble.write("Hey!") code in the for-loop gives rise to the same questions: Before the measurement? After the measurement? Leading to the same confusion.
And where should all this bunch of code together:
ble.write("Hey!");
// Vout is read 1000 Times for precision
for(int i = 0; i < 1000; i++) {
Vout = (Vout + (resADC * analogRead(A0)));
delay(1);
}
be placed? In the void loop or in the setup? Bearing in mind that I just want 1 data transmission. The void loop wouldn't stop making data transmissions unless I would add some sort of stop-code in it. Or do I have to make multiple data transmissions and thus keep the code in the void loop?
