Code for BMP280 sensor added, but still disabled
This commit is contained in:
@@ -4,7 +4,13 @@
|
||||
* It can measure wind speed, wind gust , wind direction, rain fall, temperature,
|
||||
* humidity and air pressure and has an RS-485 ModBus interface for your convenience.
|
||||
*
|
||||
* (C)2023 M.T. Konstapel https://meezenest.nl/mees
|
||||
* LED on Arduino gives status:
|
||||
*
|
||||
* ON : Booting
|
||||
* BLINK : I2C ERROR
|
||||
* FLASH : Heartbeat
|
||||
*
|
||||
* Copyright (C) 2023 M.T. Konstapel https://meezenest.nl/mees
|
||||
*
|
||||
* This file is part of weather_station
|
||||
*
|
||||
@@ -29,10 +35,14 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
//Temperature and humidit sensor
|
||||
//Temperature and humidity sensor
|
||||
#include "i2c_SI7021.h"
|
||||
SI7021 si7021;
|
||||
|
||||
// Pressure sensor
|
||||
#include "i2c_BMP280.h"
|
||||
BMP280 bmp280;
|
||||
|
||||
/**************************/
|
||||
/* Configurable variables */
|
||||
/**************************/
|
||||
@@ -137,6 +147,25 @@ void ReadSi7021 (void)
|
||||
|
||||
}
|
||||
|
||||
// Read BMP280
|
||||
void ReadBMP280 (void)
|
||||
{
|
||||
MeasuredData.Pressure=0;
|
||||
/*
|
||||
bmp280.awaitMeasurement();
|
||||
|
||||
float temperature;
|
||||
bmp280.getTemperature(temperature);
|
||||
|
||||
float pascal;
|
||||
bmp280.getPressure(pascal);
|
||||
|
||||
MeasuredData.Pressure = pascal;
|
||||
|
||||
bmp280.triggerMeasurement();
|
||||
*/
|
||||
}
|
||||
|
||||
int MaxOfArray (int array[], unsigned int length)
|
||||
{
|
||||
int maximum_value = 0;
|
||||
@@ -254,6 +283,10 @@ void setup() {
|
||||
// prefer the line below instead if possible
|
||||
// MySerial.begin (Baudrate, MB_PARITY_EVEN);
|
||||
|
||||
// initialize digital pin LED_BUILTIN as an output and turn it on.
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
//Setup control lines for RS485 driver
|
||||
pinMode(RS485_RE,INPUT); // In hardware connected to RS485_DE. Should be input to prevent a short circuit!
|
||||
pinMode(RS485_DE,OUTPUT);
|
||||
@@ -276,7 +309,9 @@ void setup() {
|
||||
|
||||
// Set Weather station ID
|
||||
mb.Ireg (SensorIDIreg, 0x5758);
|
||||
|
||||
// Set unused register to zero
|
||||
mb.Ireg (SensorRainSinceMidnightIreg, 0);
|
||||
|
||||
Serial.println(F("Weather station"));
|
||||
|
||||
//Initialize Si7021 sensor
|
||||
@@ -286,9 +321,33 @@ void setup() {
|
||||
else
|
||||
{
|
||||
Serial.println(F("missing"));
|
||||
while(1) {};
|
||||
while(1) {
|
||||
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
delay(500); // wait for half a second
|
||||
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
|
||||
delay(500);
|
||||
}
|
||||
}
|
||||
|
||||
/* // Initialize BMP280 pressure sensor
|
||||
Serial.print(F("Pressure sensor BMP280 "));
|
||||
if (bmp280.initialize())
|
||||
Serial.println(F("found"));
|
||||
else
|
||||
{
|
||||
Serial.println(F("missing"));
|
||||
while(1) {
|
||||
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
delay(500); // wait for half a second
|
||||
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
|
||||
delay(500);
|
||||
}
|
||||
}
|
||||
|
||||
// onetime-measure:
|
||||
bmp280.setEnabled(0);
|
||||
bmp280.triggerMeasurement();
|
||||
*/
|
||||
// Expected ADC values have been defined for various platforms in the
|
||||
// library, however your platform may not be included. This code will check
|
||||
// if that's the case
|
||||
@@ -299,11 +358,11 @@ void setup() {
|
||||
// resolution, so you'll need to specify it here:
|
||||
weatherMeterKit.setADCResolutionBits(10);
|
||||
#endif
|
||||
// Begin weather meter kit
|
||||
weatherMeterKit.begin();
|
||||
// Begin weather meter kit
|
||||
weatherMeterKit.begin();
|
||||
|
||||
ts = millis();
|
||||
RainPerHourCounter = ts;
|
||||
ts = millis();
|
||||
RainPerHourCounter = ts;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -316,9 +375,14 @@ void loop() {
|
||||
|
||||
ts = millis();
|
||||
|
||||
digitalWrite(LED_BUILTIN, HIGH); // LED as heartbeat
|
||||
|
||||
// Read temperature and humidity
|
||||
ReadSi7021();
|
||||
|
||||
// Read pressure and temperature
|
||||
ReadBMP280();
|
||||
|
||||
// Read Wind and rain
|
||||
ReadSparkfunWeatherStation();
|
||||
|
||||
@@ -330,6 +394,10 @@ void loop() {
|
||||
mb.Ireg (SensorRainLast24Ireg, MeasuredData.RainLast24);
|
||||
mb.Ireg (SensorTemperatureIreg, MeasuredData.Temperature);
|
||||
mb.Ireg (SensorHumidityIreg, MeasuredData.Humidity);
|
||||
mb.Ireg (SensorPressureIreg, MeasuredData.Pressure);
|
||||
|
||||
digitalWrite(LED_BUILTIN, LOW); // LED as heartbeat
|
||||
|
||||
|
||||
}
|
||||
}
|
Binary file not shown.
@@ -6,7 +6,7 @@
|
||||
|
||||
(title_block
|
||||
(title "DS-15901 weather station interface with RS-485 ModBus")
|
||||
(date "2023-12-23")
|
||||
(date "2023-12-29")
|
||||
(rev "A")
|
||||
(company "Mees Electronics")
|
||||
(comment 1 "M.T. Konstapel")
|
||||
|
Binary file not shown.
@@ -607,6 +607,7 @@ else:
|
||||
rawdat['Rain last 24 hours'] = controller.get_rain_last24()
|
||||
rawdat['Temperature'] = controller.get_temperature()
|
||||
rawdat['Humidity'] = controller.get_humidity()
|
||||
rawdat['Pressure'] = controller.get_pressure()
|
||||
|
||||
print (json.dumps(rawdat, indent=1, sort_keys=False))
|
||||
|
||||
|
Reference in New Issue
Block a user