DevHeads IoT Integration Server

DII

DevHeads IoT Integration Server

The DevHeads IoT Integration Server accelerates technology engineering by helping pro devs learn, share and collaborate.

Join

seeking-collabs

πŸͺ²-firmware-and-baremetal

πŸ“¦-middleware-and-os

πŸ“‘-edge-networking

🟩-pcb-and-analog

jobs

☁-iot-cloud

βœ…-code-review

devheads-feed

general-dev-chat

Efficiently Converting and Quantizing a Trained Model to TensorFlow Lite

Hey guys in contiuation of my project Disease Detection from X-Ray Scans Using TinyML, i am done training my model and would like to know the most easiest and efficient method for converting the trained model to TensorFlow Lite for deployment on a microcontroller, i have converted it using TensorFlow Lite's converter to convert it to a .tflite file but dont know if its the best method, and also how can i quantinize it to reduce the model size and improve inference speed
Solution:
Hey @Enthernet Code good job on getting this far with your project, The method you used to convert your model to TensorFlow Lite is perfectly valid and commonly used. However, if you’re concerned about the model size and performance on a microcontroller, quantization is definitely something you should look into. Quantization helps by reducing the precision of the weights and biases, most times from 32-bit floats to 8-bit integers, which reduces the model size and can significantly speed up inference, especially on hardware with limited resources like microcontrollers. You can apply quantization during the conversion process like this:...

Issues Setting Up Zephyr OS on AVR32UC - Board Configuration and Toolchain Errors

hello guys, I'm setting up Zephyr OS on my AVR32UC microcontroller and running into some issues during the initial configuration. I've already installed the Zephyr SDK and set up the toolchain, but when I try to build the project for my AVR32UC board using west build -b avr32uc_board, I get errors related to the board configuration and toolchain paths. Has anyone else faced similar problems with the toolchain setup or missing board definitions? What are some common mistakes to watch out for, a...
Solution:
@Dark AI Thanks I started by cleaning the build environment with west build -t clean, and I also double-checked my toolchain paths and updated the board definitions, and it worked just fine.

Can ESP32-WROVER-KIT handle wake word detection without an audio chip?

Hi everyone, im starting to work with esp32-wrover-kit right now. I'm looking for wake word engine (and speech recognition like Alexa) throught sdcard audio file. But i saw that esp-adf and Skainet framework works only with board with built-in audio chip. Anyone know if is possible to do something like that with my board, or im just wasting time?...
Solution:
@wafa_ath Yes, it's possible to get wake word detection and speech recognition working on your ESP32-WROVER-KIT. You'll just need to add an external audio codec and tweak frameworks like ESP-ADF or Skainet to suit your board. It's definitely doable, but it will take some extra hardware and setup

What could be causing intermittent UART communication failures in my AVR32UC MCU running Zephyr OS?

I'm trying to develop a smart healthcare system using an AVR32UC microcontroller running Zephyr OS. The system uses UART to communicate between the MCU and a central monitoring station. However, I'm experiencing intermittent communication failures, where the data received is occasionally corrupted or incomplete. I suspect the issue might be related to my UART configuration or the Zephyr OS UART driver. I have Verified the baud rate and ensured it's the same on both ends, checked for noise issues on the UART lines, and experimented with different buffer sizes. What could be causing the intermittent UART communication failures? Are there any specific configurations in Zephyr OS that I might be missing to ensure stable UART communication? The UART initialization code is attached....
Solution:
If you dealing with intermittent UART communication issues on a AVR32UC microcontroller running Zephyr OS , you must check your UART setup . Your hardware flow control should be enabled, adjust the buffer sizes, ensure the ISR is running smoothly...
attachment 0

Resolving Deadlocks in ESP32 Robotic Arm Control with FreeRTOS

Hey guys i'm attempting on working on an ESP32 robotic arm control system using FreeRTOS and MQTT, but the system occasionally freezes. I suspect a deadlock between controlArmTask and sendCommandTask. These tasks manage critical arm control logic, including inverse kinematics,, and motor control. ```c void controlArmTask(void *pvParameter) { while (1) {...

How to store and manage ADC values in a 2D array for FFT processing in an FMCW radar system

I am using an FMCW radar to determine the distance and speed of a moving object with an STM32L476 microcontroller. To find the range of a stationary object, I store the ADC values into the "fft_in" array using the "HAL_ADC_ConvCpltCallback" function. I have initialized "is_data_ready_for_fft = 1" as follows: ```c void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc1) { is_data_ready_for_fft = 1;...
Solution:
Yes, precisely!πŸ‘ @Sterling As you proceed through each chirp, that will store your {fft_in} array into the matrix row by row. After that, you may examine the matrix to calculate the velocity or any other desired parameter.

Why Does Piping Output to Hexdump Fail for My Assembly printf Function?

Here is a low level debugging tool for an Intel Core i7 12700K system running Ubuntu 22.04 that requires precise control over output formatting. As part of this tool, I'm implementing a custom printf like function in assembly using NASM assembler and GNU Linker. I've encountered unexpected behavior when piping the output of my assembly printf function to hexdump . The output is displayed correctly when printed directly to the terminal, but piping it to hexdump results in no output. From printf.c , output to STDOUT: ``` $ ./printf...
Solution:
@Marvee Amasi The issue you're encountering is due to the buffering behavior of the standard output stream (stdout). In C, the standard library handles the buffering of stdout, which ensures that the buffer is flushed when the program exits or when the buffer is full. However, when you implement printf in assembly, you're bypassing these standard library mechanisms, which can lead to different behavior, especially when piping the output. To make sure that your assembly implementation behaves consistently, you need to explicitly flush the stdout buffer. You can achieve this by using a write system call directly instead of relying on the C printf function....
attachment 0

How can I achieve high-frequency (over 100kHz) data acquisition with an STM32F107VC using SPI

Please how can I achieve high-frequency (over 100kHz) data acquisition with an STM32F107VC using SPI for an ADC while considering limitations of RTOS tick frequency? FreeRTOS seems insufficient, and high tick rates in Keil RTX5 raise concerns. What's the best approach? @Middleware & OS...
Solution:
Sure, DMA is ideal! Here are some key points for configuration: 1. Buffer Size:Choose a buffer size that holds enough samples to minimize data loss at high speeds. Consider factors like ADC sampling rate and desired data acquisition duration. 2. Interrupt Strategy: Configure DMA to generate an interrupt when the transfer completes (or halfway for double buffering). This allows the RTOS to handle post-processing efficiently. ...

How to Implement a 6-Hour Delay in FreeRTOS Task?

I would like to know if i can do vtaskdelay of a period of 6 hours, what is the way to do it. I have a task I wanted to be excuted eeach 6 hours whats is the best way to do it .? Thanks...
Solution:
@youcef_ali vTaskDelay takes the delay period in ticks, you need to convert the 6 hours into ticks based on your system's tick rate. Normally, u'll are to multiply the number of seconds in 6hours with your ticks per second which would result in a very high number and using large value isn't ideal so a better approach would be using a loop i.e πŸ‘‡ (this is assuming ur tick is 1000/sec) ```c #define HOUR_TICKS (3600000) // 1 hour in ticks void vTaskFunction(void *pvParameters)...

How to Efficiently Transfer Large Data from ISR to Task on STM32F401 with FreeRTOS?

Good day Devs, I am working with an STM32F401 microcontroller for audio acquisition and need to transfer 384 bytes of PCM audio data from an ISR to a task using queues. The queue size currently used for this transfer is 5, but the high frequency of the ISR (8 kHz) seems to be causing data loss due to queue overflow, resulting in noisy audio recordings. Is there a more efficient method to transfer large amounts of data from an ISR to a task??? (The RTOS in use is FreeRTOS, and the ISR is triggered by the DMA callback from the I2S microphone peripheral)....
Solution:
@Sterling It is suggested not to use large code inside the ISR rather than just define a flag and set that flag inside the isr when the flag is set just read those data from the memory and reset that flag Assuming you are using dma peripheral to memory...

Initialize AVR32UC with Zephyr OS for DHT22 Sensor Communication and Resolve Data Fetch Failure

Hey guys, how can I initialize the AVR32UC microcontroller with Zephyr OS to communicate with the DHT22 temperature and humidity sensor, and address the issue of failing to fetch sensor data? I have been able to configure Zephyr OS for the AVR32UC and ensured all necessary drivers are enabled. The DHT22 sensor is connected correctly, and the initial code for reading temperature and humidity data is implemented. However, the microcontroller still fails to fetch data from the DHT22. what could be wrong? here is my code snippet: ```c #include <zephyr.h> #include <device.h>...

Using Google Test for C-Code and mocking C-Modules

I currently face a situation where I have to use Google Test for C-Code. So I am not really able to use gmock to mock C-modules. What I want to do instead is use the CMake build system to choose mocked modules when needed. I want to accomplish that if possible by telling the build system to first search for includes/header files in lets say "path/to/mock/include" and if the regarding header file cant be found there I want it to choose the header file from the "normal" production code path like "path/to/production/include". That I want to do for every target I define. A target will be the test suite for a specific C-module. Normally that should be possible like this: Why do I want to mock? Some of the modules my module under test includes are hardware dependent. ...

What are the best practices for handling priority inversion in FreeRTOS on ESP32?

Hi guys While working on real-time task scheduling and management with FreeRTOS on ESP32 for a wireless communication system, I faced priority inversion and task starvation issues. I observed that lower priority tasks occasionally blocked higher priority ones, causing missed deadlines, missed sensor readings, and unreliable communication. This was evident as higher priority tasks waited indefinitely for resources held by lower priority tasks. What are the best practices for handling priority inv...
Solution:
Yes, I used a mutex as suggested, and it was the first step that @Joseph Ogbonna gave me that made the difference.

How to resolve SSL handshake failure with error code -0x7780 in STM32 SSL client integration?

Hey guys, I am currently working on integrating an SSL client into my IoT project. I've copied the SSL_Client example from STM32Cube_FW_F7_V1.15.0 into my project, and it compiles successfully. However, the SSL handshake fails with the error code -0x7780 (MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE). I would appreciate any guidance on resolving this issue. Below is the console debug output:...
Solution:
You can usually find this information in the server's documentation or by using tools such as SSL Labs' SSL Test. Also, try to verify that your root CA certificates are properly loaded on the client side.

How to convert relative cursor movement to absolute position for BLE HID using Zephyr?

Hey @MCU, MPU & Firmware @Helper Guys, i have a slight logic problem, So i built a BLE HID device using zephyr which tags input from a console and send BLE HID packets to the connected device All well and good...for now The problem arises here, where the HID report is based of the relative position of the cursor, but my client requires a way to give it through Absolute position of a device(Main eg: phone) ...

How to ensure reliable OTA updates with FreeRTOS on ESP32 and handle failures?

Hi guys I'm implementing OTA updates for an ESP32 project running FreeRTOS to add new features and security patches. The update process often fails mid-way with the error message "OTA Update Failed: Incomplete Write," leaving the device in an inconsistent state and non-operational. Integrating OTA functionality with existing FreeRTOS tasks causes system instability, with tasks being interrupted during critical operations. How can I ensure seamless and reliable OTA updates on ESP32 with FreeRTOS?...
Solution:
For Embedded Linux, I use Mender. I know they are working on integration with ESP32 https://mender.io/blog/mender-ota-on-the-esp32-part-1...

How to optimize SIMD instructions for double precision floating point operations on Intel Core i7

I want to optimize a computationally intensive loop using SIMD instructions on an Intel Core i7 12700K processor and 32GB of DDR4 3200 memory , to boost the performance for a double precision floating point vector addition operation within a larger scientific computation``` section .data data_array: dq 1.0, 2.0, 3.0, 4.0, ..., 1000000.0 ; Array of 1 million double-precision values section .text...

How to Fix CAN Controller Initialization Error in ATmega2560 with Zephyr OS?

Hey guys, I am trying to implement a real-time control system for automotive applications using an ATmega2560 microcontroller, an MCP2515 CAN controller, and Zephyr OS, while integrating a Bosch BMP280 sensor for pressure data. How can I address the error of failing to initialize the CAN controller? I have tried configuring the SPI peripheral in Zephyr, integrating the MCP2515 CAN controller, and the Bosch BMP280 sensor, but I still encounter the error "CAN: Device driver not found." If the implementation is successful, the output should log a message indicating that the CAN frame has been sent successfully. Here is my code in the attached file....
Solution:
Yeah, I was able to redefine the MCP2515 CAN controller in the device tree file and also confirmed that the MCP2515 CS pin is correctly configured. I've been able to get a lead on it, thanks buddy @RED HAT
attachment 0

How to Fix "Failed to Read Sensor: OSError" on Arduino Nano 33 BLE Sense with MicroPython?

Hey guys am developing an air quality monitoring system using an Arduino Nano 33 BLE Sense, MicroPython, and a CCS811 gas sensor. The system will use a TinyML model to predict air quality index (AQI) based on sensor data. I have set up the flash MicroPython firmware on the Arduino Nano 33 BLE Sense, connected the CJMCU-8128 module to the Arduino (I2C pins: SDA to A4, SCL to A5), also connected the OLED display to the Arduino using I2C. But am getting the error Failed to read sensor: OSError Here's my code ...
Solution:
Thanks @RED HAT o checked if my sensor was initialized using the script you sent and it was but I after I changed the frequency to 100kHz it started working properly πŸ‘, thanks once again

What am I doing wrong with "scanf" ?

When I compiled my actuat_so assembly file's code using
nasm -f elf64 example.asm -o example.o
gcc -no-pie -m64 example.o -o example
nasm -f elf64 example.asm -o example.o
gcc -no-pie -m64 example.o -o example
and then run
./example
./example
...
Solution:
Troubleshooting Steps: 1) Verify that scanf is linked correctly and the assembly code matches the calling convention. 2) Ensure that you are aligning the stack properly before calling scanf. 3) Check if printf or other functions in your code are causing issues indirectly....
attachment 0