arduino "simple led script example" help

24 replies [Last post]
garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011

Hi,

I was wondering if someone could offer me yet more help?.

I am trying to do the simple LED arduino script discussed in the wiki to test serial xap transmission to my arduino Deumilanova.

I have plugged it in and got the port address as tty/usb1 port

I have set up the bridge as per the wiki with the above address.

however, I do not see any xap messages in XFX viewer and cannot control the LED with a xAPBSC command.

If I log in to microcom I can see the heartbeat message being sent via serial but thay do not appear in xfx viewer, does this point to a bridge issue? (see below)

any advice of pointers as to what I am doing wrong would be great.

 

Thanks,

Garry

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
is HAH-Bridge deprecated?

noticed its gone from the google source code? does this mean its deprecated?

 

thanks,

 

Garry

brett
Offline
Providence, United States
Joined: 9 Jan 2010
New arudino control sample

Gary indeed the xap-bridge and the samples you where referencing are all deprecated.... sorry about that I hadn't got around to updating this wiki page.  The good news is I wrote a new set of samples for you.

http://www.dbzoo.com/livebox/hah_arduino#led_control_with_a_bsc_schema

This demonstrates how to interface an arduino and simple control protocol to turn on/off a LED and have this exposed as a BSC controllable endpoint.  Let me know how you get on with this one.   You'll need to adjust the PORT to suit where your arduino appears on the HAH.

Brett

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
No Problem

Thanks Brett,

This will do nicely. Will test tomorrow night.

My end use is to IR control my home theatre system, it works great on the standalone arduino just need to connect and automate with HAH which should now be possible.

Just one more question, When the Jeenodes are available can I connect two units and use Xap-serial or will I have to try and combine my ir tx script into the rf12demo sketch on the jeenode?

 

thanks,

Garry

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
works a treat

Brett,

Have now tested and it works a treat thanks,

 

Garry.

jim_lewis1
Offline
Joined: 12 May 2012
Help setting up Arduino

i'm also trying to establish communication with the Arduino via the HAH.

I'm a total noob to all this, so forgive any glaring errors or omissions.

following the how to guide referred to above:

http://www.dbzoo.com/livebox/hah_arduino#led_control_with_a_bsc_schema

I have reached step 3 where reference is made to LUA scripts.

I hadn't previously heard of these, but managed to work out that I needed a LUA editor which I found and downloaded to my windows machine.

It's the next step that I'm stumbling on.

how do I implement these scripts?

I have tried running them on the windows machine but get errors, should they be run on the livebox?

If so, how do I go about doing this?

derek
Offline
Glasgow, United Kingdom
Joined: 26 Oct 2009
Read about the Plugboard

Lua scripts run on the HAH (not on a PC). Scripts run under the Plugboard, so it's best to read the Plugboard writeup at http://www.dbzoo.com/livebox/hah_plugboard_v2

If you can use an editor such as vi, you can telnet onto the HAH & edit the scripts directly on the HAH. If you prefer to edit in Windows, you can create the scripts on your PC then ftp the scripts from the PC to the HAH.

Hope this helps.

Derek.

jim_lewis1
Offline
Joined: 12 May 2012
OK, so Telnet-ing seems the

OK, so Telnet-ing seems the most straightforward.

 

I have been using LUA edit. Will this not Telnet to the Livebox?

jim_lewis1
Offline
Joined: 12 May 2012
Or, having now got the

Or, having now got the scripts in an editor on Windows, how do I use FTP to get them onto the HAH?

derek
Offline
Glasgow, United Kingdom
Joined: 26 Oct 2009
FTP

I tend to edit files directly on the HAH, so generally don't use ftp.

However, the first step is to enable the ftp server on the HAH. Do this on the Admin/Services tab. Then, install a nice ftp client tool on your PC. Filezilla Client is a good one that you can use to drag and drop files to and from your PC and the HAH.

http://filezilla-project.org/download.php

Once you have the file transfer thing sorted, readup on the Plugboard page of the wiki as to how to debug Applets on the HAH.

Derek.

jim_lewis1
Offline
Joined: 12 May 2012
Again, a bit vague to be

Again, a bit vague to be honest.

I have read everything on the site and and still having difficulty as described.

 

If you are editing on the HAH how is this done? Is there an editor, (Vi I think you said), on there?

How does one install Vi if not?

 

I must have used FTP as I think that's how I got the firmware onto the Livebox in the first place, but again, if the file is in the FTp folder what exactly do I need to do to make the Livebox bring the script over?

 

This project is never going to take off if it remains so inaccessible to beginners.

I don't think I should need a degree in computer science to make this thing work.

