Hardware Reference
In-Depth Information
Chapter 6
Simulating Sensors
Arduinos can be used to simulate sensors for Arduinos or other platforms that use sensors. Simulating sensors allows
you to produce repeatable and known data that can be used to test and debug systems, as well as explore sensors that
may not be available. The concepts in this chapter focus on the connection types of various sensors instead of the
data sent. Although the data is purposely skewed, it is being sent via the same methods used by the actual sensors.
To better demonstrate that Arduinos can directly simulate the various sensors, reader code for each type of interface
is included with the examples; this code is unmodified sensor reader code available from various sources.
These concepts are not designed to replace sensors, and may take more time to get working than using the actual
sensor for small projects. The techniques of sensor simulation become useful for applications that require controlled
data manipulation, such as robotic development, testing platforms, and studying how a sensor works. Ultimately, this
chapter aims to help you get over some of the speed bumps you'll encounter when developing systems to simulate
sensors or creating more complex sensor packages.
Sensors convert various physical changes to electrical data, which can then be read by computer systems.
Temperature, position, and chemical concentrations are examples of physical elements that can be measured by
sensors. When emulating sensors, it is not important to simulate the entire workings or the complete functionality;
however, the data needs to be sent at the same time, in the same order, and with the same method as the sensor
being simulated. Data sheets provide the necessary information for a sensor's important functions (e.g., data range,
communication types, and data types). The hardware requirements for this chapter are two Arduino-compatible
boards based on the ATmega 328P and a good assortment of general prototyping components. One Arduino is to be
used as the sensor reader and the other is to simulate a sensor. Using two boards will accommodate a wide range of
sensors and allows the sensor sketch to remain separate from the reader's sketch. This allows for the most accurate
simulation in terms of program timing, and when the simulated sensor is replaced with a functional sensor, it requires
no modification of the sketch on the reader side.
Analog Sensors
There are a variety of analog sensors that can measure temperature, movement, or position, for example. These types
of sensors continuously control the output voltage, which is directly correlated with the state of the sensor. The output
information can then be read by the Arduino when the analog pins are accessed. You could mimic the analog data
with a potentiometer, but since a potentiometer is a sensor type itself, it is not effective for automated control.
The Arduino has analog inputs but no true analog out. There are methods to remedy the lack of analog output
with a digital-to-analog converter (DAC) or a digital potentiometer, which are great for full production systems, but
they are rarely found in the average collection of components. The examples in this section demonstrate how to make
two different DACs using only resistors and capacitors to produce analog signals. The first example is focused on an
Analog Devices TMP35 temperature sensor code for the Arduino.
 
Search WWH ::




Custom Search