Nodejs modules do not work as expected on different devices

I am using twitter streaming api and johnny-five with some other http , express & socket.io with arduino uno

My script works fine on a laptop. But my production will be on the tablet. I have two tablets, and both of them react differently. On hp omni tablet, I get the following error

enter image description here

I also have arduino-uno connected to COM3 port, but its indicating device is connected to COM1

As far as I know, this error occurs when standard firmata not disclosed in arduino. I downloaded this program and it works great on a laptop.

In Acer Tablet, I do not get any errors, the program runs fine, without any problems, but I do not get tweets from twitter streaming api

I cross-checked many times when it worked perfectly on a laptop every time I run it, but it gives two different problems with tablets

Here is the code I'm using

 var Twitter = require('twitter'); var five = require("johnny-five"); var express = require('express') , app = express() , http = require('http') , server = http.createServer(app) , io = require('socket.io').listen(server); server.listen(8080); // routing app.use(express.static(__dirname + '/http')); app.use(function (req, res, next) { res.setHeader('Access-Control-Allow-Origin', "http://"+req.headers.host+':80'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); next(); } ); var client = new Twitter({ consumer_key: 'abc', consumer_secret: 'abc', access_token_key: 'abc', access_token_secret: 'abc' }); var board = new five.Board(); board.on("ready", function() { this.pinMode(5, five.Pin.OUTPUT); this.pinMode(10, five.Pin.INPUT); //Ask to visit url console.log("Visit http://localhost:8080"); var randomHashtag = Math.floor((Math.random() * 10000) +1); var count = 0;//Initialize counter io.sockets.on('connection', function (socket) { console.log('Ready to recieve tweets');//Prints Message when Socket.io is ready to recieve tweets io.emit('stream',{number:randomHashtag});//Send random no when socket initzilize client.stream('statuses/filter', {track: '#tweetMe'}, function(stream) { stream.on('data', function(tweet) { if(tweet.text.search(randomHashtag) > 0){ count++;//Increment pending tweets randomHashtag = Math.floor((Math.random() * 10000) +1); io.emit('stream',{number:randomHashtag}); board.digitalWrite(5,1); console.log(tweet.text); } else{ console.log("Tweet Without random No"); } }); stream.on('error', function(error) { throw error; }); }); }); }); 
+6
source share
2 answers

As you said, it works fine with other devices, and also managed to fix the problem with other tablets, and I can think of a damaged installation of nodejs or other modules that you use

Try cleaning up the reinstallation of nodejs and all modules . Maybe there are some problems in your modules, not in your code.

Another reason you have the following nodejs problem nodejs that it supports two different versions, both handle installing modules in a different way.

Use the same version that you use on your laptop.

+1
source

I solved the problem with my HP OMNI tablet by manually telling johnny-five which port my arduino is connected to, as indicated in OFFICIAL DOCUMENTATION p>

 new five.Board({ port: "COM3" });//FOR WINDOWS ONLY 

I also had to reinstall all the modules to make it work

(However, does not work with the Acer tablet)

0
source

All Articles