Simple feeding button through IOModule

Do you have a question on how to do something.
Ask in here.
Post Reply
MisterTang
Posts: 58
Joined: Sat Jan 04, 2014 3:12 pm

Simple feeding button through IOModule

Post by MisterTang »

So I've worked most of the kinks out of my setup and am really happy with RA so far. I bought an IO module knowing that I'd want to tinker around with it, but also because I want to have a doorbell button on the back of my tank for my neighbor to push when she's feeding my fish when I'm out of town that will activate feeding mode.


Now I did some digging around the forums and I know I want to call "FeedingModeStart()", but what I'm unsure of is exactly how I want to monitor Controller.getIOChannel - I assume that it's a zero-based array of my channels, and that "closed" will cause this bool to return true?

Lastly, where should I put my custom stuff? If I make changes in the Wizard in the future, won't it clobber my code?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Simple feeding button through IOModule

Post by lnevo »

You are done with the wizard now. Welcome to RA grade school :) you should put the custom code in the loop section in between the comments that say insert custom code here. You should save that file as a reference because you are right, if you run the wizard again you will lose the changes. I dont know the code for the IO module so I cant point you in the right direction there, but figured I would officially graduate you :)
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Simple feeding button through IOModule

Post by rimai »

Actually, true is open and false is closed.
You can use a code like this:

Code: Select all

if (!ReefAngel.IO.GetChannel(0))
{
// Do something if door bell is pressed

}
Roberto.
MisterTang
Posts: 58
Joined: Sat Jan 04, 2014 3:12 pm

Re: Simple feeding button through IOModule

Post by MisterTang »

rimai wrote:Actually, true is open and false is closed.
You can use a code like this:

Code: Select all

if (!ReefAngel.IO.GetChannel(0))
{
// Do something if door bell is pressed

}

Thanks, Roberto! Out of curiosity, how do you distinguish the channels on multiple IO modules?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Simple feeding button through IOModule

Post by rimai »

The 0 means channel 0. You can use 0 through 5.
Roberto.
MisterTang
Posts: 58
Joined: Sat Jan 04, 2014 3:12 pm

Re: Simple feeding button through IOModule

Post by MisterTang »

So this didn't work:
void loop()
{

if (!ReefAngel.IO.GetChannel(0)) // If the feeding mode button is pressed, start feeding mode.
{
ReefAngel.FeedingModeStart();

}

}

- I added the IO libraries and the screen is showing up on my RA unit.
- I inserted some doorbell wire into Channel 0 and one of the GND ports.
- I made sure the IO module USB was plugged into my hub, and that I plugged in the power for the IO module
- I touch the two exposed pieces of doorbell wire together and... nothing

EDIT: Also not seeing any of the dots change on the IO screen on the RA unit... not sure if they're supposed to register something.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Simple feeding button through IOModule

Post by rimai »

Yes, the dots were supposed to change when you touch the wires.
Is the green LED lit on the side of the module?
What happens when you use another channel?
What about a different port on the hub or connected straight into the relay box?
Roberto.
MisterTang
Posts: 58
Joined: Sat Jan 04, 2014 3:12 pm

Re: Simple feeding button through IOModule

Post by MisterTang »

rimai wrote:Yes, the dots were supposed to change when you touch the wires.
Is the green LED lit on the side of the module?
Yep!
rimai wrote:What happens when you use another channel?
Nothing. None of them seem to be working
rimai wrote:What about a different port on the hub or connected straight into the relay box?
Plugged it directly into the relay box with the same result.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Simple feeding button through IOModule

Post by rimai »

Can you run the I2CScanner code and send me the results?
http://forum.reefangel.com/viewtopic.php?p=18831#p18831
Roberto.
MisterTang
Posts: 58
Joined: Sat Jan 04, 2014 3:12 pm

Re: Simple feeding button through IOModule

Post by MisterTang »

I2CScanner ready!
starting scanning of I2C bus from 1 to 128...
addr: 1 addr: 2 addr: 3 addr: 4
addr: 5 addr: 6 addr: 7 addr: 8
addr: 9 addr: A addr: B addr: C
addr: D addr: E addr: F addr: 10
addr: 11 addr: 12 addr: 13 addr: 14
addr: 15 addr: 16 addr: 17 addr: 18
addr: 19 addr: 1A addr: 1B addr: 1C
addr: 1D addr: 1E addr: 1F addr: 20 found!
addr: 21 addr: 22 addr: 23 addr: 24
addr: 25 addr: 26 addr: 27 addr: 28
addr: 29 addr: 2A addr: 2B addr: 2C
addr: 2D addr: 2E addr: 2F addr: 30
addr: 31 addr: 32 addr: 33 addr: 34
addr: 35 addr: 36 addr: 37 addr: 38
addr: 39 addr: 3A addr: 3B addr: 3C
addr: 3D addr: 3E addr: 3F addr: 40
addr: 41 addr: 42 addr: 43 addr: 44
addr: 45 addr: 46 addr: 47 addr: 48
addr: 49 addr: 4A addr: 4B addr: 4C
addr: 4D addr: 4E addr: 4F addr: 50 found!
addr: 51 addr: 52 addr: 53 addr: 54 found!
addr: 55 addr: 56 addr: 57 addr: 58
addr: 59 addr: 5A addr: 5B addr: 5C
addr: 5D addr: 5E addr: 5F addr: 60
addr: 61 addr: 62 addr: 63 addr: 64
addr: 65 addr: 66 addr: 67 addr: 68 found!
addr: 69 addr: 6A addr: 6B addr: 6C
addr: 6D addr: 6E addr: 6F addr: 70
addr: 71 addr: 72 addr: 73 addr: 74
addr: 75 addr: 76 addr: 77 addr: 78
addr: 79 addr: 7A addr: 7B addr: 7C
addr: 7D addr: 7E addr: 7F addr: 80

