We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Ciao, Guys.
Now I want to try Serial communication with Arduino using three kinds of sensor. There is no problem to check Values on Arduino, but I really don't know how can I read the data on Processing. I know this question is so stupid, please help me.
I using DHT sensor for Humidity and Temperature, a moisture sensor, and UV sensor. Here is my Arduino code.
#include "Adafruit_Sensor.h" #include "DHT.h" #include "DHT_U.h" #include "DHT.h" #define DHTPIN 2 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); } void loop() { delay(1500); int h = dht.readHumidity(); //for DHT11 int t = dht.readTemperature(); //for DHT11 int m = analogRead(A0); //for moisture sensor int u = analogRead(A1); // Serial.print("Humidity: "); Serial.print(h); // Serial.print(" %\t"); // Serial.print("Temperature: "); Serial.print(t); // Serial.println(" C"); // Serial.print("Moisture Sensor Value:"); Serial.println(m); // Serial.print("UV Value: "); Serial.println(u); }
Answers
sorry, I don't know why the font is too big..
https://forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text
https://forum.Processing.org/two/discussion/16618/processing-with-arduino-void-serialevent#Item_1
The font is big due to markdown (check the Markdown link at the bottom f any comment box here or in any post)
You can fix this by formatting your code properly in the forum. To do so, edit your post (gear icon on the top right corner of your post) and then highlight your code and hit ctrl+o. Ensure there is an empty line above and below your code.
Antoher relevant post: https://forum.processing.org/two/discussion/comment/88115/#Comment_88115
Kf
GoToLoop #kfrajer
Thank you so much, guys. Following your advice, finally, I can get the data from Arduino.
however, I have some problem with showing data on Processing windows(Java). now I can check data on Processing console, but it's only on the console. can you help me again, please?
it's my Arduino Code.
Processign Code.
You aren't using bufferUntil() + serialEvent() combo. L-)
And at your Arduino's C code, the last sent data should be w/ println() instead of just print(). :-\"
GoToLoop
Thanks, I'm a newbie on programming. Maybe it makes you little drawling. Can you explain about "befferUntil()+serialEvent() combo"?
I wanna show that data using "int"
After you add println() in your ino code at the end of each package, then in Processing you do this (un-tested):
Kf
I changed my code on Processing, but in this case showing data is "null".... I don't know why...
@yohan You are accessing your arduino data stream at two spots: line 15 and 24. It is better if you stick to one of the examples provided in previous posts or links that @GoToLoop shared before.
Personally, I will handle everything in serialEvent() and do all the sketch update on draw().
Kf
@kfrajer
Finally, I can get information from Arduino to Processing, and It works. But, It has still a problem. The value on the con?ole in Processing is not steady, sometimes it is changed. At the first time it works, but after 3~4 second it was mixed. Can you help me, please?
Arduino code
Processing code