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)
if (myserial.available()){ Serial.write(myserial.read()); }
. And delete the rest of the code in the loop() routine.