Microcontroller and Open-Source Hardware

PART A: GENERALITIES

Presentation

After the week of labs at AIME to create a gas sensor, we had another course with the physical department on how to implement it in a bigger circuit with microcontrollers to collect and analyze its data. The objective of these courses was to create a datasheet for our sensor and to implement it with a microcontroller to create an application using a LoRa network able to display the results collected by the sensor.

PART B: DESCRIPTIVE PART

Experience Details

Environment and Context

During this course, I had the opportunity to work on both theoretical and practical aspects of microcontroller technology. The relevance of microcontrollers in modern technology, especially in IoT applications was evident throughout the course. The hands-on sessions were particularly beneficial, allowing me to apply the concepts learned in class to real-world scenarios.

My Function

In this course, I was responsible for:

PART C: TECHNICAL PART

This section explain the technical aspects of integrating the gas sensor with a microcontroller and developing applications for data collection and visualization.

Technical Concepts Learned

1. Gas Sensor Fabrication

The gas sensor was fabricated during a training period at AIME. It uses nanoparticles of WO3, which allows for high sensitivity to specific gases like ethanol and ammonia. The sensor includes:

2. Wiring and Integration

To create a functional system, we wired the following components:


The connections were as follows:

3. Arduino Code

The Arduino code consists of two main parts: initialization and data transmission.

Initialization:

Data Transmission:

Here is a simplified version of the code:

#include <TheThingsNetwork.h>
#include <TheThingsMessage.h>
#include <SoftwareSerial.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiAvrI2c.h"

const char *appEui = "9314122f9f48664f";
const char *appKey = "77F85835964FC8C511F87CE864B96A6D";

#define I2C_ADDRESS 0x3C
#define GAZ_SENSOR_PIN A0
#define LED_PIN 4
#define freqPlan TTN_FP_EU868

SSD1306AsciiAvrI2c oled;
SoftwareSerial loraSerial(10, 11); // TX, RX
TheThingsNetwork ttn(loraSerial, Serial, freqPlan);

void setup() {
    loraSerial.begin(57600);
    Serial.begin(57600);
    while (!Serial && millis() < 10000);

    Serial.println("-- STATUS");
    ttn.showStatus();

    Serial.println("-- JOIN");
    ttn.join(appEui, appKey);

    pinMode(LED_PIN, OUTPUT);

    oled.begin(&Adafruit128x64, I2C_ADDRESS);
    oled.setFont(Adafruit5x7);
    oled.clear();
    oled.set2X();
    oled.println("Hello user1");
}

void loop() {
    Serial.println("-- LOOP");

    byte GAZ_VALUE = analogRead(GAZ_SENSOR_PIN);
    Serial.print("GAZ_VALUE: ");
    Serial.println(GAZ_VALUE);

    if (GAZ_VALUE > 100) {
        digitalWrite(LED_PIN, HIGH);
        oled.clearField(0, 2, 5);
        oled.println("HELP");
    } else {
        digitalWrite(LED_PIN, LOW);
        oled.clearField(0, 2, 5);
    }

    ttn.sendBytes(&GAZ_VALUE, 1);
    delay(10000);
}

This code initializes the LoRa module and gas sensor, reads the sensor data, and sends it via LoRa. It also updates an OLED display and controls an LED based on the gas level.

4. Node-RED Overview

The Node-RED flow for this project is designed to receive, process, and display data from a LoRa sensor. The flow involves:



5. MIT App Inventor

The MIT App Inventor app is designed to connect to the Arduino, allowing users to control the system and view sensor data in real-time. Features include:


PART D: ANALYTICAL PART

The Knowledge and Skills Mobilized

Self Evaluation

This course was a reutilization of many skills acquired during the year and throughout my engineering studies, notably with Node-RED, MQTT, C language, and wiring. As I remembered almost everything, I didn’t have any trouble developing the project. A special mention goes to MIT App Inventor, KitCad and ChirpStack, which was a first discovery for me, adding new knowledge to my skill set. I can confidently say that this project was carried out well, and every step I aimed to complete was successfully achieved.

My Opinion

I really appreciated this course as it involved working on a project from the sensor component to the board creation. It is exactly the kind of work I enjoy handling a complete project from start to finish. Additionally, touching on all hardware and software was interesting as it allowed me to understand everything and stay informed about the project. Being part of a team was beneficial as we had good communication, which facilitated the project’s advancement.

You can find the complete project report on GitHub_Microcontroller_Project.