Introduction: Openremote Arduino Sensors Servo RGB Led and Switch

This is How to use Openremote Software to Control a RGB led with sliders for each color , use a switch to turn a led on or off , move a servo with a slider , and read a temperature sensor. All item provide feedback to show position and color.

Items needed

1. Openremote software controller setup and working

can be found here if you have not already

2. Arduino , can be pretty much any of them I use a UNO for this

3. RGB LED , can use 3 separate

4. regular LED any color

5. a servo , most any will work

6. DS18B20 temp sensor

7. 4 X 220ohm resistor 1 X 4.7k

Step 1: Build the Arduino Circuit

assemble the arduino circuit per the picture. Load the provided Sketch remember to set your ip address to one available on your network. Once this has been done you can test the setup without the openremote software by using a web browser , Chrome or firefox work better as they don't try to download the file . just put in or what your ip is you used and you should get something like this

{"A1": 373,"A0": 371,"S0": 91,"RED": 0,"GREEN": 255,"BLUE": 54,"D7": 0,"TEMP": 77.90,}

its a JSON file it shows the value of 2 analog inputs , the servo position , the color rage for the 3 LED's from 0 - 255 , the status of switch 1 on pin 7 and the temp. To change one of the values in the web browser enter this will change the site to

{"A1": 364,"A0": 363,"S0": 91,"RED": 200,"GREEN": 255,"BLUE": 54,"D7": 0,"TEMP": 77.90,}

and the red led will go to almost full brightness. To turn switch 1 on (digital pin7) use for on or for off

{"A1": 369,"A0": 368,"S0": 91,"RED": 200,"GREEN": 255,"BLUE": 54,"D7": 1,"TEMP": 77.90,}

notice the "D7" changed to a 1 and the LED should have come on. if you want to change all 3 colors at once you can use this,255,255,255 this will set all 3 colors R,G,B in that order to 255 full Brightness.

{"A1": 365,"A0": 364,"S0": 91,"RED": 255,"GREEN": 255,"BLUE": 255,"D7": 1,"TEMP": 77.90,}

here is a copy of the arduino IDE sketch


* Respond to requests in the URL to change digital and analog output ports
* show the number of ports changed and the value of the analog input pins.
* for example:
* sending turns digital pin 2 on
* sending turns digital pin 2 off
* sending turns red color to 150
* sending turns green color to 100
* sending,255,255,255 turns all colors up to white on one line
* sending turns blue color to 200 0 to 255 max val
* sending moves servo to 90 deg mark
* sending {"A1": 369,"A0": 368,"S0": 11,"RED": 0,"GREEN": 255,"BLUE": 54,"D7": 1,"TEMP": 78.35,}

#include //only for ds18b20 temp
#include //only for ds18b20 temp
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress Sensor1 = {0x28, 0xAC, 0xD2, 0x6E, 0x04, 0x00, 0x00, 0xF9 }; // diffrent for every device ! use sketch to find
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xF0 };
IPAddress ip(192,168,2, 157);
IPAddress myDns(192,168,2,254);
IPAddress gateway(192, 168, 2, 254);
EthernetServer server(80);
int brightnessR = 0; //need only for rgb
int brightnessG = 0; //need only for rgb
int brightnessB = 0; //need only for rgb
int pos = 0; //need only for servo
int timer = 0;
Servo myservo; //need only for servo
void setup()
sensors.setResolution(Sensor1, 10); //for temp
sensors.setWaitForConversion(false); //for temp
sensors.requestTemperatures(); // for temp
myservo.attach(9); //need only for servo which pin servo is attached
Ethernet.begin(mac, ip);
void loop()
// this timer keeps the temp sensor from running to much and slowing down sketch
timer = (timer +1 );
if (timer == 1000){
sensors.requestTemperatures(); // for temp
timer = 0;

EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
// counters to show the number of pin change requests
int digitalRequests = 0;
int analogRequests = 0;
if( client.find("GET /") ) { // search for 'GET'
// find tokens starting with "pin" and stop on the first blank line
// search to the end of line for 'pin'
while(client.findUntil("pin", "\n\r")){
char type =; // D or A

// the next ascii integer value in the stream is the pin
int pin = client.parseInt();
int val = client.parseInt(); // the integer after that is the value
int valg = client.parseInt();
int valb = client.parseInt();

if( type == 'D') {
Serial.print("Digital pin ");
pinMode(pin, OUTPUT);
digitalWrite(pin, val);

if( type == 'S') {
Serial.print("Servo input");
pos = val;


if( type == 'C') {

analogWrite(3, val);
analogWrite(5, valg);
analogWrite(6, valb);

brightnessR = val ;

brightnessG = valg ;

brightnessB = valb ;

if( type == 'P') {

pinMode(pin, OUTPUT);
analogWrite(pin, val);
if (pin == 3 ) {
brightnessR = val ;
if (pin == 5 ) {
brightnessG = val ;

if (pin == 6 ) {
brightnessB = val ;

else if( type == 'A'){
Serial.print("Analog pin ");
analogWrite(pin, val);

// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: application/json");

// output the value of each analog input pin as a json-p object



client.print("\": ");


client.print("\": ");


client.print("\": ");


client.print("\": ");


client.print("\": ");



client.print("\": ");



client.print("\": ");
int sw1 = digitalRead(7);
if (sw1 == HIGH){
if (sw1 == LOW){


client.print("\": ");
float tempC1 = sensors.getTempC(Sensor1);



// give the web browser time to receive the data

Step 2: Connect With OpenRemote

I am assuming you already have openremote installed and are a little familure with its operation. Open remote designer login , go to device and click on new give it a name like Arduino , model UNO, vendor , whatever. Then create a new command

Name: get arduino temp

Protocol: HTTP


Method GET

polling interval 10s

JSONPath Expression $.TEMP

and submit

now create a new sensor

Name: get arduino temp

Command: get arduino temp

Type: custom

then Submit.

go to designer layout drag a Label onto the grid and select sensor and choose Device Arduino and select get arduino temp

this should provide you with a temp reading


Step 3: Add Sliders to Openremote

Now we can add some sliders to the Layout

lets do the red ,,, it will be the same for red blue and green the only change is in the JSON value

choose new command

Name: get brightness red

Protocol: HTTP


Method: GET

Polling: 1s

JSONPath Expression $.RED

And now Submit and continue and just change the RED to BLUE, and GREEN

Now , create the command to set the value again change the RED BLUE and GREEN ,,, Also ! in the URL pinP3 for RED pinP5 for GREEN and pinP6 for BLUE

Name: set brightness RED

Protocol: HTTP


Method: GET

submit and continue to do the other 2

Now create a new sensor .

Name: get RED

Command: get brightness RED

Type: range

Min: 0

Max: 255

do this for the other colors also

now create the sliders

new slider

name: RED

sensor: get RED

setValue: set brightness RED

and submit

now add them to your layout

drag a slider onto the grid select the SliderCommand RED and do the same for the other 2

Step 4: Add a Servo

now we can add a servo , this can be omitted if you don't need it , will not hurt script to not be added

create a command

Name: Servo pos

Protocol: HTTP


Method: GET

Polling: 2s

JSONPath: $.S0

now submit and continue

Name: servo set

Protocol: HTTP


and submit

now create a sensor

Name: servo pos

Command: servo pos

Type: range

Min: 10

Max: 180

and submit

now create a slider


sensor: servo pos

setValue: servo set

and add to the layout same as the rgb sliders

Step 5: