← Insights IoT & Connected Products

How To Send Data From A Rails Application To An IoT Device?

November 3, 2017 · CognitiveClouds Editorial Team · 2 min read

Today, our phones are smarter, the internet is a lot more accessible, and even our pets have connected accessories. These devices aren’t all built by prominent organizations. Most are associated with young engineers, programmers and up until now, obscurely funded start-ups. With a decent grasp of programming and equipped with the right tools, you can make your own connected device in no time.

Ruby on Rails has been used to power modern websites for about a decade now, including many of the sites built here at CognitiveClouds. Ruby remains one of our favorite languages to code in through the years since Rails has made it increasingly easy to build fully functional websites and applications in a short time. Ruby is a beautiful and elegant programming language. It is easier to learn and understand, faster to code in, well documented with an active community behind it, focusing on Object-Oriented Programming and comes with a lot of helpful packages and frameworks, especially concerning web applications.

Ruby on Rails and the Internet of Things: Is there a future?

If you choose to run on low power endpoints, then no. However, a lot of IoT is not low power endpoints. But instead, if you are running Ruby on a RasPi-Zero type of platform, there’ll be no problem, and this platform is quickly gaining popularity with IoT projects. In a low power, low CPU environment, it’s best to use compiled languages. You can use a compiled language like C and sometimes lightweight scripting languages. Soon, Ruby could be primarily used for fast prototyping web API for connected devices.

How can I send data to an IoT device?

We’ve all had days when our servers were slammed with data from all kinds of IoT devices and applications. Recently, we upgraded our entire backend and increased the capacity to support our growth. One of the key decisions in our redesign was to select Phusion Passenger Enterprise to power the Internet of Things API. Phusion Passenger’s multithreaded, hybrid evented, multi-process design is perfect for the Internet of Things pattern for applications.

Phusion Passenger is an application server and web server for Ruby, Node.js, Python, and other web apps. It has helped make web app deployments a lot simpler and far less complex by managing our apps processes and resources. Its zero-copy architecture, its C++ core, its watchdog system and its multi-threaded, hybrid evented, multi-process design have made it fast and reliable at the same time.

Typically, when it comes to communication with IoT devices, you can use REST API if the device has a direct endpoint, but many of the IoT Devices may not have one. The IoT Devices generally use low power consuming protocols like MQTT, CoAP which interacts with broker topics. So ideally if when you want to send data from a rails application, send to a pub/sub model, usually to a topic. The IoT Device which has subscribed to this topic will take the data from the specific topic and work accordingly.

Keep reading.

IoT & Connected Products

SaaS Application Development for the Industrial Sector

Explore the benefits and techniques of SaaS application development for the industrial sector. Learn how SaaS solutions can drive efficiency and innovation.

June 27, 2024

IoT & Connected Products

Node vs. Ruby vs. Python for IoT Application Development

It can get hard to pick a tech stack for your project. We decided to compare three renowned programming languages to help with that. Once we get to the end of this, you should come away with a better idea of what (Pytho…

March 18, 2024

IoT & Connected Products

IoT Application Development Guide

There is no doubt that the Internet of Things is the next big tech trend that will be hitting businesses around the globe, and revolutionizing the way we interact with our world. With the ability to incorporate a vast v…

November 20, 2023

Want this applied to your own build?

Start with a free Agent Readiness Assessment — a concrete read on whether your codebase is ready for AI-assisted delivery, and where the leverage and risk are.