derek
Offline
Glasgow, United Kingdom
Joined: 26 Oct 2009
Just use vi

vi is already on the HAH. It's much easier to just use that.

telnet onto the HAH from your PC. (we're assuming here that you have enabled telnet via the web UI on the HAH). Once you have a telnet connectoin to the HAH, you will be prompted to login. Login as 'root' ... the root password is 'admin'.

Then, to invoke the  vi editor, just enter 'vi' (in lowercase) at the # comand line prompt.

If it has been a while since you last used vi (or indeed if you've never used it before) there are tutorials all over th web e.g. http://www.unix-manuals.com/tutorials/vi/vi-in-10-1.html

Cheers,
Derek.

 

jim_lewis1
Offline
Joined: 12 May 2012
great!you see that tiny piece

great!

you see that tiny piece of info, (Vi is on the HAH and LUA script can be entered directly), would have saved me about two hours of fruitless head scratching.

 

Can I suggest Step 3 is modified to include this rather critical tip.

 

However, if I now understand the process, we have uploaded or entered the plugboard script into the HAH where it presumably takes up some memory space.

1. Does this script persist through power cycles or must it be rerun each time?

2. If a script is entered directly onto the HAH can it be retrieved for further editing or left for future retrieval?

3. Re. the following script that activates the LED: this is presumably just to ensure the plugboard is working as expected. Can it be deleted once this is confirmed?

 

thanks,

Jim

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Not an out of the box solution.

With all due respect Jim considering this is a project that both Derek and Brett do in their very precious free time, the amount and quality of the documentation is commendable. 

I don't think it has ever been said that this is an out of the box home automation solution. In fact to get the best out of it a lot of time is required learning how it works. In fact this is part of the appeal. 

I am by far a computer expert but with enough reading and time I have managed to get my HAH doing things I never dreamed of. 

Please bear in mind the aim of this project. The support Brett and Derek give free of charge and the many people on here willing to help. That said you will need to put the time in to understand the help being given. All the info is out there on the Internet. Trust me I've used it a lot!

jim_lewis1
Offline
Joined: 12 May 2012
Yes that is appreciated.When

Yes that is appreciated.

When I get time I will write an idiot's, (IE one I can understand), guide to getting this thing going.

I think a few people will come here from Arduino and that is so simple to get going in mere minutes.

As such my expectation was that getting the HAH communicating with Arduino should be as straightforward.

I think the leg work has been done it's just the documentation that is a hindrance.

There is such as thing as info overload so whilst there is no doubt 'sufficient' info on the internet it is not an easy process to follow.

When people are very familiar with a subject they tend to forget how much they know and take for granted.

the issue of LUA scripting and Vi etc. is still something I have yet to come to grips with. I think it should be possible to make this (at least blinking LED setup) more accessible to noobs.

derek
Offline
Glasgow, United Kingdom
Joined: 26 Oct 2009
Scripts are just files

They live on the HAH filesystem in the /etc/plugboard directory. When the HAH powers up, if you have enabled the plugboard service (from the Automation/Assists tab on the web UI), all scripts with a name that ends in 'Applet.lua' (e.g. myScriptApplet.lua) will be automatically started up.

The script files are persisted in the HAH filesystem (even when power is removed). You can login and edit them again at any time.

If you are finished with a test script and don't want it to run any more, but do want to keep it for future use, rename the script file to something that doesn't end in 'Applet.lua' and reboot the HAH. Otherwise, just delete the script file and reboot the HAH. 

Cheers,
Derek.

p.s. A 'get Arduino folks started' writeup would be most welcome

jim_lewis1
Offline
Joined: 12 May 2012
For example these guys are

For example these guys are capitalising on the 'internet of things' but have worked to make it plug and play:

http://supermechanical.com/twine/

andy
Offline
United Kingdom
Joined: 17 Mar 2012
Transitioning...

Jim,

 

I understand where you are comming from, as when I started with this I knew very very little about electronics, but had some knowledge about computer software. I think the guys on here are all working for a 'somewhat turnkey' approach, but at low cost some ''tinkering' is required, and when you are finished tweeting about your kitchen moisture levels with TWINE and want to integrate with your RF mains sockets at 433mhz, your US TWINE market is maybe not really going to help you much, but your HAH (and importantly the forum members) can, and cost effectively.

TWINE (and a number of other projects) do however clarify a few things for me (a HAH user):

- [We] need to tidy up/restructure the Wiki (I am more than willling to add some of my newbie docs that I have done myself).

- [We] need plenty simple use-cases - something I have said to Derek I will at least be able to help with (watch this space).

- Plugboard v2 is very flexible, [we] need a more structured 'script repository' with docs/use-cases/parts inventorys - I also offer my time here.

As a side note: 

I knew when I came across this project in March 2012 that some soldering would be required (never touched a solder iron for 10 years), and building my HAH has been extreemly satisfying (I have built 1 from scratch and assembled another for development). I have learnt a little more about electronics, rediscovered small MICRO's (AMTEL328P) and am now curious about whats inside small electrical things that make them work (not that I understand most things yet). I even took the nerve-racking path to 240v relays to drive my zoned heating (this path definately needs more documenting than the wiki provides, although I'm probably not the most competent person to do this right now, although I dont think my house will burn down just yet;)) 