done
Image
MisterTang
Posts: 58
Joined: Sat Jan 04, 2014 3:12 pm

Re: Simple feeding button through IOModule

Post by MisterTang »

This is with it plugged directly into the relay and skipping the expansion hub:




I2CScanner ready!
starting scanning of I2C bus from 1 to 128...
addr: 1 addr: 2 addr: 3 addr: 4
addr: 5 addr: 6 addr: 7 addr: 8
addr: 9 addr: A addr: B addr: C
addr: D addr: E addr: F addr: 10
addr: 11 addr: 12 addr: 13 addr: 14
addr: 15 addr: 16 addr: 17 addr: 18
addr: 19 addr: 1A addr: 1B addr: 1C
addr: 1D addr: 1E addr: 1F addr: 20 found!
addr: 21 addr: 22 addr: 23 addr: 24
addr: 25 addr: 26 addr: 27 addr: 28
addr: 29 addr: 2A addr: 2B addr: 2C
addr: 2D addr: 2E addr: 2F addr: 30
addr: 31 addr: 32 addr: 33 addr: 34
addr: 35 addr: 36 addr: 37 addr: 38
addr: 39 addr: 3A addr: 3B addr: 3C
addr: 3D addr: 3E addr: 3F addr: 40
addr: 41 addr: 42 addr: 43 addr: 44
addr: 45 addr: 46 addr: 47 addr: 48
addr: 49 addr: 4A addr: 4B addr: 4C
addr: 4D addr: 4E addr: 4F addr: 50 found!
addr: 51 addr: 52 addr: 53 addr: 54 found!
addr: 55 addr: 56 addr: 57 addr: 58
addr: 59 addr: 5A addr: 5B addr: 5C
addr: 5D addr: 5E addr: 5F addr: 60
addr: 61 addr: 62 addr: 63 addr: 64
addr: 65 addr: 66 addr: 67 addr: 68 found!
addr: 69 addr: 6A addr: 6B addr: 6C
addr: 6D addr: 6E addr: 6F addr: 70
addr: 71 addr: 72 addr: 73 addr: 74
addr: 75 addr: 76 addr: 77 addr: 78
addr: 79 addr: 7A addr: 7B addr: 7C
addr: 7D addr: 7E addr: 7F addr: 80

done
Image
MisterTang
Posts: 58
Joined: Sat Jan 04, 2014 3:12 pm

Re: Simple feeding button through IOModule

Post by MisterTang »

I also just tried a different USB cable, plugged directly into the relay.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Simple feeding button through IOModule

Post by rimai »

Do you have any other expansion module?
I can say that controller is not seeing the module.
The module uses address 27.
Roberto.
MisterTang
Posts: 58
Joined: Sat Jan 04, 2014 3:12 pm

Re: Simple feeding button through IOModule

Post by MisterTang »

I have the water level expansion, but it has never worked right - the level always drops to zero after a period of time. It wasn't plugged in when I did the test - did you want me to plug it in and try again?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Simple feeding button through IOModule

Post by rimai »

No, if you had it working at one point, I know that the expansion bus is working.
Please send me both your module for me to look at them.
PM me for RMA.
Roberto.
MisterTang
Posts: 58
Joined: Sat Jan 04, 2014 3:12 pm

Re: Simple feeding button through IOModule

Post by MisterTang »

One last one with the water level sensor and the IO module all plugged into the expansion hub:, just to prove I do know how to connect USB cables :)


I2CScanner ready!
starting scanning of I2C bus from 1 to 128...
addr: 1 addr: 2 addr: 3 addr: 4
addr: 5 addr: 6 addr: 7 addr: 8
addr: 9 addr: A addr: B addr: C
addr: D addr: E addr: F addr: 10
addr: 11 addr: 12 addr: 13 addr: 14
addr: 15 addr: 16 addr: 17 addr: 18
addr: 19 addr: 1A addr: 1B addr: 1C
addr: 1D addr: 1E addr: 1F addr: 20 found!
addr: 21 addr: 22 addr: 23 addr: 24
addr: 25 addr: 26 addr: 27 addr: 28
addr: 29 addr: 2A addr: 2B addr: 2C
addr: 2D addr: 2E addr: 2F addr: 30
addr: 31 addr: 32 addr: 33 addr: 34
addr: 35 addr: 36 addr: 37 addr: 38
addr: 39 addr: 3A addr: 3B addr: 3C
addr: 3D addr: 3E addr: 3F addr: 40
addr: 41 addr: 42 addr: 43 addr: 44
addr: 45 addr: 46 addr: 47 addr: 48
addr: 49 addr: 4A addr: 4B addr: 4C
addr: 4D addr: 4E addr: 4F found! addr: 50 found!
addr: 51 addr: 52 addr: 53 addr: 54 found!
addr: 55 addr: 56 addr: 57 addr: 58
addr: 59 addr: 5A addr: 5B addr: 5C
addr: 5D addr: 5E addr: 5F addr: 60
addr: 61 addr: 62 addr: 63 addr: 64
addr: 65 addr: 66 addr: 67 addr: 68 found!
addr: 69 addr: 6A addr: 6B addr: 6C
addr: 6D addr: 6E addr: 6F addr: 70
addr: 71 addr: 72 addr: 73 addr: 74
addr: 75 addr: 76 addr: 77 addr: 78
addr: 79 addr: 7A addr: 7B addr: 7C
addr: 7D addr: 7E addr: 7F addr: 80

done
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Simple feeding button through IOModule

Post by rimai »

Yes, 4f is the water level sensor.
Roberto.
Post Reply