How make a GUI using App designer to visualize pressure sensor data
25 views (last 30 days)
Show older comments
Hi, I have a pressure sensor matrix with 16 columns and 10 rows. And I am using the circuit with multiplexer and Arduino to get the data. The example code and circuit diagram is exactly the same as shown in this link: https://www.sensitronics.com/tutorials/fsr-matrix-array/ When I am using Arduino I am able to see the individual elements of the array changing with increasing and decreasing pressure at multiple points. This is good. However, now I want to make a pressure map of this sensor in MATLAB GUI or App designer. Does anyone have any idea how to go about it? Or any code to visualize the pressure map in real time? Thanks in advance.
1 Comment
Answers (1)
Amish
on 9 Oct 2023
Hi Anoop,
I understand that you want to plot the data that is getting generated from the Arduino’s pressure sensor. Creating a pressure map in MATLAB App Designer for your pressure sensor matrix would be a way to visualize the data in real-time.
The following workflow define the generic steps for doing the same:
- Having a proper hardware setup to read sensor data into MATLAB. (Since you state that you already can acquire the data, I assume you already have this done)
- Create your GUI using App Designer in MATLAB. Open MATLAB and type appdesigner in the command window to start designing your interface.
- Design a suitable layout that includes a visualization area for the pressure map. You can use axes or a heatmap to display the map.
- Create a timer in the App designer or use a loop to continuously acquire the data from the sensor.
- Convert the data into a heatmap and update in real-time as new data is acquired.
Here is a boiler-plate code that might help you further:
classdef PressureMapApp < matlab.apps.AppBase
properties (Access = private)
% Properties for storing sensor data and handle to heatmap
pressureData
heatmapHandle
end
methods (Access = private)
% Function to update the pressure map
function updatePressureMap(app)
% Read sensor data from Arduino (you should replace this with your data acquisition code)
sensorData = readSensorData();
% Update the pressureData array with the new sensor data
app.pressureData = sensorData;
% Update the heatmap
updateHeatmap(app.heatmapHandle, app.pressureData);
end
% Function to initialize the app
function createComponents(app)
% Create UI components here (axes, heatmap, buttons, etc.)
app.heatmapHandle = heatmap(app.UIAxes, app.pressureData);
end
% Function to set up the timer for real-time updates
function setupTimer(app)
timerObj = timer('ExecutionMode', 'fixedRate', 'Period', 1); % Update every 1 second
timerObj.TimerFcn = @(~, ~) updatePressureMap(app);
start(timerObj);
end
end
methods (Access = public)
% Constructor
function app = PressureMapApp
% Create and configure the app
createComponents(app);
setupTimer(app);
end
end
% App creation and deletion
methods (Access = public)
% Code that executes after component creation
function startupFcn(app)
% Initialize pressureData with zeros or any initial values
app.pressureData = zeros(10, 16);
end
end
end
Hope this helps!
1 Comment
Image Analyst
on 9 Oct 2023
OK but you're supposed to give attribution to the chatbot that you used to create that answer.
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!