Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Pro Mini Based CO2 Monitoring System with LoRa Wireless Transmission

View and Edit Project In Cirkit DesignerImage of Arduino Pro Mini Based CO2 Monitoring System with LoRa Wireless Transmission

Circuit Documentation

Summary of the Circuit

This circuit is designed to monitor CO2 levels using the SenseAir S8 CO2 Sensor and transmit the data wirelessly via a LoRa Ra-02 SX1278 module. The core controller of the circuit is an Arduino Pro Mini, which interfaces with both the CO2 sensor and the LoRa module. A Step Up Boost Power Converter is used to regulate the voltage supplied to the Arduino and the CO2 sensor. The power source for the circuit is a single 18650 battery in a holder.

Component List

SenseAir S8 CO2 Sensor

Step Up Boost Power Converter, Adjustable Voltage Regulator

18650 Battery in Holder

Arduino Pro Mini

LoRa Ra-02 SX1278

Wiring Details

SenseAir S8 CO2 Sensor

Step Up Boost Power Converter, Adjustable Voltage Regulator

18650 Battery in Holder

Arduino Pro Mini

LoRa Ra-02 SX1278

Documented Code

/*
 * Arduino Sketch for CO2 Monitoring and LoRa Transmission
 *
 * This code reads CO2 levels from the SenseAir S8 CO2 Sensor and transmits the
 * data wirelessly using the LoRa Ra-02 SX1278 module. The Arduino Pro Mini is
 * used as the microcontroller to interface with both the sensor and the LoRa
 * module.
 */

#include <SoftwareSerial.h>
#include <SPI.h>
#include <LoRa.h>

// Pin definitions
#define CO2_RX_PIN 5
#define CO2_TX_PIN 6
#define LORA_RST_PIN 9
#define LORA_SS_PIN 10
#define LORA_DIO0_PIN 4

// Create a SoftwareSerial object for CO2 sensor communication
SoftwareSerial co2Serial(CO2_RX_PIN, CO2_TX_PIN);

void setup() {
  // Initialize serial communication for debugging
  Serial.begin(9600);
  while (!Serial);
  Serial.println("CO2 Monitoring and LoRa Transmission");

  // Initialize SoftwareSerial for CO2 sensor
  co2Serial.begin(9600);

  // Initialize LoRa module
  LoRa.setPins(LORA_SS_PIN, LORA_RST_PIN, LORA_DIO0_PIN);
  if (!LoRa.begin(915E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
  Serial.println("LoRa Initializing OK!");
}

void loop() {
  // Read CO2 concentration from the sensor
  int co2Concentration = readCO2();
  Serial.print("CO2 Concentration: ");
  Serial.print(co2Concentration);
  Serial.println(" ppm");

  // Transmit CO2 concentration via LoRa
  LoRa.beginPacket();
  LoRa.print(co2Concentration);
  LoRa.endPacket();

  // Wait for a minute before the next reading
  delay(60000);
}

int readCO2() {
  // Send command to read CO2 concentration
  byte cmd[] = {0xFE, 0x44, 0x00, 0x08, 0x02, 0x9F, 0x25};
  co2Serial.write(cmd, 7);
  co2Serial.flush();

  // Wait for the sensor to respond
  delay(10);

  // Read the response
  byte response[7];
  co2Serial.readBytes(response, 7);

  // Calculate CO2 concentration
  int high = response[3];
  int low = response[4];
  int co2 = (high << 8) + low;

  return co2;
}

This code is responsible for initializing the communication with the CO2 sensor and the LoRa module, reading the CO2 concentration, and transmitting the data wirelessly. The readCO2 function sends a command to the CO2 sensor to get the current CO2 concentration and then reads the response to calculate the concentration value. The main loop transmits the CO2 concentration via LoRa and waits for a minute before taking the next reading.