CO2 Requirements - OtagoPolytechnic/Cloudy-with-a-Chance-of-LoRa GitHub Wiki

We were tasked with assisting Martin's CO2 project with new sensors, including testing/verifying existing ones and ensuring any new ones are giving correct readings.

Martin has requested as many CO2 sensors as we can provide.

Existing hardware

We tested the Adafruit Feather 32u4's and found that they can only handle one sensor per board. This means they are ideal for the CO2 sensors.

Results

The feathers only support the use of tiny lora which means we can only use abp on them we have figured out how to get this working. We know have data uploading to the ttn using this format. We have also decided against buying more feathers and swapping to ttgos they are slightly cheaper and more grunty so future sensors that are made once all feathers are used up will use ttgos

How to build and solder a co2 sensor

This guide will walk you through the steps to build a CO2 sensor using a copper breadboard and a CO2 sensor module. The images provided in this wiki demonstrate the key steps in assembly and soldering.

Materials needed:

  • Copper breadboard
  • CO2 sensor module
  • Header pins
  • Microcontroller board (e.g., Adafruit Feather)
  • Jumper wires
  • Soldering iron and solder
  • Wire cutters
  • Multimeter (optional, for testing)
  • Dremel with mini saw blade

Step 1: Prepare the Copper Board

Cutting and Marking

Cut a 91mm x 44mm copper board and score it down the middle separating the copper strips. Using a dremel with a mini saw blade is the easiest. Use a multimeter to ensure you have scored it correctly.
board_scored

Step 2: Add header pins

Use bluetack to holder the header pins in place in the same layout as below. This layout ensure enough room for the sensor on the board. Using pins like this ensures that wires can be swapped out easily as decaying jumper wires has been the main cause of failure in the past.
header_pins

Solder the header pins onto the breadboard as shown.
board_soldered

Solder the co2 Sensor

Use bluetack to hold this in if there isn't a clamp available. just be mindful that the bluetach can become quite sticky and runny so don't have it covering any of the holes. Using a larger blob of bluetack helps for getting any that is left remaining on the sensors.

co2_sensor_top

co2_sensor_under

Code for CO2

The code for a CO2 sensor is found here.

Using the Arduino IDE ensure the TinyLora Library is loaded via Sketch > Add .ZIP library
image

The board is an Adafruit Feather 32u4.

Register a new device on The Things Network Sandbox

image

image

Ensure that Network Settings > Advanced MAC settings frame counter is ticked.

image

Custom Javascript payload formatter:

function Decoder(bytes, port) {
  if (bytes.length !== 4) {
    return null; // Invalid payload length
  }

  let decoded = {};

  // Combine bytes into 16-bit integers
  let tempRaw = (bytes[1] << 8) | bytes[0]; // Temperature is in the first two bytes
  let co2Raw = (bytes[3] << 8) | bytes[2];  // CO2 concentration is in the last two bytes

  // Decode temperature and CO2
  // Temperature is scaled by 100 (fixed-point with 2 decimal places)
  let temperature = tempRaw / 100.0;

  // CO2 concentration is directly used
  let CO2 = co2Raw;

  decoded.temperature = temperature;
  decoded.CO2 = CO2;

  return decoded;
}