-1

The modules are the following: https://imgur.com/a/HrzpvdR This is their respective AlieExpress page: https://aliexpress.com/item/4000317884559.html?gatewayAdapt=glo2nld I am trying to send test through C# to my Arduino but once I actually send it over, the following is being received:

tststststteteteteteteteteteteteteeeeeeeeeeeseeeeeeeeeeeeee

This tells me that the connection works and data is actually being received but there's something wrong with either sending or receiving. I'm personally guessing something being wrong with sending but I'm not sure.

What could I try in order to receive just plain "test"?

The C# code:

using System.IO.Ports;

namespace ArduinoCom

{
    class Program
    {
        static void Main(string[] args)
        {
            SerialPort port = new SerialPort("COM3", 115200, Parity.None, 6);

            port.Open();
            bool run = true;
            int counter = 0;

        for (int i = 0; i < 1000; i++)
        {
            port.Write("test");
        }
        port.Dispose();
        port.Close();
       }
    } 
}

The Arduino code is as follows:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <I2C_LCD.h>

I2C_LCD LCD;
uint8_t I2C_LCD_ADDRESS = 0x51; //Device address setting, default: 0x51
SoftwareSerial mySerial(0, 1); // RX, TX

RF24 radio(7, 8); // CE, CSN

void setup() {
  Serial.begin(115200);
  Wire.begin();
  Serial1.begin(115200);

}

void loop() {
  LCD.CleanAll(WHITE);
  LCD.FontModeConf(Font_6x8, FM_ANL_AAA, BLACK_BAC);
  if (Serial1.available()) {
      {
        Serial.print((char)Serial1.read());
        LCD.DispStringAt((char)Serial1.read(), 0, 10);
      }
  }
}
5
  • reduce the data rate and insert pauses
    – jsotola
    May 12 at 15:19
  • @jsotola I appreciate your effort but this is the type of comment which glosses over too much information which might be vital. Sure I can reduce it to 9600 and add a delay but why would I want that?
    – CCG
    May 12 at 15:26
  • 1
    because that is basic debugging process ... the received data seems to indicate that the receiver is being swamped ... try to bring the system into a working state by slowing down the transmit rate ... then start increasing data rate until it breaks again ... that will give you an indication where the system is failing
    – jsotola
    May 12 at 15:47
  • What jsotola wants to say is to fix the problem, you first need to know what the problem is. And by reducing the data rate/insert pauses you know if it related to timing. May 12 at 18:03
  • Why have you defined an instance of SoftwareSerial on the same pins as Serial for the Leonardo ? As far as I can understand from the description in the Aliexpress link, a pair of those NRF24L01 devices create an end to end serial data link between themselves. That is, there is no need for the NRF24L01 specific definitions in your code. Assuming you have configured the radio parts to operate at 115200 baud then one possible problem is that the LCD screen is too slow to handle the expected data rate causing a serial buffer overflow. Comment out the write attempt to see if that is the problem.
    – 6v6gt
    May 13 at 12:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.