How do you use a Wheatstone Bridge to calculate Resistance using Bluetooth?

Too difficult?? Not really difficult but it is not simple.

:wink:

1 Like

Thanks. The problem is with the header ((arrow)) going to the left side. please, send me the aia file.

This is very nice.
Thank you so much.

image

Please, if possible, send me the aia file, as I changed the color ranges and water gauge to ppm, but the header (needle) is not working. Furthermore, I need to change the width and height to fit the app screen. ((Thanks I did it, now it is working))

Also, if you please, help me with the x-axis of the chart, as I need it to read only in seconds, not in milliseconds time since 1970.
(Remaining the x-axis in seconds.
Maybe I can send elapsedTimeSeconds on x axis and R_Unknown on y axis, but how I can do it.

Also, if you please, help me with the x-axis of the chart, as I need it to read only in seconds, not in milliseconds time since 1970.
(Remaining the x-axis in seconds.
Maybe I can send elapsedTimeSeconds on the x-axis and R_Unknown on the y-axis, but how can I do it? Please, I have tried many times to make the x-axis as time in seconds.
For the gauge, I need to connect it to ppm math to work automatically in the app.
Also, in the last version of the app, I will take the R y-axis from the math calculation of the Wheatstone bridge, so how can I do it?
BELAL2025NANOMADVERSION7 (1).aia (1.1 MB)

Thanks @ABG Also, now it can analyze the R air and R gas

image
when I press stop, the timer is still counting

ppmGauge.aia (46.7 KB)

Good luck. This should work when connected to your app's ppm data stream.

Modify the GCppm2.html that is stored in media to get the centering of the gauge as you like it. :grinning:

1 Like

Thank you so much @SteveJG

This is helpful
For my previous question I will check it

I have turned off Windows Defender examination of aia files, so I can examine your aia file.

Here is a set of blocks I must change, for readability and correctness:

old:
blocks

new:
blocks (3)

Do you see the difference between elapsed time and absolute System time?
Elapsed means you have subtracted start time from end time to get the difference.
But that is not what is being stored in this variable, as you will see further down.

old:

new:

Notice how the global variable name change makes more sense, where SystemTime of start is being subtracted from current SystemTime, giving elapsed milliseconds, then rounded into seconds.

Those seconds are being loaded into item 1 of each (time, R_Unknown) pair in list global readings. That's handy for later, when we need a list of Labels for the Chart.
image
(I have no idea why you are loading a Web URL. It's not like you are issuing any Web Gets to it. That makes your app look like a product of a cargo cult.)

I hovered my cursor over the green Set Chart1.Labels block, to raise its tool tip.
That's how I know it needed a list of x values, and not that R value you had before.

I also set the chart GridEnabled to true, since I am guessing you wanted a grid, from that ineffective block you originally had setting the setting to itself, which would have done absolutely nothing. If you don't want a grid, set it to false.

old:

new (after variable rename):


(Same deal with the Web URL mumbo jumbo)

This should clear the error message on setting Labels.

All blocks are draggable.

I suggest you drag in the init global startSystemTime first, since all the other blocks depend on it.

1 Like

By the way, I did not correct your file naming convention.

Operating systems expect file names to have suffixes (.text, .json, .csv, .html, .exe, ...) as an aid to knowing what programs eat them.

Since you have written your file to contain text Comma Separated Values (CSV), you should add the suffix .csv to the file name, as a courtesy to the operating system and any one else dealing with that file.

1 Like


Thank you so much @ABG
ValueFormat, I changed from time to Decimal, and it is now counting in 1, 2, 3, ..........



Please, I have two questions regarding how I make the pointer or cursor on screen to check (x,y) for each point I select.
Secondly, the R on the graph was deleted with increasing time; please check the video, so could you please help me to resolve it?.

Also, I found this project, which may be helpful for someone who will check this thread in the future.

https://drive.usercontent.google.com/download?id=1dUMcZs0FBvVcT8ykT35-v0c-Vac506Y-&export=download&authuser=0

Also, I have a very important question regarding finalizing my project. I will receive voltage from ESP32, and the resistance will be mathematically calculated from voltage by the Wheatstone bridge. After that, the resistance will be plotted to get Rg and Rair by the Analyze button, which has to work by clock, not by pressing, and from them I will get the response by dividing Rg/Rair or Rair/Rg, depending on the gas and material type. Also from the calibration screen, I will get the slope, which will be used to calculate the ppm, and also I need to rotate the gauge automatically. So how can I do it? Should I save the data first in a CSV file and call it in the app, or what should I do? Also, I checked screen4, and it's still crashing.
BELAL2025NANOMADVERSION7_copy_copy.aia (1.1 MB)

Events

EntryClick(series,x,y)
Indicates that the user clicked on a data entry in the Chart. The specific series, along with its x and y values, are reported.
How can I use this event?

I tried your SciBlock linear regression extension in a separate Project, and it crashed on me.
image

I had copied it from
https://github.com/SciBlock/extensions/raw/refs/heads/main/com.SciBlock_LinearRegression10demo.aix


SciBlock_demo.aia (79.3 KB)

I suggest using the AI2 linear regression component.

I also notice in Screen4 you are shoving all your textbox inputs into the extension, without checking to see if they are all number, and not blanks.

I tries a sample call to your .aix in Screen4, using what should have worked, and it also crashed.
image

The AI2 regression component looks like all you need.

I can't go further on this without some training data for the regression model.

Tyoe some (SR,PPM) pairs into a spreadsheet, and download the CSV table here.

1 Like

Here's a rewrite of the Screen4 Calculate operation, taking into account blank inputs:




The calculate procedure only adds valid x and y pairs to the regression inputs xList and yList.

I left out the Prediction calculation, because my high school algebra has faded, and I am not sure which is dependent on what (ppm vs SR).

BELAL2025NANOMADVERSION7_copy_copy (1).aia (333.6 KB)

1 Like

image

Pop up a Notifier with the x and y, or drop them into Labels.

1 Like

Looking at Screen4 and its regression model, I see you have a chicken and egg problem.

(Which came first, the chicken or the egg? Every chicken came from an egg, but each egg came from a chicken.)

Which came first, the pre-loaded sets of (SR,ppm) pairs used tor calibrations for different materials, or the experimental Bluetooth readings that needed the SR/PPM slopes for their calculations?

1 Like

To get the calibration, I have known concentrations of gases to get their response; then, I can detect unknown gas concentrations.

@ABG Thank you so much; now screen 4 is working.
I will get the calibration from known gases concentration by getting their SR response in a normal situation of R vs t to get R gas and R air in screen 1, then, i will add them in screen 4 to get the concentration of unkown gases.

I need the calibration to calculate the ppm of the unknown gases. So first I will receive voltage from ESP32, and the resistance will be mathematically calculated from voltage by the Wheatstone bridge. After that, the resistance will be plotted to get Rg and Rair by the Analyze button, which has to work by clock, not by pressing, and from them I will get the response by dividing Rg/Rair or Rair/Rg, depending on the gas and material type. Also from the calibration screen, I will get the slope, which will be used to calculate the ppm, and also I need to rotate the gauge automatically.

I need to make it pop up on the chart itself, I tried to do but it doesn't give any response.

You will need to rethink how you store calibration data.

It needs to be stored by gas.

While I go back to sleep, study

  • Dictionaries
  • JSON
  • TinyDB Namespaces
  • Three column (SR,ppm,gas) table storage and advanced list filter blocks

There is also the issue of calibration data provenance.

Will this calibration data be provided with mass produced gas sensors, or is this just a lab prototype proof of concept?

1 Like

Hello @ABG
Please I have tried to use a dictionary to save the data and recall R4 again on screen 1 from screen 3, which is the y-axis in the chart, but it does not work. Furthermore, I used tinyDB4 instead of DB1. I used the entry click to get x and y axes, but they are in text boxes, and I need them on the graph itself.
For your question, this app is for a resistive gas sensor for one gas only for this time; next time I will plan to make it for different gases.

BELALGASSENSOR.aia (333.6 KB)

Did you change the TinyDB Namespaces for TinyDB4?

What did you use?

1 Like