(LoadProhibited) on code of sensor reading

Hi,
So I was trying to unify my code im using a Lilygo TSIM 7000G, so i tried the codes alone and now Im adding them in one code, so the problems becomes with the PMS sensor and I dont really now what to do or fix, because it reads when Im trying the code but when It is in the new code just doesnt print any info.

I think it could be the requesting, i read with the same error like use pointers to doesnt load the esp32, but what i have to do.

 2
error opening test.txt

======== start print ========
temperature (unit Celsius): 0.00
pressure (unit pa):         0
altitude (unit meter):      44330.00
humidity (unit percent):    0.00
========  end print  ========
Sensor operating status : 0
Air quality index : 0
Concentration of total volatile organic compounds : 0 ppb
Carbon dioxide equivalent concentration : 0 ppm

CO = 1000.00
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x40102f14  PS      : 0x00060530  A0      : 0x800d5b96  A1      : 0x3ffb21f0  
A2      : 0x3ffc1938  A3      : 0x000000e2  A4      : 0x00000000  A5      : 0x3ffc198e  
A6      : 0x00000042  A7      : 0x3ffc1989  A8      : 0x00000000  A9      : 0x3ffb21d0  
A10     : 0x00000000  A11     : 0x00000042  A12     : 0x00000a1d  A13     : 0x00000004  
A14     : 0x3ffc2800  A15     : 0x3ffc2804  SAR     : 0x00000014  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x400872a5  LEND    : 0x400872b5  LCOUNT  : 0xffffffff  


Backtrace: 0x40102f11:0x3ffb21f0 0x400d5b93:0x3ffb2210 0x400d1ee8:0x3ffb2230 0x400da184:0x3ffb2270 0x4008a7fa:0x3ffb2290




ELF file SHA256: 7e1943899
Rebooting...

This is the code it isnt like very reduce because Im trying to get to work first and after that do the upgrading.

#include <SPI.h>
#include <SD.h>
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>

//Variables de O2
#include "DFRobot_OzoneSensor.h"
#define COLLECT_NUMBER  20 
#define Ozone_IICAddress 0x73
DFRobot_OzoneSensor Ozone;

#define SD_CS         13
#define SPI_MOSI      15
#define SPI_MISO      2
#define SPI_SCK       14

#define i2c_Address 0x3C
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1   //   QT-PY / XIAO
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
File carpeta;

//CO2
#include <DFRobot_ENS160.h>
#include "DFRobot_BME280.h"
#define SEA_LEVEL_PRESSURE    1015.0f
#define ADDRESS_1 0x53
#define ENS160_ADDRESS ADDRESS_1
#define ADDRESS_2 0x76
#define BME_ADDRESS ADDRESS_2
DFRobot_ENS160_I2C ENS160(&Wire, /*i2cAddr*/ ENS160_ADDRESS);
typedef DFRobot_BME280_IIC    BME;    // ******** use abbreviations instead of full names ********
BME   bme(&Wire, BME_ADDRESS);   // select TwoWire peripheral and set sensor address

// show last sensor operate status
void printLastOperateStatus(BME::eStatus_t eStatus)
{
  switch(eStatus) {
  case BME::eStatusOK:    Serial.println("everything ok"); break;
  case BME::eStatusErr:   Serial.println("unknow error"); break;
  case BME::eStatusErrDeviceNotDetected:    Serial.println("device not detected"); break;
  case BME::eStatusErrParameter:    Serial.println("parameter error"); break;
  default: Serial.println("unknow status"); break;
  }
}


//GASES

#include "DFRobot_MICS.h"
float COO=2;
#define Mics_I2C_ADDRESS 0x75
DFRobot_MICS_I2C mics(&Wire, Mics_I2C_ADDRESS);
#define ADC_PIN   A0
#define POWER_PIN 10

//PMS

#include "BLINKER_PMSX003ST.h"

#define RX2 14 // To sensor TXD
#define TX2 15 // To sensor RXD

HardwareSerial pmsSerial(2);// UART1/Serial1 pins 16,17

BLINKER_PMSX003ST pms;












void setup(){

  Serial.begin(9600);
 
  SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI, SD_CS); 

  Serial.println("starting");
  if(!SD.begin(SD_CS, SPI))
  {
      Serial.println("Card Mount Failed");
      return;
  }
  uint8_t cardType = SD.cardType();
  if(cardType == CARD_NONE)
  {
      Serial.println("No SD card attached");
      return;
  }
  //card details
  uint64_t cardSize = SD.cardSize() / (1024 * 1024);
  Serial.printf("SD Card Size: %lluMB\n", cardSize);
  Serial.println("-----");

  delay(250); // wait for the OLED to power up
  
  carpeta = SD.open("/test.txt", FILE_WRITE);
  if (carpeta) 
  {
    carpeta.println("Hello worl4!");
    carpeta.flush();
    carpeta.close();
  } 
  else
  {
    Serial.println("error opening test.txt");
  }

  carpeta = SD.open("/test.txt", FILE_WRITE);
  if (carpeta) 
  {
    carpeta.print("Hello wor!");
    carpeta.print("Hello wr!");
    carpeta.flush();
    carpeta.close();
  } 
  else
  {
    Serial.println("error opening test.txt");
  }

  display.begin(i2c_Address, true); // Address 0x3C default
 //display.setContrast (0); // dim display
 
  display.display();
  delay(2000);

  // Clear the buffer.
  display.clearDisplay();


  // text display tests
  display.setTextSize(1);
  display.setTextColor(SH110X_WHITE);
  display.setCursor(0, 0);
  display.println("Failure is NOT option");
  display.setTextColor(SH110X_BLACK, SH110X_WHITE); // 'inverted' text
  display.println(3.141592);
  display.setTextSize(2);
  display.setTextColor(SH110X_WHITE);
  display.print("0x"); display.println(0xDEADBEEF, HEX);
  display.display();
  delay(2000);
  display.clearDisplay();

  while(!Ozone.begin(Ozone_IICAddress)){
    Serial.println("I2c device number error !");
    delay(1000);
  }
  Serial.println("I2c connect success !");

  /**
   * set measuer mode
   * MEASURE_MODE_AUTOMATIC         active  mode
   * MEASURE_MODE_PASSIVE           passive mode
   */
    Ozone.setModes(MEASURE_MODE_PASSIVE);
  delay(5000);

//CO2
  Serial.begin(9600);
  bme.reset();
  Serial.println("bme read data test");
  while(bme.begin() != BME::eStatusOK) {
    Serial.println("bme begin faild");
    printLastOperateStatus(bme.lastOperateStatus);
    delay(2000);
  }
  Serial.println("bme begin success");
  delay(100);
  // Init the sensor
  while( NO_ERR != ENS160.begin() ){
    Serial.println("Communication with device failed, please check connection");
    delay(3000);
  }

  /**
   * Set power mode
   * mode Configurable power mode:
   *   ENS160_SLEEP_MODE: DEEP SLEEP mode (low power standby)
   *   ENS160_IDLE_MODE: IDLE mode (low-power)
   *   ENS160_STANDARD_MODE: STANDARD Gas Sensing Modes
   */
  ENS160.setPWRMode(ENS160_STANDARD_MODE);

  /**
   * Users write ambient temperature and relative humidity into ENS160 for calibration and compensation of the measured gas data.
   * ambientTemp Compensate the current ambient temperature, float type, unit: C
   * relativeHumidity Compensate the current ambient temperature, float type, unit: %rH
   */
  ENS160.setTempAndHum(/*temperature=*/bme.getTemperature(), /*humidity=*/bme.getHumidity());
  delay(5000);

//GASES
  Serial.begin(9600);
  while(!Serial);
  while(!mics.begin()){
    Serial.println("NO Deivces !");
    delay(1000);
  } Serial.println("Device connected successfully !");
  uint8_t mode = mics.getPowerState();
  if(mode == SLEEP_MODE){
    mics.wakeUpMode();
    Serial.println("wake up sensor success!");
  }else{
    Serial.println("The sensor is wake up mode");
  }
  delay(5000);


//PMS
    Serial.begin(9600);
    Serial.println("\nStart");

    pmsSerial.begin(9600,SERIAL_8N1, RX2, TX2);
    pms.begin(pmsSerial);
    //pms.wakeUp();
    pms.setMode(ACTIVE);   

}





void loop(){

  uint16_t ozoneConcentration = Ozone.readOzoneData(COLLECT_NUMBER);
  Serial.print("Ozone concentration is ");
  Serial.print(ozoneConcentration);
  Serial.println(" PPB.");
  delay(1000);
  Serial.println(" 2");

  carpeta = SD.open("/test.txt", FILE_APPEND);
  if (carpeta) 
  {
    carpeta.print(ozoneConcentration);
    carpeta.print(",");
    carpeta.print(ozoneConcentration);
    carpeta.print(",");
    carpeta.print(ozoneConcentration);
    carpeta.println(" ");
    carpeta.flush();
    carpeta.close();
  } 
  else
  {
    Serial.println("error opening test.txt");
  }


//CO2
  float   temp = bme.getTemperature();
  uint32_t    press = bme.getPressure();
  float   alti = bme.calAltitude(SEA_LEVEL_PRESSURE, press);
  float   humi = bme.getHumidity();

  Serial.println();
  Serial.println("======== start print ========");
  Serial.print("temperature (unit Celsius): "); Serial.println(temp);
  Serial.print("pressure (unit pa):         "); Serial.println(press);
  Serial.print("altitude (unit meter):      "); Serial.println(alti);
  Serial.print("humidity (unit percent):    "); Serial.println(humi);
  Serial.println("========  end print  ========");

  uint8_t Status = ENS160.getENS160Status();
  Serial.print("Sensor operating status : ");
  Serial.println(Status);

  uint8_t AQI = ENS160.getAQI();
  Serial.print("Air quality index : ");
  Serial.println(AQI);


  uint16_t TVOC = ENS160.getTVOC();
  Serial.print("Concentration of total volatile organic compounds : ");
  Serial.print(TVOC);
  Serial.println(" ppb");

  uint16_t ECO2 = ENS160.getECO2();
  Serial.print("Carbon dioxide equivalent concentration : ");
  Serial.print(ECO2);
  Serial.println(" ppm");
  Serial.println();

  delay(1000);
  
  //GASES
  int16_t red_data = 0;

  red_data = mics.getADCData(RED_MODE);
  if (red_data > 3.4f) {
    COO = 0.0;
  }
  else if (red_data < 0.01) {
    COO = 1000.0;
  }
  else {
  COO = 4.2/ pow(red_data,1.2);
  }
  Serial.print("CO = ");
  Serial.println(COO);

  delay(500);
//PMS

  pms.request();
    delay(500);
    if(!pms.read()){
        return;
    }
 
    Serial.print("PM1.0(CF1)\t");
    Serial.print(pms.getPmCf1(1.0));
    Serial.println("ug/m3");
    Serial.print("PM2.5(CF1)\t");
    Serial.print(pms.getPmCf1(2.5));
    Serial.println("ug/m3");
    Serial.print("PM10(CF1)\t");
    Serial.print(pms.getPmCf1(10));
    Serial.println("ug/m3");
    Serial.print("Formalde\t");
    Serial.print(pms.getForm());
    Serial.println("ug/m3");
    Serial.print("Temperat\t");
    Serial.print(pms.getTemp());
    Serial.println("'C");
    Serial.print("Humidity\t");
    Serial.print(pms.getHumi());
    Serial.println("%");
    Serial.println();
    
  delay(500);

}

And this is the code of the PMS alone that works.

#include "BLINKER_PMSX003ST.h"

#define RX2 14 // To sensor TXD
#define TX2 15 // To sensor RXD

HardwareSerial pmsSerial(2);// UART1/Serial1 pins 16,17

BLINKER_PMSX003ST pms;

void setup() {
    Serial.begin(9600);
    Serial.println("\nStart");

    pmsSerial.begin(9600,SERIAL_8N1, RX2, TX2);
    pms.begin(pmsSerial);
    //pms.wakeUp();
    pms.setMode(ACTIVE);
}
void loop() {
    pms.request();
    delay(500);
    if(!pms.read()){
        return;
    }
 
    Serial.print("PM1.0(CF1)\t");
    Serial.print(pms.getPmCf1(1.0));
    Serial.println("ug/m3");
    Serial.print("PM2.5(CF1)\t");
    Serial.print(pms.getPmCf1(2.5));
    Serial.println("ug/m3");
    Serial.print("PM10(CF1)\t");
    Serial.print(pms.getPmCf1(10));
    Serial.println("ug/m3");
    Serial.print("Formalde\t");
    Serial.print(pms.getForm());
    Serial.println("ug/m3");
    Serial.print("Temperat\t");
    Serial.print(pms.getTemp());
    Serial.println("'C");
    Serial.print("Humidity\t");
    Serial.print(pms.getHumi());
    Serial.println("%");
    Serial.println();
    
delay(500);
}

Please post schematics.

You are trying to use an invalid address. Run the ESP exception decoder to get the call trace source lines leading up to the error.


The schemathics are like this, i tried the code of the pms alone and works really well, but when joining it with the others is the problem(join on the Arduino ide).

The other 4 gave data just the pms that doesnt

How You do that? And where is that decoder? Im kinda a beginner at this

There is no powering of the build. Vin is an input pin for powering the controller. It can't be used as output.
also know that no microcontroller can be used for powering anything except for very low current using devices.


Is output that pin, here are the readings of PMS of the same conexión,

Hi @reyes_salomon0 ,

looked at this a few times..
a bit of a mess in your setup, you only have to Serial.begin once..
I'm guessing that pmsSerial does not begin and but it is still passed into the pms object..

these..

conflict..

Serial1 defaults to pins 16 and 17, maybe you can use them instead..
it's also why the SD is failing as well..

good luck.. ~q

Omg ty, i didnt notice I'll try it and I'll update you

1 Like

I change it and still nothing, it gives readings alone but no with the others

#include "BLINKER_PMSX003ST.h"

#define RX2 27 // To sensor TXD
#define TX2 26 // To sensor RXD

HardwareSerial pmsSerial(2);// UART1/Serial1 pins 16,17

BLINKER_PMSX003ST pms;

Well i upload the others codes to the pms and worked thanks y'all!

does it still crash??

those pins appear to be hooked up to the sim7000g..
try getting the pms working alone using the new pins before integrating back into the main sketch..

if you still having troubles, please post current revised code..

good luck.. ~q

lol, i was reply at same time.. :slight_smile:

I'll post it when i arrive at Home again.

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