Posts

Showing posts from June, 2015

Dart on Pi - Tracking Changes

Tracking Raspberry Pi GPIO values One application of the RPi is to track sensor changes over time. For example, a RPi could have various sensors for detecting water in places on the floor. The Dart program running on the RPi could detect the sensor change and send an email (see mailer pub package for sending email using Dart) reporting the problem. We can read the GPIO pin values as discussed in the previous post, but how to track them over time? Two possibilities include:
Polling Interrupts
Polling
Using the rpi_gpio pub package mentioned in the previous post, one approach for detecting a sensor change is to periodically check the value and compare it with the previous value. If the value has changed since the last time it was read, then we can react to that change. To start, create a sensor class for tracking the value of a GPIO pin. Periodically call the sensor's hasChanged method to determine if the pin has changed state.
class Sensor {  final Pin pin;  int value;
 Sensor(this.pin) …