https://github.com/conect2ai/conect2freematics
This repository contains our implementation of Freematics One+ code.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (8.8%) to scientific vocabulary
Repository
This repository contains our implementation of Freematics One+ code.
Basic Info
- Host: GitHub
- Owner: conect2ai
- License: mit
- Language: C++
- Default Branch: main
- Size: 5.39 MB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Conect2AI Freematics One+ Implementation
The objective of this repository is to host the Conect2AI adaptation of the Freematics One+ platform. Relative to the original implementation, the improvements made include the transmission of email on the server route, as well as the integration of clock synchronization functionality utilizing an NTP (Network Time Protocol) server.
:rocket: How to Execute
1 - Install Visual Studio Code
2 - Install PlatformIO (VSCode Extension)
3 - Clone this repository
bash
git clone https://github.com/conect2ai/conect2freematics
4 - Open freematics-autcloud/firmware_v5/telelogger project folder in PlatformIO, as shown in the figure below.
5 - Connect the Freematics One+ with the computer and power up it with the Freematics Emulator or in the vehicle.
6 - Compile, Upload and monitor serial (steps 1, 2 and 3, respectively in the figure below).
:computer: Sensors configuration
You can modify the sensors and the times they are collected in telelloger.ino file
C
PID_POLLING_INFO obdData[]= {
{PID_ENGINE_LOAD, 1},
{PID_RPM, 1},
{PID_MAF_FLOW, 1},
{PID_INTAKE_TEMP, 1},
{PID_TIMING_ADVANCE, 1},
{PID_MAF_FLOW, 1},
};
You can find the list with all the sensors available to collect in the OBD.h file
```C // Mode 1 PIDs
define PIDENGINELOAD 0x04
define PIDCOOLANTTEMP 0x05
define PIDSHORTTERMFUELTRIM_1 0x06
define PIDLONGTERMFUELTRIM_1 0x07
define PIDSHORTTERMFUELTRIM_2 0x08
define PIDLONGTERMFUELTRIM_2 0x09
define PIDFUELPRESSURE 0x0A
define PIDINTAKEMAP 0x0B
define PID_RPM 0x0C
define PID_SPEED 0x0D
... ```
:wrench: Network Configurations
All the information collected can be send to a server and can be stored locally in SD card. The hardware allows information to be sent both via Wi-Fi and 4G. You can configure things like Wi-Fi name and password, URL server, server port, protocol etc. in config.h file.
```C
/************************************** * Configuration Definitions **************************************/ // ...
// define your email
define USER_EMAIL "email@email.com"
/************************************** * Networking configurations **************************************/
ifndef ENABLE_WIFI
define ENABLE_WIFI 0
// WiFi settings
define WIFI_SSID "FREEMATICS"
define WIFI_PASSWORD "PASSWORD"
endif
ifndef SERVER_HOST
// cellular network settings
define CELL_APN ""
// Freematics Hub server settings
define SERVER_HOST "serverconect2ai.dca.ufrn.br"
define SERVERPROTOCOL PROTOCOLHTTP
endif
// SIM card setting
define SIMCARDPIN ""
// HTTPS settings
define SERVERMETHOD PROTOCOLMETHOD_POST
define SERVER_PATH "/freematics"
if !SERVER_PORT
undef SERVER_PORT
if SERVERPROTOCOL == PROTOCOLUDP
define SERVER_PORT 8081
elif SERVERPROTOCOL == PROTOCOLHTTP
define SERVER_PORT 1880
elif SERVERPROTOCOL == PROTOCOLHTTPS
define SERVER_PORT 443
endif
endif
```
:brain: Embedding Tiny Machine Learning Algorithms
Within the telelogger.ino file, the processOBD function assumes the pivotal role of acquiring sensor data and buffering it for subsequent transmission to both the SD card and the designated server. Consequently, this enables various applications such as utilizing the captured data to populate a vector, which can serve as input for machine learning algorithms. Also, it is possbile to calculate soft-sensors inside this function.
```C void processOBD(CBuffer* buffer) {
static int idx[2] = {0, 0}; int tier = 1; for (byte i = 0; i < sizeof(obdData) / sizeof(obdData[0]); i++) {
// calculate tier
...
// process value
byte pid = obdData[i].pid;
if (!obd.isValidPID(pid)) continue;
int value;
if (obd.readPID(pid, value)) {
obdData[i].ts = millis();
obdData[i].value = value;
buffer->add((uint16_t)pid | 0x100, ELEMENT_INT32, &value, sizeof(value));
} else {
timeoutsOBD++;
printTimeoutStats();
break;
}
if (tier > 1) break;
} int kph = obdData[0].value; if (kph >= 2) lastMotionTime = millis(); } ```
AT Commands
During the hardware initialization process, additional AT commands have been integrated. The modified file, FreematicsOBD.cpp, now includes the ATM0 and ATAT1 commands as part of its initialization sequence.
```c // FreematicsOBD.cpp file
const char *initcmd[] = {"ATE0\r", "ATH0\r", "ATM0\r", "ATAT1\r"}; ```
Email and VIN
To ensure unique identification of each trip on the server, the Email and Vehicle Identification Number (VIN) have been incorporated into the data transmission route. The following code snippet from the teleclient.cpp file illustrates these modifications.
```c // teleclient.cpp file
if (strlen(USEREMAIL) == 0 || USEREMAIL == NULL) { len = snprintf(url, sizeof(url), "%s/post/%s/%s/%s", SERVERPATH, devid, "unknown", vin); } else { len = snprintf(url, sizeof(url), "%s/post/%s/%s/%s", SERVERPATH, devid, USER_EMAIL, vin); } ```
:pagefacingup: License
This project is licensed under the MIT License - see the LICENSE file for details.
About Us
The Conect2AI research group is composed of undergraduate and graduate students from the Federal University of Rio Grande do Norte (UFRN) and aims to apply Artificial Intelligence (AI) and Machine Learning in emerging fields. Our expertise includes Embedded Intelligence and IoT, optimizing resource management and energy efficiency, contributing to sustainable cities. In energy transition and mobility, we apply AI to optimize energy use in connected vehicles and promote more sustainable mobility.
Owner
- Name: conect2ai
- Login: conect2ai
- Kind: organization
- Repositories: 1
- Profile: https://github.com/conect2ai
GitHub Events
Total
- Push event: 1
Last Year
- Push event: 1
Dependencies
- folium ==0.14.0
- matplotlib ==3.7.1
- numpy ==1.24.4
- pandas ==1.4.0
- seaborn ==0.13.1