When most people think of SDL Tridion/Web 8 they think of a kick-ass content management system to run their website. And they’re right! But, the thing about Web 8 is that you aren’t constrained to just providing content to websites. Content is needed on any number of devices these days, from native mobile apps to video game systems to billboards to fancy appliances.
With this in mind, John Winter made the comment that he’d like to see the most off the wall device we could control with Web 8. WhileÂ John’s original suggestion of having Tridion publish to a toaster so we can write messages on breadÂ is beyond my electrical engineering skills, I do have a pretty good starting point for a task like this: an Arduino. If you’re not sure what this is, you should absolutely check out the Arduino homepageÂ because they’re awesome. To quote their site,
“Arduino is an open-source prototyping platform based on easy-to-use hardware and software. Arduino boards are able to read inputs – light on a sensor, a finger on a button, or a Twitter message – and turn it into an output – activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. Â To do so you use the Arduino programming language (based onÂ Wiring), and the Arduino Software (IDE), based on Processing.” -Â https://www.arduino.cc/en/Guide/Introduction
What makes ArduinosÂ different than something like a Raspberry Pi is that they are not computers. They don’t have their own operating system. Instead, you upload your code and they run it as long as they’re powered. This means you can’t use Tridion to publish straight to an Arduino. Instead what I did was to publish a simple text file to my computer from Tridion, then use a buffered reader to consume this text file and use it in my Arduino code. Of course, a text file is going to be pretty limited if you’re doing something more exciting than this demo. For those projects I would recommend using JSON. In fact, in the future I’d like to modify my code to query the broker. This would allow me to use DD4T for this, but that’s another project for another weekend.
So, first things first, I published a text file from Tridion. I’m going to assume this is either something yo know how to do, or can use the many other resources out there to figure it out. For this demo I publishedÂ C:/web/website1/arduino.txt.
Next, I needed to build a buffered reader to consume the contents of my text field each time they are updated. This is a perfect use for Processing, which according to the Arduino website “is an open source language/ development tool for writing programs in othercomputers. Useful when you want those other computers to ‘talk’ with an Arduino, for instance to display or save some data collected by the Arduino.” In my case I’m doing the opposite, passing data through to my Arduino as it is read into my Processing code. After downloading and installing Processing, I created a new sketch and wrote the following code:
This will use a buffered reader to read in my text file, then send it through my laptop USB to the serial port on my Arduino, where my Arduino code can put it to work. Each time my file is updated it will send the contents to my Arduino again. Now that we have this done, IÂ needed to write some code for myÂ Arduino. After installing the Arduino IDE, I wrote the following code:
This code will write the strings being passed through the serial port out to an LCD screen connected to my Arduino. After uploading it to my Arduino, I hit play on my processing code and watched the results.
I didn’t go overboard in getting the LCD display tuned perfectly. It would be nice if the text would scroll to allow for larger text files, but this is really just a POC. I’ll be curious to hear if anyone has any suggestions on what kind of uses an Arduino connected to Tridion might be. If you have a good one make sure to comment below and I’ll give the good ones a try if I can.
Haha, pretty cool! The first thing that comes to mind is using a similar technique for skywriting…
Awesome indeed, well done Tanner!
Awesome! I’ve had an Arduino for awhile and wondered how you might integrate it with Tridion (flashing LEDs on publish and that sort of thing).