🎥 Künstliche Intelligenz VideosJulian Goldie SEO: Elevenlabs MCP + GPT-6 Astra + Hermes is WILD!(15.09.2026 um 19:00 Uhr)
🎥 Künstliche Intelligenz VideosFrontier Day | Claude for startups(15.09.2026 um 20:16 Uhr)
🎥 IT Security VideoThe Cyber Mentors: Start Hardware Hacking for Just $20!(15.09.2026 um 19:00 Uhr)
🍏 iOS / Mac OSApples Fahrplan bis Mitte 2027 umfasst 16 neue Produkte(15.09.2026 um 16:15 Uhr)
🎥 Künstliche Intelligenz VideosJulian Goldie SEO: Elevenlabs MCP + GPT-6 Astra + Hermes is WILD!(15.09.2026 um 19:00 Uhr)
🎥 Künstliche Intelligenz VideosFrontier Day | Claude for startups(15.09.2026 um 20:16 Uhr)
🎥 IT Security VideoThe Cyber Mentors: Start Hardware Hacking for Just $20!(15.09.2026 um 19:00 Uhr)
🍏 iOS / Mac OSApples Fahrplan bis Mitte 2027 umfasst 16 neue Produkte(15.09.2026 um 16:15 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 4 Min Lesezeit
0

Part 3 — Real-Time Inference on Pico (Firmware Integration)

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

In this part we take the exported parameters from Part 2 (model_params.hpp) and wire them into the Raspberry Pi Pico firmware. The firmware continuously samples the onboard temperature sensor, computes the slope, applies the logistic regression, and maintains a hysteresis+hold FSM.









1) Firmware Components





  • model_params.hpp — constants exported from Python training.


  • slope_buf.hpp — efficient rolling OLS slope buffer (keeps running sums).


  • utils_rt.hpp — fast runtime helpers (fast_sigmoid, oversampling ADC read).


  • main_infer.cpp — main loop that ties it all together.









2) Firmware Initialization & Loop



Before running the real-time inference, the firmware must initialize both the serial interface and the onboard temperature sensor. This ensures that logs are reliably captured and sensor data is correctly read.






Initialization Phase






CODE
stdio_init_all();                                 // Initialize stdio (USB + UART)
while(!stdio_usb_connected()) { sleep_ms(100); } // Wait until USB serial is connected
setvbuf(stdout,nullptr,_IONBF,0); // Disable buffering for immediate printf output
printf("# BOOT OK (inference)\n");
printf("uptime_ms,temp_c,slope,prob,state\n"); // Print CSV header

adc_init(); // Initialize ADC subsystem
adc_set_temp_sensor_enabled(true); // Enable internal temperature sensor
adc_select_input(4); // Select ADC channel 4 (connected to sensor)






What’s happening here?





  • USB Setup: stdio_init_all() prepares the Pico for serial communication. The waiting loop ensures that the host PC is connected before data is sent, preventing lost logs.


  • Unbuffered Output: setvbuf(..., _IONBF, 0) disables buffering so every printf is pushed instantly to the serial console.


  • Boot Message: The firmware prints a boot marker and a CSV header so that logs can be redirected directly into a .csv file.


  • ADC Setup: The onboard temperature sensor is internally wired to ADC channel 4. Initializing the ADC and selecting this channel prepares the Pico to measure raw temperature values.






Main Inference Loop



After initialization, the firmware enters the continuous loop where it samples temperature, computes the slope, applies the logistic regression model, and updates the hysteresis FSM.




CODE
SlopeBuf buf(WIN_S);
bool alarm=false; int hold=0;

while(true){
float T = read_temp_oversampled(128, 1500);
uint32_t ms = to_ms_since_boot(get_absolute_time());
float ts = ms * 1e-3f;

buf.push(ts, T);
float m = buf.slope();
float z = (m - MU) / (SIGMA > 1e-9f ? SIGMA : 1.f);
float prob = fast_sigmoid(A_COEF*z + B_INT);

if (!alarm && prob >= P_ON) {
if (++hold >= HOLD_S) { alarm = true; hold = 0; }
} else if (alarm && prob <= P_OFF) {
if (++hold >= HOLD_S) { alarm = false; hold = 0; }
} else {
hold = 0;
}

printf("%u,%.3f,%.5f,%.2f,%s\n", ms, T, m, prob, alarm?"ALARM":"OK");
sleep_ms(1000);
}












3) CSV Output for Debugging



The firmware prints a CSV stream via USB serial:




CODE
uptime_ms,temp_c,slope,prob,state
5702,24.330,0.00011,0.35,OK
6702,23.861,0.00042,0.78,ALARM
...






Putty output:



  • 💼 Connect with me on LinkedIn

  • Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
    ↗ Original-Artikel auf dev.to lesen
    Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    6 Quellen
    Overview of Content Published in March
    1 Quelle
    Xbox Game Pass: Microsoft enthüllt 5 neue Spiele für September 2026
    1 Quelle
    How Cisco is confronting the security crisis of agentic AI
    Ähnliche Beiträge
    🔍 Verwandte News

    Auch interessante Nachrichten Part 3 — Real-Time Inference on Pico (Firmware Integration)

    Thematisch verwandte Begriffe: Part, RealTime, Inference, Pico · 6 Treffer

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...