mySensors Hit Train
License:
Public Domain
Created:
5 years ago
Updated:
5 years ago
Views:
2767
0 Collect
0 Comments
Share
11 Download (14.95 MB)
Donate to support Open Hardware

My Hit Train

(ok, my Christmas Train )

According to mom, I got my Hit Train by 1979 or so. Somehow it survived from my sisters (and recently from my kids). Some parts are missing/broken but... why not mySensor it to run under the Christmas tree?

Setup is quite simple. it is basically a pro mini running a RGBW dimmer sketch, where the (W)hite channel drives the DC motor via a MOSFET, while the other RGB channels drive some RGB leds in the two coaches.

An ordinary TP4056 board charges a 18650 Lipo Battery. As the lipo can reach 4.2V when fully charged, I added an 3.3V voltage regulator to power the nRF radio.

enter image description here

I setup my vera controller to run the hit train for ~1m on each hour, with some seconds of 'RGB light show' before and after it.

Very high WAF (and kids) factor!

Some Hints

The DC motor causes some noise in the circuit, making the Arduino sometimes hang or reset. To avoid it, I soldered some 100nF capacitors between the the two motor pins and between each motor pin and the motor's metal case (reference)

If you use vera controller with vosmont's RGBW plugin, make sure to add the code bellow to L_RGBController1.lua after line 1004 (before Color transition management) -- Thanks to BartE , Details: link

function startup (lul_device)
    log("startup", "Start plugin '" .. PLUGIN_NAME .. "' (v" .. PLUGIN_VERSION .. ")")

    -- Update static JSON file
    if updateStaticJSONFile(lul_device, PLUGIN_NAME .. "1") then
        warning("startup", "'device_json' has been updated : reload LUUP engine")
        luup.reload()
        return false, "Reload LUUP engine"
    end

    -- Init
     if luup.devices[lul_device].device_type == "urn:schemas-upnp-org:device:RGBController:1" then
         log("startup", "Found RGB master #" .. lul_device)
           initPluginInstance(lul_device)

         -- ... and now my watch begins (setting changes)
         luup.variable_watch("initPluginInstance", SID.RGB_CONTROLLER, "DeviceType", lul_device)
         luup.variable_watch("onDebugValueIsUpdated", SID.RGB_CONTROLLER, "Debug", lul_device)
    else
         -- Look for a child RGB device, which need to start up
         for child_id, v in pairs(luup.devices) do
           -- if I am the parent device of a child RGBController start it up
           if v.device_num_parent == lul_device and v.device_type == "urn:schemas-upnp-org:device:RGBController:1" then
            log("startup", "Found RGB child #" .. child_id)
                   initPluginInstance(child_id)

                 -- ... and now my watch begins (setting changes)
                 luup.variable_watch("initPluginInstance", SID.RGB_CONTROLLER, "DeviceType", child_id)
                 luup.variable_watch("onDebugValueIsUpdated", SID.RGB_CONTROLLER, "Debug", child_id)
           end
         end
    end

    if (luup.version_major >= 7) then
        luup.set_failure(0, lul_device)
    end

    return true
end

enter image description here