Created
December 7, 2017 16:51
-
-
Save sankarcheppali/11357607e1036d2a4dd987212d0992e2 to your computer and use it in GitHub Desktop.
reads A0 pin data ,prepares a JSON and sends on serial line every 5 seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int id=99; | |
#include <SoftwareSerial.h> | |
SoftwareSerial sw(2, 3); // RX, TX | |
void setup() { | |
Serial.begin(115200); | |
Serial.println("Interfacfing arduino with nodemcu"); | |
sw.begin(115200); | |
} | |
void loop() { | |
Serial.println("Sending data to nodemcu"); | |
int adc=analogRead(A0); | |
Serial.print("{\"sensorid\":"); | |
Serial.print(id);//sensor id | |
Serial.print(","); | |
Serial.print("\"adcValue\":"); | |
Serial.print(adc);//offset | |
Serial.print("}"); | |
Serial.println(); | |
sw.print("{\"sensorid\":"); | |
sw.print(id);//sensor id | |
sw.print(","); | |
sw.print("\"adcValue\":"); | |
sw.print(adc);//offset | |
sw.print("}"); | |
sw.println(); | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment