Skip to content

Instantly share code, notes, and snippets.

@dorukgezici
Created September 12, 2017 23:27
Show Gist options
  • Save dorukgezici/1e39786667038c29ec7798abc0767489 to your computer and use it in GitHub Desktop.
Save dorukgezici/1e39786667038c29ec7798abc0767489 to your computer and use it in GitHub Desktop.
Sending sensor data to RX output using Software Serial.
#include <arduino.h>
#include <SoftwareSerial.h>
#define TEMP_PIN A0
float temp;
SoftwareSerial mySerial(D6, D7); // RX, TX
void setup() {
Serial.begin(115200); // tty.wchusbserial14130
mySerial.begin(4800); // tty.wchusbserial14110
}
void loop() {
temp = analogRead(TEMP_PIN);
temp = temp * (3*100)/1024; // (Voltage*100)/1024
Serial.print("TEMPERATURE = ");
Serial.print(temp);
Serial.println(" C");
mySerial.println(temp);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment