problem with HardwareSerial

AugustQ
Posts: 2
Joined: Mon Apr 13, 2020 2:03 pm

problem with HardwareSerial

Postby AugustQ » Tue Apr 14, 2020 11:59 am

Hi,

I'm new here and I do not know if this is the right forum here. But I do have problems with HardwareSerial. So I want to ask: what's wrong with my code?

Here is a stripped down version of my code:

Code: Select all

#include "HardwareSerial.h"
#include "SDS011.h"

HardwareSerial sdsSerial(2);

#define ESP_PIN_TX  12 // 35
#define ESP_PIN_RX  13 // 34

SDS011 sdsSensor;      
float pm10, pm25;

void setup()
{
    Serial.begin(115200);
    pinMode(ESP_PIN_TX, OUTPUT);
    pinMode(ESP_PIN_RX, INPUT);

    sdsSerial.begin(9600, SERIAL_8N1, ESP_PIN_RX, ESP_PIN_TX);
    // in the following line it crashes:
    sdsSensor.begin (&sdsSerial);
    Serial.println("SDS011 start stop and reporting sample");
}

void loop()
{
    Serial.println("set sleep");
    ........
}
and this is what I see in the serial monitor:
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun 8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
HardwareSerial::end()
What Is wrong here?

This is the board I am using: https://de.aliexpress.com/item/32915894264.html
I added an SDS011, a sensor for measuring fine-dust particles.

I'm using this library: https://github.com/ricki-z/SDS011

This software runs on an Arduino Mega 2560 without any problems, after some minor modifications.

Thanks.

PS: I'm coming from the software-side, so I have (practically) no knowledge about the hardware.

AugustQ
Posts: 2
Joined: Mon Apr 13, 2020 2:03 pm

Re: problem with HardwareSerial

Postby AugustQ » Tue Apr 14, 2020 1:01 pm

OK, my fault, in parts. But it still does not work.

My fault:
I got the latest version of the library and modified my code to use

Code: Select all

//    sdsSerial.begin(9600, SERIAL_8N1, ESP_PIN_RX, ESP_PIN_TX);
//    sdsSensor.begin (&sdsSerial);          // <== crashes here
    sdsSensor.begin( &sdsSerial, ESP_PIN_RX, ESP_PIN_TX);
Now it does not crash anymore.

But it still does not work:
in loop() I'm using sdsSensor.sleep() and sdsSensor.wakeup() which do not work.
This worked fine on the Arduino Mega 2560.

On the ESP-board I swapped the definition of RX and TX: did not work. I changed the pins used for RX and TX: did not work.

Can you please give me a tip what's wrong here.
Thanks.

Who is online

Users browsing this forum: No registered users and 177 guests