Stick in there, all/most members are part-time HAH hobbyists and do this in their free time.

I have found the forums very helpful, and seen the project move forward since March. I was interested in the HAHNode (Still am), but this also lead me to Jeenodes (similar concept to TWINE devices without a case). I have had great fun experimenting with these both linked to my HAH and as seperate devices talking to each other - HAHnodes should be cheaper (at least a fraction of $99).

I also have some ideas to shortly share with the forum about plugboard, script librarys, and SaaS internet console that could help with the more HAH home-user orientated end of the spectrum.

 

--my 2c's

Andy 

 

 

 

 

jim_lewis1
Offline
Joined: 12 May 2012
OK, so I got into Telnet,

OK, so I got into Telnet, started vi and started plugging away the script.

 

However, I'm sure i saved it, but how can i find it?

Also, how can I put it in the correct directory?

It's a very long time since I looked at command line interfaces so I have no recollection of commands etc.

if I type cd/etc does this take me to the etc directory and then cd/plugboard to get to where the script should be?

I typed it into the first place I arrived once logged on with Telnet, where is this likely to be and how do I go back there?

Thanks

andy
Offline
United Kingdom
Joined: 17 Mar 2012
Telnet etc.

Jim,

Normally on Linux, when you login you will sit in the users 'home' folder, which in the case of HAH (if you have not changed anything will be):

/mnt/jffs2/jffs2_3/root

 you can find out "where" you are by issuing the 'pwd' command in the console (you dont need the quotes).

If you typed 'vi' last time in this folder and saved the doc without a path it will be stored here. Use 'ls' to see the files/folders in here.

I personally use 'ls -al' the most as it gives a more verbose listing. As with many linux commands you have simple help, by using something like 

'ls --help'

Anyhow - lets say you created myscriptApplet.lua in the 'home' folder, you can either copy or move it to the plugboard folder like this:

to move:

'mv  myscriptApplet.lua /etc/plugboard'

to copy:

'cp myscriptApplet.lua /etc/plugboard'

linux is caseSensetiVe, so make sure you get your filenames correct.

btw: Every linux user has a preference for editors/ide's/terminal emulators etc, and each has its merits/drawbacks. The HAH needs to be very frugal with its memory use, so only a minimal set of 'tools' are built in, you could add your own. If you are a windows user, you could try 'putty' for terminal use and 'WinSCP' for file transfer, You can then (generally) use your windows tools for file editing and copy then up/down from your PC.

hope this little post help some more.

 

--andy

jim_lewis1
Offline
Joined: 12 May 2012
Thanks Andy, that is very

Thanks Andy, that is very helpful, i'm afraid it's step by step instructions I need as none of this is intuitive to me.

 

I now see the Arduino listed on the xfx viewer and the attached LED.

How do I send a message to alter it's state?

brett
Offline
Providence, United States
Joined: 9 Jan 2010
http://www.dbzoo.com/livebox/

http://www.dbzoo.com/livebox/hah_arduino at Step 5 is the message you need to send. 

Brett

jim_lewis1
Offline
Joined: 12 May 2012
yes, but how?Where should i

yes, but how?

Where should i enter it?

 

I think you can assume that having worked through the previous 4 stages that if I'm asking questions it's because the instructions leave out vital information.

 

The step says that BSC messages are easily sent using xfx.

The icon to send messages is greyed out on the bottom of the window. What must I do to enable this?

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Follow the steps I, II,

Follow the steps I, II, III.   You can't send directly you need to open any arbitary message, edit it and then press send.   I didn't write this tool and as you can see other developers don't document their tools so some research is needed.

jim_lewis1
Offline
Joined: 12 May 2012
OK, finally got there, thanks

OK, finally got there, thanks for the help!

xfx is only an easy way to send messages if you know that you can open and then edit a message to send it.

 

Can't quite believe how much satisfaction I'm getting from turning an LED on and off from my computer to the Arduino on the other side of the room!

Hardware Info