<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://badge.emfcamp.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mgsb</id>
	<title>EMF Badge - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://badge.emfcamp.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mgsb"/>
	<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/wiki/Special:Contributions/Mgsb"/>
	<updated>2026-04-08T04:16:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=362</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=362"/>
		<updated>2018-08-31T09:21:42Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The TiLDA MK4 has four sensors, three sharing an I2C bus and one with an analog output:&lt;br /&gt;
&lt;br /&gt;
* Temperature and Humidity: [http://www.ti.com/product/HDC2080 TI HDC2080]&lt;br /&gt;
* Luminance: [http://www.ti.com/product/OPT3001 TI OPT3001]&lt;br /&gt;
* Temperature: [http://www.ti.com/product/TMP102 TI TMP102] - the TMP102 has higher precision and extended temperature range with no calibration needed compared to HDC2080&lt;br /&gt;
* Magnetic: [http://www.ti.com/product/DRV5055 TI DRV5055]&lt;br /&gt;
&lt;br /&gt;
The sensors are physically located on the badge as shown in the picture below. Since these are environmental sensors, the orientation and location of the badge will affect the values returned from the sensors. For example, wearing the badge close to your body will likely raise the temperature readings.&lt;br /&gt;
 &lt;br /&gt;
[[File:Sensor graphic - with fixed transparency-01.png|400px]]&lt;br /&gt;
[[File:Sensor graphic - with fixed transparency-02.png|400px]]&lt;br /&gt;
&lt;br /&gt;
In addition, the battery charger circuit (TI BQ25601), powered via USB, has status available via the I2C bus.&lt;br /&gt;
&lt;br /&gt;
These sensors are managed by the tilda.Sensors module. This module takes care of initializing the devices and periodically updating readings from them. This makes it easier to use from applications as all the low-level interactions and data formatting are available directly via MicroPython methods. There are more features available in the devices that could be enabled. Currently this would be done by enhancing the C code in the ports/ti directory. In the future, the devices might also be directly programmable via the MicroPython I2C API.&lt;br /&gt;
&lt;br /&gt;
You can see what's provided by the Sensors module using the standard Python dir() operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the usual Python conventions, the all upper-case identifiers are symbolic constant values. The other identifiers are methods that should be semi-obviously apparent in what functions they perform.&lt;br /&gt;
&lt;br /&gt;
== Temperature and Humidity ==&lt;br /&gt;
&lt;br /&gt;
Two methods are provided for the HDC2080. get_hdc_temperature() returns the current ambient temperature in degrees Centigrade. get_hdc_humidity() returns the relative humidity as a percentage.&lt;br /&gt;
&lt;br /&gt;
get_tmp_temperature() returns the current ambient temperature in degrees Centigrade from the TMP102 sensor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;HDC temperature: {} C&amp;quot;.format(Sensors.get_hdc_temperature()))&lt;br /&gt;
print(&amp;quot;TMP temperature: {} C&amp;quot;.format(Sensors.get_tmp_temperature()))&lt;br /&gt;
print(&amp;quot;HDC humidity: {}%&amp;quot;.format(Sensors.get_hdc_humidity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Luminance ==&lt;br /&gt;
&lt;br /&gt;
The OPT3001 measures light intensity (luminance) scaled to match the way the human eye perceives light. This is useful for applications controlling lighting so that changes appear more natural to people.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    print(&amp;quot;Light intensity: {} lux&amp;quot;.format(Sensors.get_lux()))&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place your hand over the OPT3001 sensor and observe the measured intensity change.&lt;br /&gt;
&lt;br /&gt;
== Magnetic Flux - Hall Effect ==&lt;br /&gt;
&lt;br /&gt;
The DRV5055 senses magnetic fields (hooray for ElectroMAGNETIC FIELD Camp!). The device provides an analog output that is sampled by the ADC on the MCU. The particular device on the badge has a sensitivity of 12.5mV / mT. Note that the earth's magnetic field is in the range of micro Teslas (uT). Bring a small magnetic close to the sensor and watch the measurements change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from machine import ADC&lt;br /&gt;
from time import sleep_ms&lt;br /&gt;
&lt;br /&gt;
mag = ADC(ADC.ADC_HALLEFFECT)&lt;br /&gt;
while True:&lt;br /&gt;
    print(mag.convert())&lt;br /&gt;
    sleep_ms(200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Battery ==&lt;br /&gt;
&lt;br /&gt;
The BQ25601 takes care of charging the LiPo battery when the badge is attached to a USB power source - PC, car, battery. You can monitor the status by using the get_charge_status() and get_vbus_connected() methods. For example, you might want to turn off the display more often when there is no USB power so that the battery lasts longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from machine import Pin&lt;br /&gt;
&lt;br /&gt;
backlight = Pin(Pin.PWM_LCD_BLIGHT)&lt;br /&gt;
if Sensors.get_vbus_connected() != Sensors.BAT_NO_INPUT:&lt;br /&gt;
    backlight.on()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While there is power supplied via USB, you can monitor the charging status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
charging = Sensors.get_charge_status()&lt;br /&gt;
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is charging&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_DONE_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is full&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_NOT_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is discharging&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Rate ==&lt;br /&gt;
&lt;br /&gt;
You can change how often the sensors are read using the sample_rate() method. Like other Python APIs, this function is both a &amp;quot;setter&amp;quot; and a &amp;quot;getter&amp;quot;. If you call it with no argument, it returns the current sample rate in Hz. If you supply a value, the sample rate is changed. Changing the sample rate can let you see sensor values change more rapidly; conversely, a slower sample rate will update less often but use less energy, making the battery last longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Sensor sample rate: {}&amp;quot;.format(Sensors.sample_rate()))&lt;br /&gt;
Sensors.sample_rate(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=360</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=360"/>
		<updated>2018-08-30T22:01:27Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The TiLDA MK4 has four sensors, three sharing an I2C bus and one with an analog output:&lt;br /&gt;
&lt;br /&gt;
* Temperature and Humidity: [http://www.ti.com/product/HDC2080 TI HDC2080]&lt;br /&gt;
* Luminance: [http://www.ti.com/product/OPT3001 TI OPT3001]&lt;br /&gt;
* Temperature: [http://www.ti.com/product/TMP102 TI TMP102] - the TMP102 has higher precision and extended temperature range with no calibration needed compared to HDC2080&lt;br /&gt;
* Magnetic: [http://www.ti.com/product/DRV5055 TI DRV5055]&lt;br /&gt;
&lt;br /&gt;
The sensors are physically located on the badge as shown in the picture below. Since these are environmental sensors, the orientation and location of the badge will affect the values returned from the sensors. For example, wearing the badge close to your body will likely raise the temperature readings.&lt;br /&gt;
 &lt;br /&gt;
[[File:Sensor graphic - with fixed transparency-01.png|400px]]&lt;br /&gt;
[[File:Sensor graphic - with fixed transparency-02.png|400px]]&lt;br /&gt;
&lt;br /&gt;
In addition, the battery charger circuit (TI BQ25601), powered via USB, has status available via the I2C bus.&lt;br /&gt;
&lt;br /&gt;
These sensors are managed by the tilda.Sensors module. This module takes care of initializing the devices and periodically updating readings from them. This makes it easier to use from applications as all the low-level interactions and data formatting are available directly via MicroPython methods. There are more features available in the devices that could be enabled. Currently this would be done by enhancing the C code in the ports/ti directory. In the future, the devices might also be directly programmable via the MicroPython I2C API.&lt;br /&gt;
&lt;br /&gt;
You can see what's provided by the Sensors module using the standard Python dir() operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the usual Python conventions, the all upper-case identifiers are symbolic constant values. The other identifiers are methods that should be semi-obviously apparent in what functions they perform.&lt;br /&gt;
&lt;br /&gt;
== Temperature and Humidity ==&lt;br /&gt;
&lt;br /&gt;
Two methods are provided for the HDC2080. get_hdc_temperature() returns the current ambient temperature in degrees Centigrade. get_hdc_humidity() returns the relative humidity as a percentage.&lt;br /&gt;
&lt;br /&gt;
get_tmp_temperature() returns the current ambient temperature in degrees Centigrade from the TMP102 sensor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;HDC temperature: {} C&amp;quot;.format(Sensors.get_hdc_temperature()))&lt;br /&gt;
print(&amp;quot;TMP temperature: {} C&amp;quot;.format(Sensors.get_tmp_temperature()))&lt;br /&gt;
print(&amp;quot;HDC humidity: {}%&amp;quot;.format(Sensors.get_hdc_humidity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Luminance ==&lt;br /&gt;
&lt;br /&gt;
The OPT3001 measures light intensity (luminance) scaled to match the way the human eye perceives light. This is useful for applications controlling lighting so that changes appear more natural to people.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    print(&amp;quot;Light intensity: {} lux&amp;quot;.format(Sensors.get_lux()))&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place your hand over the OPT3001 sensor and observe the measured intensity change.&lt;br /&gt;
&lt;br /&gt;
== Magnetic Flux - Hall Effect ==&lt;br /&gt;
&lt;br /&gt;
The DRV5055 senses magnetic fields (hooray for ElectroMAGNETIC FIELD Camp!). The device provides an analog output that is sampled by the ADC on the MCU. The particular device on the badge has a sensitivity of 12.5mV / mT. Note that the earth's magnetic field is in the range of micro Teslas (uT). Bring a small magnetic close to the sensor and watch the measurements change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from machine import ADC&lt;br /&gt;
from time import sleep_ms&lt;br /&gt;
&lt;br /&gt;
mag = ADC(ADC.ADC_HALLEFFECT)&lt;br /&gt;
while True:&lt;br /&gt;
    print(mag.convert())&lt;br /&gt;
	sleep_ms(200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Battery ==&lt;br /&gt;
&lt;br /&gt;
The BQ25601 takes care of charging the LiPo battery when the badge is attached to a USB power source - PC, car, battery. You can monitor the status by using the get_charge_status() and get_vbus_connected() methods. For example, you might want to turn off the display more often when there is no USB power so that the battery lasts longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from machine import Pin&lt;br /&gt;
&lt;br /&gt;
backlight = Pin(Pin.PWM_LCD_BLIGHT)&lt;br /&gt;
if Sensors.get_vbus_connected() != Sensors.BAT_NO_INPUT:&lt;br /&gt;
    backlight.on()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While there is power supplied via USB, you can monitor the charging status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
charging = Sensors.get_charge_status()&lt;br /&gt;
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is charging&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_DONE_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is full&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_NOT_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is discharging&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Rate ==&lt;br /&gt;
&lt;br /&gt;
You can change how often the sensors are read using the sample_rate() method. Like other Python APIs, this function is both a &amp;quot;setter&amp;quot; and a &amp;quot;getter&amp;quot;. If you call it with no argument, it returns the current sample rate in Hz. If you supply a value, the sample rate is changed. Changing the sample rate can let you see sensor values change more rapidly; conversely, a slower sample rate will update less often but use less energy, making the battery last longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Sensor sample rate: {}&amp;quot;.format(Sensors.sample_rate()))&lt;br /&gt;
Sensors.sample_rate(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=359</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=359"/>
		<updated>2018-08-30T22:00:51Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The TiLDA MK4 has four sensors, three sharing an I2C bus and one with an analog output:&lt;br /&gt;
&lt;br /&gt;
* Temperature and Humidity: [http://www.ti.com/product/HDC2080 TI HDC2080]&lt;br /&gt;
* Luminance: [http://www.ti.com/product/OPT3001 TI OPT3001]&lt;br /&gt;
* Temperature: [http://www.ti.com/product/TMP102 TI TMP102] - the TMP102 has higher precision and extended temperature range with no calibration needed compared to HDC2080&lt;br /&gt;
* Magnetic: [http://www.ti.com/product/DRV5055 TI DRV5055]&lt;br /&gt;
&lt;br /&gt;
The sensors are physically located on the badge as shown in the picture below. Since these are environmental sensors, the orientation and location of the badge will affect the values returned from the sensors. For example, wearing the badge close to your body will likely raise the temperature readings.&lt;br /&gt;
 &lt;br /&gt;
[[File:Sensor graphic - with fixed transparency-01.png|400px]]&lt;br /&gt;
[[File:Sensor graphic - with fixed transparency-02.png|400px]]&lt;br /&gt;
&lt;br /&gt;
In addition, the battery charger circuit (TI BQ25601), powered via USB, has status available via the I2C bus.&lt;br /&gt;
&lt;br /&gt;
These sensors are managed by the tilda.Sensors module. This module takes care of initializing the devices and periodically updating readings from them. This makes it easier to use from applications as all the low-level interactions and data formatting are available directly via MicroPython methods. There are more features available in the devices that could be enabled. Currently this would be done by enhancing the C code in the ports/ti directory. In the future, the devices might also be directly programmable via the MicroPython I2C API.&lt;br /&gt;
&lt;br /&gt;
You can see what's provided by the Sensors module using the standard Python dir() operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the usual Python conventions, the all upper-case identifiers are symbolic constant values. The other identifiers are methods that should be semi-obviously apparent in what functions they perform.&lt;br /&gt;
&lt;br /&gt;
== Temperature and Humidity ==&lt;br /&gt;
&lt;br /&gt;
Two methods are provided for the HDC2080. get_hdc_temperature() returns the current ambient temperature in degrees Centigrade. get_hdc_humidity() returns the relative humidity as a percentage.&lt;br /&gt;
&lt;br /&gt;
get_tmp_temperature() returns the current ambient temperature in degrees Centigrade from the TMP102 sensor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;HDC temperature: {} C&amp;quot;.format(Sensors.get_hdc_temperature()))&lt;br /&gt;
print(&amp;quot;TMP temperature: {} C&amp;quot;.format(Sensors.get_tmp_temperature()))&lt;br /&gt;
print(&amp;quot;HDC humidity: {}%&amp;quot;.format(Sensors.get_hdc_humidity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Luminance ==&lt;br /&gt;
&lt;br /&gt;
The OPT3001 measures light intensity (luminance) scaled to match the way the human eye perceives light. This is useful for applications controlling lighting so that changes appear more natural to people.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    print(&amp;quot;Light intensity: {} lux&amp;quot;.format(Sensors.get_lux()))&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place your hand over the OPT3001 sensor and observe the measured intensity change.&lt;br /&gt;
&lt;br /&gt;
== Magnetic Flux - Hall Effect ==&lt;br /&gt;
&lt;br /&gt;
The DRV5055 senses magnetic fields (hooray for ElectroMAGNETIC FIELD Camp!). The device provides an analog output that is sampled by the ADC on the MCU. The particular device on the badge has a sensitivity of 12.5mV / mT. Note that the earth's magnetic field is in the range of micro Teslas (uT). Bring a small magnetic close to the sensor and watch the measurements change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from machine import ADC&lt;br /&gt;
from time import sleep_ms&lt;br /&gt;
&lt;br /&gt;
mag = ADC(ADC.ADC_HALLEFFECT)&lt;br /&gt;
while True:&lt;br /&gt;
    print(mag.convert())&lt;br /&gt;
	sleep_ms(200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Battery ==&lt;br /&gt;
&lt;br /&gt;
The BQ25601 takes care of charging the LiPo battery when the badge is attached to a USB power source - PC, car, battery. You can monitor the status by using the get_charge_status() and get_vbus_connected() methods. For example, you might want to turn off the display more often when there is no USB power so that the battery lasts longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from machine import Pin&lt;br /&gt;
&lt;br /&gt;
backlight = Pin(Pin.PWM_LCD_BLIGHT)&lt;br /&gt;
if Sensors.get_vbus_connected() != Sensors.BAT_NO_INPUT:&lt;br /&gt;
    backlight.on()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While there is power supplied via USB, you can monitor the charging status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
charging = Sensors.get_charge_status()&lt;br /&gt;
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is charging&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_DONE_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is full&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_NOT_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is discharging&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Rate ==&lt;br /&gt;
&lt;br /&gt;
You can change how often the sensors are read using the sample_rate() method. Like other Python APIs, this function is both a &amp;quot;setter&amp;quot; and a &amp;quot;getter&amp;quot;. If you call it with no argument, it returns the current sample rate in Hz. If you supply a value, the sample rate is changed. Changing the sample rate can let you see sensor values change more rapidly; conversely, a slower sample rate will update less often but use less energy, making the battery last longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Sensor sample rate: {}&amp;quot;.format(Sensors.sample_rate()))&lt;br /&gt;
Sensors.sample_rate(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: picture/graphic of the board with sensors' locations&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=358</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=358"/>
		<updated>2018-08-30T22:00:27Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The TiLDA MK4 has four sensors, three sharing an I2C bus and one with an analog output:&lt;br /&gt;
&lt;br /&gt;
* Temperature and Humidity: [http://www.ti.com/product/HDC2080 TI HDC2080]&lt;br /&gt;
* Luminance: [http://www.ti.com/product/OPT3001 TI OPT3001]&lt;br /&gt;
* Temperature: [http://www.ti.com/product/TMP102 TI TMP102] - the TMP102 has higher precision and extended temperature range with no calibration needed compared to HDC2080&lt;br /&gt;
* Magnetic: [http://www.ti.com/product/DRV5055 TI DRV5055]&lt;br /&gt;
&lt;br /&gt;
The sensors are physically located on the badge as shown in the picture below. Since these are environmental sensors, the orientation and location of the badge will affect the values returned from the sensors. For example, wearing the badge close to your body will likely raise the temperature readings.&lt;br /&gt;
 &lt;br /&gt;
[[File:Sensor graphic - with fixed transparency-01.png:400px]]&lt;br /&gt;
[[File:Sensor graphic - with fixed transparency-02.png:400px]]&lt;br /&gt;
&lt;br /&gt;
In addition, the battery charger circuit (TI BQ25601), powered via USB, has status available via the I2C bus.&lt;br /&gt;
&lt;br /&gt;
These sensors are managed by the tilda.Sensors module. This module takes care of initializing the devices and periodically updating readings from them. This makes it easier to use from applications as all the low-level interactions and data formatting are available directly via MicroPython methods. There are more features available in the devices that could be enabled. Currently this would be done by enhancing the C code in the ports/ti directory. In the future, the devices might also be directly programmable via the MicroPython I2C API.&lt;br /&gt;
&lt;br /&gt;
You can see what's provided by the Sensors module using the standard Python dir() operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the usual Python conventions, the all upper-case identifiers are symbolic constant values. The other identifiers are methods that should be semi-obviously apparent in what functions they perform.&lt;br /&gt;
&lt;br /&gt;
== Temperature and Humidity ==&lt;br /&gt;
&lt;br /&gt;
Two methods are provided for the HDC2080. get_hdc_temperature() returns the current ambient temperature in degrees Centigrade. get_hdc_humidity() returns the relative humidity as a percentage.&lt;br /&gt;
&lt;br /&gt;
get_tmp_temperature() returns the current ambient temperature in degrees Centigrade from the TMP102 sensor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;HDC temperature: {} C&amp;quot;.format(Sensors.get_hdc_temperature()))&lt;br /&gt;
print(&amp;quot;TMP temperature: {} C&amp;quot;.format(Sensors.get_tmp_temperature()))&lt;br /&gt;
print(&amp;quot;HDC humidity: {}%&amp;quot;.format(Sensors.get_hdc_humidity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Luminance ==&lt;br /&gt;
&lt;br /&gt;
The OPT3001 measures light intensity (luminance) scaled to match the way the human eye perceives light. This is useful for applications controlling lighting so that changes appear more natural to people.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    print(&amp;quot;Light intensity: {} lux&amp;quot;.format(Sensors.get_lux()))&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place your hand over the OPT3001 sensor and observe the measured intensity change.&lt;br /&gt;
&lt;br /&gt;
== Magnetic Flux - Hall Effect ==&lt;br /&gt;
&lt;br /&gt;
The DRV5055 senses magnetic fields (hooray for ElectroMAGNETIC FIELD Camp!). The device provides an analog output that is sampled by the ADC on the MCU. The particular device on the badge has a sensitivity of 12.5mV / mT. Note that the earth's magnetic field is in the range of micro Teslas (uT). Bring a small magnetic close to the sensor and watch the measurements change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from machine import ADC&lt;br /&gt;
from time import sleep_ms&lt;br /&gt;
&lt;br /&gt;
mag = ADC(ADC.ADC_HALLEFFECT)&lt;br /&gt;
while True:&lt;br /&gt;
    print(mag.convert())&lt;br /&gt;
	sleep_ms(200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Battery ==&lt;br /&gt;
&lt;br /&gt;
The BQ25601 takes care of charging the LiPo battery when the badge is attached to a USB power source - PC, car, battery. You can monitor the status by using the get_charge_status() and get_vbus_connected() methods. For example, you might want to turn off the display more often when there is no USB power so that the battery lasts longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from machine import Pin&lt;br /&gt;
&lt;br /&gt;
backlight = Pin(Pin.PWM_LCD_BLIGHT)&lt;br /&gt;
if Sensors.get_vbus_connected() != Sensors.BAT_NO_INPUT:&lt;br /&gt;
    backlight.on()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While there is power supplied via USB, you can monitor the charging status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
charging = Sensors.get_charge_status()&lt;br /&gt;
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is charging&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_DONE_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is full&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_NOT_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is discharging&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Rate ==&lt;br /&gt;
&lt;br /&gt;
You can change how often the sensors are read using the sample_rate() method. Like other Python APIs, this function is both a &amp;quot;setter&amp;quot; and a &amp;quot;getter&amp;quot;. If you call it with no argument, it returns the current sample rate in Hz. If you supply a value, the sample rate is changed. Changing the sample rate can let you see sensor values change more rapidly; conversely, a slower sample rate will update less often but use less energy, making the battery last longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Sensor sample rate: {}&amp;quot;.format(Sensors.sample_rate()))&lt;br /&gt;
Sensors.sample_rate(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: picture/graphic of the board with sensors' locations&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=357</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=357"/>
		<updated>2018-08-30T21:59:21Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The TiLDA MK4 has four sensors, three sharing an I2C bus and one with an analog output:&lt;br /&gt;
&lt;br /&gt;
* Temperature and Humidity: [http://www.ti.com/product/HDC2080 TI HDC2080]&lt;br /&gt;
* Luminance: [http://www.ti.com/product/OPT3001 TI OPT3001]&lt;br /&gt;
* Temperature: [http://www.ti.com/product/TMP102 TI TMP102] - the TMP102 has higher precision and extended temperature range with no calibration needed compared to HDC2080&lt;br /&gt;
* Magnetic: [http://www.ti.com/product/DRV5055 TI DRV5055]&lt;br /&gt;
&lt;br /&gt;
The sensors are physically located on the badge as shown in the picture below. Since these are environmental sensors, the orientation and location of the badge will affect the values returned from the sensors. For example, wearing the badge close to your body will likely raise the temperature readings.&lt;br /&gt;
 &lt;br /&gt;
[[File:Sensor graphic - with fixed transparency-01.png]]&lt;br /&gt;
[[File:Sensor graphic - with fixed transparency-02.png]]&lt;br /&gt;
&lt;br /&gt;
In addition, the battery charger circuit (TI BQ25601), powered via USB, has status available via the I2C bus.&lt;br /&gt;
&lt;br /&gt;
These sensors are managed by the tilda.Sensors module. This module takes care of initializing the devices and periodically updating readings from them. This makes it easier to use from applications as all the low-level interactions and data formatting are available directly via MicroPython methods. There are more features available in the devices that could be enabled. Currently this would be done by enhancing the C code in the ports/ti directory. In the future, the devices might also be directly programmable via the MicroPython I2C API.&lt;br /&gt;
&lt;br /&gt;
You can see what's provided by the Sensors module using the standard Python dir() operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the usual Python conventions, the all upper-case identifiers are symbolic constant values. The other identifiers are methods that should be semi-obviously apparent in what functions they perform.&lt;br /&gt;
&lt;br /&gt;
== Temperature and Humidity ==&lt;br /&gt;
&lt;br /&gt;
Two methods are provided for the HDC2080. get_hdc_temperature() returns the current ambient temperature in degrees Centigrade. get_hdc_humidity() returns the relative humidity as a percentage.&lt;br /&gt;
&lt;br /&gt;
get_tmp_temperature() returns the current ambient temperature in degrees Centigrade from the TMP102 sensor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;HDC temperature: {} C&amp;quot;.format(Sensors.get_hdc_temperature()))&lt;br /&gt;
print(&amp;quot;TMP temperature: {} C&amp;quot;.format(Sensors.get_tmp_temperature()))&lt;br /&gt;
print(&amp;quot;HDC humidity: {}%&amp;quot;.format(Sensors.get_hdc_humidity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Luminance ==&lt;br /&gt;
&lt;br /&gt;
The OPT3001 measures light intensity (luminance) scaled to match the way the human eye perceives light. This is useful for applications controlling lighting so that changes appear more natural to people.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    print(&amp;quot;Light intensity: {} lux&amp;quot;.format(Sensors.get_lux()))&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place your hand over the OPT3001 sensor and observe the measured intensity change.&lt;br /&gt;
&lt;br /&gt;
== Magnetic Flux - Hall Effect ==&lt;br /&gt;
&lt;br /&gt;
The DRV5055 senses magnetic fields (hooray for ElectroMAGNETIC FIELD Camp!). The device provides an analog output that is sampled by the ADC on the MCU. The particular device on the badge has a sensitivity of 12.5mV / mT. Note that the earth's magnetic field is in the range of micro Teslas (uT). Bring a small magnetic close to the sensor and watch the measurements change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from machine import ADC&lt;br /&gt;
from time import sleep_ms&lt;br /&gt;
&lt;br /&gt;
mag = ADC(ADC.ADC_HALLEFFECT)&lt;br /&gt;
while True:&lt;br /&gt;
    print(mag.convert())&lt;br /&gt;
	sleep_ms(200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Battery ==&lt;br /&gt;
&lt;br /&gt;
The BQ25601 takes care of charging the LiPo battery when the badge is attached to a USB power source - PC, car, battery. You can monitor the status by using the get_charge_status() and get_vbus_connected() methods. For example, you might want to turn off the display more often when there is no USB power so that the battery lasts longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from machine import Pin&lt;br /&gt;
&lt;br /&gt;
backlight = Pin(Pin.PWM_LCD_BLIGHT)&lt;br /&gt;
if Sensors.get_vbus_connected() != Sensors.BAT_NO_INPUT:&lt;br /&gt;
    backlight.on()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While there is power supplied via USB, you can monitor the charging status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
charging = Sensors.get_charge_status()&lt;br /&gt;
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is charging&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_DONE_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is full&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_NOT_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is discharging&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Rate ==&lt;br /&gt;
&lt;br /&gt;
You can change how often the sensors are read using the sample_rate() method. Like other Python APIs, this function is both a &amp;quot;setter&amp;quot; and a &amp;quot;getter&amp;quot;. If you call it with no argument, it returns the current sample rate in Hz. If you supply a value, the sample rate is changed. Changing the sample rate can let you see sensor values change more rapidly; conversely, a slower sample rate will update less often but use less energy, making the battery last longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Sensor sample rate: {}&amp;quot;.format(Sensors.sample_rate()))&lt;br /&gt;
Sensors.sample_rate(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: picture/graphic of the board with sensors' locations&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=File:Sensor_graphic_-_with_fixed_transparency-01.png&amp;diff=356</id>
		<title>File:Sensor graphic - with fixed transparency-01.png</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=File:Sensor_graphic_-_with_fixed_transparency-01.png&amp;diff=356"/>
		<updated>2018-08-30T21:55:25Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=File:Sensor_graphic_-_with_fixed_transparency-02.png&amp;diff=355</id>
		<title>File:Sensor graphic - with fixed transparency-02.png</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=File:Sensor_graphic_-_with_fixed_transparency-02.png&amp;diff=355"/>
		<updated>2018-08-30T21:55:06Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=339</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=339"/>
		<updated>2018-08-30T09:39:02Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The TiLDA MK4 has four sensors, three sharing an I2C bus and one with an analog output:&lt;br /&gt;
&lt;br /&gt;
* Temperature and Humidity: [http://www.ti.com/product/HDC2080 TI HDC2080]&lt;br /&gt;
* Luminance: [http://www.ti.com/product/OPT3001 TI OPT3001]&lt;br /&gt;
* Temperature: [http://www.ti.com/product/TMP102 TI TMP102] - the TMP102 has higher precision and extended temperature range with no calibration needed compared to HDC2080&lt;br /&gt;
* Magnetic: [http://www.ti.com/product/DRV5055 TI DRV5055]&lt;br /&gt;
&lt;br /&gt;
The sensors are physically located on the badge as shown in the picture below. Since these are environmental sensors, the orientation and location of the badge will affect the values returned from the sensors. For example, wearing the badge close to your body will likely raise the temperature readings.&lt;br /&gt;
&lt;br /&gt;
In addition, the battery charger circuit (TI BQ25601), powered via USB, has status available via the I2C bus.&lt;br /&gt;
&lt;br /&gt;
These sensors are managed by the tilda.Sensors module. This module takes care of initializing the devices and periodically updating readings from them. This makes it easier to use from applications as all the low-level interactions and data formatting are available directly via MicroPython methods. There are more features available in the devices that could be enabled. Currently this would be done by enhancing the C code in the ports/ti directory. In the future, the devices might also be directly programmable via the MicroPython I2C API.&lt;br /&gt;
&lt;br /&gt;
You can see what's provided by the Sensors module using the standard Python dir() operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the usual Python conventions, the all upper-case identifiers are symbolic constant values. The other identifiers are methods that should be semi-obviously apparent in what functions they perform.&lt;br /&gt;
&lt;br /&gt;
== Temperature and Humidity ==&lt;br /&gt;
&lt;br /&gt;
Two methods are provided for the HDC2080. get_hdc_temperature() returns the current ambient temperature in degrees Centigrade. get_hdc_humidity() returns the relative humidity as a percentage.&lt;br /&gt;
&lt;br /&gt;
get_tmp_temperature() returns the current ambient temperature in degrees Centigrade from the TMP102 sensor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;HDC temperature: {} C&amp;quot;.format(Sensors.get_hdc_temperature()))&lt;br /&gt;
print(&amp;quot;TMP temperature: {} C&amp;quot;.format(Sensors.get_tmp_temperature()))&lt;br /&gt;
print(&amp;quot;HDC humidity: {}%&amp;quot;.format(Sensors.get_hdc_humidity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Luminance ==&lt;br /&gt;
&lt;br /&gt;
The OPT3001 measures light intensity (luminance) scaled to match the way the human eye perceives light. This is useful for applications controlling lighting so that changes appear more natural to people.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    print(&amp;quot;Light intensity: {} lux&amp;quot;.format(Sensors.get_lux()))&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place your hand over the OPT3001 sensor and observe the measured intensity change.&lt;br /&gt;
&lt;br /&gt;
== Magnetic Flux - Hall Effect ==&lt;br /&gt;
&lt;br /&gt;
The DRV5055 senses magnetic fields (hooray for ElectroMAGNETIC FIELD Camp!). The device provides an analog output that is sampled by the ADC on the MCU. The particular device on the badge has a sensitivity of 12.5mV / mT. Note that the earth's magnetic field is in the range of micro Teslas (uT). Bring a small magnetic close to the sensor and watch the measurements change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from machine import ADC&lt;br /&gt;
from time import sleep_ms&lt;br /&gt;
&lt;br /&gt;
mag = ADC(ADC.ADC_HALLEFFECT)&lt;br /&gt;
while True:&lt;br /&gt;
    print(mag.convert())&lt;br /&gt;
	sleep_ms(200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Battery ==&lt;br /&gt;
&lt;br /&gt;
The BQ25601 takes care of charging the LiPo battery when the badge is attached to a USB power source - PC, car, battery. You can monitor the status by using the get_charge_status() and get_vbus_connected() methods. For example, you might want to turn off the display more often when there is no USB power so that the battery lasts longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from machine import Pin&lt;br /&gt;
&lt;br /&gt;
backlight = Pin(Pin.PWM_LCD_BLIGHT)&lt;br /&gt;
if Sensors.get_vbus_connected() != Sensors.BAT_NO_INPUT:&lt;br /&gt;
    backlight.on()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While there is power supplied via USB, you can monitor the charging status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
charging = Sensors.get_charge_status()&lt;br /&gt;
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is charging&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_DONE_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is full&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_NOT_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is discharging&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Rate ==&lt;br /&gt;
&lt;br /&gt;
You can change how often the sensors are read using the sample_rate() method. Like other Python APIs, this function is both a &amp;quot;setter&amp;quot; and a &amp;quot;getter&amp;quot;. If you call it with no argument, it returns the current sample rate in Hz. If you supply a value, the sample rate is changed. Changing the sample rate can let you see sensor values change more rapidly; conversely, a slower sample rate will update less often but use less energy, making the battery last longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Sensor sample rate: {}&amp;quot;.format(Sensors.sample_rate()))&lt;br /&gt;
Sensors.sample_rate(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: picture/graphic of the board with sensors' locations&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=338</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=338"/>
		<updated>2018-08-30T08:52:40Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The TiLDA MK4 has four sensors, three sharing an I2C bus and one with an analog output:&lt;br /&gt;
&lt;br /&gt;
* Temperature and Humidity: TI HDC2080&lt;br /&gt;
* Luminance: TI OPT3001&lt;br /&gt;
* Temperature: [TI TMP102](http://www.ti.com/product/TMP102)&lt;br /&gt;
* Magnetic: TI DRV5055&lt;br /&gt;
&lt;br /&gt;
The sensors are physically located on the badge as shown in the picture below. Since these are environmental sensors, the orientation and location of the badge will affect the values returned from the sensors. For example, wearing the badge close to your body will likely raise the temperature readings.&lt;br /&gt;
&lt;br /&gt;
In addition, the battery charger circuit (TI BQ25601), powered via USB, has status available via the I2C bus.&lt;br /&gt;
&lt;br /&gt;
These sensors are managed by the tilda.Sensors module. This module takes care of initializing the devices and periodically updating readings from them. This makes it easier to use from applications as all the low-level interactions and data formatting are available directly via MicroPython methods. There are more features available in the devices that could be enabled. Currently this would be done by enhancing the C code in the ports/ti directory. In the future, the devices might also be directly programmable via the MicroPython I2C API.&lt;br /&gt;
&lt;br /&gt;
You can see what's provided by the Sensors module using the standard Python dir() operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the usual Python conventions, the all upper-case identifiers are symbolic constant values. The other identifiers are methods that should be semi-obviously apparent in what functions they perform.&lt;br /&gt;
&lt;br /&gt;
== Temperature and Humidity ==&lt;br /&gt;
&lt;br /&gt;
Two methods are provided for the HDC2080. get_hdc_temperature() returns the current ambient temperature in degrees Centigrade. get_hdc_humidity() returns the relative humidity as a percentage.&lt;br /&gt;
&lt;br /&gt;
get_tmp_temperature() returns the current ambient temperature in degrees Centigrade from the TMP102 sensor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;HDC temperature: {} C&amp;quot;.format(Sensors.get_hdc_temperature()))&lt;br /&gt;
print(&amp;quot;TMP temperature: {} C&amp;quot;.format(Sensors.get_tmp_temperature()))&lt;br /&gt;
print(&amp;quot;HDC humidity: {}%&amp;quot;.format(Sensors.get_hdc_humidity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Luminance ==&lt;br /&gt;
&lt;br /&gt;
The OPT3001 measures light intensity (luminance) scaled to match the way the human eye perceives light. This is useful for applications controlling lighting so that changes appear more natural to people.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    print(&amp;quot;Light intensity: {} lux&amp;quot;.format(Sensors.get_lux()))&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place your hand over the OPT3001 sensor and observe the measured intensity change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Magnetic - Hall Effect ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The DRV5055 senses magnetic fields (hooray for ElectroMAGNETIC FIELD Camp!). The device provides an analog output that is sampled by the ADC on the MCU. Bring a small magnetic close to the sensor and watch the measurements change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from machine import ADC&lt;br /&gt;
from time import sleep_ms&lt;br /&gt;
&lt;br /&gt;
mag = ADC(ADC.ADC_HALLEFFECT)&lt;br /&gt;
while True:&lt;br /&gt;
    print(mag.convert())&lt;br /&gt;
	sleep_ms(200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Battery ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The BQ25601 takes care of charging the LiPo battery when the badge is attached to a USB power source - PC, car, battery. You can monitor the status by using the get_charge_status() and get_vbus_connected() methods. For example, you might want to turn off the display more often when there is no USB power so that the battery lasts longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from machine import Pin&lt;br /&gt;
&lt;br /&gt;
backlight = Pin(Pin.PWM_LCD_BLIGHT)&lt;br /&gt;
if Sensors.get_vbus_connected() != Sensors.BAT_NO_INPUT:&lt;br /&gt;
    backlight.on()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While there is power supplied via USB, you can monitor the charging status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
charging = Sensors.get_charge_status()&lt;br /&gt;
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is charging&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_DONE_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is full&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_NOT_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is discharging&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sample Rate ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can change how often the sensors are read using the sample_rate() method. Like other Python APIs, this function is both a &amp;quot;setter&amp;quot; and a &amp;quot;getter&amp;quot;. If you call it with no argument, it returns the current sample rate in Hz. If you supply a value, the sample rate is changed. Changing the sample rate can let you see sensor values change more rapidly; conversely, a slower sample rate will update less often but use less energy, making the battery last longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Sensor sample rate: {}&amp;quot;.format(Sensors.sample_rate()))&lt;br /&gt;
Sensors.sample_rate(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: picture/graphic of the board with sensors' locations&lt;br /&gt;
&lt;br /&gt;
TODO: what's the difference in temperature sensing between HDC2080 and TMP102?&lt;br /&gt;
&lt;br /&gt;
TODO: links to sensors' info&lt;br /&gt;
&lt;br /&gt;
TODO: link to human light perception&lt;br /&gt;
&lt;br /&gt;
TODO: magnetic units and scale and sensitivity?&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=337</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=337"/>
		<updated>2018-08-30T08:45:07Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OVerview ==&lt;br /&gt;
&lt;br /&gt;
The TiLDA MK4 has four sensors, three sharing an I2C bus and one with an analog output:&lt;br /&gt;
&lt;br /&gt;
* Temperature and Humidity: TI HDC2080&lt;br /&gt;
* Luminance: TI OPT3001&lt;br /&gt;
* Temperature: TI TMP102&lt;br /&gt;
* Magnetic: TI DRV5055&lt;br /&gt;
&lt;br /&gt;
The sensors are physically located on the badge as shown in the picture below. Since these are environmental sensors, the orientation and location of the badge will affect the values returned from the sensors. For example, wearing the badge close to your body will likely raise the temperature readings.&lt;br /&gt;
&lt;br /&gt;
In addition, the battery charger circuit (TI BQ25601), powered via USB, has status available via the I2C bus.&lt;br /&gt;
&lt;br /&gt;
These sensors are managed by the tilda.Sensors module. This module takes care of initializing the devices and periodically updating readings from them. This makes it easier to use from applications as all the low-level interactions and data formatting are available directly via MicroPython methods. There are more features available in the devices that could be enabled. Currently this would be done by enhancing the C code in the ports/ti directory. In the future, the devices might also be directly programmable via the MicroPython I2C API.&lt;br /&gt;
&lt;br /&gt;
You can see what's provided by the Sensors module using the standard Python dir() operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the usual Python conventions, the all upper-case identifiers are symbolic constant values. The other identifiers are methods that should be semi-obviously apparent in what functions they perform.&lt;br /&gt;
&lt;br /&gt;
== Temperature and Humidity ==&lt;br /&gt;
&lt;br /&gt;
Two methods are provided for the HDC2080. get_hdc_temperature() returns the current ambient temperature in degrees Centigrade. get_hdc_humidity() returns the relative humidity as a percentage.&lt;br /&gt;
&lt;br /&gt;
get_tmp_temperature() returns the current ambient temperature in degrees Centigrade from the TMP102 sensor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;HDC temperature: {} C&amp;quot;.format(Sensors.get_hdc_temperature()))&lt;br /&gt;
print(&amp;quot;TMP temperature: {} C&amp;quot;.format(Sensors.get_tmp_temperature()))&lt;br /&gt;
print(&amp;quot;HDC humidity: {}%&amp;quot;.format(Sensors.get_hdc_humidity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Luminance ==&lt;br /&gt;
&lt;br /&gt;
The OPT3001 measures light intensity (luminance) scaled to match the way the human eye perceives light. This is useful for applications controlling lighting so that changes appear more natural to people.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    print(&amp;quot;Light intensity: {} lux&amp;quot;.format(Sensors.get_lux()))&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place your hand over the OPT3001 sensor and observe the measured intensity change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Magnetic - Hall Effect ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The DRV5055 senses magnetic fields (hooray for ElectroMAGNETIC FIELD Camp!). The device provides an analog output that is sampled by the ADC on the MCU. Bring a small magnetic close to the sensor and watch the measurements change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from machine import ADC&lt;br /&gt;
from time import sleep_ms&lt;br /&gt;
&lt;br /&gt;
mag = ADC(ADC.ADC_HALLEFFECT)&lt;br /&gt;
while True:&lt;br /&gt;
    print(mag.convert())&lt;br /&gt;
	sleep_ms(200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Battery ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The BQ25601 takes care of charging the LiPo battery when the badge is attached to a USB power source - PC, car, battery. You can monitor the status by using the get_charge_status() and get_vbus_connected() methods. For example, you might want to turn off the display more often when there is no USB power so that the battery lasts longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from machine import Pin&lt;br /&gt;
&lt;br /&gt;
backlight = Pin(Pin.PWM_LCD_BLIGHT)&lt;br /&gt;
if Sensors.get_vbus_connected() != Sensors.BAT_NO_INPUT:&lt;br /&gt;
    backlight.on()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While there is power supplied via USB, you can monitor the charging status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
charging = Sensors.get_charge_status()&lt;br /&gt;
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is charging&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_DONE_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is full&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_NOT_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is discharging&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sample Rate ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can change how often the sensors are read using the sample_rate() method. Like other Python APIs, this function is both a &amp;quot;setter&amp;quot; and a &amp;quot;getter&amp;quot;. If you call it with no argument, it returns the current sample rate in Hz. If you supply a value, the sample rate is changed. Changing the sample rate can let you see sensor values change more rapidly; conversely, a slower sample rate will update less often but use less energy, making the battery last longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Sensor sample rate: {}&amp;quot;.format(Sensors.sample_rate()))&lt;br /&gt;
Sensors.sample_rate(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: picture/graphic of the board with sensors' locations&lt;br /&gt;
&lt;br /&gt;
TODO: what's the difference in temperature sensing between HDC2080 and TMP102?&lt;br /&gt;
&lt;br /&gt;
TODO: links to sensors' info&lt;br /&gt;
&lt;br /&gt;
TODO: link to human light perception&lt;br /&gt;
&lt;br /&gt;
TODO: magnetic units and scale and sensitivity?&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=336</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=336"/>
		<updated>2018-08-30T08:44:25Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The TiLDA MK4 has four sensors, three sharing an I2C bus and one with an analog output:&lt;br /&gt;
&lt;br /&gt;
* Temperature and Humidity: TI HDC2080&lt;br /&gt;
* Luminance: TI OPT3001&lt;br /&gt;
* Temperature: TI TMP102&lt;br /&gt;
* Magnetic: TI DRV5055&lt;br /&gt;
&lt;br /&gt;
The sensors are physically located on the badge as shown in the picture below. Since these are environmental sensors, the orientation and location of the badge will affect the values returned from the sensors. For example, wearing the badge close to your body will likely raise the temperature readings.&lt;br /&gt;
&lt;br /&gt;
In addition, the battery charger circuit (TI BQ25601), powered via USB, has status available via the I2C bus.&lt;br /&gt;
&lt;br /&gt;
These sensors are managed by the tilda.Sensors module. This module takes care of initializing the devices and periodically updating readings from them. This makes it easier to use from applications as all the low-level interactions and data formatting are available directly via MicroPython methods. There are more features available in the devices that could be enabled. Currently this would be done by enhancing the C code in the ports/ti directory. In the future, the devices might also be directly programmable via the MicroPython I2C API.&lt;br /&gt;
&lt;br /&gt;
You can see what's provided by the Sensors module using the standard Python dir() operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the usual Python conventions, the all upper-case identifiers are symbolic constant values. The other identifiers are methods that should be semi-obviously apparent in what functions they perform.&lt;br /&gt;
&lt;br /&gt;
== Temperature and Humidity ==&lt;br /&gt;
&lt;br /&gt;
Two methods are provided for the HDC2080. get_hdc_temperature() returns the current ambient temperature in degrees Centigrade. get_hdc_humidity() returns the relative humidity as a percentage.&lt;br /&gt;
&lt;br /&gt;
get_tmp_temperature() returns the current ambient temperature in degrees Centigrade from the TMP102 sensor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;HDC temperature: {} C&amp;quot;.format(Sensors.get_hdc_temperature()))&lt;br /&gt;
print(&amp;quot;TMP temperature: {} C&amp;quot;.format(Sensors.get_tmp_temperature()))&lt;br /&gt;
print(&amp;quot;HDC humidity: {}%&amp;quot;.format(Sensors.get_hdc_humidity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Luminance ==&lt;br /&gt;
&lt;br /&gt;
The OPT3001 measures light intensity (luminance) scaled to match the way the human eye perceives light. This is useful for applications controlling lighting so that changes appear more natural to people.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    print(&amp;quot;Light intensity: {} lux&amp;quot;.format(Sensors.get_lux()))&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place your hand over the OPT3001 sensor and observe the measured intensity change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Magnetic - Hall Effect ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The DRV5055 senses magnetic fields (hooray for ElectroMAGNETIC FIELD Camp!). The device provides an analog output that is sampled by the ADC on the MCU. Bring a small magnetic close to the sensor and watch the measurements change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from machine import ADC&lt;br /&gt;
from time import sleep_ms&lt;br /&gt;
&lt;br /&gt;
mag = ADC(ADC.ADC_HALLEFFECT)&lt;br /&gt;
while True:&lt;br /&gt;
    print(mag.convert())&lt;br /&gt;
	sleep_ms(200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Battery ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The BQ25601 takes care of charging the LiPo battery when the badge is attached to a USB power source - PC, car, battery. You can monitor the status by using the get_charge_status() and get_vbus_connected() methods. For example, you might want to turn off the display more often when there is no USB power so that the battery lasts longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from machine import Pin&lt;br /&gt;
&lt;br /&gt;
backlight = Pin(Pin.PWM_LCD_BLIGHT)&lt;br /&gt;
if Sensors.get_vbus_connected() != Sensors.BAT_NO_INPUT:&lt;br /&gt;
    backlight.on()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While there is power supplied via USB, you can monitor the charging status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
charging = Sensors.get_charge_status()&lt;br /&gt;
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is charging&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_DONE_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is full&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_NOT_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is discharging&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sample Rate ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can change how often the sensors are read using the sample_rate() method. Like other Python APIs, this function is both a &amp;quot;setter&amp;quot; and a &amp;quot;getter&amp;quot;. If you call it with no argument, it returns the current sample rate in Hz. If you supply a value, the sample rate is changed. Changing the sample rate can let you see sensor values change more rapidly; conversely, a slower sample rate will update less often but use less energy, making the battery last longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Sensor sample rate: {}&amp;quot;.format(Sensors.sample_rate()))&lt;br /&gt;
Sensors.sample_rate(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: picture/graphic of the board with sensors' locations&lt;br /&gt;
&lt;br /&gt;
TODO: what's the difference in temperature sensing between HDC2080 and TMP102?&lt;br /&gt;
&lt;br /&gt;
TODO: links to sensors' info&lt;br /&gt;
&lt;br /&gt;
TODO: link to human light perception&lt;br /&gt;
&lt;br /&gt;
TODO: magnetic units and scale and sensitivity?&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=335</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=335"/>
		<updated>2018-08-30T08:37:30Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;TODO: picture/graphic of the board with sensors' locations&lt;br /&gt;
TODO: what's the difference in temperature sensing between HDC2080 and TMP102?&lt;br /&gt;
TODO: links to sensors' info&lt;br /&gt;
TODO: link to human light perception&lt;br /&gt;
TODO: magnetic units and scale and sensitivity?&lt;br /&gt;
&lt;br /&gt;
The TiLDA MK4 has four sensors, three sharing an I2C bus and one with an analog output:&lt;br /&gt;
&lt;br /&gt;
* Temperature and Humidity: TI HDC2080&lt;br /&gt;
* Luminance: TI OPT3001&lt;br /&gt;
* Temperature: TI TMP102&lt;br /&gt;
* Magnetic: TI DRV5055&lt;br /&gt;
&lt;br /&gt;
The sensors are physically located on the badge as shown in the picture below. Since these are environmental sensors, the orientation and location of the badge will affect the values returned from the sensors. For example, wearing the badge close to your body will likely raise the temperature readings.&lt;br /&gt;
&lt;br /&gt;
In addition, the battery charger circuit (TI BQ25601), powered via USB, has status available via the I2C bus.&lt;br /&gt;
&lt;br /&gt;
These sensors are managed by the tilda.Sensors module. This module takes care of initializing the devices and periodically updating readings from them. This makes it easier to use from applications as all the low-level interactions and data formatting are available directly via MicroPython methods. There are more features available in the devices that could be enabled. Currently this would be done by enhancing the C code in the ports/ti directory. In the future, the devices might also be directly programmable via the MicroPython I2C API.&lt;br /&gt;
&lt;br /&gt;
You can see what's provided by the Sensors module using the standard Python dir() operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per the usual Python conventions, the all upper-case identifiers are symbolic constant values. The other identifiers are methods that should be semi-obviously apparent in what functions they perform.&lt;br /&gt;
&lt;br /&gt;
Temperature and Humidity&lt;br /&gt;
&lt;br /&gt;
Two methods are provided for the HDC2080. get_hdc_temperature() returns the current ambient temperature in degrees Centigrade. get_hdc_humidity() returns the relative humidity as a percentage.&lt;br /&gt;
&lt;br /&gt;
get_tmp_temperature() returns the current ambient temperature in degrees Centigrade from the TMP102 sensor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;HDC temperature: {} C&amp;quot;.format(Sensors.get_hdc_temperature()))&lt;br /&gt;
print(&amp;quot;TMP temperature: {} C&amp;quot;.format(Sensors.get_tmp_temperature()))&lt;br /&gt;
print(&amp;quot;HDC humidity: {}%&amp;quot;.format(Sensors.get_hdc_humidity()))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Luminance&lt;br /&gt;
&lt;br /&gt;
The OPT3001 measures light intensity (luminance) scaled to match the way the human eye perceives light. This is useful for applications controlling lighting so that changes appear more natural to people.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    print(&amp;quot;Light intensity: {} lux&amp;quot;.format(Sensors.get_lux()))&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Place your hand over the OPT3001 sensor and observe the measured intensity change.&lt;br /&gt;
&lt;br /&gt;
Magnetic - Hall Effect&lt;br /&gt;
&lt;br /&gt;
The DRV5055 senses magnetic fields (hooray for ElectroMAGNETIC FIELD Camp!). The device provides an analog output that is sampled by the ADC on the MCU. Bring a small magnetic close to the sensor and watch the measurements change.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from machine import ADC&lt;br /&gt;
from time import sleep_ms&lt;br /&gt;
&lt;br /&gt;
mag = ADC(ADC.ADC_HALLEFFECT)&lt;br /&gt;
while True:&lt;br /&gt;
    print(mag.convert())&lt;br /&gt;
	sleep_ms(200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Battery&lt;br /&gt;
&lt;br /&gt;
The BQ25601 takes care of charging the LiPo battery when the badge is attached to a USB power source - PC, car, battery. You can monitor the status by using the get_charge_status() and get_vbus_connected() methods. For example, you might want to turn off the display more often when there is no USB power so that the battery lasts longer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
from machine import Pin&lt;br /&gt;
&lt;br /&gt;
backlight = Pin(Pin.PWM_LCD_BLIGHT)&lt;br /&gt;
if Sensors.get_vbus_connected() != Sensors.BAT_NO_INPUT:&lt;br /&gt;
    backlight.on()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While there is power supplied via USB, you can monitor the charging status:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
charging = Sensors.get_charge_status()&lt;br /&gt;
if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is charging&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_DONE_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is full&amp;quot;)&lt;br /&gt;
elif charging == Sensors.BAT_NOT_CHARGING:&lt;br /&gt;
    print(&amp;quot;Battery is discharging&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample Rate&lt;br /&gt;
&lt;br /&gt;
You can change how often the sensors are read using the sample_rate() method. Like other Python APIs, this function is both a &amp;quot;setter&amp;quot; and a &amp;quot;getter&amp;quot;. If you call it with no argument, it returns the current sample rate in Hz. If you supply a value, the sample rate is changed. Changing the sample rate&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from tilda import Sensors&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;Sensor sample rate: {}&amp;quot;.format(Sensors.sample_rate()))&lt;br /&gt;
Sensors.sample_rate(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=327</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=327"/>
		<updated>2018-08-29T18:03:43Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Coming soon ... how to read the sensors supported in the tilda.Sensors module&lt;br /&gt;
&lt;br /&gt;
Let's get started.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; from tilda import Sensors&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; dir(Sensors)&lt;br /&gt;
['__class__', '__name__', 'BAT_ADAPTER_24', 'BAT_DONE_CHARGING', 'BAT_FAST_CHARGING', 'BAT_NOT_CHARGING', 'BAT_NO_INPUT', 'BAT_OTG', 'BAT_PRE_CHARGING', 'BAT_USB_HOST', '_raw_bq', 'get_charge_status', 'get_hdc_humidity', 'get_hdc_temperature', 'get_lux', 'get_tmp_temperature', 'get_vbus_connected', 'sample_rate']&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Sensors.get_charge_status()&lt;br /&gt;
0&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Sensors.get_charge_status()&lt;br /&gt;
2&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Sensors.BAT_FAST_CHARGING&lt;br /&gt;
2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
	<entry>
		<id>https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=326</id>
		<title>TiLDA MK4/sensors</title>
		<link rel="alternate" type="text/html" href="https://badge.emfcamp.org/w/index.php?title=TiLDA_MK4/sensors&amp;diff=326"/>
		<updated>2018-08-29T17:56:12Z</updated>

		<summary type="html">&lt;p&gt;Mgsb: Created page with &amp;quot;Coming soon ... how to read the sensors supported in the tilda.Sensors module&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Coming soon ... how to read the sensors supported in the tilda.Sensors module&lt;/div&gt;</summary>
		<author><name>Mgsb</name></author>
	</entry>
</feed>