RPi gateway options



  • Hi,

    I'm very new to MySensors and think that I already understand the sensor side a bit. But I have problems to find out what I need (to do) on the gateway/controller side.

    What I want to do is:

    • use a RPi 3B+ as controller, probably with FHEM
    • build some RS485 controllers to control my ventilation systems

    Currently I have no idea what to do regarding the gateway. I'd like to connect it directly to the Pi, without another Arduino or similar in between. I read https://www.mysensors.org/build/raspberry and https://github.com/mysensors/MySensors/blob/development/configure but am still unsure whether it's possible to just connect the RS485 directly to the Pi. Can someone clarify that, please? Or is it preferable to have a dedicated gateway?


  • Mod

    @pikim I don't think anyone has tried it before, which means there is nobody to guide you. But it is probably possible.



  • @pikim said in RPi gateway options:

    Or is it preferable to have a dedicated gateway?

    Imo it's highly recommended to use a dedicated WG. This way you get a better separation of Hardware (your Pi acting as a server) and the GW functionality. Once the later is running, you may use it with any other hardware (I myself started with a Pi als server platform, but then decided to go for x64 architecture, especially to get rid of the SD card), or try new forms of Gateway (there's a "multi-transceiver-option upcoming" somewhen in the future) . Just replace a rather simple piece of hardware and the DEF in FHEM and there you go...



  • @rejoe2 said in RPi gateway options:

    Gateway (there's a "multi-transceiver-option upcoming" somewhen in the future)

    @rejoe2
    Maybe you're right and it makes sense to separate things. Where can I find informations about that gateway? Which MCU it uses and how things are connected?

    https://www.openhardware.io/view/776/STM32-Ethernet-RS485-MySensors-Gate could also be used for a universal gateway, but it's nearly impossible to get the according MCU at the moment.



  • @pikim said in RPi gateway options:

    Where can I find informations about that gateway? Which MCU it uses and how things are connected?

    See announcement here: https://forum.mysensors.org/post/105364. Afaik this will run on any mcu, also ATMega32 based.

    https://www.openhardware.io/view/776/STM32-Ethernet-RS485-MySensors-Gate could also be used for a universal gateway, but it's nearly impossible to get the according MCU at the moment.

    If you don't already have experience with STM32 based boards, do not start with these. They really are a good base, but may require some fiddeling around to find apropriate libraries, the bootloader up and running and so on.

    I'd advice to choose an ordinary Arduino Nano as a first GW, and then you might either go for a Pro Micro (ATMega32U based, "Leonardo") to get a second hardware-serial interface for RS485 transport layer or then give STM32 a chance (opt for "Maple" version, as some Blue Pill versions have wrong resistors soldered).
    Note: Pro Micro requires some tweaks to get e.g. the MySensors bootlogo visible...



  • Thanks for pointing me to the Sensebender. It looks great, although I'd prefer some AVR, as they're easier to handle. The ATmega324PB would be perfect imo, as it offers 2 SPIs, 2 USARTs and 2 I2Cs. Unfortunately Arduino supports only one of each type - that makes things complicated again.

    I've already worked with STM32, so that wouldn't be a problem. But I always coded in plain C up to now and I'm new to C++ and Arduino. And although the Arduino stuff should make life easier, I find it more complicated at the moment, because it does many things in the background. I prefer to know exactly what is happening on the MCU, but unfortunately MySensors doesn't run without the Arduino dependencies. And I don't want to reinvent the whole protocol...

    And I'm afraid that the STM32 is not so well supported as the AVR or a SAMD21.



  • @pikim said in RPi gateway options:

    The ATmega324PB would be perfect imo, as it offers 2 SPIs, 2 USARTs and 2 I2Cs. Unfortunately Arduino supports only one of each type - that makes things complicated again.

    I'm not sure wheather this assumption is right. Where comes this info from?

    I've already worked with STM32, so that wouldn't be a problem. [...] And I'm afraid that the STM32 is not so well supported as the AVR or a SAMD21.

    I just have one other's users report wrt. to STM32 in mind, stating he got relatively big binaries for "easy" sketches and a need to get the right versions of libraries and STM32 board definitions. Didn't sound like fun, so I never went for anything other than AVR...
    Nevertheless it's possible to get that up and running as well, but for a start I'd highly recommend to use "common ground".

    See also the short write up here: https://wiki.fhem.de/wiki/MySensors_Starter_Guide#STM32



  • @rejoe2 said in RPi gateway options:

    I'm not sure wheather this assumption is right. Where comes this info from?

    Ah cool, you're right: the second SPI is available as SPI1, using the MightyCore. Do you, coincidentally, know whether the hardware SPI can be passed to MySensors?



  • @pikim Don't understand your point. It's even possible to use SPI0 for e.g. digital resistors together with nRF24+. In general, MySensors isn't that special, you just have to adress things at the right point in time, e.g. use preHwInit() to initialize other SPI Hardware on the same interface.



  • I thought the W5100 must have its own SPI bus.



  • @pikim said in RPi gateway options:

    I thought the W5100 must have its own SPI bus.

    That seems to be true for AVR at least.
    I'd been taking about sharing SPI on node side, e.g. for common use for Radio (nRF24) and MCP4341.

    I'm unsure at what level of experience you are with MySensors in general. Assuming you beeing complete noob wanting to start with RS485, I'd highly recommend to just start with a simple serial gw - built using an ordinary Nano and RS485 modules. As soon as this works, you may choose how to adding any other kind of complexity, either on the RS485 side (by usage of CAN transceivers) or be it switching over to STM32, later adding LAN modules...
    Doing things step by step most likly will lead to faster progress in the end (imo).



  • OK, now I understand what you meant. And I was talking about immediately building an all-in-one gateway with W5100, RS485, NRF24 and RFM69. That would require 2 SPIs and 2 USARTs. Taking that into account the ATmega324PB would be a perfect match. And, indeed, I wanted to build it step-by-step and only wire the according MCU pins to pinheads to extend it later.

    The big downside of the ATmega324PB is the 5V voltage level @ 16MHz and the limited memory. I compiled the sketch from the all-in-one gateway and came up with about 95% flash usage. So there's not much space left for the future. And I think 16MHz would make sense for the gateway and 8MHz could be a bit slow. 12MHz@5V would be in spec, but 12MHz is quite uncommon.


Log in to reply
 

Suggested Topics

  • 1
  • 6
  • 3
  • 10
  • 2
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts