Home › Forums › EasyTransfer Library Support Forum › Determening When Data Is Received Or Not
- This topic has 1 reply, 1 voice, and was last updated 10 years, 9 months ago by Anonymous.
-
AuthorPosts
-
February 25, 2014 at 6:36 pm #3133AnonymousInactive
Hi all!
I’m working on a project where multiple Arduino’s feed back sensor info to a main Arduino Mega 2560, which then data display, etc. functions.
Sometimes one of my Arduino boards, for a reason I have yet to figure out yet, will freeze up and stop sending data, activating outputs… Working all together. What I’d like to do is when expected data from one of the “slave” Arduinos doesn’t come in to the Mega after so many set seconds or cycles, the Mega will use an IO to reset the halted Arduino.
I’m a novice to programming and electronics so any help to get me started in the right direction would be really helpful. I just can’t seem to figure out how to manipulate the code to do this. I’m thinking it would be with using the ET.Receive function and then the specific assigned data strings.
Thanks!
February 25, 2014 at 6:38 pm #3134AnonymousInactiveForgot, here is my code.
[quote]
#include <EasyTransfer.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>//create object
EasyTransfer ET;
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set LCD I2C Address and line sizestruct RECEIVE_DATA_STRUCTURE{
//put your variable definitions here for the data you want to receive
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
int roomTemp;
int roomHumidity;
int leftTemp;
int leftHumidity;
int rightTemp;
int rightHumidity;
int co2Value;
int co2_error;};
///////////////////////////////////////////
int co2Value_Clear;//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;void setup(){
lcd.init();
lcd.backlight();
Serial.begin(9600);
//start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
ET.begin(details(mydata), &Serial);}
void loop(){
co2Value_Clear = mydata.co2Value;//check and see if a data packet has come in.
if(ET.receiveData()){
//this is how you access the variables. [name of the group].[variable name]
//since we have data, we will blink it out.}
//LCD Print Out
//lcd.clear();
lcd.setCursor(0,0);
lcd.print(“R:”);
lcd.print(mydata.roomTemp, 1);
lcd.print(“F”);
lcd.setCursor(6,0);
lcd.print(mydata.roomHumidity, 1);
lcd.print(“%”);if(mydata.co2Value < 1000 && co2Value_Clear >= 1000){
lcd.clear();
}
lcd.setCursor(10,0);
lcd.print(mydata.co2Value);if(mydata.co2_error > 9){
lcd.setCursor(14,0);
}
else{
lcd.setCursor(15,0);
}
lcd.print(mydata.co2_error);//lcd.print(“ppm”);
lcd.setCursor(0,1);
lcd.print(“L:”);
lcd.print(mydata.leftTemp);
lcd.setCursor(5,1);
lcd.print(mydata.leftHumidity);
lcd.setCursor(8,1);
lcd.print(“R:”);
lcd.print(mydata.rightTemp);
lcd.setCursor(13,1);
lcd.print(mydata.rightHumidity);
///////////////////////////////////////////////////////////////////////
/*
//Room DHT22/CO2
Serial.println(“———————————–“);
Serial.println(” Room Conditions:”);
Serial.print(“* Temp: “);
Serial.print(mydata.roomTemp, 1);
Serial.print(“\t”);
Serial.print(“Humidity: “);
Serial.print(mydata.roomHumidity, 1);
Serial.println(“%”);
Serial.print(“* CO2: “);
Serial.print(mydata.co2Value);
Serial.print(“ppm”);
Serial.print(“\t”);
Serial.println(“\n”);Serial.println(” Canopy Conditions”);
//Canopy Left DHT22
Serial.println(“Left: “);
Serial.print(“* Temp: “);
Serial.print(mydata.leftTemp, 1);
Serial.print(“F”);
Serial.print(“\t”);
Serial.print(“Humidity: “);
Serial.print(mydata.leftHumidity, 1);
Serial.println(“%”);
//Canopy Right DHT22
Serial.println(“Right: “);
Serial.print(“* Temp: “);
Serial.print(mydata.rightTemp, 1);
Serial.print(“F”);
Serial.print(“\t”);
Serial.print(“Humidity: “);
Serial.print(mydata.rightHumidity, 1);
Serial.println(“%”);
Serial.print(“————————————-“);
*/
delay(100);}
[/quote]
-
AuthorPosts
- You must be logged in to reply to this topic.