Skip to content

Commit

Permalink
Bug fixes (#57)
Browse files Browse the repository at this point in the history
* SQM feature. Code cleaning. Remove explicit use of String class which causes random bugs

* Update for the 1.2 branch

* Update README.md

* Got the old breadboard design

* Got the old BOM

* Reference for lux to W/m2

* Using referenced formulas for SQM

* MSAS cannot be negative

* Code cleaning

* Initial commit of 1.3

* Removed required commented code and a couple of bugs

* Small fixes

* Created 2.0 after changes in relays and their commands. Bigger perfboard.

* Fixed glitches

* Big refactoring: do not power sensors in case of rain event / Use of HW config

* Update README.md

* Update BOM

* Update README.md

* Fixed bug in runtime config management causing crash. Minor improvements

* Add SN74AHCT125 and LM7805 to output 5V. Replace mosfets to match the new 5V output

* Update README.md

* Added pictures of the perfboard

* Re-exported perfboard pictures as jpg

* Added some debug info. Changed GPIO pins to match the new HW design

* JsonDocument size increased to accomodate new OTA parameters reporting. Couple of cosmetic changes

* Minor improvements. Capability to disable sensors in runtime config

* Major rework, OO design. WIP.

* housekeeping

* Update README.md

* Code cleanup. Added support for ultrasonic wind sensor VMS-3003-CFSFX-N01. Fixed IP or DHCP for wifi. Thread for sensor readings

* 12V version: gerber and schematics

* 12V:add pcb view

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* AWSGPS files

* Cleanup

* Update README.md

* Update README.md

* Close #4 #5 #8 #11 #12 #16

* Added one dome status input pin, small part moves and added ground fill

* Close #1 #8 #9 #10 #11 #12 #16 #18 #19 #27 #29

* Small fixes after merge with main

* Close #34, Close #40, Close #35, Close #35, Close #37, Close #38, Close #39, Close #40, Close #41

* Close #22, #43, #44, #45, #47
  • Loading branch information
switux authored Dec 25, 2023
1 parent d9b88ca commit ecede07
Show file tree
Hide file tree
Showing 29 changed files with 962 additions and 834 deletions.
193 changes: 113 additions & 80 deletions src/AWS.cpp

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions src/AWS.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
#ifndef _AWS_H
#define _AWS_H

#undef CONFIG_DISABLE_HAL_LOCKS
#define _ASYNC_WEBSERVER_LOGLEVEL_ 0
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 0
#include "AWSWeb.h"
#include "AWSSensorManager.h"
#include "dome.h"
#include "alpaca.h"

void OTA_callback( int, int );

Expand All @@ -38,7 +39,7 @@ class AstroWeatherStation {
solar_panel;
char *json_sensor_data;
char uptime[32];
uint8_t eth_mac[6] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED },
uint8_t eth_mac[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF },
wifi_mac[6];

EthernetClient *ethernet;
Expand All @@ -60,7 +61,7 @@ class AstroWeatherStation {

TaskHandle_t aws_periodic_task_handle;

AWSSensorManager sensor_manager;
AWSSensorManager *sensor_manager;
AWSConfig *config;
AWSWebServer *server;
alpaca_server *alpaca;
Expand Down Expand Up @@ -91,6 +92,10 @@ class AstroWeatherStation {
bool startup_sanity_check( void );
bool stop_hotspot( void );
void wakeup_reason_to_string( esp_sleep_wakeup_cause_t, char * );
char *ota_board;
char *ota_device;
char *ota_config;


public:

Expand Down
108 changes: 45 additions & 63 deletions src/AWSConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,14 @@
You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#undef CONFIG_DISABLE_HAL_LOCKS
#define _ASYNC_WEBSERVER_LOGLEVEL_ 0
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 0
#define ASYNCWEBSERVER_REGEX 1

#include <Ethernet.h>
#include <SSLClient.h>
#include <time.h>
#include <FS.h>
#include <SPIFFS.h>
#include <ArduinoJson.h>

#include <AsyncUDP_ESP32_W5500.hpp>
#include <ESPAsyncWebSrv.h>
#include <SoftwareSerial.h>
#include <TinyGPSPlus.h>
#include <FS.h>
#include <SPIFFS.h>

#include "defaults.h"
#include "SC16IS750.h"
#include "AWSGPS.h"
#include "AstroWeatherStation.h"
#include "SQM.h"
#include "AWSSensorManager.h"
#include "AWSWeb.h"
#include "dome.h"
#include "alpaca.h"
#include "AWSConfig.h"
#include "AWS.h"

Expand Down Expand Up @@ -159,9 +142,9 @@ bool AWSConfig::get_has_mlx( void )
return has_mlx;
}

bool AWSConfig::get_has_rg9( void )
bool AWSConfig::get_has_rain_sensor( void )
{
return has_rg9;
return has_rain_sensor;
}

bool AWSConfig::get_has_sc16is750( void )
Expand Down Expand Up @@ -244,7 +227,7 @@ char *AWSConfig::get_json_string_config( void )
aws_json_config["anemometer_model"] = anemometer_model;
aws_json_config["has_wv"] = has_wv;
aws_json_config["windvane_model"] = wind_vane_model;
aws_json_config["has_rg9"] = has_rg9;
aws_json_config["has_rain_sensor"] = has_rain_sensor;
aws_json_config["rain_event_guard_time"] = rain_event_guard_time;
aws_json_config["has_gps"] = has_gps;
aws_json_config["wifi_mode"] = wifi_mode;
Expand Down Expand Up @@ -527,9 +510,9 @@ bool AWSConfig::read_config( void )
if ( has_mlx != x )
has_mlx = x;

x = aws_json_config.containsKey( "has_rg9" ) ? ( aws_json_config["has_rg9"] == 1 ) : DEFAULT_HAS_RG9;
if ( has_rg9 != x )
has_rg9 = x;
x = aws_json_config.containsKey( "has_rain_sensor" ) ? ( aws_json_config["has_rain_sensor"] == 1 ) : DEFAULT_HAS_RAIN_SENSOR;
if ( has_rain_sensor != x )
has_rain_sensor = x;

z = aws_json_config.containsKey( "rain_event_guard_time" ) ? atof( aws_json_config["rain_event_guard_time"] ) : DEFAULT_RAIN_EVENT_GUARD_TIME;
if ( rain_event_guard_time != z )
Expand Down Expand Up @@ -697,46 +680,45 @@ bool AWSConfig::verify_entries( JsonVariant &proposed_config )

for( JsonPair item : config_items ) {

switch( str2int( item.key().c_str(), 0 )) {

case str2int("alpaca_iface", 0 ):
case str2int("anemometer_model", 0 ):
case str2int("ap_ssid", 0 ):
case str2int("eth_dns", 0 ):
case str2int("eth_gw", 0 ):
case str2int("eth_ip", 0 ):
case str2int("pref_iface", 0 ):
case str2int("rain_event_guard_time", 0 ):
case str2int("remote_server", 0 ):
case str2int("root_ca", 0 ):
case str2int("sta_ssid", 0 ):
case str2int("tzname", 0 ):
case str2int("url_path", 0 ):
case str2int("wifi_ap_dns", 0 ):
case str2int("wifi_ap_gw", 0 ):
case str2int("wifi_ap_ip", 0 ):
case str2int("wifi_ap_password", 0 ):
case str2int("wifi_mode", 0 ):
case str2int("wifi_sta_dns", 0 ):
case str2int("wifi_sta_gw", 0 ):
case str2int("wifi_sta_ip", 0 ):
case str2int("wifi_sta_ip_mode", 0 ):
case str2int("wifi_sta_password", 0 ):
case str2int("windvane_model", 0 ):
switch( str2int( item.key().c_str() )) {

case str2int( "alpaca_iface" ):
case str2int( "anemometer_model" ):
case str2int( "ap_ssid" ):
case str2int( "eth_dns" ):
case str2int( "eth_gw" ):
case str2int( "eth_ip" ):
case str2int( "pref_iface" ):
case str2int( "rain_event_guard_time" ):
case str2int( "remote_server" ):
case str2int( "root_ca" ):
case str2int( "sta_ssid" ):
case str2int( "tzname" ):
case str2int( "url_path" ):
case str2int( "wifi_ap_dns" ):
case str2int( "wifi_ap_gw" ):
case str2int( "wifi_ap_ip" ):
case str2int( "wifi_ap_password" ):
case str2int( "wifi_mode" ):
case str2int( "wifi_sta_dns" ):
case str2int( "wifi_sta_gw" ):
case str2int( "wifi_sta_ip" ):
case str2int( "wifi_sta_ip_mode" ):
case str2int( "wifi_sta_password" ):
case str2int( "windvane_model" ):
break;
case str2int("eth_ip_mode", 0):
case str2int( "eth_ip_mode" ):
x = ( item.value() == "0" ) ? dhcp : fixed;
break;
case str2int("clone_dome_on_rain", 0):
case str2int("has_bme", 0):
case str2int("has_dome", 0):
case str2int("has_gps", 0):
case str2int("has_mlx", 0):
case str2int("has_rg9", 0):
case str2int("has_tsl", 0):
case str2int("has_ws", 0):
case str2int("has_wv", 0):
case str2int("has_dome",0):
case str2int( "clone_dome_on_rain" ):
case str2int( "has_bme" ):
case str2int( "has_dome" ):
case str2int( "has_gps" ):
case str2int( "has_mlx" ):
case str2int( "has_rain_sensor" ):
case str2int( "has_tsl" ):
case str2int( "has_ws" ):
case str2int( "has_wv" ):
config_items[item.key().c_str()] = ( item.value() == "on" ) ? 1 : 0;
break;
default:
Expand Down
8 changes: 3 additions & 5 deletions src/AWSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
#ifndef _AWSConfig_H
#define _AWSConfig_H

#undef CONFIG_DISABLE_HAL_LOCKS
#define _ASYNC_WEBSERVER_LOGLEVEL_ 0
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 0
#include <ArduinoJson.h>

extern const char *_anemometer_model[3];
extern const char *_windvane_model[3];
Expand Down Expand Up @@ -82,7 +80,7 @@ class AWSConfig {
bool get_has_dome( void );
bool get_has_gps( void );
bool get_has_mlx( void );
bool get_has_rg9( void );
bool get_has_rain_sensor( void );
bool get_has_sc16is750( void );
bool get_has_tsl( void );
bool get_has_ws( void );
Expand Down Expand Up @@ -138,7 +136,7 @@ class AWSConfig {
has_dome,
has_gps,
has_mlx,
has_rg9,
has_rain_sensor,
has_sc16is750,
has_tsl,
has_ws,
Expand Down
8 changes: 0 additions & 8 deletions src/AWSGPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@
with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#undef CONFIG_DISABLE_HAL_LOCKS
#define _ASYNC_WEBSERVER_LOGLEVEL_ 0
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 0

#include <SoftwareSerial.h>
#include <TinyGPSPlus.h>
#include "defaults.h"
#include "SC16IS750.h"

#include "AWSGPS.h"

AWSGPS::AWSGPS( bool _debug_mode)
Expand Down
6 changes: 3 additions & 3 deletions src/AWSGPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#ifndef _AWSGPS_H
#define _AWSGPS_H

#undef CONFIG_DISABLE_HAL_LOCKS
#define _ASYNC_WEBSERVER_LOGLEVEL_ 0
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 0
#include <SoftwareSerial.h>
#include <TinyGPSPlus.h>
#include "SC16IS750.h"

struct gps_data_t {

Expand Down
Loading

0 comments on commit ecede07

Please sign in to comment.