Hola que tal necesito ayuda sobre como incorporar XBEE a mi codigo IDE en arduino , el proyecto inicial es una red de sensores donde 1 coordinador reciba la informacion de dos dispositivos finales que tienen un sesor de humedad y temperatura y asu vez una LCD que muestra los datos , los modulos estan configurados pero no entiendo como agregar XBEE a mi codigo
`#include <LiquidCrystal.h>
#include <DHT.h>
#include <DHT_U.h>
#include <XBee.h>
int rs = 12;
int e = 11;
int d4 = 5;
int d5 = 4;
int d6 = 3;
int d7 = 2;
int dTime = 500;
LiquidCrystal lcd(rs, e, d4, d5, d6, d7);
#define Type DHT22
int dhtPin = 8;
DHT HT(dhtPin, Type);
int humidity;
float tempC;
float tempF;
XBee xbee = XBee();
union {
float fval;
byte b[4];
} u;
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
HT.begin();
xbee.setSerial(Serial);
}
void loop() {
humidity = HT.readHumidity();
tempC = HT.readTemperature();
uint8_t payload[8];
for(int i=0; i<4; i++) {
u.fval = humidity;
payload[i] = u.b[i];
u.fval = tempC;
payload[i+4] = u.b[i];
}
XBeeAddress64 addr64_device1 = XBeeAddress64(0x0013a200, 0x406F5762);
ZBTxRequest zbTx_device1 = ZBTxRequest(addr64_device1, payload, sizeof(payload));
xbee.send(zbTx_device1);
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("% / Temperature: ");
Serial.print(tempC);
Serial.print("*C / ");
Serial.print(tempF);
Serial.println("*F");
lcd.setCursor(0, 0);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Temp: ");
lcd.print(tempC);
lcd.print("*C");
delay(dTime);
lcd.clear();
}`
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
#include <DHT.h>
#include <DHT_U.h>
#include <XBee.h>
int rs = 12;
int e = 11;
int d4 = 5;
int d5 = 4;
int d6 = 3;
int d7 = 2;
int dTime = 500;
LiquidCrystal lcd(rs, e, d4, d5, d6, d7);
#define Type DHT22
int dhtPin = 8;
DHT HT(dhtPin, Type);
int humidity;
float tempC;
float tempF;
SoftwareSerial xbeeSerial(0, 1); // RX, TX
XBee xbee = XBee();
union {
float fval;
byte b[4];
} u;
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
HT.begin();
xbee.setSerial(Serial);
}
void loop() {
humidity = HT.readHumidity();
tempC = HT.readTemperature();
uint8_t payload[8];
for(int i=0; i<4; i++) {
u.fval = humidity;
payload[i+4] = u.b[i];
u.fval = tempC;
payload[i+8] = u.b[i];
}
XBeeAddress64 addr64_device1 = XBeeAddress64(0x0013A200, 0x407C994E);
ZBTxRequest zbTx_device1 = ZBTxRequest(addr64_device1, payload, sizeof(payload));
xbee.send(zbTx_device1);
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("% / Temperature: ");
Serial.print(tempC);
Serial.print("*C / ");
Serial.print(tempF);
Serial.println("*F");
lcd.setCursor(0, 0);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Temp: ");
lcd.print(tempC);
lcd.print("*C");
delay(dTime);
lcd.clear();
}
Este es otro código pero nunca he trabajado con Xbee por lo tanto no se.
Editado por moderador usando minúsculas
pert
March 31, 2024, 7:55pm
3
He trasladado su tema de una categoría de idioma inglés del foro a la categoría International > Español @vbermanm .
En adelante por favor usar la categoría apropiada a la lengua en que queráis publicar. Esto es importante para el uso responsable del foro, y esta explicado aquí la guía "How to get the best out of this forum " .
Este guía contiene mucha información útil. Por favor leer.
De antemano, muchas gracias por cooperar.
Moderador:
Por favor, lee las Normas del foro y edita tu código/error usando etiquetas de código.
Ve a edición, luego selecciona todo el código que has publicado, lo cortas y click en (<CODE/> )
Hola buenas noches ya lo acomodé!!!gracias y feliz noche
system
Closed
September 28, 2024, 4:07am
6
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.