How can I make the sensor simpler?
Sensors spread over the surface of the Earth and the surrounding space to provide data to the world. These cheap sensors are one of the driving forces behind the Internet of Things and the digital revolution that our society is now facing. However, connecting to the sensor and getting data from the sensor is not always straightforward or easy. Here are five tips to help engineers connect to the sensor for the first time.
1. Start with the bus tool
The first step any engineer should take when first touching the sensor is to use the bus tool to limit the unknowns. The bus tool connects to the PC via I2C, SPI or any other protocol the sensor may be talking on and then connects to the sensor. The PC application associated with the bus tool provides a known working source for sending and receiving data, rather than an unknown untested embedded MCU driver. In the working environment of the bus tool, developers can send and receive messages to understand how the part works before attempting to operate at the embedded level.
2. Write interface code in Python
Once the developer has tested the sensor using the bus tool, the next step is to write the application code for the sensor. However, instead of jumping directly to the MCU code, you should first write the application code in Python. Many bus tools come with plugins and sample code for writing scripts. Python is usually one of the languages used with .Net. Writing applications in Python is fast and easy, and provides a way to test sensors again in an application environment without compromising the complexity of the embedded environment. Having advanced code allows non-embedded engineers to easily mine scripts and test sensors without the need for embedded software engineers to track and match.
3. Test the sensor using Micro Python
One of the advantages of writing the first cut application code in Python is that you can easily replace application calls to the bus tool API by calling Micro Python. Micro Python runs within the real-time embedded software limitations that many sensor engineers have recognized. Micro Python runs on the Cortex-M4 processor and is an ideal environment for debugging application code. It's not only simpler, it doesn't require writing I2C or SPI drivers because they are included as part of the Micro Python library.
4. Using the sensor vendor code
Any sample code that can be plundered from the sensor manufacturer can provide a good understanding of how the sensor works. Unfortunately, many sensor vendors are not experts in embedded software design, so don't expect to find a beautifully crafted and elegant example of production. Get the vendor code, understand how the part works, and rebuild it until it can be cleanly integrated into the embedded software. It can start with pasta, but using the manufacturer's understanding of how its sensors work will help reduce how many weekends are destroyed before the product launch.
5 . Using sensor fusion libraries
Many chip manufacturers offer an entire library called the "sensor fusion library" to help developers speed up, even better, to prevent them from reinventing the wheel. Many sensors can be combined into common types and categories, which makes driver development almost universal or at least reusable if done properly. Look for these sensor fusion libraries and learn about their strengths and weaknesses.
There are many ways to help increase the speed and ease of use of sensors into embedded systems. Developers will never go wrong, starting with advanced abstractions and understanding how sensors work before integrating sensors into low-level systems.