Jeenode With 4 Digital Inputs
Moderator: Mdamen
Jeenode With 4 Digital Inputs
Hello,
Now that my other node's are working quite well
I need a Jeenode with 4 inputs i want to use this for my co2 unit that is using 3 leds to give the state off
the co2 in the house.
I asked it to Digit and he is making this sketch so when its ready
he will post it here.
Thanks Digit
Now that my other node's are working quite well
I need a Jeenode with 4 inputs i want to use this for my co2 unit that is using 3 leds to give the state off
the co2 in the house.
I asked it to Digit and he is making this sketch so when its ready
he will post it here.
Thanks Digit
Re: Jeenode With 4 Digital Inputs
Hi Ed,
It looks like you really caught the JeeNode 'fever'
1 last question for you, Ed: is it going to be battery powered or not?
Maybe you already use a power source for the CO2 unit that can also be used the the JeeNode?
It looks like you really caught the JeeNode 'fever'

1 last question for you, Ed: is it going to be battery powered or not?
Maybe you already use a power source for the CO2 unit that can also be used the the JeeNode?
Re: Jeenode With 4 Digital Inputs
Hello,
Yes i am happy with the nodes now i can build my own.
Cheap and nice to to
If it can be battery powerd then i can also use them for the doors and other things
if not then i can power the node with the brick from the co2 meter
Thanks
Ed
Yes i am happy with the nodes now i can build my own.
Cheap and nice to to
If it can be battery powerd then i can also use them for the doors and other things
if not then i can power the node with the brick from the co2 meter
Thanks
Ed
Re: Jeenode With 4 Digital Inputs
Ed,
Sketch is finished; (I will show what changes were needed; it's really VERY easy; took me about 5 minutes) well to be more accurate, it compiles. I will do some tests tonight and if all is OK, I will post it.
I made a non-battery powered sketch first for this application, knowing that a power brick is nearby and because of the following:
The battery-powered version will have some limitations; the ATMega has 2 external interrupts; one of them is being used by the RF12 unit. That leaves 1 interrupt for waking up the JeeNode when something happens (door or window opening, motion etc.) you want to know about ASAP. Maybe you can put multiple triggers in parallel on this single interrupt so each one will trigger a wake up, but then you need to be able to find out what triggered the wake-up from the sketch. I've never tried something like that, although it shouldn't be hard to do that (trying, I mean).
Let's see if the upcoming sketch suits your purpose for this CO2 sensor and have a look at a battery powered version later, OK?
Sketch is finished; (I will show what changes were needed; it's really VERY easy; took me about 5 minutes) well to be more accurate, it compiles. I will do some tests tonight and if all is OK, I will post it.
I made a non-battery powered sketch first for this application, knowing that a power brick is nearby and because of the following:
The battery-powered version will have some limitations; the ATMega has 2 external interrupts; one of them is being used by the RF12 unit. That leaves 1 interrupt for waking up the JeeNode when something happens (door or window opening, motion etc.) you want to know about ASAP. Maybe you can put multiple triggers in parallel on this single interrupt so each one will trigger a wake up, but then you need to be able to find out what triggered the wake-up from the sketch. I've never tried something like that, although it shouldn't be hard to do that (trying, I mean).
Let's see if the upcoming sketch suits your purpose for this CO2 sensor and have a look at a battery powered version later, OK?
Re: Jeenode With 4 Digital Inputs
On the jeenode, all the ports are connected to the same interrupt, since the other interrupt is in use by the radio as Digit already said.
What I do is install an expander port, which generates the interrupt. This gives you 8 extra Digital I/O, and the expander port can also tell you which of those 8 ports triggered the interrupt.
Or you can hook them all up to the same interrupt, and check every port on the JeeNode to see which one changed. Bit more work, but less hardware.
What I do is install an expander port, which generates the interrupt. This gives you 8 extra Digital I/O, and the expander port can also tell you which of those 8 ports triggered the interrupt.
Or you can hook them all up to the same interrupt, and check every port on the JeeNode to see which one changed. Bit more work, but less hardware.
Re: Jeenode With 4 Digital Inputs
If I find the time, I'm going to look at Pin Change Interrupts (PCINTx). Maybe those can be used; but have to try first..
Re: Jeenode With 4 Digital Inputs
Hello,
Thanks for finding the time to make the sketch.
This sktech is fine for my co2 meter so i will try that first.
Its nice that you show the differents within this sketch and the other one
so i can learn from you what to change within the sketch.
Take the time for the sketch with batt power i must first make this Jeenode ready for use in the room
Thanks
Ed
Thanks for finding the time to make the sketch.
This sktech is fine for my co2 meter so i will try that first.
Its nice that you show the differents within this sketch and the other one
so i can learn from you what to change within the sketch.
Take the time for the sketch with batt power i must first make this Jeenode ready for use in the room
Thanks
Ed
Re: Jeenode With 4 Digital Inputs
Hi,
OK, here it goes. The line numbers below are the line numbers as in the JeeNode_for_Homeseer_IO sketch. I used that one to create this one: Here are all the changes that were needed:
Line 5.
The original sketch had 3 devices, for this one it's 4
Line 9.
4 Ports: DIn1...DIn4. I could just as well have named them DigiIn1... DigiIn4 or P1...P4. It's 'just' a variable name.
Line 220.
Configuration of the Devices.
Their Names as you want them to be in HomeSeer, their types (all DigIn), the statuses and statusnames, and the corresponding Ports.
Line 272.
Setting the right mode (INPUT) for the Ports.
That's it... hopefully not too hard to follow.
The rest of the code? Just leave it as it is...
If you still have some questions, just let me know.
OK, here it goes. The line numbers below are the line numbers as in the JeeNode_for_Homeseer_IO sketch. I used that one to create this one: Here are all the changes that were needed:
Line 5.
The original sketch had 3 devices, for this one it's 4
Code: Select all
//const byte totalDevices = 3;
const byte totalDevices = 4;
4 Ports: DIn1...DIn4. I could just as well have named them DigiIn1... DigiIn4 or P1...P4. It's 'just' a variable name.
Code: Select all
//Port AIn(1);
//Port DOut(2);
//Port DIn(3);
Port DIn1(1);
Port DIn2(2);
Port DIn3(3);
Port DIn4(4);
Configuration of the Devices.
Their Names as you want them to be in HomeSeer, their types (all DigIn), the statuses and statusnames, and the corresponding Ports.
Code: Select all
// //===============================//
// // config devices
//
// //device 1: Analog In
// arrayCopy(devices[0].name, "AIn ");
// devices[0].devType = Device::AnaIn;
// devices[0].currentStatus = 0;
// devices[0].amountStatus = 0;
// devices[0].inputPort = &AIn;
//
// //device 2: Digital Out
// arrayCopy(devices[1].name, "DOut");
// devices[1].devType = Device::DigOut;
// devices[1].currentStatus = 0;
// devices[1].amountStatus = 2;
// arrayCopy(devices[1].statusArray[0].statusName, "Off");
// devices[1].statusArray[0].value = 0;
// arrayCopy(devices[1].statusArray[1].statusName, "On");
// devices[1].statusArray[1].value = 1;
// devices[1].outputPort = &DOut;
//
// //device 3: Digital In
// arrayCopy(devices[2].name, "DIn");
// devices[2].devType = Device::DigIn;
// devices[2].currentStatus = 0;
// devices[2].amountStatus = 2;
// arrayCopy(devices[2].statusArray[0].statusName, "Off");
// devices[2].statusArray[0].value = 0;
// arrayCopy(devices[2].statusArray[1].statusName, "On");
// devices[2].statusArray[1].value = 1;
// devices[2].inputPort = &DIn;
//===============================//
// config devices
//device 1: Type Digital In
arrayCopy(devices[0].name, "DIn1");
devices[0].devType = Device::DigIn;
devices[0].currentStatus = 0;
devices[0].amountStatus = 2;
arrayCopy(devices[0].statusArray[0].statusName, "Off");
devices[0].statusArray[0].value = 0;
arrayCopy(devices[0].statusArray[1].statusName, "On");
devices[0].statusArray[1].value = 1;
devices[0].inputPort = &DIn1;
//device 2: Type Digital In
arrayCopy(devices[1].name, "DIn2");
devices[1].devType = Device::DigIn;
devices[1].currentStatus = 0;
devices[1].amountStatus = 2;
arrayCopy(devices[1].statusArray[0].statusName, "Off");
devices[1].statusArray[0].value = 0;
arrayCopy(devices[1].statusArray[1].statusName, "On");
devices[1].statusArray[1].value = 1;
devices[1].inputPort = &DIn2;
//device 3: Type Digital In
arrayCopy(devices[2].name, "DIn3");
devices[2].devType = Device::DigIn;
devices[2].currentStatus = 0;
devices[2].amountStatus = 2;
arrayCopy(devices[2].statusArray[0].statusName, "Off");
devices[2].statusArray[0].value = 0;
arrayCopy(devices[2].statusArray[1].statusName, "On");
devices[2].statusArray[1].value = 1;
devices[2].inputPort = &DIn3;
//device 4: Type Digital In
arrayCopy(devices[3].name, "DIn4");
devices[3].devType = Device::DigIn;
devices[3].currentStatus = 0;
devices[3].amountStatus = 2;
arrayCopy(devices[3].statusArray[0].statusName, "Off");
devices[3].statusArray[0].value = 0;
arrayCopy(devices[3].statusArray[1].statusName, "On");
devices[3].statusArray[1].value = 1;
devices[3].inputPort = &DIn4;
Setting the right mode (INPUT) for the Ports.
Code: Select all
// other config, application specific
// AIn.mode(INPUT);
// DIn.mode(INPUT);
// DIn.mode2(INPUT);
// DOut.mode(OUTPUT);
DIn1.mode2(INPUT);
DIn2.mode2(INPUT);
DIn3.mode2(INPUT);
DIn4.mode2(INPUT);
The rest of the code? Just leave it as it is...
If you still have some questions, just let me know.
Re: Jeenode With 4 Digital Inputs
Hello,
Great this sketch works fantastic.
So i can make now my co2 unit remote
With the fantastic explanation from Robert I have managed to make a sketch with
1Input and 1ouput Port
So now I have the things I need to make my Personal Jeenode´s
Thanks Robert.
Ed
Great this sketch works fantastic.
So i can make now my co2 unit remote
With the fantastic explanation from Robert I have managed to make a sketch with
1Input and 1ouput Port
So now I have the things I need to make my Personal Jeenode´s
Thanks Robert.
Ed
Re: Jeenode With 4 Digital Inputs
That's good to hear!
Now waiting for Ed's post called "My first Personal JeeNode"...
Now waiting for Ed's post called "My first Personal JeeNode"...
