Elastic AI implementation for the Elastic Node version 5.
For compiling the project the tools are:
- required:
- gcc
- arm-non-eabi-gcc
- CMake
- Ninja
- recommended:
- pre-commit
First you need to load CMake once (CLion does that for you):
cmake -B cmake-build-debug -G Ninja .
The flag -G Ninja
tells CMake to use Ninja as the build tool.
If this flag is not passed CMake will use the default build tool on your machine (mostly Makefiles).
In the configuration.h file the Network and MQTT connection settings can be change. To stop changes in these to be committed you can do:
git update-index --assume-unchanged src/network_configuration.h
To build and run the unit tests the test.sh script can be used.
The tests can then be found under cmake-build-debug/unit-test/test/unit
as executables.
The main executable (main.c) can be build with:
cmake --build cmake-build-debug --target main
The resulting uf2 file to flash the pico can be found in the out
folder.
The hardware tests can be build using
cmake --build cmake-build-debug --target <test_name>
replacing <test_name>
with the name of the test.
The resulting u2f files to flash the pico can be found in the out
folder.
If the pico is connected to the local machine the print()
inside the code will be redirected to the USB and is
available as serial port output.
This output can be read via a serial port reader like screen,
minicom, putty.
The following shows minicom as an example:
minicom -b 115200 -o -D /dev/ttyACM0
-b 115200
-> baud rate for connection-D /dev/ttyACM0
-> serial port (maybe different on your machine)-o
-> disable modem initialisation
To enable enhanced Debug output add the flag -D DEBUG_OUTPUT:BOOL=ON
to the cmake setup call (or
add it in the CLion CMake options).
This enables the PRINT_DEBUG(...)
from common.h in all targets.
When MQTT messages are sent to fast to the device, some message will be dropped.
- Type: PAC193X
- Datasheet
- Usage:
- Measure Power consumption of sensor array
- Measure Power consumption of WiFi module
- Provided Functionality can be found in
src/pac193x/pac193x_public.h
#include "pac193x/pac193x_public.h"
#include "hardware/i2c.h"
float resistanceValues[4] = {0.82f, 0.82f, 0, 0};
pac193x_usedChannels usedChannels = {.uint_channelsInUse = 0b00000011};
int main(void) {
// Initialize Sensor (ALWAYS REQUIRED)
pac193x_errorCode errorCode = pac193x_init(i2c1, resistanceValues, usedChannels);
if (errordCode != PAC193X_NO_ERROR) {
return errorCode;
}
// DO STUFF
// Example: Read Values from Channel
pac193x_measurements measurements;
errorCode = pac193x_getAllMeasurementsForChannel(PAC193X_CHANNEL_SENSORS, &measurements);
if (errordCode != PAC193X_NO_ERROR) {
return errorCode;
}
// ...
return 0;
}
More detailed examples, on how to use this sensor, can be found in test/hardware/Sensors/test_pac193x.c
.
- Type: SHT3X
- Datasheet
- Usage:
- Measure the current temperature
- Measure the current humidity
- Provided functionality can be found in
src/sht3x/sht3x_public.h
#include "sht3x/sht3x_public.h"
#include "hardware/i2c.h"
int main(void) {
// Initialize Sensor (ALWAYS REQUIRED)
sht3x_errorCode errorCode = sht3x_init(i2c0);
if (errorCode != SHT3X_NO_ERROR) {
return errorCode;
}
// DO STUFF
// Example: Read Temperature and Humidity
float temperature, humidity;
errorCode = sht3x_getTemperatureAndHumidity(&temperature, &humidity);
if (errorCode != SHT3X_NO_ERROR) {
return errorCode;
}
// ...
return 0;
}
More detailed examples, on how to use this sensor, can be found in test/hardware/Sensors/test_sht3x.c
.
- Type: ADXL345B
- Datasheet
- Usage:
- Measure the acceleration in x,y,z direction
- Provided functionality can be found in
src/adxl345b/adxl345b_public.h
#include "adxl345b/adxl345b_public.h"
#include "hardware/i2c.h"
int main(void) {
// Initialize Sensor (ALWAYS REQUIRED)
adxl345b_errorCode errorCode = adxl345b_init(i2c0, ADXL345B_I2C_ALTERNATE_ADDRESS);
if (errorCode != ADXL345B_NO_ERROR) {
return errorCode;
}
// DO STUFF
// Example: Read G value in x, y and z direction
float xAxis, yAxis, zAxis;
errorCode = adxl345b_readMeasurements(&xAxis, &yAxis, &zAxis);;
if (errorCode != ADXL345B_NO_ERROR) {
return errorCode;
}
// ...
return 0;
}
More detailed examples, on how to use this sensor, can be found in test/hardware/Sensors/test_adxl345b.c
.
Following submodules are being used