1

I need help with an Arduino project. I want to read values from a TCS150 scale using the serial port. The hardware I have is an UNO R3 board and a MAX3232 level converter.

I have connected:

MAX3232 power supply - 5V from UNO R3 TX -> D10 When checking the voltage on the TX cable connected to UNO, it varies between 3.5V and 4.2V, so there shouldn't be any connection problem. I tried to upload a simple program as shown in the picture, but I can't receive any values So far, I haven't found a solution. The incoming data when I plugged in scale to computer via Putty is correct. Do you know where I might have made a mistake in connecting or programming the Arduino?

Program:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,-1);  // -1 if not using TX to save a pin

void setup()
{
   Serial.begin(9600);
   Serial.println("<Arduino is ready>");
   mySerial.begin(9600);
}

void loop()
{
  if(Serial.available()) {
    Serial.println("serial available");
  } else {
    Serial.println("serial not available");
  }

  if(mySerial.available()) {
    Serial.println("myserial available");
  } else {
    Serial.println("myserial not available");
  }
  string x = mySerial.readString();
  Serial.println(x);
  delay(1000);
}

The output is:
-> serial not available
-> myserial not available
-> ? (question mark in rhombus)
2
  • Quick comment: It looks like you are trying to open a hardware serial port and a software serial port. Two serial ports! Is that what you really wanted to do?
    – st2000
    Mar 21, 2023 at 12:51
  • @st2000 I think Konrad wants to read from a scale TCS150 and forward the reading to the Arduino Terminal. So both channel are required. The Serial.available if statement is not needed, there is no writing from the terminal to the Arduino. I would do it like if (myserial.available()){ Serial.write(myserial.read()); }. And delete the rest of the code in the loop() routine. Mar 21, 2023 at 13:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.