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

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

Sorry, in the first I did not get it, I will change it now, I am so sorry

image
Prefinalappgassensing (2).aia (333.9 KB)
As you see, it can calculate the resistance R4, but it is not showing on the chart, and also V2 is showing in text box V2. Also, the gauge is working, so thank you so much for being kind to teach me and answer my questions.

I'm confused because of this.

I have to use something like this example; I will try.
Could you please explain how I can use in my project to store Voltage and R4, and call R4 in char2D?


https://groups.google.com/g/mitappinventortest/c/dYFiE6xrEKc

You need to put more thoughts into how you aggregate and store data.

Collections of readings should be identified by either gas name or by sample identification.

Eventually, I imagine you would be matching sample reading collections against known gas data, for the purposes of identifying samples

1 Like



Actually, it is difficult to show the resistance calculated from voltage on screen 3 on the chart on screen 1, I am trying, but I did not get the solution.
Now I can get the voltage and resistance on screen 3, but still no response on the screen 1 chart.


BELALFINALPROJECT.aia (337.1 KB)

AI2 Screens are separate programs that share no global variables and no components.

The only thing available to them across Screens are instances of TinyDB, according to their NameSpaces.

If you switch Screens, you have to reload all your global variables and GUI components from TinyDB or Files.

There are two events that capture coming into a Screen:

  • Screen.Initialize, and
  • When Other Screen Closed.

To cover both possibilities, you could do your reloading in a common procedure called from both events.

1 Like

image

Why are you setting the WebViewer gauge pointer based on a missing Slider component's thumb position?

Do you not see the red X?

1 Like

In Screen3, you are treating global variable Readings as a list when you add a pair to it.

image

But look how you initialize global Readings in Screen3:

image

The number 0 is not a list.

You can't add items to the number 0.

To start an empty list, use the Create Empty List block.

1 Like

In that same Screen, you calculate a local value R4
image

but then you store the text NameSpace value TinyDB1 into TiinyDB1 under tag R4.

image

I also see you loading values from tags R1,R2, R3 in other Screens, but not R4.

Did R4 offend you in some way?

1 Like

Thanks, I am trying to find how I can do it, as I still need two things, and I will finish my project. First is plotting R versus time and ppm to rotate the gauge.
Still, it is giving error


BELALFINALPROJECT3.aia (336.2 KB)

From the following photo, I can tell, it is now calling the screen 3 data.


BELALFINALPROJECT3 (1).aia (336.4 KB)
Please I am almost near to doing it; please help me to know the solution for the error.



Here, it is reading the voltage, but on the PC screen for MIT APP WEBSITE, it is reading the R4

You can't select items from an empty list.

Item numbers start at 1, not 0.

You need to test the number of items in the list before trying to select items.

If there are no items, don't do anything with it.

Use length of list block for the comparison against zero.

1 Like

BELALFINALPROJECT3 (2).aia (338.9 KB)


Thanks, the problem now is only in chart entry as now I can call the R4 on Res text box and it is working but on chart not working only reading the volatge values

Your graph went up like your examples but then it went down.

The code to locate the peak Rg did not take into account a descending section.

Revise the section of code that finds the rising section to limit the extraction to just the points with ascending y values.

P.S. Because your y values are locally noisy, you might need to set a minimum threshold to determine ascending and descending.

Also, research smoothing techniques like a Kalman filter.


BELALFINALPROJECT3 (3).aia (338.7 KB)
Please, could you check?
image

So, please, is it available in the Chartmaker extension?
how I can apply it