.. highlight:: csharp Data Producer ------------- Components that create data, be it sensors or firmware features, are represented by the `IDataProducer `_ interface. Manipulating the producer data, whether on the Android device or on the board itself, is expressed by a building a data route, more on that in the :doc:`data_route` section. There are three main types of data producers represented by the API: * Asynchronous * Forced * Active These three producers control the data flow slightly differently from each other, as expanded upon in the following sub sections. Async Data Producer ^^^^^^^^^^^^^^^^^^^ Asynchronous data producers, when active, constantly measure data in the background and send it when new data is available. Once configured, call `Start `_ to begin collecting data and call `Stop `_ to put the producer back into standby mode. Most sensors, such as the accelerometer, gyroscope, and magnetometer, are async data producers. :: using MbientLab.MetaWear; public void AsycProducerCtrl(IAsyncDataProducer producer) { // Tells producer to begin creating data producer.Start(); // Puts producer back to standby mode producer.Stop(); } Forced Data Producer ^^^^^^^^^^^^^^^^^^^^ Unlike async producers, forced data producers only create data on demand when a read request is received via the `Read `_ function. Asynchronous behavior can be mimicked using the :doc:`timer` module to schedule periodic reads. GPIO analog/digital, temperature, and humidity data are examples of forced data producers. :: using MbientLab.MetaWear; public void ReadForcedProducer(IForcedDataProducer producer) { // instructs producer to collect one data sample producer.Read(); } Active Data Producer ^^^^^^^^^^^^^^^^^^^^ Active data producers are similar to async data producers in that they send data whenever it is ready, however, as the name implies, they are always active and are not user controlled like the other two producers. Only a few sensors are considered to be an active data producer, namely the push button switch and the power/charge status monitoring pins.