Contact sales

Intro to Particle Logic

The Particle Team article author avatarThe Particle TeamJuly 31, 2024
Intro to Particle Logic

Our IoT experts at Particle are always looking for ways to make building connected products easier and more powerful. Their latest innovation is Particle Logic, a game-changing tool that lets you build business logic, data processing, and automation for IoT devices in the cloud, avoiding complex firmware updates.

What exactly is Particle Logic? 

Put simply, Logic allows you to write JavaScript code that executes in the cloud in response to events, schedules, or data changes, opening up a whole new world of possibilities for your IoT applications – you can easily set up custom data transformations, aggregations, and third-party integrations, all without touching your device firmware.

Working alongside Logic is Particle Ledger, which provides a structured way to store and sync data between devices and the cloud, ensuring that your data is always contextualized and actionable. Together, Logic and Ledger enable seamless data processing and automation.

As Cole Abbeduto, a Particle engineer, explains, “We built Logic to be as user-friendly and easy to use as possible while still being extremely powerful.”

So how does it actually work? 

At its core, Particle Logic operates on a trigger-based system. These triggers can be device events, scheduled tasks using cron syntax, or data changes within the Particle ecosystem. When a trigger occurs, Logic executes the associated JavaScript code, allowing for immediate response to device activities or data updates. 

For example, a basic Logic function might look like this:

function processTemperature(event) {
  const temp = JSON.parse(event.data).temperature;
  if (temp > 30) {
    Particle.publish("high-temp-alert", JSON.stringify({
      deviceId: event.deviceId,
      temp: temp
    }));
  }
}

This function processes temperature data from a device, checking for high-temperature conditions and publishing an alert if necessary.

Key features and capabilities

Particle Logic and Ledger bring a suite of powerful features designed to give developers greater control over their IoT ecosystems, enabling more sophisticated applications without increasing device complexity. By leveraging cloud computing power and integrating seamlessly with the existing Particle platform, these tools open up new possibilities for IoT development.

  1. JavaScript processing: Utilize familiar JavaScript for data handling and processing.
  2. Event-driven architecture: Respond to device events in real-time.
  3. Scheduled tasks: Set up regular processing or maintenance tasks.
  4. Data transformation: Clean, decompress, or reformat data before it reaches your application.
  5. Particle API integration (coming soon): Interact directly with the Particle API to automatically take actions on your fleet; respond to event data, scheduled blocks, and more.
  6. User-friendly implementation: Access templates and an intuitive interface in the Particle Console.

Use cases and applications

The versatility of Logic and Ledger enables a wide range of applications across various industries and use cases, offering solutions that can be tailored to your specific needs. Here are some of the key applications where these tools can make a significant impact:

  • Data preprocessing: Prepare and format raw device data for further processing.
  • Threshold-based alerting: Implement custom alert conditions without firmware modifications.
  • Machine learning preprocessing: Prepare data for ML models directly in the cloud.
  • Automate actions: Set up dynamic actions and workflows across fleets efficiently, using data managed and contextualized by Ledger. 
  • Data aggregation and analytics: Perform initial data analysis to optimize main application performance.

Get started developing with Logic

Developers can access Particle Logic through the Particle Console. The interface allows for the creation of Logic blocks, trigger setup, and JavaScript code implementation. Particle provides templates and documentation to facilitate a smooth onboarding process.

Sandbox users can create up to 20 Logic functions per account, each with a maximum of five triggers and a 30-second timeout. Enterprise and paid users may have expanded capabilities and are encouraged to contact Particle for specific details.

Advancing IoT development with Particle Logic and Ledger

Logic and Ledger represent a significant step forward in IoT data processing and device management. By providing a flexible, cloud-based layer for data transformation and decision-making, they allow developers to create more sophisticated IoT applications without increasing device complexity.

Ready to start building your Logic and Ledger-powered applications? Head over to the Particle Console and dive in. And don’t forget to join the Particle community to get support, submit feature requests, and see what others are building.

Particle Logic is just the latest addition to Particle’s incredible IoT platform and development tools. To keep leveling up your IoT skills, check out the full Particle design series for helpful videos and tutorials.

Happy building!

Comments are not currently available for this post.