Arduino Pico Project - Drop test of CANSAT model satellite

// MAIN BALLOON TESTING CODE - By Vivek Samani
// Send b or B to trigger the burn wire from GS
// Serial transmit string format: Read_Count, gps_Altd, Lat, Lng, Sats, Hf, T, Po

/* ************ PROJECT DESCRIPTION ************ 

  HOT AIR BALLOON - MODEL SATELLITE DROP TEST

  Hardware description:
  MCU : Rpi Pico
  Burn wire triggering: MOSFET Module
  LOCATION: L89 GPS module
  Temp / Absolute Altitude / Pressure: BMP 280
  For Burnner valve control: Servo SG90
  Radio Module: LORA EBYTE E22 400T30D

  GS : Ground station occupied with LORA With (viaz TTL to USB) laptop and monitoring data on CUTECOM Software)
*/

// Including necessary libraries

#include <Wire.h>
#include <Servo.h>
#include <TinyGPS++.h>
#include <hardware/uart.h>
#include <Adafruit_BMP280.h>
#include <SimpleKalmanFilter.h>

// LORA Rx & Tx pins declaration
#define LORA_Tx 16
#define LORA_Rx 17

// GPS @ Rx & Tx pins declaration
#define Tx_UART1 8
#define Rx_UART1 9

#define burn_pin 15

// Servo pin
#define svr_pin 22

bool newData;
float incoming_serial_pressure, Po, Pf;

SimpleKalmanFilter pressureKalmanFilter(1, 1, 1);

// Instance and object declaration6h
Servo svr;
TinyGPSPlus gps;
Adafruit_BMP280 bmp;

// Serial output refresh time
unsigned long refresh_time;
const long SERIAL_REFRESH_TIME = 100;

volatile float gps_Altd, Lat, Long, Hf, T, P, H;
volatile signed int Sats, svr_pos = 0, Read_Count = 1;

void setup() {
  // GPS Baud Rates and UART declaration
  Serial2.setTX(Tx_UART1);
  Serial2.setRX(Rx_UART1);
  Serial2.begin(9600);

  // LORA Baud Rates and UART declaration
  Serial1.setTX(LORA_Tx);
  Serial1.setRX(LORA_Rx);
  Serial1.begin(9600);

  // Serial monitor baud rate
  Serial.begin(9600);

  // Attach & Set servo to initial position
  svr.attach(svr_pin);
  svr.write(svr_pos);

  // Check the status of sensor
  unsigned status;
  status = bmp.begin(0x76);
  if (!status) 
  {
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring or "
                     "try a different address!"));
  }

  // Defining sampling rates for BMP280
  bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,   /* Operating Mode. */
                  Adafruit_BMP280::SAMPLING_X2,   /* Temp. oversampling */
                  Adafruit_BMP280::SAMPLING_X16,  /* Pressure oversampling */
                  Adafruit_BMP280::FILTER_X16,    /* Filtering. */
                  Adafruit_BMP280::STANDBY_MS_1); /* Standby time. */

  // Set reference pressure
  for (int i = 0; i < 10; i++) {
    incoming_serial_pressure += bmp.readPressure();
    // wait for next reading
    delay(200);
  }

  // Reference pressure
  Po = incoming_serial_pressure / 10; P = Po;
}

void loop() 
{
  // send to Serial output every 100ms
  if (millis() > refresh_time) 
  {
    /* Activate burn wire or Rotate servo as per command */
    if (Serial1.available() > 0) 
    {
      char receivedChar = Serial1.read();
      if (receivedChar == 'B' || receivedChar == 'b') 
      {
        BurnWire();
      }

      svr_pos = Serial1.read();
      if (svr_pos >= 0 || svr_pos <= 180) 
      {
        svr.write(svr_pos);
      }
    }

    // Collect data from L89 GPS Module
    if (Serial2.available() > 0) 
    {
      if (gps.encode(Serial2.read())) 
      { 
        SATS = gps.satellites.value();
         LAT = gps.location.lat();
        LAT = gps.location.lng();
        gps_Altd = gps.altitude.meters();
      }
    }

    // filtered_pressure_value
    Pf = pressureKalmanFilter.updateEstimate(bmp.readPressure());

    // measured altitude
    H = bmp.readAltitude(Po * 0.01);

    // measured temperature
    T = bmp.readTemperature();

    // filtered altitude
    Hf = 44330 * (1 - pow((Pf / Po), (0.1903)));

    // Read_Count, gps_Altd, Lat, Lng, Sats, Hf, T, Po
    String csvData = String(Read_Count) + "," + String(gps_Altd) + "," + String(Lat) + "," + 
    String(Long) + "," + String(Sats) + "," + String(Hf) + "," + String(T) + "," + String(Po);

    Serial1.println(csvData); // Send this data to UART pins of LORA Tx
    Serial.println(csvData); // Print it to current serial monitor

    Read_Count+=1;

    refresh_time = millis() + SERIAL_REFRESH_TIME;
  }
}

