Companion APP

ProiectIA Android APP

The application allows you to connect to the ESP32 board using Bluetooth Classic or Bluetooth Low Energy.

The app requires the Bluetooth module and location services to be enabled on the smartphone, as well as several permissions to access Bluetooth specific functions, such as scanning for devices, connecting and advertising.

The application will ask for the location permission, which is necessary for Bluetooth Low Energy in order to complete a scan. It does NOT extract or use your location in any way.

The requests and responses are specific for each project category and are detailed in the following sections.

IMPORTANT: Check this page often for app updates!

Download (2.0.2)

API projects requests and response specifications

getNetworks

The getNetworks request is the first request sent by the app and is used for obtaining the list of available WiFi networks available to the ESP32 device, as well as setting the teamId parameter, which will be a required parameter for all responses.

{
    action: 'getNetworks',
    teamId: string
}

The teamId value must be saved in the ESP32 program. Without it, the app will not allow further actions. The expected response is a JSON encoded object for each WiFi network, in the following form:

{
    ssid: string,
    strength: int|float,
    encryption: string|int,
    teamId: string
}

Any additional fields will be ignored by the app.

connect

The connect request is used to connect to a specified network with the WiFi password (if required). Notice that the teamId parameter is no longer sent in this request or any other subsequent request, but the previously stored value will have to be included in all responses, matching the initial value the was sent by the getNetworks request

{
    action: 'connect',
    ssid: string,
    password: string
}

The expected response is a JSON encoded object in the following form:

{
    ssid: string,
    connected: bool,
    teamId: string
}

Any additional fields will be ignored by the app.

getData

The getData request is used for querying the list of records from the API.

{
    action: 'getData'
}

Each API returns a different set of attributes. The ESP32 program should send only the relevant response to the app. The required response is a JSON encoded object for each list record, in the following form:

{
    id: int|string,
    name: string,
    image: string (url|base64),
    teamId: string
}

Any additional fields will be ignored by the app.

getDetails

The getDetails request is used for querying a single record. The id attribute represents the id of the item from the previous list.

{
    action: 'getDetails',
    id: int|string
}

Since each API returns different attributes for the records, the description attribute must be constructed in the ESP32 program, using the relevant attributes returned by the API. The required response is a JSON encoded object in the following form:

{
    id: int|string,
    name: string,
    image: string (url|base64),
    description: string,
    teamId: string
}

Any additional fields will be ignored by the app.

LED projects requests and response specifications

getLEDs

The getLEDs request is the first request sent by the app and is used for obtaining the list of LEDs connected to the ESP32 device, as well as setting the teamId parameter, which will be a required parameter for all responses.

{
    action: 'getLEDs',
    teamId: string
}

The teadId value must be saved in the ESP32 program. Without it, the app will not allow further actions. The expected response is a JSON encoded object for each LED, in the following form:

{
    color: string,
    pin: int,
    pwm: bool,
    channel: int,
    id: int,
    teamId: string
}

The channel will be one of the available PWM channels (0 - 15) and is required only when the pwm attribute is true. The id attribute will be assigned manually as a unique integer value for each LED. Any additional fields will be ignored by the app.

getValue

The getValue request is used for querying the current value of a LED. The id attribute represents the id of the LED from the previous list. Notice that the teamId parameter is no longer sent in this request or any other subsequent request, but the previously stored value will have to be included in all responses, matching the initial value the was sent by the getLEDs request.

{
    action: 'getValue',
    id: int
}

Depending on the LED configuration (the pwm attribute value), the expected result will be a digital value 0 or 1 (when the pwm attribute is false ) or a numeric value between 0 - 100 (when the pwm attribute is true ), where 0 represents a 0% duty cycle and 100 represents a 100% duty cycle. Depending on the channel resolution, the ESP32 program will have to map the values of the PWM channel to the interval 0 - 100. The required response is a JSON encoded object, in the following form:

{
    id: int,
    value: int|float,
    teamId: string
}

Any additional fields will be ignored by the app.

setValue

The setValue request is used for setting the current value of a LED. Depending on the LED configuration (the pwm attribute value), the value will be a digital value true or false (when the pwm attribute is false ) or a numeric value between 0 - 100 (when the pwm attribute is true ), where 0 represents a 0% duty cycle and 100 represents a 100% duty cycle. Depending on the channel resolution, the ESP32 program will have to map the received value to the appropriate interval of the PWM channel.

