ni-c / heimcontrol.js

Home-Automation with node.js and Raspberry PI
MIT License
1.41k stars 297 forks source link

Arduino Problems #13

Closed rupertbuesst closed 10 years ago

rupertbuesst commented 10 years ago

Heimcontrol is up and running for me on my pi, but having problems with arduino.

I have a macbook which I can use to upload the duino code to the arduino, but there are errors. I'm pretty sure I'm not doing things right. Can someone please help?

I have the following equipment for my home automation setup. Raspberry pi Macbook air Arduino Uno R3 + rf transmitter etc.

ni-c commented 10 years ago

Hey rubertbuesst,

You can find a guide here: http://arduino.cc/en/Guide/Environment#uploading

Can you post the errors that you receive when you try to upload the duino code?

rupertbuesst commented 10 years ago

Hi ni-c,

Here are the errors when I upload du.ino:

sketch_oct04a.ino:2:22: error: RCSwitch.h: No such file or directory sketchoct04a.ino: In function 'void handleRCTriState(char, char_)': sketch_oct04a:261: error: 'RCSwitch' was not declared in this scope sketch_oct04a:261: error: expected `;' before 'rc' sketch_oct04a:262: error: 'rc' was not declared in this scope

Thanks!

Also, heimcontrol is an awesome project - congratulations!

rupertbuesst commented 10 years ago

Ok, I think I've worked out how to do it. I wasn't importing the relative files as libraries.

I have a quick question though: Can you turn a non RGB LED on and off through heimcontrol? How do I do this?

Kind regards!

ConnorRoberts commented 10 years ago

Non-RGB LEDs can be controlled through the standard Arduino control plugin as shown here http://ni-c.github.io/heimcontrol.js/plugins/arduino.html

and just connect it to the Arduino as shown http://arduino.cc/en/uploads/Tutorial/ExampleCircuit_bb.png

rupertbuesst commented 10 years ago

Hi Connor,

Which heimcontrol setting do I use please? Do I do it under the Arduino settings, if so which method?

Many Thanks!

ConnorRoberts commented 10 years ago

That's a fair point actually! I seem to remember having it working, i'll have play when I'm home.

I'd try the rc-switch mode with the positive connected to whatever pin and ground to arduino ground and then just leave the Tristate blank or fill it with anything, that seems like it may work.

Will have a proper play later and will probably send a pull request with a proper setting anyway, shouldn't be much work and will remove confusion :)

ConnorRoberts commented 10 years ago

Have added an LED option in pull request #18 :)

rupertbuesst commented 10 years ago

Hi Connor,

Thanks for adding the option!

Now just wondering how I update heimcontrol so I can take advantage of the changes you made. Do I have to format the pi SD card and start again?

Kind regards,

Rupert

On 13/10/2013, at 6:23 AM, Connor Roberts notifications@github.com wrote:

Have added an LED option in pull request #18 :)

— Reply to this email directly or view it on GitHub.

ConnorRoberts commented 10 years ago

Delete the heimcontrol folder, then run

git clone https://github.com/ConnorRoberts/heimcontrol.js.git

and then restart it like you normally would :)

or just

git pull

in the directory (but this will only work when the pull request is merged)

(All data will be safe as it stays in the database)

rupertbuesst commented 10 years ago

Thanks Connor,

I was able to use the git pull method which is awesome.

I'll test out the new feature today. Thanks again for your help!

On 13/10/2013, at 9:41 AM, Connor Roberts notifications@github.com wrote:

Delete the heimcontrol folder, then run

git clone https://github.com/ConnorRoberts/heimcontrol.js.git and then restart it like you normally would :)

or just

git pull in the directory (but this will only work when the pull request is merged)

(All data will be safe as it stays in the database)

— Reply to this email directly or view it on GitHub.

ConnorRoberts commented 10 years ago

That may have brought you up to date but it won't include my changes, they haven't been merged yet.

To get my changes, clone my version of the repo for now or wait until the changes are merged :)

rupertbuesst commented 10 years ago

Hi Connor,

In heimcontrol it now actually lets me add an LED, but when I hook it up to my arduino and breadboard it doesn't work. Does there need to be a change to the duino plugin for the addition of the LED feature?

Thanks :)

On 13/10/2013, at 11:09 AM, Connor Roberts notifications@github.com wrote:

That may have brought you up to date but it won't include my changes, they haven't been merged yet.

To get my changes, clone my version of the repo for now or wait until the changes are merged :)

— Reply to this email directly or view it on GitHub.

ConnorRoberts commented 10 years ago

Just tested on my Arduino (just used duinos debug mode to test before) and it works great, when you wired it up did you include a resistor like in the diagram I posted above? If you did, that'll be why - apparently it's not needed :)

No duino code needs to be changed :)

rupertbuesst commented 10 years ago

Have tried everything, still not working (I'm not using a resistor either).

When I click the LED ON in the heimcontrol interface, and look at my terminal ssh, everything seems to be working, heimcontrol writes to the pin 13 on the arduino where I have breadboard connected with a few leds on it.

For some reason, the arduino isn't taking the commands. Maybe I'll try reloading the duino code to the arduino.

ConnorRoberts commented 10 years ago

Yeah, I'd try reloading du.ino :)

Also, run

ls /dev | grep usb

On the Pi and then if that returns nothing then run

ls /dev | grep -E 'usb|ttyACM*'

And let me know which works :)

rupertbuesst commented 10 years ago

Hi Connor,

Thanks for the reply, the first command didn't return anything, but the second command returned: ttyACM0

Thanks,

Rupert On 19/10/2013, at 10:37 PM, Connor Roberts notifications@github.com wrote:

ls /dev | grep -E 'usb|ttyACM*'

ConnorRoberts commented 10 years ago

Okay go into /node_modules/duino and open up board.js

Look for the line

child.exec('ls /dev | grep usb', function(err, stdout, stderr){

and replace it with

child.exec("ls /dev | grep -E 'usb|ttyACM*'", function(err, stdout, stderr){

that should fix it (Source: http://jvrbaena.github.io/blog/2013/07/15/node-dot-js-arduino-raspberry-pi-ii/)

Let me know how you get on :)

rupertbuesst commented 10 years ago

Thanks Connor,

I'll try that. Sorry again for the nooby question, but which command should I use to edit the board.js file? I tried: pico board.js (but I think this is wrong it didn't open properly).

Thanks so much, I'm really grateful for your help :)

Rupert

On 20/10/2013, at 9:37 AM, Connor Roberts notifications@github.com wrote:

Okay go into /node_modules/duino and open up board.js

Look for the line

child.exec('ls /dev | grep usb', function(err, stdout, stderr){ and replace it with

child.exec("ls /dev | grep -E 'usb|ttyACM*'", function(err, stdout, stderr){ that should fix it (Source: http://jvrbaena.github.io/blog/2013/07/15/node-dot-js-arduino-raspberry-pi-ii/)

Let me know how you get on :)

— Reply to this email directly or view it on GitHub.

ConnorRoberts commented 10 years ago

Would probably easier to run

rm board.js

and then

wget https://raw.github.com/JvrBaena/duino/master/lib/board.js
rupertbuesst commented 10 years ago

Hi Connor,

It works :) Thanks so much for your help!!

Led is now working for me, can't wait for my rf transmitter to arrive, so I can start playing round with my rc adapters. I'll also do some work with some applescript so hopefully I can make some sort of make do voice control with apple speech, or dragon dictate as I have an old apple laptop with a broken screen which would be perfect for this.

Thanks again! On 20/10/2013, at 11:15 AM, Connor Roberts notifications@github.com wrote:

Would probably easier to run

rm board.js and then

wget https://raw.github.com/JvrBaena/duino/master/lib/board.js — Reply to this email directly or view it on GitHub.

rupertbuesst commented 10 years ago

oh s*\ my sd card just corrupted on the pi!

Have to start again :( at least I know what to do know!

ConnorRoberts commented 10 years ago

Just as you got it working! ;)

@ni-c Just noticed heimcontrol.js already runs from a forked version of duino (with another variation of the "ls /dev" bit of board.js), just wanted to point out that this isn't working for everyone and

ls /dev | grep -E 'usb|ttyACM*'

worked in this case, I'd have sent a pull request if that line hadn't already been changed by you, which was obviously to fix something in the first place!

I'd suggest something along the lines of

ls /dev | grep 'ACM|ttyACM*'

but I couldn't say for certain that wouldn't break anything else, so would you take a look please?

rupertbuesst commented 10 years ago

Hi Connor,

Just one more question. How do I start the MongoDB? (say if the pi restarts - I get the MongoDB error when I run heimcontrol)

Thanks,

Rupert On 21/10/2013, at 8:38 AM, Connor Roberts notifications@github.com wrote:

Just as you got it working! ;)

@ni-c Just noticed heimcontrol.js already runs from a forked version of duino (with another variation of the "ls /dev" bit of board.js), just wanted to point out that this isn't working for everyone and

child.exec("ls /dev | grep -E 'usb|ttyACM*'", function(err, stdout, stderr){ worked in this case, I'd have sent a pull request if that line hadn't already been changed by you, which was obviously to fix something in the first place!

I'd suggest something along the lines of

ls /dev | grep ACM|ttyACM* but I couldn't say for certain that wouldn't break anything else, so would you take a look please?

— Reply to this email directly or view it on GitHub.

bkiss commented 10 years ago

Hi rupertbuesst,

you will find the documentation here:

http://stackoverflow.com/questions/17901627/setting-up-mongodb-raspberry-pi

Please notice that, i have changed this script to start the mongodb with journalling, somewhere i put:

--journal

rupertbuesst commented 10 years ago

Is there a quick command to just start the database?

Thanks :) On 21/10/2013, at 7:28 PM, bkiss notifications@github.com wrote:

Hi rupertbuesst,

you will find the documentation here:

http://stackoverflow.com/questions/17901627/setting-up-mongodb-raspberry-pi

Please notice that, i have changed this script to start the mongodb with journalling, somewhere i put:

--journal

— Reply to this email directly or view it on GitHub.

bkiss commented 10 years ago

I'm using the sudo service mongodb start command, but you need to register as service, simplest way:

cd /etc/init.d sudo wget -O mongodb https://gist.github.com/ni-c/fd4df404bda6e87fb718/raw/36d45897cd943fbd6d071c096eb4b71b37d0fcbb/mongodb.sh sudo chmod +x mongodb sudo update-rc.d mongodb defaults sudo service mongodb start

--- from the get started documentation...

rupertbuesst commented 10 years ago

The problem is, when I turn pi off, then on again - nothing works! The database won't start neither will heimcontrol (cos the database won't start).

Any advice?

:)

izim commented 10 years ago

Do you halt or shutdown the raspi or du you cut the power? If you don't properly shut down the raspi you have to delete /var/lib/mongodb/mongod.lock and then start the mongodb daemon

bkiss commented 10 years ago

I have solved this, starting the mongo database with journalling enabled.

Edit the startup script from init.d (?) and specifify --journal maybe.

http://docs.mongodb.org/manual/tutorial/manage-journaling/

after this, you don't need to delete every time the lock file.