Reading Time: 4 minutes

MuleSoft’s lightweight Runtime Engine can be used to expose microservices and APIs on any IoT device. In this post, I will demonstrate how users can use MuleSoft and a Python script to create a simple API that lights up an LED bulb 10 times in a loop. To get started, please refer to the requirements, video tutorial, and steps below.

Requirements:

Raspberry Pi 3, LED Bulbs, resistors, jumper wires, Mule server, and a breadboard.

Git Repository:

latest report
Learn why we are the Leaders in API management and iPaaS

Mule IoT LED Project

Video Tutorial:

Project Steps:

1. Build the LED blink project:

  • Setup Raspberry Pi and make sure it is and running and that you can SSH into it using an IP (preferably static IP).
  • Ensure Raspberry Pi is connected to the WiFi router (Wireless or LAN cable)

 2. Install Mule on Raspberry Pi:

  • Install the Mule server in Raspberry Pi. It should be up as an instance, or as a service.

3. Create a Python script with GPIO commands:

  • Write a Python script that can control GPIO commands to blink the LED bulb, which should be connected with the proper resistor and jumper wire to Raspberry PI.

4. Create a Mule app and call the Python script in localhost (Raspberry Pi):

  • Deploy the Mule app in Raspberry Pi. Make sure it is able to call the Python script to blink the LED bulb.

5. Create a proxy app on a client machine, and call the Mule Raspberry Pi app using the Raspberry Pi IP address through the RAML Console:

  • Call the Mule app running on Raspberry Pi from another client machine through a REST RAML-based API on the static IP (Raspberry Pi IP address).

6. Expose REST API endpoints by making the Raspberry IP address public

  • Finally, configure the Raspberry IP address as public, enabling you to access it from any location and at any time.

As this demo has demonstrated, MuleSoft’s Runtime Engine can be used in an innovative way to connect various devices, data, and applications and, in the process, expose IoT services to the outside world.

Explore MuleSoft’s solutions for IoT and learn more about Anypoint Platform.