Nodes on the Gateway or connected via I2C

  • Plugin Developer

    Hi there,
    First cheers for this AMAZING project which woken up the electronics passion of my childhood...

    I've succefully built an ethernet gateway and some nodes, but I would like to add some nodes directly in the gateway.
    For example, I would like to add a 433mghz tranceiver, a 315Mhz tranceiver, as well as a few sensors like BS18B20, and such directly in the gateway...

    Here is how I understand it can / cannot be done:

    1. wiring all on the GW arduino, but as read on the forums, it seems that at this time, Mysensors Gateway code does not support sensor (nodes) directly in the Gateway sketch. and I understand that it might be challenging.
      Any progress on the idea? Would you implement it a day or definitively not?

    2. current solution seems to build multiple hardware nodes (Arduino + radio) in the same box, which is taking more space(unused radio), taking more hardware (multiple radios) , is slower than a wire, and spending more radio messages just to communicate to an arduino near him within the same box.

    3. Wiring another arduino (acting as node) on the I2C bus to the gateway arduino, an make him exchange infos with the gateway.
      The benefit of this approach (if implemented in MySensors) is that:

    • This would allow easy implementation of sensors/actuator on the gateway, by simply adding another arduino, connected to the 2 pins of I2C bus, and just adding a line on the gateway, ie "gw.useNodesOnI2C()" telling him to also communicate to I2C nodes, plus adding a MySensor "gw(I2C, I2C_ID)" declaration line in each connected node.

    • This would also permit to extends some complicated nodes (those that need to run parrallel tasks), to easily solve the huge complexity of building multi-threading arduino applications, by simply running multiple arduinos (in the same box), who talk together on the I2C bus.

    • nodes would be seens as normal nodes, except that their transport is on the I2Cbus instead on the radio module

    • It might * maybe* be simplier from the Mysensors library side to implement I2C slaves nodes, by "simply" implementing a new transport type, isnt it?

    It seems to be possible to code this "manually" for the I2Cbus using Wire.h library, but it would definitively be more elegant and cool to implement it directly in MySensor Lib. Unfortunately my C++ skill are so limited that I can't understand if is is easily feasible or not.

    Does it make sense to you?
    Any thoughts?
    Other Solutions?

    Keep up the excellent work !
    Best regards

  • Mod

    The development version supports locally attached sensors. See these treads (and others):

    The i2c idea is interesting though. I have a project where I need to connect two Arduinos (to get more io pins and more flash space). My plan was to use SoftSerial but i2c might be a better alternative.

    Edit: I only have one available pin on the Arduino and i2c requires 2 pins so I2c isn't going to work in my project. Back to the drawing board 🙂

  • Hardware Contributor

    @mfalkvidd said:

    Edit: I only have one available pin on the Arduino and i2c requires 2 pins so I2c isn't going to work in my project. Back to the drawing board 🙂

    I assume you looked at using shift registers already? I've experimented with a few and some of them work well on the SPI bus (and are very fast). They do require extra pins for the various latches - I use 3 pins (+spi) to run an 8 pin input and 8 pin output register and more could be added. If you want more info, let me know...

  • Mod

    @TD22057 Thanks for the suggestion, and sorry for going off-topic. I have connected a screen with a 16-bit bus, so that's why I need so many pins. It should be possible to convert the screen library to use shift registers but it would probably be a hassle to get the timings right. And it would likely require more flash space, which is already a problem. Buying a screen with hardware SPI support is probably a better solution than rolling my own.

  • Plugin Developer

    @mfalkvidd Thank you very much for pointing me to the dev branch which now implements nodes on the gateway. Things are evolving really fast here 😉 I'm certainly gonna wait until it reach the master branch to use it "in production".

    While this is just an excellent news solving the sensor-on-gateway issues, it don't solve/standardize multiple arduinos communication. But maybe this feature is outside of the scope od MySensors, and should be developped independently by extending the Wire.h methods.

    Any other thoughts?