10 Nodes and 1 Gateway network?

Started by rubychen, April 05, 2015, 04:42:27 AM

rubychen

Hi everyone!
I've dig in this forum and learned that Moteino is not designed for duplex communication. I'm trying to use 11 Moteino in my installation and hit a brick wall (at least for me ...), so I want to share my idea and gather some advice before I keep going ...

In my installation, I have ten sets of Node Moteino+RGB LED strip+photo interrupter, and one Gateway Moteino. Each set will be placed in a box. The idea is when one box is opened, the LED strip will turn on with one specific color, and the boxes around it will also be on for a sec. What I was trying to implement is sending the photo interrupter status (in each Node) to Gateway all the time, and the Gateway determine which color to show (or maybe turn LED off) and send the information to all effected Nodes.

I was able to get two Nodes and one Gateway to work as my plan. There were some packet loss but way below half. When I added the third Node, almost nothing work. It seems like the Gateway is trying to send out message all the time and can't listen. I use the same structure in Node example to send message in my Gateway, but I wasn't sure can I use sendWithRetry() in a for loop. (PS. I have the color information saved in an array, so the Node only need one integer to understand which color. That's why I just put 1 in the sendSize.)

  int currPeriod = millis()/TRANSMITPERIOD;
  if (currPeriod != lastPeriod){
    lastPeriod=currPeriod;
    
    for(int j=1 ; j<4 ; j++){
      if (radio.sendWithRetry(j, order[j], 1))
        Serial.print(" sent!");
      else Serial.print(" nothing...");    
    }
  }



Eventually, I'd like to know if this is a "correct" use of these amount of Moteino. Am I suppose to use Moteino to do communication like this? Or is it that my code is just not good enough?

Any comment is appreciated. Thank you!

TomWS

Quote from: rubychen on April 05, 2015, 04:42:27 AM
<...snip>I've dig in this forum and learned that Moteino is not designed for duplex communication. <snip...>
Moteino is not designed for FULL duplex communication (exactly simultaneous transmissions), but it certainly is capable of Half Duplex (two way) communication.

Stepping back a bit from your full description of your system, as I understand it, what you are trying to do is have your nodes report when its box is opened to the gateway.  The gateway then wants to tell that node and all the nodes around it to set their LED strips to some ON/OFF/Color (possibly different for each node).   And maybe, when the box is closed again, you want this reported and the gateway to do something similiar (with different ON/OFF/Color states).

Is that basically the goal?

If so, I have a couple of basic questions:


  • How often is a box opened?
  • How quickly do you want the LEDs changed in all the boxes when a box is opened or closed?
  • Will you ever have more than one box change state at a time (two boxes opened or closed simultaneously)?

Tom

rubychen

Hi Tom,

Thanks for the explanation!

Quote from: TomWS on April 05, 2015, 08:56:18 AM
Stepping back a bit from your full description of your system, as I understand it, what you are trying to do is have your nodes report when its box is opened to the gateway.  The gateway then wants to tell that node and all the nodes around it to set their LED strips to some ON/OFF/Color (possibly different for each node).   And maybe, when the box is closed again, you want this reported and the gateway to do something similiar (with different ON/OFF/Color states).

Is that basically the goal?
Yes, that's exactly the goal!

Before answering the question, I'd like to tell a little bit more about the project context. I'm going to put this installation in a newsrack:


The "box" I was referring to is the room for each newspaper. I don't know the official term so let's keep calling it box...


  • How often is a box opened?
    I guess the open frequency is depend on human behavior? I'll say open one box one time per second might be the most.


  • How quickly do you want the LEDs changed in all the boxes when a box is opened or closed?
    For the one that you open, it should change faster than you can feel the lag, and stay for one second, and then the boxes around it turn on for one second (they get one second before changing color). Ideally it should looks like a spreading animation.


  • Will you ever have more than one box change state at a time (two boxes opened or closed simultaneously)?
    Yes it is possible. When more than one people interact with the installation, then there might be two or more boxes opened at the same time. The animation will both happen and for the box that's overlap in between, the color will just determined by which comes the last I guess. (Ideally I'd like it to have a mix color, but this feature is not urgent.)


Thanks!!!

Best,
Ruby

TomWS

You didn't say what a fun project you had!

I don't think you should have a technical problem using Moteinos for this application, however, I have more questions...


  • Where are the Moteinos going to be mounted (inside each Box)?
  • Are the boxes made of solid metal?
  • Is this a commercial application (where you or your company will be selling this to others) or is this a personal project?
  • Is there a power source or will these radios be powered from batteries?
  • Where is the 'gateway' located?
  • How many LEDs per box?
  • How bright and how many colors do you want to have?

Sorry for so many questions, but I can imagine several different ways to do this and I'm trying to narrow down the choices.

Tom

rubychen

Thanks Tom! I'm glad to hear you think it's fun!

This is sort of a personal project, but will be shown in Market Street Prototyping Festival http://marketstreetprototyping.org/.
While they were calling for proposal, I had this idea and got selected. If you click on the link you can find out that it's happening in four days... I didn't realize all my limitation (knowledge and ability to do this) until recently :-[ so I decide to pivot my project to a scale that I can implement faster. 

However, the idea I posted here is still something I want to do! Hopefully I can finish it and have other opportunity to show it.


  • Where are the Moteinos going to be mounted (inside each Box)?
    Sadly I have no permission to mount it, so I'll just put the Moteino in a cardboard box (ten project boxes are kind of expensive) and tape it somewhere inside each Box. (Maybe ignore my stuff might be stolen first.)

  • Are the boxes made of solid metal?
    If you are referring to the newsrack, yes, I believe they are made out of solid metal.

  • Is this a commercial application (where you or your company will be selling this to others) or is this a personal project?
    This is personal and not for commercial use.

  • Is there a power source or will these radios be powered from batteries?
    From batteries.

  • Where is the 'gateway' located?
    Probably one of the box.

  • How many LEDs per box?
    There are 25 RGB LEDs on the strip that I cut for each box. It will also be powered by batteries (12v 3800mAh).

  • How bright and how many colors do you want to have?
    I'm going with full bright (analogWrite 255) due to it might be hard to see the light during day time, and 8 colors (all RGB combination include black/off).



Please don't hesitate to ask me more about this project as I might forget to mention some details. Using Moteino is just one option that I heard from a friend, and I'm open to any solution that suit this case. Thank you!!

Best,
Ruby

TomWS

Quote from: rubychen on April 06, 2015, 02:05:02 AM
Thanks Tom! I'm glad to hear you think it's fun!

This is sort of a personal project, but will be shown in Market Street Prototyping Festival http://marketstreetprototyping.org/.
While they were calling for proposal, I had this idea and got selected. If you click on the link you can find out that it's happening in four days... I didn't realize all my limitation (knowledge and ability to do this) until recently :-[ so I decide to pivot my project to a scale that I can implement faster. 

However, the idea I posted here is still something I want to do! Hopefully I can finish it and have other opportunity to show it.


  • Where are the Moteinos going to be mounted (inside each Box)?
    Sadly I have no permission to mount it, so I'll just put the Moteino in a cardboard box (ten project boxes are kind of expensive) and tape it somewhere inside each Box. (Maybe ignore my stuff might be stolen first.)

  • Are the boxes made of solid metal?
    If you are referring to the newsrack, yes, I believe they are made out of solid metal.

  • Is this a commercial application (where you or your company will be selling this to others) or is this a personal project?
    This is personal and not for commercial use.

  • Is there a power source or will these radios be powered from batteries?
    From batteries.

  • Where is the 'gateway' located?
    Probably one of the box.

  • How many LEDs per box?
    There are 25 RGB LEDs on the strip that I cut for each box. It will also be powered by batteries (12v 3800mAh).

  • How bright and how many colors do you want to have?
    I'm going with full bright (analogWrite 255) due to it might be hard to see the light during day time, and 8 colors (all RGB combination include black/off).



Please don't hesitate to ask me more about this project as I might forget to mention some details. Using Moteino is just one option that I heard from a friend, and I'm open to any solution that suit this case. Thank you!!

Best,
Ruby
FOUR DAYS! Holy Mackeral!  Ok, I think I heard you say that THIS implementation doesn't need to be done in 4 days as you've 'changed the scope of that project'  ;)

The good news is that it's a 'cardboard box prototype' so you don't need to dwell on antenna design, performance, etc.  Just 'get the thing done'!  Cool.

So, ONE more question and then some observations (give back time):

Are the 25 LEDs in the strip individually addressable and, if so, how?  (Maybe that's two questions, sorry)

Observations:

1. As I said, being a prototype means you can run at full power on the radios and not have 'sleeping' issues to deal with in the timing.
2. If you are lighting the LEDs to FULL on, there's no point in bothering with analogWrite(ledPin,255), digitalWrite(ledPin,HIGH) would produce the same signal without any system overhead or needing to find PWM pins.  OTOH, RGB leds typically do not have the same light output (mCd) for each color LED so, if you need color matching, you could drive the Red LED with a PWM signal OR just use a higher value resistor for the Red LED as an expedient (depends on the answer to my question above).
3. If you can setup the program for each node so that it individually 'knows' it's position WRT to other nodes then each node, when it has a 'door event' (open or close), can simply broadcast this event to all nodes.  Let the other nodes decide whether they need to do anything about it.  Broadcast is SIMPLE!
   struct NEWSPAPER_NODE_INFO {
      bool 
         bOpen;
      byte
         x,
         y;
    } myInfo;
   myInfo.bOpen = doorState;
   myInfo.x = 3;   // third box over
   myInfo.y = 2;   // lower level

   radio.send(RF69_BROADCAST_ADDR, &myInfo, sizeof(myInfo), false);   // tell everyone about this event with NO ACK
   ...


Then, while each node is managing it's LED timing, interspersed with the LEDs state change timing checks, simply do a call to radio.receiveDone() to see if the node's gotten a broadcast from another node and, if so, use the info in the data structure to control its OWN timing.  Easy Peasy.  AND NO GATEWAY to program!  (Sorry, Felix, no sale here)

Tom
PS: ENJOY the Festival!

rubychen

Quote from: TomWS on April 06, 2015, 08:25:49 AM
... 'changed the scope of that project'  ;)
;)
It's really a hard decision, but I want to avoid my interest being broken by time pressure. I really like making these interactive electronic stuffs but still not very pro to avoid frustration. (Keep calm and carry on?!)


