You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to develop a Zetta server, in which the APP can collect and process (statics, analyze and so on) data from multiple sensors of the same type, and the number of sensors is changeable. Is it possible to implement this function by Zetta?
Zetta in itself does not offer any capabilities to process the data but you're on the right track for how to collect data using Zetta.
See our dusk to dawn example that would "process" a fake light sensor and turn the lights on when it is dark. https://github.com/zettajs/zetta-hello-world/blob/master/apps/dusk_to_dawn_light.js To further process the data you will need to pipe the data into another tool. There are many open source options depending on what you're trying todo.
We have also published a number of data collectors that collects all data from every device and pumps the data into different tools:
@AdamMagaluk
Thank you for your reply, we eventually realized the function to process data within Zetta. Although the code is not perfect, we can process changeable numbers of sensors of the same type.
In the app.js:
First, a changeable sequence of queries is used as the first argument of "server.observe(query, cb)".
this.queries = new Array();
for (var i=0; i < this.sensor_number; i++) { //start from 0
const pm25Query = server.from('*').where({type: 'pm_sensor', name: 'pm_sensor_'+i});
this.queries.push(pm25Query);
}
Second, Array.forEach() of Javascript is used to receive data from each sensor.
this.pmSensors = new Array();
for (var i=1; i <= this.sensor_number; i++) { //start from 1, can be changed later
this.pmSensors.push('pmsensor');
}
this.pmSensors.forEach(processValue);
function processValue(sensor, index, arr) {
console.log(sensor);
console.log(index);
server.observe(this.queries[index], (sensor) => {
...//calculate the average of all sensor data
});
}
I am trying to develop a Zetta server, in which the APP can collect and process (statics, analyze and so on) data from multiple sensors of the same type, and the number of sensors is changeable. Is it possible to implement this function by Zetta?
The text was updated successfully, but these errors were encountered: