how to send two data to an html file via socket.io?

1

the code with nodejs, I'm working with socket.io

function onDato(dato){
io.sockets.emit('lectura', dato);
}

Here I show the code made with angularjs, if it shows me in html the data but as I am sending two at the same time nothing else shows me one.

    var app = angular.module('tutorial', []);
    var socket = io();

    app.controller('temperatura', ['$scope', function ($scope){

        socket.on('lectura', function(lectura){
         $scope.$apply(function(){
            $scope.dato = lectura;
             console.log(lectura);
              });
        });

    }]);

I append the code I did in arduino:

#include <DHT.h>
#define DHTPIN 7
#define HT1 7
#define HT2 8
#define DHTTYPE DHT11

DHT dht1 (HT1, DHTTYPE);
DHT dht2 (HT2, DHTTYPE);

void setup() {
Serial.begin(9600);
dht1.begin();
dht2.begin();


}

void loop() {
float t1, t2;
t1 = dht1.readTemperature();
t2 = dht2.readTemperature();

Serial.println("S1");
Serial.println(t1);
Serial.println("S2");
Serial.println(t2);

delay(10000);
}
    
asked by Julio Cesar 16.03.2018 в 00:16
source

0 answers