Yeah, fortunately it's a "just get the thing done" project and I don't need to worry about how it looks to much now. Haha
While answering your previous questions, a question about antenna and performance did occur me: will placing the Moteino inside the box (which is an enclosed environment) effect the communication/broadcasting?


1) Why is that I can run at full power on the radios and not have 'sleeping' issues to deal with in the timing?
"The timing" do you mean the frequency of people opening the box? Or do you mean in a three day long festival?
I'd like to consider if there a chance to make it stay longer, like have it install and running for three months, will the sleeping mode (promiscuousMode?) make a lot difference?

2)
The LED strip I got should be the same type as this: http://www.amazon.com/SUPERNIGHT-TM-Waterproof-Epoxy-Strip/dp/B0085IXEYS
I believe there is no control to individual LED, or maybe just I don't know how?
I was trying to have 10 colors, each for one box, so that's why I use analogWrite(). Didn't realize that they don't have same light output! I guess that's why I had a hard time to make it pink, or brown... Is there a table like how we usually show RGB colors but specific for LED? Or does every LED have different light output even it's on the same color?

3)
Wow!!! It sounds a lot easier while you describing this solution! So using RF69_BROADCAST_ADDR it will send out message to every node on the same network?
If I want the spreading light effect have more steps, for example, when the box (1,0) open, after one sec box (2,0) turn on for a sec, after one more sec box (3,0) turn on for a sec ...etc

