Close

Single Wire UART Communication

A project log for SnapBloks

Tools for students, makers, designers and artists to quickly demonstrate interactive concepts.

ekawahyu-susiloEkawahyu Susilo 04/15/2017 at 10:010 Comments

Single Wire UART Communication, that is how I call it for now. The concept is pretty simple. Let's make a project with Thermometer Blok, Light Blok, Sound Blok, and a Battery Blok. Once we snapped on all Bloks together, they all get power from the Battery Blok through + and - contacts. All Bloks are in listening mode (RX).

Only one Blok may send data over the wire at a time, like this:

, or this one:

but definitely not like the following scenario. When two or more Bloks are in TX mode and sending at the same tim, collision occurs and none of messages went through:

So how does each Blok know when to send a message? Well, that depends how you program the Bloks. Let's say we want to see the Light Blok flashing when the temperature is beyond 75 degree F, and then the alarm goes off on Sound Blok when the temperature reaches 80 degree F. We could have several solutions listed as follow:

  1. Conditional tests happen internally in Thermometer Blok and then it sends commands to Light and Sound Bloks whenever the condition is met. So, Light and Sound Bloks are passively waiting for commands from the Thermometer Blok.
  2. Thermometer Blok can send messages periodically, Light Blok does the conditional test for beyond 75 degree F reading, and Sound Blok does the conditional test for 80 degree F. So the task is kind of distributed among Bloks.
  3. Light and Sound Bloks take turn in doing data request from Thermometer Blok. Thermometer Blok is passively waiting for acquisition command. Please note that collision might happens because at any given moment in time, Light and Sound Bloks might both switch to TX mode and send messages. There should be a traffic listening mechanism in each Blok before actually switching to TX mode and sending a message.
  4. You could program the Light Blok as a master, acquiring data from Thermometer Blok and send command to set the alarm to Sound Blok.
  5. Etc... etc... etc....

There are so many solutions we could do for just this one project example with SnapBloks. Each solution has its pros and cons. It all depends on how we would use SnapBloks to solve the problem.

Discussions