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.
Raspberry Pi 3, LED Bulbs, resistors, jumper wires, Mule server, and a breadboard.
1. Build the LED blink project:
- Set up your Raspberry Pi and make sure it is running and that you can SSH into it using an IP (preferably a static IP).
- Ensure the Raspberry Pi is connected to the Wi-Fi 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 your 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 a way to connect various devices, data, and applications and, in the process, expose IoT services to the outside world.