Merry Boxes & LEDs

Enter Your Project for a chance to win a Maker Tool Kit, an Oscilloscope Grand Prize for the project that brings the Most Joy to the Heart, and Gift to Gives!

Back to The Project14 homepage

Project14 Home
Monthly Themes
Monthly Theme Poll

 

It looks like I'll finally have some time to do a project!

Guess there is a benefit to longer nights and colder weather - more time spent indoors to be nerdy like this

 

Earlier this year I ordered a couple of Christmas tree kits from the land of the Internets. That place on-the-line that's so far away it takes months to get the packages into my mailbox. But the prices are nice, the products are cool, and... free shipping!

Christmas Tree kits

 

Once assembled, these should be cute little trees with blinky lights.

 

Then I thought, wouldn't it be cool if we had a little tree here, and a friend somewhere else at a different node on the Interconnected Webs had the other little tree, and they could somehow magically interact?

 

In my drawers of hoarded items I also have an ever expanding assortment of ESP8266 boards, from the same far away lands that got me the little trees, and these boards are really nice in that they are very tiny and yet very powerful... plus they have built-in Wi-Fi!

 

The specific boards I have in mind are the Wemos D1 Mini type, because they are easy to program using the Arduino IDE and upload is also easy by plugging it in similar to the way the UNO works.

Plus, it's simple to power them with a USB charger, which then should also be able to power the tree.

 

Tonight I implemented the first phase of the overall plan - that is, how can we best send messages between the two boards?

 

I chose to use MQTT for the quick response time, rather than writing my own server scripts and polling for status updates. MQTT is a nice standard for other uses too, so it's also worthwhile to do a bit of learning there.

 

Turns out it was actually very easy to get an example working tonight, using a free online MQTT broker, the accompanying online client interface they provide, the PubSub Arduino library, and the WiFi Witty I used for testing.

 

The WiFi Witty is another ESP8266 board that's very handy to have in the drawer of hoarded goods. It's very similar to the Wemos D1 Mini in that it's easy to program, upload, and power, but the Witty also includes a user button, RGB LED, a little blue LED, and a light sensor. This makes it a perfect platform for testing new things - all the basics are provided to stand in for the final project details, with no soldering or wiring required. I've used it for similar starting/testing steps in the past too - very handy. The Wemos will require some soldering and external hardware, so I'll leave that for later.

 

So earlier tonight I set up the Witty to connect to the MQTT broker, and had it send a message with each button push. It also receives messages via the same topic, and I set it up to turn on the green LED when the message starts with 1, and turn it off when the message starts with 0. The PubSub library includes examples that provide plenty of code examples to make for a quick and easy start.

 

This actually covers all the steps I will need in my final project, so I'm very pleased with how well that came together!

 

Right, I didn't describe the final project yet...

 

I will have two little blinking-LED Christmas trees, using the kits in the picture above.

Both will get a Wemos D1 Mini to control them

Each Wemos will:

a) have a small motion sensor attached to them (also in that drawer-of-many-hoarded-items)

b) be connected to their tree via an output pin, via a transistor, to light up the tree

c) run the single top LED of the tree from a separate output pin

 

When one senses motion, it will send a message to the other tree, and that far tree will light up. The very tip of the tree of the local tree is turned on when motion is sensed, to show that it did something (otherwise the local user won't know anything is happening).

 

Next step - solder those kits into pretty little trees!

 

I will post updates and source code as things progress

 

Cheers,

-Nico

 

Next blog posts:

Assembling the Trees

Finally! Two Trees Assembled

Two Trees by a Tree

Connecting the Tree to the Internet

Motion Sensor on Wemos

Trees! one with motion sickness...

Motion Sensor Issues, continued

The Connected Trees are Working!

Merry Boxes - A Project Within a Project

Connected Christmas Trees - Finished!