You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
887 B

#include <SoftwareSerial.h>
#include <Wire.h>
#include <BME280I2C.h>
#define ENABLE_PIN1 8 // dir
#define ENABLE_PIN2 9 // speed
#define SERIAL_RO 10
#define SERIAL_DI 11
BME280I2C bme;
//const int enable[] = {ENABLE_PIN1, ENABLE_PIN1};
const byte codes[] = {0x01 ,0x03 ,0x00 ,0x00 ,0x00 ,0x02 ,0xC4 ,0x0B};
byte values[2][20];
SoftwareSerial sensor(SERIAL_RO, SERIAL_DI);
int windSpeed = 0;
int windDirection = 0;
float temperature = 0;
float humidity = 0;
float pressure = 0;
void setup() {
// Initialize Serial Monitor for debugging
Serial.begin(9600);
while(!Serial);
// Initialize a SoftwareSerial
sensor.begin(4800);
delay(500);
pinMode(ENABLE_PIN1, OUTPUT);
pinMode(ENABLE_PIN2, OUTPUT);
}
void loop() {
getWind();
Serial.print("Direction: ");
Serial.println(windDirection);
Serial.print("Speed: ");
Serial.println(windSpeed);
delay(5000);
}