void BurnWire() 
{
  static bool executed = false;
  if (!executed) {
    Serial.println(" BURN WIRE TRIGGERED SUCCESSFULLY !! ");
    digitalWrite(burn_pin, HIGH);
    delay(1000);
    digitalWrite(burn_pin, LOW);
  }
  executed = true;
}

Problems and errors :

1). I'm not getting GPS data, I tried debugging the block of GPS separately without modifying it and it worked. but with the integrated code it didn't worked!

2). I tried testing the burn wire triggering but as soon as I transmitted b or B the main system of MCU didn't received it.

3). Same as 2nd it is with the servo angle transmitting.

4). The communication is only happening one way: MCU to GS and not GS to MCU (Viaz Radio) ....already I have set the radio to Normal mode (2 WAY UART = > M0 = M1 = GND! ) but still it didn't worked!.... I'm only getting string to GS but not getting triggering logic for burn wire and servo.

My references:

  1. Arduino Pico : Rpi Pico With Arduino IDE - Documentation

  2. Lora Ebyte E22: Lora E22 - User manual

Please help me out with the way to get the solutions with the above problems and errors.
Thank you for investing your time and effort in reading!

Is this before or after the drop test?

If it worked before the drop test and not after then you broke something, and you need to fix it. As you built it you should know everything you did to make it. So retrace your steps and find what is broken.

Did you start at the beginning ?

As in did you write programs that just covered one part of the setup such as;

A program to just read the GPS and output location stuff to the serial monitor ?

Then a simple program to send and receive a 'Hello World' message with the radio modules ?

Etc.

Not sure I see why a EBYTE E22 400T30D module is needed, thats capable of a massive 1W output, no way you needs that amout of RF power to receive signals from a 'satellite'. Also be aware that the current counsumed could be very high and thus cause problems with a power supply.

I did build a real World satellite, 1/2 the size of a Cansat. I spent a while looking at using a 1W RF module, for long range reasons, but the power demands were too extreme, so I stuck with a mere 100mW. It worked.

in addition to what @srnet said, I suggest you start with how millis works. This:

  // send to Serial output every 100ms
  if (millis() > refresh_time) 
  {

Will do nothing for the first 100ms then be true for the next 47 and a bit days. Millis is greater than 100 after 100ms have elapsed from power up until it rolls over 47 days or so later.

This might help:

And this:

before the actual drop test I was testing my whole integrated code!

What does that actually mean?

Was the tests successful or had you not got round to testing the bit that now causes you problems?

Why are you not answering questions other have posted?
like

We only know what you tell us, and without knowing what you have, we don't stand a chance.

You might want to look at this How to get the best out of this forum before you proceed any further. You had one chance of looking at it before you posted your first post. Now try again to read and understand what it says, please.

1 Like

Really very sorry for the late replies and all.

So we were at the CANSAT : I mean that I have not done the actual drop test of satellite from a building. I was just testing the whole integrated system code at my college lab it self. By varying the can height little bit and testing the burn wire triggering using radios I have. So my point is I have come across some error which I have listed above in my first post of this topic. Can you suggest what could be the problem with the logic of the code.

Well @PerryBebbington has already suggested what could be the matter. Did you read and understand that point?

Code is mainly useless without knowing what the hardware setup it is running on. So could you please send a schematic of your wiring. Hand drawn is fine, but fritizing or pictures connected by lines is not.

1 Like

Sure sure, here it is:

The hand drawn circuit / wiring diagram of my whole setup is attached herwith.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.