Go Down

Topic: Trouble Identifying Port  (Read 464 times) previous topic - next topic

nikobeast

I am trying to do this tutorial https://openhomeautomation.net/bluetooth-heart-rate-sensor-arduino
this is the code

Code: [Select]

var express = require('express');
var app = express();


var port = 3000;


app.set('veiw engine','jade')


app.use(express.static(__dirname + '/public'))


app.get('/', function(req, res){
  res.render('simple');
});


var rest = require("arest")(app);

rest.addDevice('serial','COM3', 115200);


app.listen(port);
console.log("Listening on port " + port);



void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}



In the tutorial, it said to alter this line rest.addDevice('serial','/dev/tty.usbmodem1a12121', 115200); so I changed it to rest.addDevice('serial', 'COM3', 115200);
but I am getting the error code below. Am I writing it wrong or is that the wrong port?


ERROR CODE:
Arduino: 1.8.4 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\Wicke\OneDrive\Documents\Arduino\sketch_jan12a\sketch_jan12a.ino:2:23: warning: character constant too long for its type

 var express = require('express');

                       ^

C:\Users\Wicke\OneDrive\Documents\Arduino\sketch_jan12a\sketch_jan12a.ino:9:9: warning: character constant too long for its type

 app.set('veiw engine','jade')

         ^

C:\Users\Wicke\OneDrive\Documents\Arduino\sketch_jan12a\sketch_jan12a.ino:9:23: warning: character constant too long for its type

 app.set('veiw engine','jade')

                       ^

C:\Users\Wicke\OneDrive\Documents\Arduino\sketch_jan12a\sketch_jan12a.ino:12:36: warning: character constant too long for its type

 app.use(express.static(__dirname + '/public'))

                                    ^

C:\Users\Wicke\OneDrive\Documents\Arduino\sketch_jan12a\sketch_jan12a.ino:16:14: warning: character constant too long for its type

   res.render('simple');

              ^

C:\Users\Wicke\OneDrive\Documents\Arduino\sketch_jan12a\sketch_jan12a.ino:22:16: warning: character constant too long for its type

 rest.addDevice('serial','COM3', 115200);

                ^

C:\Users\Wicke\OneDrive\Documents\Arduino\sketch_jan12a\sketch_jan12a.ino:22:25: warning: character constant too long for its type

 rest.addDevice('serial','COM3', 115200);

                         ^

sketch_jan12a:2: error: 'var' does not name a type

 var express = require('express');

 ^

sketch_jan12a:3: error: 'var' does not name a type

 var app = express();

 ^

sketch_jan12a:6: error: 'var' does not name a type

 var port = 3000;

 ^

sketch_jan12a:9: error: 'app' does not name a type

 app.set('veiw engine','jade')

 ^

sketch_jan12a:17: error: expected unqualified-id before ')' token

 });

  ^

sketch_jan12a:20: error: 'var' does not name a type

 var rest = require("arest")(app);

 ^

sketch_jan12a:22: error: 'rest' does not name a type

 rest.addDevice('serial','COM3', 115200);

 ^

sketch_jan12a:25: error: 'app' does not name a type

 app.listen(port);

 ^

sketch_jan12a:26: error: 'console' does not name a type

 console.log("Listening on port " + port);

 ^

exit status 1
'var' does not name a type

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

pert

The tutorial actually says this:
Quote
Then, open the file called app.js, and modify the following line:

rest.addDevice('serial','/dev/tty.usbmodem1a12121', 115200);
It doesn't say anything about taking the code out of that file and copy/pasting it into a blank Arduino sketch. Do you see the part of the filename ".js". That means JavaScript. Arduino sketches are C++. You will never be able to compile JavaScript code using the Arduino IDE. You need to take some time to understand what this tutorial is actually about.

There is a program that runs on your Arduino, which is found in the pulse_sensor_bluetooth or subfolder of https://github.com/openhomeautomation/bluetooth-pulse-rate-sensor. You can tell they are sketches because the filename ends in .ino and you can open them in the Arduino IDE without any monkey business.

Then there is an application that runs on your computer to display the data transmitted from the Arduino via Bluetooth. That is found in the interface folder.

There is another sketch in the repository, pulse_sensor_test.ino. That should be used first to make sure your pulse sensor is working before you add in all the extra complexity of the Bluetooth communication and the PC application. It simply prints the heart rate to the Serial Monitor.

nikobeast

Yes but how do I run the application for transmitting the data from the arduino via ble if it is javascript. I tried to download javascript but I am unsure as to whether I am downloading the correct program.

pert

Well the tutorial does provide instructions:
Quote
Go in the folder where you put all the application files, and type:
sudo npm install arest express jade

Then, start the application with:
node app.js
Unfortunately those are for Linux. For Windows you'll either need to ask our old friend Google or hang out and hope some kind soul here on the forum comes along to help.

gdsports

To download and install node.js (Javascript), go to https://nodejs.org/.

Go Up