Team Ai
Apppublic

IDKHowToCodeFr/tinyml-backend

sourceHugging Faceupdated 12h agoView on Hugging Face
1likes
main.cpp42 linesDownload Raw Back to src
1#include <Arduino.h>2 3// This header is automatically generated by HEARTFLOW_OS /export_tinyml4// Place the exported model.h file in the src/ directory alongside this main.cpp5#include "model.h"6 7void setup() {8  Serial.begin(115200);9  while (!Serial);10  11  Serial.println("==========================================");12  Serial.println("HEARTFLOW_OS // EDGE INFERENCE NODE ONLINE");13  Serial.println("==========================================");14  15  // Mock Telemetry Vector16  // Format: [Heart_Rate, SpO2_Level, Systolic_BP, Diastolic_BP, Body_Temp]17  float features[5] = {75.0, 98.0, 120.0, 80.0, 37.0};18  19  Serial.println("Feeding telemetry payload to C-compiled Random Forest...");20  21  unsigned long start_time = micros();22  23  // The predict() function is defined in model.h24  // Returns integer class (e.g., 0 = Healthy, 1 = Heart Disease, etc.)25  int prediction = predict(features);26  27  unsigned long end_time = micros();28  29  Serial.print(">> INFERENCE RESULT: CLASS ");30  Serial.println(prediction);31  32  Serial.print(">> INFERENCE TIME: ");33  Serial.print(end_time - start_time);34  Serial.println(" microseconds");35}36 37void loop() {38  // In a real environment, read from physical sensors (MAX30102, MLX90614) here39  // then pass to predict() and emit via BLE or MQTT.40  delay(5000);41}42