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.
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!
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
Qty | Value | Device | Package | Parts | Description | MF | MPN | Aliexpress or Ebay link |
---|---|---|---|---|---|---|---|---|
1 | Hit Train ;-) | |||||||
1 | Arduino Pro Mini | |||||||
1 | Lipo Battery | 18650 | ||||||
1 | TP 4056 board | |||||||
1 | 7833 regulator | |||||||
1 | 10uF | electrolytic capacitor | ||||||
1 | nRF24L01 radio | |||||||
1 | IRLZ44N N-Channel MOSFET | |||||||
1 | 10K | resistor | ||||||
3 | 360R | resistor | ||||||
3 | 100nF | ceramic capacitor | ||||||
2 | RGB LED (Common Cathode) |
Name | Size | # Downloads |
---|---|---|
myHitTrain.ino | 8.09 kB | 298 |