Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino WB3S Software Serial #7

Open
ITstreet1 opened this issue Dec 15, 2021 · 14 comments
Open

Arduino WB3S Software Serial #7

ITstreet1 opened this issue Dec 15, 2021 · 14 comments

Comments

@ITstreet1
Copy link

Doing a few experiments with the WB3S module and Uno. How can I change default UART pins to, say, 6 and 7?

Can I work with WB3S using AT commands or in any other way, than the ones from your lib?

@shiliu-yang
Copy link
Contributor

  1. You can use the arduino's soft serial port.
    Example:
#include <TuyaWifi.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial= SoftwareSerial(5, 6);
TuyaWifi my_device(&mySerial);
...
void setup() 
{
...
  mySerial.begin(9600);
...
}
...

2.No support other commands

@oksimple
Copy link

c:\Users\jianzhichao\Documents\Arduino\libraries\Tuya_WiFi_MCU_SDK\src/TuyaWifi.h:47:5: note: candidate: 'TuyaWifi::TuyaWifi(HardwareSerial*)'
   47 |     TuyaWifi(TY_UART *serial);
      |     ^~~~~~~~
c:\Users\jianzhichao\Documents\Arduino\libraries\Tuya_WiFi_MCU_SDK\src/TuyaWifi.h:47:23: note:   no known conversion for argument 1 from 'SoftwareSerial*' to 'HardwareSerial*'
   47 |     TuyaWifi(TY_UART *serial);
c:\Users\jianzhichao\Documents\Arduino\libraries\Tuya_WiFi_MCU_SDK\src/TuyaWifi.h:46:5: note: candidate: 'TuyaWifi::TuyaWifi()'
   46 |     TuyaWifi(void);
      |     ^~~~~~~~
c:\Users\jianzhichao\Documents\Arduino\libraries\Tuya_WiFi_MCU_SDK\src/TuyaWifi.h:46:5: note:   candidate expects 0 arguments, 1 provided
c:\Users\jianzhichao\Documents\Arduino\libraries\Tuya_WiFi_MCU_SDK\src/TuyaWifi.h:43:7: note: candidate: 'constexpr TuyaWifi::TuyaWifi(const TuyaWifi&)'
   43 | class TuyaWifi
      |       ^~~~~~~~
c:\Users\jianzhichao\Documents\Arduino\libraries\Tuya_WiFi_MCU_SDK\src/TuyaWifi.h:43:7: note:   no known conversion for argument 1 from 'SoftwareSerial*' to 'const TuyaWifi&'
c:\Users\jianzhichao\Documents\Arduino\libraries\Tuya_WiFi_MCU_SDK\src/TuyaWifi.h:43:7: note: candidate: 'constexpr TuyaWifi::TuyaWifi(TuyaWifi&&)'
c:\Users\jianzhichao\Documents\Arduino\libraries\Tuya_WiFi_MCU_SDK\src/TuyaWifi.h:43:7: note:   no known conversion for argument 1 from 'SoftwareSerial*' to 'TuyaWifi&&'

exit status 1

Compilation error: no matching function for call to 'TuyaWifi::TuyaWifi(SoftwareSerial*)'

The way TuyaWifi modifies the software serial port does not seem to work correctly

@oksimple
Copy link

Switching to HardwareSerial will cause the output chip to get stuck.

@shiliu-yang
Copy link
Contributor

shiliu-yang commented Sep 26, 2023

Switching to HardwareSerial will cause the output chip to get stuck.

What MCU are you using to connect to the Tuya modules?

@oksimple
Copy link

切换到HardwareSerial会导致输出芯片卡住。

Switching to HardwareSerial will cause the output chip to get stuck.

What MCU are you using to connect to the Tuya modules?

STM32F103C8T6

@shiliu-yang
Copy link
Contributor

shiliu-yang commented Sep 26, 2023

Switching to HardwareSerial will cause the output chip to get stuck.

What MCU are you using to connect to the Tuya modules?

STM32F103C8T6

You can check if the version of the arduino library you are using is 0.0.3. In 0.0.3 he may not support SoftwareSerial.

Are you using the stm32 library https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json?

@oksimple
Copy link

Switching to HardwareSerial will cause the output chip to get stuck.

What MCU are you using to connect to the Tuya modules?

STM32F103C8T6

You can check if the version of the arduino library you are using is 0.0.3. In 0.0.3 he may not support SoftwareSerial.

Are you using the stm32 library https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json?

I confirmed that the V0.0.3 I was using, SoftwareSerial could not be used, so I switched to HardwareSerial, but it would cause my chip to freeze. This is part of my code. When the button is pressed, hello will be output, but this code will Causing my chip to get stuck.
if (btn_W_State == LOW) {
mySerial.println("Hello luke"); // Send data through the serial port
} else {
.....
}

@shiliu-yang
Copy link
Contributor

Switching to HardwareSerial will cause the output chip to get stuck.

What MCU are you using to connect to the Tuya modules?

STM32F103C8T6

You can check if the version of the arduino library you are using is 0.0.3. In 0.0.3 he may not support SoftwareSerial.
Are you using the stm32 library https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json?

I confirmed that the V0.0.3 I was using, SoftwareSerial could not be used, so I switched to HardwareSerial, but it would cause my chip to freeze. This is part of my code. When the button is pressed, hello will be output, but this code will Causing my chip to get stuck. if (btn_W_State == LOW) { mySerial.println("Hello luke"); // Send data through the serial port } else { ..... }

Can you post the full code?

@oksimple
Copy link

Switching to HardwareSerial will cause the output chip to get stuck.

What MCU are you using to connect to the Tuya modules?

STM32F103C8T6

You can check if the version of the arduino library you are using is 0.0.3. In 0.0.3 he may not support SoftwareSerial.
Are you using the stm32 library https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json?

I confirmed that the V0.0.3 I was using, SoftwareSerial could not be used, so I switched to HardwareSerial, but it would cause my chip to freeze. This is part of my code. When the button is pressed, hello will be output, but this code will Causing my chip to get stuck. if (btn_W_State == LOW) { mySerial.println("Hello luke"); // Send data through the serial port } else { ..... }

Can you post the full code?


#include <HardwareSerial.h>
#include <Arduino.h>
#include <TuyaWifi.h>
#include <TuyaUart.h>

#define LED_W_PIN PB2

//unsigned char pid[] = { "ma67l9sgmdyg3d2k" };
//unsigned char mcu_ver[] = { "1.0.0" };

// SoftwareSerial s1 = SoftwareSerial(PA9, PA10);

HardwareSerial mySerial = HardwareSerial(PA9, PA10);
TuyaWifi my_device(&mySerial);

void setup() {

  mySerial.begin(9600);

  // my_device.init(pid, mcu_ver);
}

void loop() {

  // my_device.uart_service();

  int btn_W_State = digitalRead(BUTTON_W_PIN); 

  if (btn_W_State == LOW) {
    mySerial.println("Hello luke");  
  } else {
    //....
  }

}

@shiliu-yang
Copy link
Contributor

Switching to HardwareSerial will cause the output chip to get stuck.

What MCU are you using to connect to the Tuya modules?

STM32F103C8T6

You can check if the version of the arduino library you are using is 0.0.3. In 0.0.3 he may not support SoftwareSerial.
Are you using the stm32 library https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json?

I confirmed that the V0.0.3 I was using, SoftwareSerial could not be used, so I switched to HardwareSerial, but it would cause my chip to freeze. This is part of my code. When the button is pressed, hello will be output, but this code will Causing my chip to get stuck. if (btn_W_State == LOW) { mySerial.println("Hello luke"); // Send data through the serial port } else { ..... }

Can you post the full code?


#include <HardwareSerial.h>
#include <Arduino.h>
#include <TuyaWifi.h>
#include <TuyaUart.h>

#define LED_W_PIN PB2

//unsigned char pid[] = { "ma67l9sgmdyg3d2k" };
//unsigned char mcu_ver[] = { "1.0.0" };

// SoftwareSerial s1 = SoftwareSerial(PA9, PA10);

HardwareSerial mySerial = HardwareSerial(PA9, PA10);
TuyaWifi my_device(&mySerial);

void setup() {

  mySerial.begin(9600);

  // my_device.init(pid, mcu_ver);
}

void loop() {

  // my_device.uart_service();

  int btn_W_State = digitalRead(BUTTON_W_PIN); 

  if (btn_W_State == LOW) {
    mySerial.println("Hello luke");  
  } else {
    //....
  }

}

Here you've added some header files that aren't necessary, and there are some initializations that are wrong and incomplete. You can start by looking at the https://github.com/tuya/tuya-wifi-mcu-sdk-arduino-library/blob/master/examples/start/start.ino

@shiliu-yang
Copy link
Contributor

Switching to HardwareSerial will cause the output chip to get stuck.

What MCU are you using to connect to the Tuya modules?

STM32F103C8T6

You can check if the version of the arduino library you are using is 0.0.3. In 0.0.3 he may not support SoftwareSerial.
Are you using the stm32 library https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json?

I confirmed that the V0.0.3 I was using, SoftwareSerial could not be used, so I switched to HardwareSerial, but it would cause my chip to freeze. This is part of my code. When the button is pressed, hello will be output, but this code will Causing my chip to get stuck. if (btn_W_State == LOW) { mySerial.println("Hello luke"); // Send data through the serial port } else { ..... }

Can you post the full code?


#include <HardwareSerial.h>
#include <Arduino.h>
#include <TuyaWifi.h>
#include <TuyaUart.h>

#define LED_W_PIN PB2

//unsigned char pid[] = { "ma67l9sgmdyg3d2k" };
//unsigned char mcu_ver[] = { "1.0.0" };

// SoftwareSerial s1 = SoftwareSerial(PA9, PA10);

HardwareSerial mySerial = HardwareSerial(PA9, PA10);
TuyaWifi my_device(&mySerial);

void setup() {

  mySerial.begin(9600);

  // my_device.init(pid, mcu_ver);
}

void loop() {

  // my_device.uart_service();

  int btn_W_State = digitalRead(BUTTON_W_PIN); 

  if (btn_W_State == LOW) {
    mySerial.println("Hello luke");  
  } else {
    //....
  }

}

About hardware serial port pin settings, you can refer to this topic: https://www.stm32duino.com/viewtopic.php?t=1446

@oksimple
Copy link

Switching to HardwareSerial will cause the output chip to get stuck.

What MCU are you using to connect to the Tuya modules?

STM32F103C8T6

You can check if the version of the arduino library you are using is 0.0.3. In 0.0.3 he may not support SoftwareSerial.
Are you using the stm32 library https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json?

I confirmed that the V0.0.3 I was using, SoftwareSerial could not be used, so I switched to HardwareSerial, but it would cause my chip to freeze. This is part of my code. When the button is pressed, hello will be output, but this code will Causing my chip to get stuck. if (btn_W_State == LOW) { mySerial.println("Hello luke"); // Send data through the serial port } else { ..... }

Can you post the full code?


#include <HardwareSerial.h>
#include <Arduino.h>
#include <TuyaWifi.h>
#include <TuyaUart.h>

#define LED_W_PIN PB2

//unsigned char pid[] = { "ma67l9sgmdyg3d2k" };
//unsigned char mcu_ver[] = { "1.0.0" };

// SoftwareSerial s1 = SoftwareSerial(PA9, PA10);

HardwareSerial mySerial = HardwareSerial(PA9, PA10);
TuyaWifi my_device(&mySerial);

void setup() {

  mySerial.begin(9600);

  // my_device.init(pid, mcu_ver);
}

void loop() {

  // my_device.uart_service();

  int btn_W_State = digitalRead(BUTTON_W_PIN); 

  if (btn_W_State == LOW) {
    mySerial.println("Hello luke");  
  } else {
    //....
  }

}

About hardware serial port pin settings, you can refer to this topic: https://www.stm32duino.com/viewtopic.php?t=1446

ok thanks i will try again and if i fix the problem i will come back and let everyone know

@oksimple
Copy link

Switching to HardwareSerial will cause the output chip to get stuck.

What MCU are you using to connect to the Tuya modules?

STM32F103C8T6

You can check if the version of the arduino library you are using is 0.0.3. In 0.0.3 he may not support SoftwareSerial.
Are you using the stm32 library https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json?

I confirmed that the V0.0.3 I was using, SoftwareSerial could not be used, so I switched to HardwareSerial, but it would cause my chip to freeze. This is part of my code. When the button is pressed, hello will be output, but this code will Causing my chip to get stuck. if (btn_W_State == LOW) { mySerial.println("Hello luke"); // Send data through the serial port } else { ..... }

Can you post the full code?


#include <HardwareSerial.h>
#include <Arduino.h>
#include <TuyaWifi.h>
#include <TuyaUart.h>

#define LED_W_PIN PB2

//unsigned char pid[] = { "ma67l9sgmdyg3d2k" };
//unsigned char mcu_ver[] = { "1.0.0" };

// SoftwareSerial s1 = SoftwareSerial(PA9, PA10);

HardwareSerial mySerial = HardwareSerial(PA9, PA10);
TuyaWifi my_device(&mySerial);

void setup() {

  mySerial.begin(9600);

  // my_device.init(pid, mcu_ver);
}

void loop() {

  // my_device.uart_service();

  int btn_W_State = digitalRead(BUTTON_W_PIN); 

  if (btn_W_State == LOW) {
    mySerial.println("Hello luke");  
  } else {
    //....
  }

}

About hardware serial port pin settings, you can refer to this topic: https://www.stm32duino.com/viewtopic.php?t=1446

Is it possible to use SoftwareSerial? Soft serial port

@shiliu-yang
Copy link
Contributor

Is it possible to use SoftwareSerial? Soft serial port

not support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants