Hello, i am new to arduino and currently seeking guidance on how to proceed.
my project uses 3 ACS712 sensor connected to UNO to detect current flowing through and then send the data to ThingSpeak using Wemos D1 R2 as the internet.
so far i managed to send the sensor data to wemos via serial communication, the problem is i don't know whether the data sent to the wemos corresponds to the sensor it belongs to.
if(Serial.available()){
sensor1 = Serial.parseFloat(); //receiver float data that SHOULD BE coming from SENSOR 1
delay(1000);
sensor2 = Serial.parseFloat(); //receiver float data that SHOULD BE coming from SENSOR 2
delay(1000);
sensor3 = Serial.parseFloat(); //receiver float data that SHOULD BE coming from SENSOR 3
delay(1000);
}
unfortunately i can't ascertain if its actually receiving from the correct sensor or actually overwriting each other. Since i need to upload all 3 data to thingspeak every 20sec interval, i don't want to get the wrong data.
how should i manage this problem? and how do i implement it in my code?
Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.
The way you are sending and receiving the data in the programs in your Original Post you have no means to know which item of data is which. Look at how it is done in the 3rd example in my tutorial. You can send data in a compatible format like this
Robin2:
Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.
The way you are sending and receiving the data in the programs in your Original Post you have no means to know which item of data is which. Look at how it is done in the 3rd example in my tutorial. You can send data in a compatible format like this
Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker
...R
Thanks for replying and sorry for not replying so long.
i kinda get how to receive it by using the marker example but the problem is the sensor data needed to upload to thingspeak needed to be converted into string. since i only know how to upload all three values instead of one each time, its hard to convert value of each array into string.
i used the code in Serial input basics in example 3 and
this is what i can think of:
but this code might get the wrong data to upload since i just guessing which index the data belong to also how to empty the receivedString array after i get all the data then uploaded it.
AndiAkF:
i kinda get how to receive it by using the marker example but the problem is the sensor data needed to upload to thingspeak needed to be converted into string.
Your problem seems to be in your function uploadThingSepak(); but you did not post that.
String s1 = receivedString[0]; // this line should get the sensor 1 value but idk which index
String s2 = receivedString[2]; // this line should get the sensor 2 value but idk which index
String s3 = receivedString[4]; // this line should get the sensor 3 value but idk which index
but how do i empty "receivedString" array when serial received the end marker?, i tried using the same line with "receivedChar" but it doesn't work.
i think its fine not to empty it since it reset the index to 0, but just in case.
and how do i identify which data i want it "receivedString" array?, the code above is just a guess.
AndiAkF:
Hello, i am new to arduino and currently seeking guidance on how to proceed.
my project uses 3 ACS712 sensor connected to UNO to detect current flowing through and then send the data to ThingSpeak using Wemos D1 R2 as the internet.