{
    action: 'setValue',
    id: int,
    value: int|float
}

The required response is a JSON encoded object, in the following form:

{
    id: int,
    value: int|float,
    teamId: string
}

Any additional fields will be ignored by the app.

blink

The blink request is used for blinking a LED a specific number of times and with a certain frequency (between 0.5 - 10Hz). The frequency attribute will be used by the ESP32 program to compute the period for each blink.

{
    action: 'blink',
    id: int,
    frequency: float,
    number: int
}

The blink_number attribute in the response will be the current blink number and, at the end of the process, it will have to match the requested number. The') }} value property will represent the final value of the LED, after the blinking has finished. The required response is a JSON encoded object, in the following form:

{
    id: int,
    value: int|float,
    blink_number: int,
    teamId: string
}

Any additional fields will be ignored by the app.

sweep

The sweep request is used for varying the light intensity of a LED from minimum to maximum and back for a specific number of times. This action is available only for LEDs configured with the pwm option enabled. Each sweep will have a specific duration , which will be specified in the number of seconds required for the LED to complete a full sweep (min - max - min).

{
    action: 'sweep',
    id: int,
    duration: int,
    number: int
}

The sweep_number attribute in the response will be the current sweep number and, at the end of the process, it will have to match the requested number. The') }} value property will represent the final value of the LED, after the sweeping has finished. The required response is a JSON encoded object, in the following form:

{
    id: int,
    value: int|float,
    sweep_number: int,
    teamId: string
}

Any additional fields will be ignored by the app.

LCD projects requests and response specifications

getLCDs

The getLCDs request is the first request sent by the app and is used for obtaining the list of LCDs connected to the ESP32 device, as well as setting the teamId parameter, which will be a required parameter for all responses.

{
    action: 'getLCDs',
    teamId: string
}

The teadId value must be saved in the ESP32 program. Without it, the app will not allow further actions. The expected response is a JSON encoded object for each LED, in the following form:

{
    type: enum('16x2', '20x4', 'OLED 1306', 'Nokia 3310', 'Nokia 5510'),
    interface: enum('I2C', 'SPI', 'Parallel 4-bit'),
    resolution: string,
    id: int,
    teamId: string
}

The type and interface attributes will be one of the enumerated values, according to the LCD model. The resolution attribute will be a string representing the number of pixels of the display, in the form WIDTHxHEIGHT (e.g. 84x48). The id attribute will be assigned manually as a unique integer value for each LCD. Any additional fields will be ignored by the app.

setText

The setText request is used for setting the text displayed on the LCD. The text will be sent as an array for each line (row) of the display. Depending on the LCD model, the number of lines (the number of elements in the array) and the maximum number of characters on each line will be different. The id attribute represents the id of the LCD from the previous list. Notice that the teamId parameter is no longer sent in this request or any other subsequent request, but the previously stored value will have to be included in all responses, matching the initial value the was sent by the getLCDs request.

{
    action: 'setText',
    id: int,
    text: [string]
}

The same text received by the ESP32 program will be included in the response to the app for confirmation. The required response is a JSON encoded object, in the following form:

{
    id: int,
    text: [string],
    teamId: string
}

Any additional fields will be ignored by the app.

setIcons

The setIcons request is used for setting the custom icons displayed on the LCD. The icons will be sent as an array of JSON objects, each object containing the name of the icon and the data in the form of a byte array. Only 16x2 and 20x4 LCDs are compatible with this action. The icons can be displayed anywhere on the LCD.

{
    action: 'setIcons',
    id: int,
    icons: [
        {
            name: string,
            data: [byte array]
        }
        ...
    ]
}

The number of icons received by the ESP32 program will be included in the response to the app for confirmation. The required response is a JSON encoded object, in the following form:

{
    id: int,
    number_icons: int,
    teamId: string
}

Any additional fields will be ignored by the app.

setImage

The setImage request is used for setting a custom image drawn in the app displayed on the LCD. This action require the ESP32 module to be connected the the internet, as the image data will be downloaded from the API server. Only Nokia 5510, Nokia 3310 and OLED 1306 displays are compatible with this action. The data received from the server will be a JSON array containing the pixel coordinates which must be drawn on the display. The url parameter will indicate the web url which contains the image data.

{
    action: 'setImage',
    id: int,
    url: string
}

The number of pixels drawn on the display will be included in the response to the app for confirmation. The required response is a JSON encoded object, in the following form:

