Sketch Generator

  • Been working with single sensor setups so far and starting to get into multi-sensor nodes. I've seen some mentions to a sketch generator being on the "road map" but no ETA or updates recently.

    Would like to be able to select the board type and desired sensors, then have a sketch generated with clear directions/instructions on how to wire everything up.


  • Admin

    Yes, it is still on the long-term roadmap.

    The amount of time I can put on the MySensors project (during nights/weekends) is the limiting factor here.

  • Mod

    I guess we have a bit of chicken-and-egg problem here. People who can create such a tool don't need it, since they're already comfortable enough with programming. People who need such a tool aren't good enough at programming to create the tool.

    Open projects often rely on people scratching their own itch.

    We can't (and shouldn't) rely on hek doing everything. Could we maybe come up with good motivation factors? Or find people who want to scratch this itch?

  • Hardware Contributor

    I definitely fall in the "don't need it/don't want it" category. But - if I was going to try and design something like that, I'd think about building a "standard" set of component classes (Switch, Led, Relay, etc) and use a state machine style interface. The user then doesn't need to worry about how an item works, just which items they need to construct. The documentation for each class would explain how to wire it up and the user would create an instance of each class with the pins it's attached to and supply a callback function which would get called when the state of that item gets changed. So the user is just responsible for filling in the "what happens when things change" portion of the code. The main loop function would be a series of poll commands to each item. I've used that kind of design in my own sensors and it's a nice way to separate the hardware code (pins, polling) from the sensor code (what happens when the state changes). I think something like that could help with basic needs - obviously it wouldn't help much with complicated sensor behavior. It does still require coding - but not coding that cares about low level arduino stuff.

    I haven't put anything up on github yet but I could do that if anyone is interested in them. I have fully documented classes with wiring guides for a Switch (low or high, digital or analog pin), Timer (simple polling trigger), DigitalOutput (used for LED's and relays including blinking), and articulated water valve.

    Here's an example of a callback in my leak detector test case (no MS messages in this one) to give you an example of what this kind of code looks like. What I like about this kind of design is that the real work in the state change code has nothing do with hardware, pins, bit flags, etc. In 5 years when I've forgotten all of that stuff, I can still look at this and see exactly what's going on. The g_xxx variables are the globals for the Switch, Led, etc.

    statusChange( Status status )
       if ( status == g_status )
    #ifdef DEBUG_LEAK
       Serial.print( "Status  -> " ); Serial.println( status );
       switch( status )
       case NORMAL:
          // Going back to normal operations.  Turn off the LED and open
          // the valve.
          // TODO: send message, leak cleared.
       case LEAK:
          // Leak in secondary sensor - don't close the valves.
          // TODO: send message, leak, valves opened
       case LEAK_SHUTOFF:
          // Leak in primary sensor - close the valves.
          // TODO: send message, leak, valves closing
       g_status = status;

  • Admin


    Yes, had the same thought..

    Even described it a bit under "Helper Classes" here:

    Feel free to add/edit/tweak in your ideas in the document.

    Having these building blocks makes it much easier to generate the code.

  • I fall into the "not enough skills to program" category, and like many others are just getting my feet wet. Sadly as I read some of the above and review the code, it doesn't all make sense nor do I understand how to utilize the building blocks provided.

  • @nftrix , I have always thought about it. So, after read this thread I started to build a tool that I don't know if it is what you want but I am trying to make easier the development of new nodes (compile and upload too).

    So, feel free if you want to take a look and give some feedback.

  • Admin


    Cool. If you create something usable, we could throw it up on the main site with a web frontend.

  • Nice @hek ! I've just released version 0.1, so I think who has at minimum of dev skills, it is an usable tool. I would like that someone could test it.

    When I get something more usable for who doesn't have such that skills, I will let you know. 🙂

  • If you are interested, here is my beginning of work :

  • Mod

    It is not a generator, but @tonberg's framework might be useful for someone looking for a code generator.

Log in to reply

Suggested Topics