Getting started, where to begin?

  • Hero Member

    Hi guys,

    I'm just getting started with building my own sensors and buttons using arduino. I have standardised on the RFM96HW radio connected either to a moteino or an anarduino. On the server side I am running OpenHAB on a Linux computer.

    My plan is to take one Arduino and connected to my server to create a serial interface. I intend to write a simple server in Python which reads the serial interface and pushes messages to an mqtt broker.

    I have been looking into radio libraries, and I recently found RadioHead which seems to do the job nicely for any radio I might want to use.

    My first applications will be a light switch based on a simple distance sensor which will allow me to wave my hand in front of the sensor to toggle the lights. I'm also planning a simple doorbell/door sensor combination which will be integrated with OpenHAB to grab an image from a web camera and send an email with the attached image to the owners of the house whenever the doorbell is run or the door is opened (at least when they are away).

    My question is, does it make sense for me to use the library provided by mysensors, or am I better off just writing something myself directly against the radio library? I do not require much functionality to begin with since I will only be reading from the devices, but eventually I would want to write two devices as well by having the Python server subscribe to messages from the broker and relay these through radio.

    Is it perhaps easiest just to modify the link layer (i.e. radio library) for your library to support the RadioHead library? I suspect this shouldn't be too difficult, and maybe it will help others as well?

    Let me know what you think 🙂

  • Admin

    DistanceSensor light switch sounds like a fun project.

    It would require quite a surgery to get the RadioHead library in. The question is which part you want to keep of MySensors?
    Do you want to reuse the example sketches? The serial protocol (to keep controller plugin support)?
    To get started you could probably just do some quick-n-dirty reading from the sensors since you planning to write you own OpenHAB integration.

  • Hero Member

    @kolaf The RFM96HW is an interesting alternative, and possibly cheaper than its NRF24 equivalent (the PA+NLA antenna model) it's just too bad that it is so hard to find. From what I understand the Chinese manufacturer handles them solely through just one American reseller. There were some RFM96HW on AliExpress but they are gone now.

    Another snag would be that the model that most people recommend and the one I've seen sold, the 915MHz version, would be illegal to operate in Sweden and a lot of other places as well I imagine. Don't know if any shady government agency would chase you down though 🙂 868MHz versions seem even rarer and may not offer the same stellar range, I don't know?

    Very good range on this thing though on 915MHz:
    It of course requires up to 130mA so it may be as unsuitable as the nRF24L01+ PA+LNA for some projects.

  • Hero Member

    Thanks for your replies.

    For the library I was hoping to use the arduino API, the message formats (with packet types et cetera), and a serial interface. I assumed that it would be relatively easy to simply replace any calls to the radio library used by mysensors with that of the new library. Why is this very difficult? Is perhaps the radio library integrated into the mysensors library?

    I do not really care about reuse of the example sketches, but if someone wants to create a standardised library to support Arduino IoT it makes sense to do something with the same API for interoperability.

    For the radios I simply buy prebuilt moteinos or anaduinos with the RFM96HW from US suppliers. An anarduino (mini wireless) with the radio unit and 128 MB of flash comes out at around $16 which seems quite fair.

    According to the documentation I read on the moteino website you can use the 900 MHz radio in the 800 MHz band simply by shortening the antenna and initialising the radio for the correct frequency. This is apparently even suggested by the manufacturer, HopeRF. This will make the radios legal to use in Norway :-).

    I have been discussing with myself whether I should go for the 400 or 800 MHz bands, but I decided to go for the same as is used by Z-wave since there is probably a reason why they use this band :-).

    I went for the high-power version of the radio this allows me the greatest flexibility in output power range through software configuration.

    As for the motion light sensor, the first version of this will be used in my office at home. I usually close the door to my office since I have small kids and lots of sensitive things (electronics, RC planes, and so on), so I am thinking of using this to save power for battery operation.

    I believe that I could simply connect a reed switch to the power supply so that the light switch is only powered whenever the door is open. Now that I think about it I guess that an open door will leave the reed switch circuit open, which means that it would actually power the switch only when the door is closed. Maybe I can instead connected to an interrupt to have the lightswitch sleep most of the time when the door is closed. As you can see, there are still a few details in the design that needs to be ironed out 🙂

  • Mod

    @kolaf said:

    Why is this very difficult?

    It all depends on your (software) skills of course, but currently the MySensors sensor class is implemented as a derived class from the NRF24 class. Probably the easiest way to implement this for your radio would be to emulate the NRF24 interface in the driver for your radio. Only change required for MySensors would be to derive from your new class instead of NRF24.
    The NRF24 interface is quite stable while MySensors still changes now and then...