Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizInternet of Things IoT Frameworks 2 years ago
Posted on 16 Aug 2022, this text provides information on IoT Frameworks related to Internet of Things. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Internet of Things 0 Answers
Internet of Things 0 Answers
Internet of Things 0 Answers
Internet of Things 0 Answers
Internet of Things 0 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.
manpreet
Best Answer
2 years ago
_x000D_ There are basically 2 questions in it. How to format the data and use the express server and send it to the front-end How to display more than one data-set in in the graph using chart.js For 1st The line in your code ... const parser = port.pipe(new Readline({delimiter: '\r\n'})); ... Actually captures each line of data. But since your output from arduino contains data in the same line, we will have to split() it at the space character. So to get an array of more than one temperature values, you can use tempArray = temp.split(" ");. This array then can be sent to the front-end. For 2nd After you have the array of the temperature values, you can send that array itself to the front end using // Notice I have replaced `temp` with `tempArray` io.sockets.emit('temp', {date:today.getDate()+"-"+today.getMonth()+1+"-"+today.getFullYear(), time: (today.getHours())+":"+(today.getMinutes()), temp:tempArray}); }); In the front-end, the dataset in the Chart object is an array. And if you want to add more than one datasets to the chart, you can add them simply by adding one more dataset object : .... datasets: [{ label: "Sensor1", borderColor: "#FF5733", data: [], fill: false, pointStyle: 'circle', backgroundColor: '#3498DB', pointRadius: 5, pointHoverRadius: 7, lineTension: 0, }, .... .... { label: "Sensor2", borderColor: "#FFFF33", data: [], fill: false, pointStyle: 'circle', backgroundColor: '#34FFDB', pointRadius: 5, pointHoverRadius: 7, lineTension: 0, }, ] .... Now, inside the socket.on('temp', function(data){...}) you can push data like this : chart.dataset[i].data.push(data.temp[i]) // looping over i Edit To put in the data into the datasets, you can use a 'for' loop as follows : for (var i = 0; i < datasets.length; i++) { chart.datasets[i].data.push(data.temp[i]); }