{
    id: int,
    number_pixels: int,
    teamId: string
}

Any additional fields will be ignored by the app. The JSON object received from the API server url has the following attributes:

{
    width: int,
    height: int,
    data: [
        {
            x: int,
            y: int
        }
    ]
}

The width and height attributes represent the image dimensions, usually corresponding to the dimensions of the display. The data attribute is an array of objects, each object containing the x and y coordinates of the pixels that need to be drawn on the display.

scroll

The scroll request is used for scrolling the contents of the display. To implement this action, the use of interrupts is recommended.

{
    action: 'scroll',
    id: int,
    direction: enum('Left', 'Right', 'Off')
}

The required response is a JSON encoded object, in the following form:

{
    id: int,
    scrolling: enum('Left', 'Right', 'Off'),
    teamId: string
}

Any additional fields will be ignored by the app.

clearDisplay

The clearDisplay request is used for clearing the display.

{
    action: 'clearDisplay',
    id: int,
}

The required response is a JSON encoded object, in the following form:

{
    id: int,
    cleared: bool,
    teamId: string
}

Any additional fields will be ignored by the app.

Sensor projects requests and response specifications

getSensors

The getSensors request is the first request sent by the app and is used for obtaining the list of Sensors connected to the ESP32 device, as well as setting the teamId parameter, which will be a required parameter for all responses.

{
    action: 'getSensors',
    teamId: string
}

The teadId value must be saved in the ESP32 program. Without it, the app will not allow further actions. The expected response is a JSON encoded object for each LED, in the following form:

{
    type: enum('Sharp Analog', 'Sharp Digital', 'Pololu Analog', 'Pololu Digital', 'PIR', 'Gas', 'Ultrasonic', 'Light', 'Temperature', 'Photocell', 'Photoresistor', 'PIR', 'DHT11', 'DHT22', 'BMP260', 'BME260'),
    pin: int,
    interface: enum('Analog', 'Digital', 'I2C', 'SPI', '1-Wire'),
    id: int,
    parameters: [
        {
            parameter: string,
            unit: string
        }
    ],
    teamId: string
}

The parameters attribute will be an array of objects, representing the parameters measured by the sensor. The id attribute will be assigned manually as a unique integer value for each sensor. Any additional fields will be ignored by the app.

getValues

The getValues request is used for querying the current values of the parameters of a sensor. The id attribute represents the id of the sensor from the previous list. Notice that the teamId parameter is no longer sent in this request or any other subsequent request, but the previously stored value will have to be included in all responses, matching the initial value the was sent by the getSensors request.

{
    action: 'getValues',
    id: int
}

The response will include the value for each parameter of the sensor. The required response is a JSON encoded object, in the following form:

{
    id: int,
    values: {
        parameter_name_1: int|float,
        parameter_name_2: int|float,
        ...
    },
    teamId: string
}

The values object will contain a key corresponding to each parameter configured in the sensor list and the value measured for that parameter. Any additional fields will be ignored by the app.

getAverages

The getAverages request is used for querying the average values of the parameters of a sensor, computed after a number of measurments.

{
    action: 'getAverages',
    number: int,
    id: int
}

The response will include the value for each parameter of the sensor. The required response is a JSON encoded object, in the following form:

{
    id: int,
    averages: {
        parameter_name_1: int|float,
        parameter_name_2: int|float,
        ...
    },
    teamId: string
}

The averages object will contain a key corresponding to each parameter configured in the sensor list and the average value measured for that parameter. Any additional fields will be ignored by the app.

startChart

The startChart request is used for periodically querrying the sensor values in order to plot them on a chart..

{
    action: 'startChart',
    id: int
}

The recommended implementation for this request is to use of a timer interrupt which will transmit the sensor data at a predefined interval. The response will include the value for each parameter of the sensor. The required response is a JSON encoded object, in the following form:

{
    id: int,
    points: {
        parameter_name_1: int|float,
        parameter_name_2: int|float,
        ...
    },
    teamId: string
}

The points object will contain a key corresponding to each parameter configured in the sensor list and the value measured for that parameter. The object will include only the most recent (current) value of the sensor. Any additional fields will be ignored by the app.

stopChart

The stopChart request is used for stopping the previous action and disabling the corresponding interrupt..

{
    action: 'stopChart',
    id: int
}

The required response is a JSON encoded object, in the following form:

{
    id: int,
    stopped: bool,
    teamId: string
}

Any additional fields will be ignored by the app.

Videos