Arduino Analog Sensor Protocol

Each analog sensor device can measure a single analog pin.
You can install multiple devices on a microcontroller.

How to build a test circuit with an Analog Sensor and an Arduino Mega?
Arduino codes are included.

I. 'Welcome' event from microcontroller

Example

c=welcome&id=knRJ67&type=OzAnalogSensor&pos=1&name=MyAnalogSensor&t=3

Parameters

Parameter Type Range Functionality
c String 'welcome' Identifies the welcome message.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
type String 'OzAnalogSensor' Determines the type of the device.
pos Byte 0-255 Determines the position of the device on the list of the ID manager of the microcontroller. Please make sure there are no other devices in the same position.
name String e.g. 'MyAnalogSensor' This is how the device will appear in Ozeki 10.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.



II. Commands to microcontroller

'getvalue' command

You can request the pin value of the device.

Example

c=getvalue&id=knRJ67&t=0

Parameters

Parameter Type Range Functionality
c String 'getvalue' Identifies the command.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of commands sent. Counts from 0 to 255 then from 0 again.

Response

Responds the current value of the pin connected to the Oz Analog Sensor Device.

Example

c=getvalue_resp&value=62&id=knRJ67&t=3

Parameters

Parameter Type Range Functionality
c String 'getvalue_resp' Identifies the response
value Double 0.00-1023.00 The digital value of the measured pin.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.



'repchange' command

Sets threshold compared to the last measured value, so a 'change' event is sent everytime it passes the threshold in one of the directions. If it is set to 0 it is turned off.

Example

c=repchange&value=5.00&id=knRJ67&t=1

Parameters

Parameter Type Range Functionality
c String 'repchange' Identifies the command.
value Double 0.00-1023.00
(The range of the ADC.)
Sets measurement threshold value compared to the last measured value. If it is set to 0 than the 'change' event is turned off.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of commands sent. Counts from 0 to 255 then from 0 again.

Response

Responds if the threshold value has been set.

Example

c=repchange_resp&value=5.00&id=knRJ67&t=4

Parameters

Parameter Type Range Functionality
c String 'repchange_resp' Identifies the response.
value Double 0.00-1023.00 The measurement threshold value to trigger a 'change' event has been set. If it is set to 0 than the 'change' event is turned off.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.



'repabove' command

Triggers an 'above' event everytime the digital pin value passes the value you set with this command.

Example

c=repabove&value=655.00&id=knRJ67&t=2

Parameters

Parameter Type Range Functionality
c String 'repabove' Identifies the command.
value Double 0.00-1023.00
(The range of the ADC.)
If the measured value of the pin crosses this value than an 'above' event is triggered.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of commands sent. Counts from 0 to 255 then from 0 again.

Response

Responds if the above value has been set.

Example

c=repabove_resp&value=655.00&id=knRJ67&t=5

Parameters

Parameter Type Range Functionality
c String 'repabove_resp' Identifies the response.
value Double 0.00-1023.00 If the measured value of the pin crosses this value than an 'above' event is triggered.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.



'repbelow' command

Triggers a 'below' event everytime the digital pin value passes the value you set with this command.

Example

c=repbelow&value=133.00&id=knRJ67&t=3

Parameters

Parameter Type Range Functionality
c String 'repbelow' Identifies the command.
value Double 0.00-1023.00
(The range of the ADC.)
If the measured value of the pin crosses this value than a 'below' event is triggered.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of commands sent. Counts from 0 to 255 then from 0 again.

Response

Responds if the below value has been set.

Example

c=repbelow_resp&value=133.00&id=knRJ67&t=6

Parameters

Parameter Type Range Functionality
c String 'repbelow_resp' Identifies the response.
value Double 0.00-1023.00 If the measured value of the pin crosses this value than a 'below' event is triggered.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.



III. Event from microcontroller

'change' event

This event is called if the signal value has changed more then the threshold set with the 'repchange' command. This event can show the current value of the OzAnalogDevice.

Example

c=change&value=112.00&id=knRJ67&t=7

Parameters

Parameter Type Range Functionality
c String 'change' Identifies the event.
value Double 0.00-1023.00 The current value of the pin. It is the value measured after it has passed the threshold.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.


'above' event

This event is called if the signal value has crossed above a preset value which you can set with the 'repabove' command.

Example

c=above&value=655.00&id=knRJ67&t=8

Parameters

Parameter Type Range Functionality
c String 'above' Identifies the event.
value Double 0.00-1023.00 The current value of the pin. It is the value measured after it has crossed the 'above' value that has been set.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.


'below' event

This event is called if the signal value has crossed below a preset value which you can set with the 'repbelow' command.

Example

c=below&value=133.00&id=knRJ67&t=9

Parameters

Parameter Type Range Functionality
c String 'below' Identifies the event.
value Double 0.00-1023.00 The current value of the pin. It is the value measured after it has crossed the 'below' value that has been set.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.

More information