Skip to content

Instantly share code, notes, and snippets.

@gautric
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gautric/edba044d912d53e4bf31 to your computer and use it in GitHub Desktop.
Save gautric/edba044d912d53e4bf31 to your computer and use it in GitHub Desktop.
package com.github.camellabs.component.pi4j;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A simple application to run RaspberryPi Camel
*/
public final class Accel2MQTT {
private static final Logger LOG = LoggerFactory.getLogger(Accel2MQTT.class);
public static void main(String[] args) throws Exception {
LOG.info("main");
String host = "tcp://remotemqtt:1883"; // Change It
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("pi4j-i2c://1/0x19?driver=lsm303-accel&delay=500")
.wireTap("pi4j-gpio://12?mode=DIGITAL_OUTPUT&state=LOW&action=BLINK")
.to(Pi4jConstants.LOG_COMPONENT)
.to("mqtt://pi4j?publishTopicName=i2c/accel&host=" + host);
}
});
context.start();
Thread.sleep(60000);
context.stop();
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment