Sensor commands plus a sample run of Softata Console App with Sensor selection.

c# Console Softatalib App commands for Sensors

App Start

SoftataLib.Init(ipaddressStr, port);
SoftataLib.SendMessageCmd("Begin")
string SoftataLib.SendMessageCmd("Version"); //Get Arduino app Version
string SoftataLib.SendMessageCmd("Devices"); // Get list of device types supported

Sensor Queries and Setup

string[] SoftataLib.Sensor.GetSensors()
SoftataLib.Sensor.GetPins(sensorIndex)
(byte)sensorLinkedListIndex = SoftataLib.Sensor.SetupDefault(sensorIndex)

Read Sensors

double[]? SoftataLib.Sensor.ReadAll(sensorLinkedListIndex,debug)
string SoftataLib.Sensor.GetTelemetry(sensorLinkedListIndex,debug)
double? SoftataLib.Sensor.Read(sensorLinkedListIndex, p,debug)
  • debug If false (default is true) can turn off some debug messages.

Sending Telemetry

To Bluetooth … to Azure IoT Hub coming

string SoftataLib.Sensor.SendTelemetry(sensorLinkedListIndex)
string SoftataLib.Sensor.PauseSendTelemetry(sensorLinkedListIndex)
string SoftataLib.Sensor.ContinueSendTelemetry(sensorLinkedListIndex);

Finish: Close app on Arduino device and restart it.

SoftataLib.SendMessageCmd("End")
  • Executing soft reset of device puts it in a known (clear) state.

Corresponding Arduino commands

  • 0xF0: Sensor type commands
    • Param is the Sensor subcommand:
      • 0x00 GetPins
      • 0x01 GetProperties
      • 0x02 SetupDefault
      • 0x03 Setup
      • 0x04 ReadAll
      • 0x05 Read
      • 0x06 GetTelemetry
      • 0x07 SendTelemetryBT
      • 0x08 SendTelemetryToIoTHub (Coming)
      • 0x09 PauseSendTelemetry
      • 0x0A ContinueTelemetry
      • 0xFF GetSensors
  • Subcommands 0x00 to 0x03:
    other parameter specifies the sensor type
  • Subcommands 0x02 and 0x03:
    Both return the linked list node index where the reference to the instantiated sensor class instance is stored. Besides the pin parameter, the second (0x03) requires setup data specific to the sensor.
  • Subcommands 0x04 to 0x0A:
    other` parameter is that index to the sensor instantiated node in the sensors linked list

Note:_ Subcomands 0x00 to 0x03 are implemented specifically for each sensor type. Subcommands 0x04 to 0x0A are implemented in a sensor type agnostic manner, using class polymorphism. The last command requires no parameters.

Commands sent to Arduino server from Softatalib as array of bytes:

  • Length of array
  • Sensor Command Class Type (0xF0)
  • Pin
  • Param: Subcommand
  • Other: Sensor Type / Sensor Linked List index
  • OtherData:
    • Array of additional data (Used by 2nd Setup method)
    • Default setup uses default settings

Sample Console app output: Sensor

1. Main Menu

Hello from Soft-ata!

TESTS
1.              Digital
2.              Analog
3.              PWM
4.              Servo
5.              Sensors
6.              SPI
7.              OneWire
8.              Serial
9.              NeopixelDisplay
10.             LCD1602Display
11.             PotLightSoundAnalog
12.             USonicRange
13.             PotRelay
14.             PotServo

Please make a selection (Default is 13):5
Testtype: Sensors

  • Option 5: Sensors selected

2. Connect to Server

Connecting to Softata Server.
Socket created to 192.168.0.9:4242
Sending 2 data bytes
Sent 2 bytes
Received Ready [5] bytes

Sending 2 data bytes
Sent 2 bytes
Received 3.10 [4] bytes

Softata Version: 3.10
Sending 2 data bytes
Sent 2 bytes
Received DEVICES:sensor,actuator,communication,display [45] bytes
DEVICES:sensor,actuator,communication,display
  • Got Arduino app version and supported device types

3. Get Sensor Types

Sending 3 data bytes
Sent 3 bytes
Received OK:SENSORS:DHT11,BME280,URANGE [30] bytes
  • List of sensors implemented returned. Used in following menu:

4. Select Sensor

Sensors found:
1.              SENSORS:DHT11
2.              BME280
3.              URANGE
Selection:2
  • Option 2: BME280 chosen

5. Get sensor connections

Sending 5 data bytes
Sent 5 bytes
Received OK:I2C0 (Pins8/9 (SDA/SCL) fixed): Address 0x77 (Alt 0x76). Embedded in driver though. [86] bytes

BME280 getPins OK
BME280 Pins = I2C0 (Pins8/9 (SDA/SCL) fixed): Address 0x77 (Alt 0x76). Embedded in driver though.
Press any key to continue.
  • I2C0 @ 0x77 Connection

6. Setup Sensor

Sending 5 data bytes
Sent 5 bytes
Received OK:0 [4] bytes

Instantiated BME280 found at 0
  • BME280 Sensor setup OK
  • Sensor node index in Sensor Linked list is 0
    • Is passed to subsequent commands

7. Get Sensor properties

Sending 5 data bytes
Sent 5 bytes
Received OK:Temperature,Pressure,Humidity [32] bytes

BME280 getProperties OK
BME280 property = Temperature
BME280 property = Pressure
BME280 property = Humidity
Press any key to continue.
  • Got properties

8. Select Sensor Mode

(START) SELECT SENSOR MODE
1. Read Sensor Values.
2. Get Telemetry
3. Start Stream Telemetry to Bluetooth
Default 1.
Selection:1
  • Will read sensor values explicitly using ReadAll() and individual property Read()

9. Enter period between reads

Please enter the period btw sensor reads (Default 2500mS): 2000
  • 2 seconds entered (2000 mS)

10. Output

ReadAll():
                BME280 Temperature = 21.44
                BME280 Pressure = 100679.53
                BME280 Humidity = 53.75
Individual Read():
                BME280 Temperature = 21.43

                BME280 Pressure = 100679.66

                BME280 Humidity = 53.73

Press [Esc] to stop
  • [Esc] pressed

11. Finish

SELECT SENSOR MODE
1. Read Sensor Values.
2. Get Telemetry
4. Pause Telemetry Stream
5. Continue Telemetry Stream
6. Quit
Default 1.
Selection:6
  • Quit selected
Quitting app. Please wait.
Sending 2 data bytes
Sent 2 bytes
Received Done [4] bytes

C:\SoftataConsole.exe (process 48412) exited with code 0.
  • Finished

 TopicSubtopic
   
 This Category Links 
Category:Softata Index:Softata
  Next: > Softata
<  Prev:   Softata