-
Notifications
You must be signed in to change notification settings - Fork 15
Using Analogread
With Analogread you can measure the voltage on one of the port A pins on the Hexabus-Socket. (e.g. for reading out potentiometers, light sensors or similar devices)
Simply connect the output of your device to one of the pins on port A. Mind that the output voltage should be at most the supply voltage of the Atmega.
Set ANALOGREAD_ENABLE in firmware/contiki-2.x/platform/Hexabus-Socket/hexabus_config.h to 1.
Set ANALOGREAD_PIN to the pin you connect your device.
Set ANALOGREAD_MULT to a multiplicator you want to apply to the measured value. The ADC measures a value between 0 and 1023, where 0 is 0V and 1023 is the supply voltage. Which means if you want to have the value in volts and your supply voltage is 2.5V, set the multiplicator to 2.5/1024 = 0024414062.
The value can now be accessed directly via EID 22 or broadcast periodically using the auto broadcast feature of value_broadcast.