How to read Sensor data from STM32U5 ( B-U585IOT02A )
Hello community,
I've B-U585IOT02A. I want to use sensor values from it to my application running on node.js. I think to import those sensor values to application over the local network using mqtt. But as their is already a web-server installed in B-U585IOT02A . So I found that I can access sensor values after runing web-server at:
For example web-server is live at my local wifi ip : 192.168.1.33
192.168.1.33/Read_Temperature for temperature
192.168.1.33/Read_Humidity for humidity
192.168.1.33/Read_Pressure for Pressure
So I try to fetch directly these urls but fails these response are header less response.
So they didn't work with fetch, axios or https, even not with curl.
But these seems to be working in browser so I tried a trick to get data, I used header-less browser or we can say virtual browser to access the data.
The code by which I able to read data:
const puppeteer = require('puppeteer');
Read_Sensors();
function Read_Sensors(){
(async () => {
try {
const browser = await puppeteer.launch();
const [page] = await browser.pages();
//Read Temperature
await page.goto('http://192.168.1.33/Read_Temperature', { waitUntil: 'networkidle0' });
const data = await page.evaluate(() => document.querySelector('pre').innerHTML);
//Read Pressure
await page.goto('http://192.168.1.33/Read_Pressure', { waitUntil: 'networkidle0' });
const data2 = await page.evaluate(() => document.querySelector('pre').innerHTML);
//Read Humidity
await page.goto('http://192.168.1.33/Read_Humidity', { waitUntil: 'networkidle0' });
const data3 = await page.evaluate(() => document.querySelector('pre').innerHTML);
console.log("Temperature :" + data);
console.log("Pressure :" + data2);
console.log("Humidity :" + data3);
await browser.close();
} catch (err) {
console.error(err);
}
})();
}Here I'm using puppeteer package which use chromium in background which use 200mb of data, which we can say not a stable method.
So any on can suggest me a way another than this to read data from B-U585IOT02A by mqtt or another way directly to application.
Thanks in advance for you valuable answer.
