Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In the following I will show you how to process sensor data from an Arduino device with the Odysseus data stream management system.

Arduino as a sensor platform

The sensor we use in this Hand-on is a DHT11. The DHT11 is a low cost sensor capable to measure the temperature and the humidity of it’s surrounding. The DHT11 has actually four pins but uses only three pins: VCC, GND, and Data. We connect the power pins of the sensor to VCC and GND and connect the Data to pin 7 of the Arduino device.

...

Code Block
languagejs
match = SASE({schema=[['temperature','Double']], 
type='Result', 
query='PATTERN SEQ(Arduino+ a[]) WHERE skip_till_any_match(a[]){ 
  a[1].temperature >= 0.8 * a[a.LEN].temperature 
 } WITHIN 60 seconds RETURN a[a.LEN].temperature' 
}, Arduino)

...

Code Block
languagejs
out = SENDER({ TRANSPORTSINK = 'SMTPMail', DATAHANDLER
TRANSPORT = 'TupleSMTP', SINK
DATAHANDLER = 'MailTuple',  
WRAPPER = 'GenericPush', 
PROTOCOL = 'CSV', 
OPTIONS = [ 
 ['from','odysseus@example.com'], 
 ['to','me@example.com'], 
 ['subject','Open window'], 
 ['host','smtp.example.com'], 
 ['tls','true'], 
 ['username','Alice'], 
 ['password','***'] 
] }, match)

 

The configuration of the operator is similar to the access operator used to receive the data from the Arduino device. We use the generic push wrapper, the tuple data handler, and the CSV protocol handler to transform the result back into a comma-separated value. However, now we use the SMTP transport handler to forward the processing results as an email consisting of a comma separated line with the processing result. To do so, we further have to setup some options for the SMTP transport handler including the sender email address, the receiver email address and the SMTP hostname including authentication data. Other protocol handler are also available here.

...