Advertisement
chayanforyou

Arduino Serial Data Transfer

Jan 27th, 2022
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. //----------- NodeMCU Code -----------//
  2. #include<SoftwareSerial.h>
  3.  
  4. SoftwareSerial ss(5, 6);  // RX, TX
  5.  
  6. float myData = 123.45;
  7.  
  8. void setup() {
  9.   ss.begin(9600);
  10. }
  11.  
  12. void loop() {
  13.   ss.println(myData);
  14.   delay(500);
  15. }
  16.  
  17. //----------- Arduino Code -----------//
  18. float myData;
  19.  
  20. void setup() {
  21.   Serial.begin(9600);
  22. }
  23.  
  24. void loop() {
  25.   if (Serial.available()) {
  26.     myData = Serial.parseFloat();
  27.     Serial.print("Sensor Value: ");
  28.     Serial.println(myData);
  29.   }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement