BitFlip

What is BitFlip?

  • BitFlip is a simple IoT (Internet of Things) client that runs in your browser. It simulates a device with buttons and leds without the need for actual hardware!
  • The BitFlip device is configurable on the query string of the URL. This makes it easy to share your device with others.
  • Your device automatically connects to the public Hive MQ MQTT broker and subscribes to the topic you provide on the query string.
  • Use the BitFlip buttons to send messages on your topic to another IoT device or server. This can be used to take an action.
  • Other devices can send messages to your device to toggle the BitFlip leds on or off.

BOYB (Build Your Own BitFlips)

Building BitFlips is easy. You just create a URL with a query string. BitFlips consist of buttons, leds and a topic.

  • To create a button use the btn key on the query string. The value is the name of the button. You can create as many buttons as you like, but each must have a unique value.
  • To create an led use the led key on the query string. The value is the color of the led. Valid colors are: white,red,green,blue,purple,yellow,cyan. You can only have one led of each color.
  • Set Your topic with the topic key on the query string. If you omit a topic, one will be generated for you. Since BitFlip uses a public broker, you will see all messages sent to this topic, even ones you do not send.

Examples:

  • This query string creates two buttons (button one and button two) and one red led with a topic of example1
    btn=button+one&btn=button+two&led=red&topic=example1
  • This query string creates a button named phone home with a red, white, and blue leds and topic demo1
    btn=phone+home&led=red&led=white&led=blue&topic=demo1

MQTT Messages

Button messages are sent to your topic. While led messages are recieved.

Button Message Format

When you click a button, the BitFlip device publishes a message on the topic you provide on the query string of the form:
{ "click" : "button-name"}
Another program can subscribe to this topic then decide what to do with the message.

Example:

A BitFlip button on the query string btn=Play+chime&topic=test sends the message {"click":"play chime"} to the topic /bitflip/test. Any application subscribing to that topic will recieve the message and decide how to take action for example perhaps it plays a random tone.

Led Message Format

When a message arrives on your topic, it can turn an LED ON or OFF. The message the device sends must be of the form:
{ "led" : "color", "state" : "ON|OFF"}
The color is the color of the led you want to turn on or off, one of the values white,red,green,blue,purple,yellow,cyan. The state is either ON or OFF.

Example:

When this message arrives on your topic: {"led" : "purple", "state" : "ON"}, your BitFlip device will turn on the purple led (provided it has one).

Non-Actionable Messages

When you see a message in your logs like this:
INFO: { "led" : "green", "state" : "off" } is not actionable
BitFlip is telling you that it cannot take action on the message. The MQTT protocol makes no restrictions on the message format, and BitFlip can only toggle LEDs you have setup. These messages are displayed for informational purposes as you will see all the messages on your MQTT topic.

Useful Links