0
votes

I have Wifi module hlk-rm04 connected to my arduino UNO. Wifi module sends data to udp server when it has data in rx buffer.

It works when I typing data directly in serial monitor window and clicking send button.

But when I use Serial.print() or Serial.write data is not sending.

Is there any difference between Serial.print() and typing and clicking send button, and how can I program it?

Testing code witch every second should send random value + Hello

unsigned long time0;

void setup() {
  Serial.begin(115200);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  time0= millis();
}

void loop() {
time0 = millis();
if ((time0 % 1000) == 20)
    {
    Serial.print(random(0, 10));
    Serial.print("Hello");
    Serial.print(("_____________________________"));    
    delay(2);}    
}
1

1 Answers

1
votes

When you use serial.print, you display something in the serial monitor. When you type something in the serial monitor and send it, it goes to the arduino. Rx means receive. It is used when the arduino is receiving something. When you serial.print you are transmitting something (tx). I hope this clears things up for you. Happy coding!