second          0     |     1     |     2     |     3     |     4     |     5     |
box(1,0)   LED on |            |            |            |            |            |
box(2,0)              | LED on |    off    |            |            |            |
box(3,0)              |            | LED on |    off    |            |            |
box(4,0)              |            |            | LED on |    off    |            |
box(5,0)              |            |            |            | LED on |    off    |

Then for box(5,0), when it knows box(1,0) is opened, it will wait for 4 second and then turn on. Is that correct?



Thank you so much!! I'll share some photos of my half scope project in the festival  :)



TomWS

I'll answer your questions below where the answer might be of general interest to others on the forum.  If you want more detailed help on your project, PM me and I'll see what I can do.

Quote from: rubychen on April 06, 2015, 08:04:22 PM
<snip>
While answering your previous questions, a question about antenna and performance did occur me: will placing the Moteino inside the box (which is an enclosed environment) effect the communication/broadcasting?
Absolutely.  The box is going to be RF opaque in a number of directions.  The good news is that the Moteino output power and sensitivity should overcome most of that with such close range.


Quote from: rubychen on April 06, 2015, 08:04:22 PM
1) Why is that I can run at full power on the radios and not have 'sleeping' issues to deal with in the timing?
"The timing" do you mean the frequency of people opening the box? Or do you mean in a three day long festival?
I'd like to consider if there a chance to make it stay longer, like have it install and running for three months, will the sleeping mode (promiscuousMode?) make a lot difference?
The Moteino is capable of operating at very low power if the radio is OFF.   There are ways to have the radio on for 'some' of the time, but then the coordination of this ON time with any devices it is talking to begins to get complicated.  For your project, I would suggest keeping it simple and not worry about trying to get long battery life until the rest of the logic is working.

"Promiscuous Mode" is a very poorly named mode.  It has nothing to do with sleeping.  It is used for when you want to listen to EVERYTHING, ALL of the time.  Totally unnecessary in your case.

Quote from: rubychen on April 06, 2015, 08:04:22 PM
2)
The LED strip I got should be the same type as this: http://www.amazon.com/SUPERNIGHT-TM-Waterproof-Epoxy-Strip/dp/B0085IXEYS
I believe there is no control to individual LED, or maybe just I don't know how?
I was trying to have 10 colors, each for one box, so that's why I use analogWrite(). Didn't realize that they don't have same light output! I guess that's why I had a hard time to make it pink, or brown... Is there a table like how we usually show RGB colors but specific for LED? Or does every LED have different light output even it's on the same color?
I only mentioned the analogWrite because you were specifically using only analogWrite(pin, 255) - at the output pin this will have the same result as digitalWrite(pin, HIGH);   Looking at your choice of LEDs, these should be easy to control and, since the LEDs are 12V strips, you'll need a driver on each color (R,G,B) and you could easily use PWM to select a more refined color than just the seven available if you drive each color full ON or OFF.  Also, that particular strip has resistors for every LED and they may have selected the resistor values to get a matched output - I don't know, there isn't a datasheet for the strip.  You'll have to experiment.

Quote from: rubychen on April 06, 2015, 08:04:22 PM
3)
<snipped to reduce to within posting limits>
Then for box(5,0), when it knows box(1,0) is opened, it will wait for 4 second and then turn on. Is that correct?
You've got it!  But, you could probably go one step further and add:
   
#define MAX_NUM_COLORS 7          // only 7 colors if just ON/OFF on each RGB pin
struct NEWSPAPER_NODE_INFO {
      bool 
         bOpen;
      byte
         x,
         y,
         color;
    } myInfo;
   myInfo.bOpen = doorState;
   myInfo.x = 3;   // third box over
   myInfo.y = 2;   // lower level
   myInfo.color = random(1,MAX_NUM_COLORS);   // tell my neighbors what color I'm using this time...

   radio.send(RF69_BROADCAST_ADDR, &myInfo, sizeof(myInfo), false);   // tell everyone about this event with NO ACK
   ...


Quote from: rubychen on April 06, 2015, 08:04:22 PM
Thank you so much!! I'll share some photos of my half scope project in the festival  :)
Looking forward to it!

Tom