Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b0059f6e9f | |||
| 4653fe05cb | |||
| c74a0501c1 | |||
| 8e82e21a3d | |||
| e9c22810a4 | |||
| 8e96b0ef37 | |||
| 1053515ced | |||
| 91cc34a33e | |||
| b0a765d0cc | |||
| c3766d4e14 | |||
| e20c90a021 | |||
| cb708d72f7 | |||
| e986120e66 | |||
| 12be9a6141 | |||
| 1c7cf84ece | |||
| a7385654f4 | |||
| b54d3c744c | |||
| 6582872ed0 | |||
| 969fda6ad4 | |||
| 1aa2ebbadc | |||
| be7234f621 | |||
| eb897dca9e | |||
| d49c69f647 | |||
| ebee1553ae | |||
| 60c6a19f13 | |||
| fafd6a9a7a | |||
| 2b86ff133c | |||
| a1f687e644 | |||
| 6f37e0d420 | |||
| 4be663e688 | |||
| 95ee47386d | |||
| c0758b071e | |||
| 4a9a3ef805 | |||
| ed7fb9fda6 | |||
| 558413df41 | |||
| 94d2a61cad | |||
| eb980d286d | |||
| 55c11f2471 | |||
| ba590b982c | |||
| d1cf04ffdb | |||
| 3dc234eecb | |||
| 3d8962b188 | |||
| 9f848dcc3f | |||
| 5cce419c74 | |||
| 135823b620 | |||
| ff8f6324e5 | |||
| 29ecd9be17 | |||
| 24c454aa88 | |||
| 97d78f7c28 | |||
| 2a2cb42b0b | |||
| 906dfa91f0 | |||
| c03e60e56f | |||
| c7abf18736 | |||
| d6bd1932d3 | |||
| 8ad766c377 | |||
| ba10840f50 | |||
| 64852b2a67 | |||
| 09fed73696 | |||
| c8c27d440c | |||
| 3973d7b41d | |||
| cf3230c470 | |||
| 412354fe88 | |||
| 6dd4b87a0f | |||
| fe2e04ee38 | |||
| 1a10abc4d6 | |||
| cbf42aae0a | |||
| 5f154cb20f | |||
| 82dba30e18 | |||
| af4cb39230 | |||
| 4ab01eb3a4 | |||
| fff7c84206 | |||
| 4243734056 | |||
| 1e7be9adb6 | |||
| c94f7d2982 | |||
| 2800986f17 | |||
| 1a7858198e | |||
| 04a8564d46 |
+11
-5
@@ -22,13 +22,9 @@ build/
|
||||
*.arduino/
|
||||
*.ino.cpp
|
||||
|
||||
# Arduino libraries you might not want tracked
|
||||
# Arduino libraries
|
||||
libraries/
|
||||
|
||||
# PlatformIO (if you ever use it)
|
||||
.pio/
|
||||
.vscode/
|
||||
|
||||
# === OS and Editor specific ===
|
||||
# macOS
|
||||
.DS_Store
|
||||
@@ -56,6 +52,9 @@ $RECYCLE.BIN/
|
||||
# VS Code
|
||||
.vscode/
|
||||
|
||||
# Zed
|
||||
.zed
|
||||
|
||||
# Backup files
|
||||
*~
|
||||
*.orig
|
||||
@@ -63,3 +62,10 @@ $RECYCLE.BIN/
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
|
||||
# EDA
|
||||
eda/atmega/atmega-backups
|
||||
|
||||
# Personal
|
||||
*-debug.sh
|
||||
wifi-credentials-erick.h
|
||||
|
||||
@@ -0,0 +1,638 @@
|
||||
{
|
||||
"board": {
|
||||
"3dviewports": [],
|
||||
"design_settings": {
|
||||
"defaults": {
|
||||
"apply_defaults_to_fp_fields": false,
|
||||
"apply_defaults_to_fp_shapes": false,
|
||||
"apply_defaults_to_fp_text": false,
|
||||
"board_outline_line_width": 0.05,
|
||||
"copper_line_width": 0.2,
|
||||
"copper_text_italic": false,
|
||||
"copper_text_size_h": 1.5,
|
||||
"copper_text_size_v": 1.5,
|
||||
"copper_text_thickness": 0.3,
|
||||
"copper_text_upright": false,
|
||||
"courtyard_line_width": 0.05,
|
||||
"dimension_precision": 4,
|
||||
"dimension_units": 3,
|
||||
"dimensions": {
|
||||
"arrow_length": 1270000,
|
||||
"extension_offset": 500000,
|
||||
"keep_text_aligned": true,
|
||||
"suppress_zeroes": true,
|
||||
"text_position": 0,
|
||||
"units_format": 0
|
||||
},
|
||||
"fab_line_width": 0.1,
|
||||
"fab_text_italic": false,
|
||||
"fab_text_size_h": 1.0,
|
||||
"fab_text_size_v": 1.0,
|
||||
"fab_text_thickness": 0.15,
|
||||
"fab_text_upright": false,
|
||||
"other_line_width": 0.1,
|
||||
"other_text_italic": false,
|
||||
"other_text_size_h": 1.0,
|
||||
"other_text_size_v": 1.0,
|
||||
"other_text_thickness": 0.15,
|
||||
"other_text_upright": false,
|
||||
"pads": {
|
||||
"drill": 0.8,
|
||||
"height": 1.27,
|
||||
"width": 2.54
|
||||
},
|
||||
"silk_line_width": 0.1,
|
||||
"silk_text_italic": false,
|
||||
"silk_text_size_h": 1.0,
|
||||
"silk_text_size_v": 1.0,
|
||||
"silk_text_thickness": 0.1,
|
||||
"silk_text_upright": false,
|
||||
"zones": {
|
||||
"min_clearance": 0.5
|
||||
}
|
||||
},
|
||||
"diff_pair_dimensions": [],
|
||||
"drc_exclusions": [],
|
||||
"meta": {
|
||||
"version": 2
|
||||
},
|
||||
"rule_severities": {
|
||||
"annular_width": "error",
|
||||
"clearance": "error",
|
||||
"connection_width": "warning",
|
||||
"copper_edge_clearance": "error",
|
||||
"copper_sliver": "warning",
|
||||
"courtyards_overlap": "error",
|
||||
"creepage": "error",
|
||||
"diff_pair_gap_out_of_range": "error",
|
||||
"diff_pair_uncoupled_length_too_long": "error",
|
||||
"drill_out_of_range": "error",
|
||||
"duplicate_footprints": "warning",
|
||||
"extra_footprint": "warning",
|
||||
"footprint": "error",
|
||||
"footprint_filters_mismatch": "ignore",
|
||||
"footprint_symbol_mismatch": "warning",
|
||||
"footprint_type_mismatch": "ignore",
|
||||
"hole_clearance": "error",
|
||||
"hole_to_hole": "warning",
|
||||
"holes_co_located": "warning",
|
||||
"invalid_outline": "error",
|
||||
"isolated_copper": "warning",
|
||||
"item_on_disabled_layer": "error",
|
||||
"items_not_allowed": "error",
|
||||
"length_out_of_range": "error",
|
||||
"lib_footprint_issues": "warning",
|
||||
"lib_footprint_mismatch": "warning",
|
||||
"malformed_courtyard": "error",
|
||||
"microvia_drill_out_of_range": "error",
|
||||
"mirrored_text_on_front_layer": "warning",
|
||||
"missing_courtyard": "ignore",
|
||||
"missing_footprint": "warning",
|
||||
"net_conflict": "warning",
|
||||
"nonmirrored_text_on_back_layer": "warning",
|
||||
"npth_inside_courtyard": "ignore",
|
||||
"padstack": "warning",
|
||||
"pth_inside_courtyard": "ignore",
|
||||
"shorting_items": "error",
|
||||
"silk_edge_clearance": "warning",
|
||||
"silk_over_copper": "warning",
|
||||
"silk_overlap": "warning",
|
||||
"skew_out_of_range": "error",
|
||||
"solder_mask_bridge": "error",
|
||||
"starved_thermal": "error",
|
||||
"text_height": "warning",
|
||||
"text_on_edge_cuts": "error",
|
||||
"text_thickness": "warning",
|
||||
"through_hole_pad_without_hole": "error",
|
||||
"too_many_vias": "error",
|
||||
"track_angle": "error",
|
||||
"track_dangling": "warning",
|
||||
"track_segment_length": "error",
|
||||
"track_width": "error",
|
||||
"tracks_crossing": "error",
|
||||
"unconnected_items": "error",
|
||||
"unresolved_variable": "error",
|
||||
"via_dangling": "warning",
|
||||
"zones_intersect": "error"
|
||||
},
|
||||
"rules": {
|
||||
"max_error": 0.005,
|
||||
"min_clearance": 0.0,
|
||||
"min_connection": 0.0,
|
||||
"min_copper_edge_clearance": 0.5,
|
||||
"min_groove_width": 0.0,
|
||||
"min_hole_clearance": 0.25,
|
||||
"min_hole_to_hole": 0.25,
|
||||
"min_microvia_diameter": 0.2,
|
||||
"min_microvia_drill": 0.1,
|
||||
"min_resolved_spokes": 2,
|
||||
"min_silk_clearance": 0.0,
|
||||
"min_text_height": 0.8,
|
||||
"min_text_thickness": 0.08,
|
||||
"min_through_hole_diameter": 0.3,
|
||||
"min_track_width": 0.0,
|
||||
"min_via_annular_width": 0.1,
|
||||
"min_via_diameter": 0.5,
|
||||
"solder_mask_to_copper_clearance": 0.0,
|
||||
"use_height_for_length_calcs": true
|
||||
},
|
||||
"teardrop_options": [
|
||||
{
|
||||
"td_onpthpad": true,
|
||||
"td_onroundshapesonly": false,
|
||||
"td_onsmdpad": true,
|
||||
"td_ontrackend": false,
|
||||
"td_onvia": true
|
||||
}
|
||||
],
|
||||
"teardrop_parameters": [
|
||||
{
|
||||
"td_allow_use_two_tracks": true,
|
||||
"td_curve_segcount": 0,
|
||||
"td_height_ratio": 1.0,
|
||||
"td_length_ratio": 0.5,
|
||||
"td_maxheight": 2.0,
|
||||
"td_maxlen": 1.0,
|
||||
"td_on_pad_in_zone": false,
|
||||
"td_target_name": "td_round_shape",
|
||||
"td_width_to_size_filter_ratio": 0.9
|
||||
},
|
||||
{
|
||||
"td_allow_use_two_tracks": true,
|
||||
"td_curve_segcount": 0,
|
||||
"td_height_ratio": 1.0,
|
||||
"td_length_ratio": 0.5,
|
||||
"td_maxheight": 2.0,
|
||||
"td_maxlen": 1.0,
|
||||
"td_on_pad_in_zone": false,
|
||||
"td_target_name": "td_rect_shape",
|
||||
"td_width_to_size_filter_ratio": 0.9
|
||||
},
|
||||
{
|
||||
"td_allow_use_two_tracks": true,
|
||||
"td_curve_segcount": 0,
|
||||
"td_height_ratio": 1.0,
|
||||
"td_length_ratio": 0.5,
|
||||
"td_maxheight": 2.0,
|
||||
"td_maxlen": 1.0,
|
||||
"td_on_pad_in_zone": false,
|
||||
"td_target_name": "td_track_end",
|
||||
"td_width_to_size_filter_ratio": 0.9
|
||||
}
|
||||
],
|
||||
"track_widths": [],
|
||||
"tuning_pattern_settings": {
|
||||
"diff_pair_defaults": {
|
||||
"corner_radius_percentage": 80,
|
||||
"corner_style": 1,
|
||||
"max_amplitude": 1.0,
|
||||
"min_amplitude": 0.2,
|
||||
"single_sided": false,
|
||||
"spacing": 1.0
|
||||
},
|
||||
"diff_pair_skew_defaults": {
|
||||
"corner_radius_percentage": 80,
|
||||
"corner_style": 1,
|
||||
"max_amplitude": 1.0,
|
||||
"min_amplitude": 0.2,
|
||||
"single_sided": false,
|
||||
"spacing": 0.6
|
||||
},
|
||||
"single_track_defaults": {
|
||||
"corner_radius_percentage": 80,
|
||||
"corner_style": 1,
|
||||
"max_amplitude": 1.0,
|
||||
"min_amplitude": 0.2,
|
||||
"single_sided": false,
|
||||
"spacing": 0.6
|
||||
}
|
||||
},
|
||||
"via_dimensions": [],
|
||||
"zones_allow_external_fillets": false
|
||||
},
|
||||
"ipc2581": {
|
||||
"dist": "",
|
||||
"distpn": "",
|
||||
"internal_id": "",
|
||||
"mfg": "",
|
||||
"mpn": ""
|
||||
},
|
||||
"layer_pairs": [],
|
||||
"layer_presets": [],
|
||||
"viewports": []
|
||||
},
|
||||
"boards": [],
|
||||
"cvpcb": {
|
||||
"equivalence_files": []
|
||||
},
|
||||
"erc": {
|
||||
"erc_exclusions": [],
|
||||
"meta": {
|
||||
"version": 0
|
||||
},
|
||||
"pin_map": [
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
]
|
||||
],
|
||||
"rule_severities": {
|
||||
"bus_definition_conflict": "error",
|
||||
"bus_entry_needed": "error",
|
||||
"bus_to_bus_conflict": "error",
|
||||
"bus_to_net_conflict": "error",
|
||||
"different_unit_footprint": "error",
|
||||
"different_unit_net": "error",
|
||||
"duplicate_reference": "error",
|
||||
"duplicate_sheet_names": "error",
|
||||
"endpoint_off_grid": "warning",
|
||||
"extra_units": "error",
|
||||
"footprint_filter": "ignore",
|
||||
"footprint_link_issues": "warning",
|
||||
"four_way_junction": "ignore",
|
||||
"global_label_dangling": "warning",
|
||||
"hier_label_mismatch": "error",
|
||||
"label_dangling": "error",
|
||||
"label_multiple_wires": "warning",
|
||||
"lib_symbol_issues": "warning",
|
||||
"lib_symbol_mismatch": "warning",
|
||||
"missing_bidi_pin": "warning",
|
||||
"missing_input_pin": "warning",
|
||||
"missing_power_pin": "error",
|
||||
"missing_unit": "warning",
|
||||
"multiple_net_names": "warning",
|
||||
"net_not_bus_member": "warning",
|
||||
"no_connect_connected": "warning",
|
||||
"no_connect_dangling": "warning",
|
||||
"pin_not_connected": "error",
|
||||
"pin_not_driven": "error",
|
||||
"pin_to_pin": "warning",
|
||||
"power_pin_not_driven": "error",
|
||||
"same_local_global_label": "warning",
|
||||
"similar_label_and_power": "warning",
|
||||
"similar_labels": "warning",
|
||||
"similar_power": "warning",
|
||||
"simulation_model_issue": "ignore",
|
||||
"single_global_label": "ignore",
|
||||
"unannotated": "error",
|
||||
"unconnected_wire_endpoint": "warning",
|
||||
"unit_value_mismatch": "error",
|
||||
"unresolved_variable": "error",
|
||||
"wire_dangling": "error"
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"pinned_footprint_libs": [],
|
||||
"pinned_symbol_libs": []
|
||||
},
|
||||
"meta": {
|
||||
"filename": "atmega.kicad_pro",
|
||||
"version": 3
|
||||
},
|
||||
"net_settings": {
|
||||
"classes": [
|
||||
{
|
||||
"bus_width": 12,
|
||||
"clearance": 0.2,
|
||||
"diff_pair_gap": 0.25,
|
||||
"diff_pair_via_gap": 0.25,
|
||||
"diff_pair_width": 0.2,
|
||||
"line_style": 0,
|
||||
"microvia_diameter": 0.3,
|
||||
"microvia_drill": 0.1,
|
||||
"name": "Default",
|
||||
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||
"priority": 2147483647,
|
||||
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||
"track_width": 0.2,
|
||||
"via_diameter": 0.6,
|
||||
"via_drill": 0.3,
|
||||
"wire_width": 6
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"version": 4
|
||||
},
|
||||
"net_colors": null,
|
||||
"netclass_assignments": null,
|
||||
"netclass_patterns": []
|
||||
},
|
||||
"pcbnew": {
|
||||
"last_paths": {
|
||||
"gencad": "",
|
||||
"idf": "",
|
||||
"netlist": "",
|
||||
"plot": "",
|
||||
"pos_files": "",
|
||||
"specctra_dsn": "",
|
||||
"step": "",
|
||||
"svg": "",
|
||||
"vrml": ""
|
||||
},
|
||||
"page_layout_descr_file": ""
|
||||
},
|
||||
"schematic": {
|
||||
"annotate_start_num": 0,
|
||||
"bom_export_filename": "${PROJECTNAME}.csv",
|
||||
"bom_fmt_presets": [],
|
||||
"bom_fmt_settings": {
|
||||
"field_delimiter": ",",
|
||||
"keep_line_breaks": false,
|
||||
"keep_tabs": false,
|
||||
"name": "CSV",
|
||||
"ref_delimiter": ",",
|
||||
"ref_range_delimiter": "",
|
||||
"string_delimiter": "\""
|
||||
},
|
||||
"bom_presets": [],
|
||||
"bom_settings": {
|
||||
"exclude_dnp": false,
|
||||
"fields_ordered": [
|
||||
{
|
||||
"group_by": false,
|
||||
"label": "Reference",
|
||||
"name": "Reference",
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"group_by": true,
|
||||
"label": "Value",
|
||||
"name": "Value",
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"group_by": true,
|
||||
"label": "Footprint",
|
||||
"name": "Footprint",
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"group_by": false,
|
||||
"label": "Datasheet",
|
||||
"name": "Datasheet",
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"group_by": false,
|
||||
"label": "Description",
|
||||
"name": "Description",
|
||||
"show": false
|
||||
},
|
||||
{
|
||||
"group_by": false,
|
||||
"label": "Qty",
|
||||
"name": "${QUANTITY}",
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"group_by": false,
|
||||
"label": "#",
|
||||
"name": "${ITEM_NUMBER}",
|
||||
"show": false
|
||||
},
|
||||
{
|
||||
"group_by": true,
|
||||
"label": "DNP",
|
||||
"name": "${DNP}",
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"group_by": true,
|
||||
"label": "Exclude from BOM",
|
||||
"name": "${EXCLUDE_FROM_BOM}",
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"group_by": true,
|
||||
"label": "Exclude from Board",
|
||||
"name": "${EXCLUDE_FROM_BOARD}",
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"filter_string": "",
|
||||
"group_symbols": true,
|
||||
"include_excluded_from_bom": true,
|
||||
"name": "",
|
||||
"sort_asc": true,
|
||||
"sort_field": "Reference"
|
||||
},
|
||||
"connection_grid_size": 50.0,
|
||||
"drawing": {
|
||||
"dashed_lines_dash_length_ratio": 12.0,
|
||||
"dashed_lines_gap_length_ratio": 3.0,
|
||||
"default_line_thickness": 6.0,
|
||||
"default_text_size": 50.0,
|
||||
"field_names": [],
|
||||
"intersheets_ref_own_page": false,
|
||||
"intersheets_ref_prefix": "",
|
||||
"intersheets_ref_short": false,
|
||||
"intersheets_ref_show": false,
|
||||
"intersheets_ref_suffix": "",
|
||||
"junction_size_choice": 3,
|
||||
"label_size_ratio": 0.375,
|
||||
"operating_point_overlay_i_precision": 3,
|
||||
"operating_point_overlay_i_range": "~A",
|
||||
"operating_point_overlay_v_precision": 3,
|
||||
"operating_point_overlay_v_range": "~V",
|
||||
"overbar_offset_ratio": 1.23,
|
||||
"pin_symbol_size": 25.0,
|
||||
"text_offset_ratio": 0.15
|
||||
},
|
||||
"legacy_lib_dir": "",
|
||||
"legacy_lib_list": [],
|
||||
"meta": {
|
||||
"version": 1
|
||||
},
|
||||
"net_format_name": "",
|
||||
"ngspice": {
|
||||
"fix_include_paths": true,
|
||||
"meta": {
|
||||
"version": 0
|
||||
},
|
||||
"model_mode": 4,
|
||||
"workbook_filename": ""
|
||||
},
|
||||
"page_layout_descr_file": "sensing",
|
||||
"plot_directory": "",
|
||||
"space_save_all_events": true,
|
||||
"spice_current_sheet_as_root": false,
|
||||
"spice_external_command": "spice \"%I\"",
|
||||
"spice_model_current_sheet_as_root": true,
|
||||
"spice_save_all_currents": false,
|
||||
"spice_save_all_dissipations": false,
|
||||
"spice_save_all_voltages": false,
|
||||
"subpart_first_id": 65,
|
||||
"subpart_id_separator": 0
|
||||
},
|
||||
"sheets": [
|
||||
[
|
||||
"90981571-11d1-4805-a2bb-89f0c5021ff9",
|
||||
"Root"
|
||||
]
|
||||
],
|
||||
"text_variables": {}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends\
|
||||
build-essential \
|
||||
gcc-avr \
|
||||
avrdude \
|
||||
arduino-core-avr \
|
||||
make \
|
||||
&& apt-get clean
|
||||
|
||||
WORKDIR /usr/src/
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN make all
|
||||
@@ -0,0 +1,45 @@
|
||||
PROJECT = vase-control
|
||||
|
||||
MCU = atmega328p
|
||||
F_CPU = 16000000UL
|
||||
|
||||
CC = avr-gcc
|
||||
LD = $(CC)
|
||||
OC = avr-objcopy
|
||||
RM = rm -f
|
||||
|
||||
O_FLAG = -Os
|
||||
|
||||
BUILD_DIR = build
|
||||
OBJ_DIR = $(BUILD_DIR)/obj
|
||||
|
||||
SRCS_C = source/adc.c source/moisture.c source/main.c source/pump.c
|
||||
OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(SRCS_C:.c=.o)))
|
||||
|
||||
CFLAGS = -Wall $(O_FLAG) -DF_CPU=$(F_CPU) -mmcu=$(MCU) -Iinclude
|
||||
LDFLAGS = -Wall $(O_FLAG) -mmcu=$(MCU)
|
||||
LIBS = -lm
|
||||
|
||||
EXEC = atmega
|
||||
ELF_TARGET = $(BUILD_DIR)/$(EXEC).elf
|
||||
TARGET = $(BUILD_DIR)/$(EXEC).hex
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(shell mkdir -p $(OBJ_DIR))
|
||||
$(shell mkdir -p $(BUILD_DIR))
|
||||
|
||||
$(ELF_TARGET): $(OBJS)
|
||||
$(LD) $(LDFLAGS) $(OBJS) -o $@ $(LIBS)
|
||||
|
||||
$(OBJ_DIR)/%.o: source/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(TARGET): $(ELF_TARGET)
|
||||
$(OC) -O ihex -R .eeprom $< $@
|
||||
|
||||
clean:
|
||||
$(RM) $(TARGET) $(ELF_TARGET) $(OBJS)
|
||||
$(RM) -r $(BUILD_DIR)
|
||||
|
||||
.PHONY: all clean
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
IMAGE_NAME="vase-control-builder"
|
||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
IMAGE_NAME="vase-control-builder"
|
||||
DOCKERFILE="$SCRIPT_DIR/Dockerfile"
|
||||
BUILD_CTX="$SCRIPT_DIR"
|
||||
DEST_HEX="$SCRIPT_DIR/build/atmega.hex"
|
||||
MCU="atmega328p"; PRG="usbasp"
|
||||
|
||||
docker build -t "$IMAGE_NAME" -f "$DOCKERFILE" "$BUILD_CTX"
|
||||
|
||||
mkdir -p "$(dirname "$DEST_HEX")"
|
||||
|
||||
docker run --rm "$IMAGE_NAME" \
|
||||
cat /usr/src/build/atmega.hex > "$DEST_HEX"
|
||||
|
||||
command -v avrdude >/dev/null || { echo "Install avrdude"; exit 1; }
|
||||
avrdude -v -p m328p -c usbasp -U flash:w:build/atmega.hex:i
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef ADC_H
|
||||
#define ADC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
void adcInit(void);
|
||||
uint16_t adcRead(uint8_t channel);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define MOISTURE_SENSOR_A0 PC0
|
||||
#define MOISTURE_SENSOR_A1 PC1
|
||||
#define MOISTURE_SENSOR_A2 PC2
|
||||
#define MOISTURE_SENSOR_A3 PC3
|
||||
#define MOISTURE_SENSOR_A4 PC4
|
||||
#define MOISTURE_SENSOR_A5 PC5
|
||||
//#define MOISTURE_SENSOR_A6 PC6
|
||||
//#define MOISTURE_SENSOR_A7 PC7
|
||||
|
||||
#define PUMP_D3 PD3
|
||||
#define PUMP_D4 PD4
|
||||
#define PUMP_D5 PD5
|
||||
//#define PUMP_D6 PD6
|
||||
//#define PUMP_D7 PD7
|
||||
|
||||
// TODO: write these to eeprom
|
||||
#define SENSOR_READINGS 5
|
||||
//#define VASE_NUM 0
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef MOISTURE_H
|
||||
#define MOISTURE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "config.h"
|
||||
|
||||
static const int8_t sensorPins[] = {
|
||||
#ifdef MOISTURE_SENSOR_A0
|
||||
MOISTURE_SENSOR_A0,
|
||||
#endif
|
||||
|
||||
#ifdef MOISTURE_SENSOR_A1
|
||||
MOISTURE_SENSOR_A1,
|
||||
#endif
|
||||
|
||||
#ifdef MOISTURE_SENSOR_A2
|
||||
MOISTURE_SENSOR_A2,
|
||||
#endif
|
||||
|
||||
#ifdef MOISTURE_SENSOR_A3
|
||||
MOISTURE_SENSOR_A3,
|
||||
#endif
|
||||
|
||||
#ifdef MOISTURE_SENSOR_A4
|
||||
MOISTURE_SENSOR_A4,
|
||||
#endif
|
||||
|
||||
#ifdef MOISTURE_SENSOR_A5
|
||||
MOISTURE_SENSOR_A5,
|
||||
#endif
|
||||
|
||||
#ifdef MOISTURE_SENSOR_A6
|
||||
MOISTURE_SENSOR_A6,
|
||||
#endif
|
||||
|
||||
#ifdef MOISTURE_SENSOR_A7
|
||||
MOISTURE_SENSOR_A7,
|
||||
#endif
|
||||
};
|
||||
|
||||
#define SENSORS_NUM (sizeof(sensorPins) / sizeof(sensorPins[0]))
|
||||
|
||||
extern volatile bool readSensors;
|
||||
|
||||
void sensorsInit(void);
|
||||
void triggerMoistureRead(void);
|
||||
uint16_t moistureAverage(uint8_t sensorPin);
|
||||
uint16_t moistureRead(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef PUMP_H
|
||||
#define PUMP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "config.h"
|
||||
|
||||
|
||||
static const int8_t actuatorPins[] = {
|
||||
#ifdef PUMP_D3
|
||||
PUMP_D3,
|
||||
#endif
|
||||
|
||||
#ifdef PUMP_D4
|
||||
PUMP_D4,
|
||||
#endif
|
||||
|
||||
#ifdef PUMP_D5
|
||||
PUMP_D5,
|
||||
#endif
|
||||
|
||||
#ifdef PUMP_D6
|
||||
PUMP_D6,
|
||||
#endif
|
||||
|
||||
#ifdef PUMP_D7
|
||||
PUMP_D7,
|
||||
#endif
|
||||
};
|
||||
|
||||
#define ACTUATORS_NUM (sizeof(actuatorPins) / sizeof(actuatorPins[0]))
|
||||
|
||||
void pumpsInit(void);
|
||||
void triggerPump(uint8_t digital_pins);
|
||||
void waterPlant(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <stdint.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
void adcInit(void) {
|
||||
// Set reference voltage to AVcc (REFS0 = 1, REFS1 = 0)
|
||||
ADMUX = (1 << REFS0);
|
||||
|
||||
// Enable ADC and set prescaler to 128 (for 16 MHz clock, gives 125 kHz ADC clock)
|
||||
ADCSRA = (1 << ADEN) | (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);
|
||||
}
|
||||
|
||||
uint16_t adcRead(uint8_t channel) {
|
||||
// Select ADC pin (A0-A7) by setting MUX bits in ADMUX
|
||||
// Pins A6 and A7 would make an 8 sensor array possible (for large vases).
|
||||
// Achievable only when using the 328p as a DIP, through port C (PC6, PC7)
|
||||
ADMUX = (ADMUX & 0xF8) | (channel & 0x07);
|
||||
|
||||
// Start conversion
|
||||
ADCSRA |= (1 << ADSC);
|
||||
|
||||
// Wait for conversion to complete (ADSC becomes '0' when done)
|
||||
while (ADCSRA & (1 << ADSC));
|
||||
|
||||
// Read ADC (reading order: ADCL --> ADCH)
|
||||
return ADC;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/sleep.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "adc.h"
|
||||
#include "moisture.h"
|
||||
#include "pump.h"
|
||||
|
||||
ISR(WDT_vect) {
|
||||
triggerMoistureRead();
|
||||
}
|
||||
|
||||
void watchdogs(void) {
|
||||
cli();
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
WDTCSR |= (1 << WDCE) | (1 << WDE);
|
||||
WDTCSR = (1 << WDIE) | (1 << WDP3) | (1 << WDP0);
|
||||
sei();
|
||||
}
|
||||
|
||||
void enterSleep(void) {
|
||||
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
|
||||
sleep_enable();
|
||||
sleep_cpu();
|
||||
sleep_disable();
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
adcInit();
|
||||
sensorsInit();
|
||||
pumpsInit();
|
||||
watchdogs();
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
if (readSensors) {
|
||||
uint16_t result = moistureRead();
|
||||
//espSend(VASE_NUM, result)
|
||||
}
|
||||
// if(espGet("ask if i need to water plants") == true) {waterPlant()}
|
||||
// or maybe it's better to do this with interrupts?
|
||||
|
||||
readSensors = false;
|
||||
enterSleep();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "moisture.h"
|
||||
#include "config.h"
|
||||
#include "adc.h"
|
||||
|
||||
volatile bool readSensors = false;
|
||||
|
||||
void sensorsInit(void) {
|
||||
uint8_t sensorMask = 0;
|
||||
for (uint8_t i = 0; i < SENSORS_NUM; i++) {
|
||||
sensorMask |= (1 << sensorPins[i]);
|
||||
}
|
||||
DDRC &= ~sensorMask;
|
||||
PORTC &= ~sensorMask;
|
||||
}
|
||||
|
||||
void triggerMoistureRead(void) {
|
||||
readSensors = true;
|
||||
}
|
||||
|
||||
uint16_t moistureAverage(uint8_t sensorPin) {
|
||||
uint16_t sum = 0;
|
||||
for (uint8_t i = 0; i < SENSOR_READINGS; i++) {
|
||||
sum += adcRead(sensorPin);
|
||||
//TODO: implement variance check (if over a certain variance discard measurements for this cycle)
|
||||
//TODO IMPORTANT: if value < 1 or > 1022, discard that measurement
|
||||
}
|
||||
return sum / SENSOR_READINGS;
|
||||
}
|
||||
|
||||
uint16_t moistureRead(void) {
|
||||
uint16_t overallSum = 0;
|
||||
|
||||
for (uint8_t i = 0; i < SENSORS_NUM; i++) {
|
||||
uint16_t sensorAverage = moistureAverage(sensorPins[i]);
|
||||
//TODO: if a sensor gives 0, discard that sensor entirely (means it is disconnected or not working)
|
||||
overallSum += sensorAverage;
|
||||
}
|
||||
|
||||
return overallSum / SENSORS_NUM;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <stdint.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
#include "pump.h"
|
||||
#include "config.h"
|
||||
|
||||
void pumpsInit(void) {
|
||||
uint8_t actuatorMask = 0;
|
||||
for (uint8_t i = 0; i < ACTUATORS_NUM; i++) {
|
||||
actuatorMask |= (1 << actuatorPins[i]);
|
||||
}
|
||||
DDRD |= actuatorMask;
|
||||
//PORTD &= ~(1 << actuatorMask);
|
||||
}
|
||||
|
||||
void triggerPump(uint8_t pump_pin) {
|
||||
// Turn on pump
|
||||
PORTD |= (1 << pump_pin);
|
||||
|
||||
_delay_ms(500);
|
||||
// Here there could be the issue of the AVR hanging when pump is on
|
||||
|
||||
// Turn off pump
|
||||
PORTD &= ~(1 << pump_pin);
|
||||
}
|
||||
|
||||
void waterPlant(void) {
|
||||
for (uint8_t i=0; i < ACTUATORS_NUM; i++) {
|
||||
triggerPump(actuatorPins[i]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(plant-manager)
|
||||
@@ -0,0 +1,48 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
wget \
|
||||
flex \
|
||||
bison \
|
||||
gperf \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
cmake \
|
||||
ninja-build \
|
||||
ccache \
|
||||
libffi-dev \
|
||||
libssl-dev \
|
||||
dfu-util \
|
||||
libusb-1.0-0 \
|
||||
&& apt-get autoremove
|
||||
|
||||
WORKDIR /usr/src/
|
||||
|
||||
ENV IDF_PATH=/usr/src/esp/esp-idf
|
||||
ENV IDF_PATH_FORCE=1
|
||||
|
||||
RUN mkdir -p /usr/src/esp/firmware
|
||||
RUN git clone --recursive https://github.com/espressif/esp-idf.git $IDF_PATH
|
||||
|
||||
RUN cd $IDF_PATH && ./install.sh esp32c3
|
||||
|
||||
COPY . /usr/src/esp/firmware/
|
||||
|
||||
WORKDIR /usr/src/esp/firmware/
|
||||
|
||||
# Create sdkconfig.defaults with correct flash settings
|
||||
RUN echo "CONFIG_ESPTOOLPY_FLASHMODE=dio" > sdkconfig.defaults && \
|
||||
echo "CONFIG_ESPTOOLPY_FLASHFREQ=40m" >> sdkconfig.defaults && \
|
||||
echo "CONFIG_ESPTOOLPY_FLASHSIZE=4MB" >> sdkconfig.defaults
|
||||
|
||||
RUN rm -rf build && /bin/bash -c "source $IDF_PATH/export.sh && idf.py set-target esp32c3 && idf.py build"
|
||||
|
||||
RUN mkdir -p /usr/src/build && \
|
||||
cp build/bootloader/bootloader.bin /usr/src/build/ && \
|
||||
cp build/partition_table/partition-table.bin /usr/src/build/ && \
|
||||
cp build/plant-manager.bin /usr/src/build/
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
IMAGE_NAME="esp32-builder"
|
||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
DOCKERFILE="$SCRIPT_DIR/Dockerfile"
|
||||
BUILD_CTX="$SCRIPT_DIR"
|
||||
DEST_DIR="$SCRIPT_DIR/build"
|
||||
|
||||
docker build -t "$IMAGE_NAME" -f "$DOCKERFILE" "$BUILD_CTX"
|
||||
|
||||
mkdir -p "$DEST_DIR"
|
||||
|
||||
docker run --rm -v "$DEST_DIR":/output "$IMAGE_NAME" cp -r /usr/src/build/. /output/
|
||||
|
||||
#echo "Erasing flash..."
|
||||
#esptool --chip esp32c3 --port /dev/tty.usbmodem101 erase-flash
|
||||
|
||||
esptool --chip esp32c3 --port /dev/tty.usbmodem101 --baud 115200 write-flash \
|
||||
--flash-mode dio \
|
||||
--flash-freq 40m \
|
||||
--flash-size 4MB \
|
||||
0x0000 "$DEST_DIR/bootloader.bin" \
|
||||
0x8000 "$DEST_DIR/partition-table.bin" \
|
||||
0x10000 "$DEST_DIR/plant-manager.bin"
|
||||
|
||||
screen -fn /dev/tty.usbmodem101 115200
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define SSID "your_wifi_ssid"
|
||||
#define PASSWORD "your_wifi_password"
|
||||
#define AUTH_MODE WIFI_AUTH_WPA2_PSK
|
||||
#define MQTT_ADDR "mqtt://yourmqttserver"
|
||||
#define MQTT_PORT 1883
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern volatile bool criticalErrorFlag;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef WIFI_HPP
|
||||
#define WIFI_HPP
|
||||
|
||||
void wifiTask(void *pvParameters);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
idf_component_register(SRCS "./main.cpp"
|
||||
"./wifi.cpp"
|
||||
INCLUDE_DIRS "../include"
|
||||
REQUIRES esp_wifi
|
||||
nvs_flash
|
||||
esp_pm
|
||||
esp_hw_support
|
||||
esp_system
|
||||
freertos
|
||||
log)
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_pm.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "wifi.hpp"
|
||||
|
||||
static const char* TAG = "MAIN";
|
||||
|
||||
volatile bool criticalErrorFlag = false;
|
||||
|
||||
static void watchdogTask(void *pvParameters) {
|
||||
esp_task_wdt_config_t twdt_config = {
|
||||
.timeout_ms = 12000,
|
||||
.idle_core_mask = 0,
|
||||
.trigger_panic = true,
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_task_wdt_deinit());
|
||||
ESP_ERROR_CHECK(esp_task_wdt_init(&twdt_config));
|
||||
|
||||
ESP_ERROR_CHECK(esp_task_wdt_add(NULL));
|
||||
|
||||
const TickType_t keepAlivePeriod = pdMS_TO_TICKS(8000);
|
||||
|
||||
for(;;) {
|
||||
if (criticalErrorFlag) {
|
||||
ESP_LOGE(TAG, "Critical error flag raised. Rebooting.");
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_task_wdt_reset());
|
||||
ESP_LOGI(TAG, "WDT reset");
|
||||
|
||||
vTaskDelay(keepAlivePeriod);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
static const esp_pm_config_t pm_cfg = {
|
||||
.max_freq_mhz = 160,
|
||||
.min_freq_mhz = 10,
|
||||
.light_sleep_enable = true
|
||||
};
|
||||
esp_pm_configure(&pm_cfg);
|
||||
|
||||
xTaskCreate(watchdogTask, "watchdogs", 2048, NULL, configMAX_PRIORITIES-1, NULL);
|
||||
xTaskCreate(wifiTask, "wifi", 4096, NULL, configMAX_PRIORITIES-4, NULL);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "main.hpp"
|
||||
#include "config.h"
|
||||
|
||||
#define WIFI_TIMEOUT_TICKS pdMS_TO_TICKS(8000)
|
||||
|
||||
static const char* TAG = "WIFI";
|
||||
const int WIFI_CONNECTED_BIT = BIT0;
|
||||
|
||||
EventGroupHandle_t wifi_event_group;
|
||||
|
||||
static void wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
|
||||
if (event_base == WIFI_EVENT) {
|
||||
switch (event_id) {
|
||||
case WIFI_EVENT_STA_START:
|
||||
ESP_LOGI(TAG, "Wi-Fi process started, connecting...");
|
||||
|
||||
esp_wifi_connect();
|
||||
break;
|
||||
case WIFI_EVENT_STA_DISCONNECTED: {
|
||||
wifi_event_sta_disconnected_t* disconn = (wifi_event_sta_disconnected_t*) event_data;
|
||||
ESP_LOGW(TAG, "Disconnected, reason: %d", disconn->reason);
|
||||
|
||||
xEventGroupClearBits(wifi_event_group, WIFI_CONNECTED_BIT);
|
||||
esp_wifi_connect();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
|
||||
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
|
||||
ESP_LOGI(TAG, "Got IP: " IPSTR, IP2STR(&event->ip_info.ip));
|
||||
xEventGroupSetBits(wifi_event_group, WIFI_CONNECTED_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void wifi_init_sta(void) {
|
||||
esp_err_t nvs_err = nvs_flash_init();
|
||||
|
||||
if (nvs_err == ESP_ERR_NVS_NO_FREE_PAGES || nvs_err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
ESP_ERROR_CHECK(nvs_flash_init());
|
||||
}
|
||||
|
||||
wifi_event_group = xEventGroupCreate();
|
||||
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
|
||||
esp_netif_create_default_wifi_sta();
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL, NULL));
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &wifi_event_handler, NULL, NULL));
|
||||
|
||||
wifi_config_t wifi_config{};
|
||||
strncpy((char*)wifi_config.sta.ssid, SSID, sizeof(wifi_config.sta.ssid));
|
||||
strncpy((char*)wifi_config.sta.password, PASSWORD, sizeof(wifi_config.sta.password));
|
||||
wifi_config.sta.threshold.authmode = AUTH_MODE;
|
||||
wifi_config.sta.pmf_cfg.capable = true;
|
||||
wifi_config.sta.pmf_cfg.required = false;
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
}
|
||||
|
||||
void wifiTask(void *pvParameters) {
|
||||
ESP_LOGI(TAG, "WiFi task started");
|
||||
|
||||
wifi_init_sta();
|
||||
ESP_ERROR_CHECK(esp_task_wdt_add(NULL));
|
||||
|
||||
for(;;) {
|
||||
wifi_ap_record_t ap;
|
||||
if (esp_wifi_sta_get_ap_info(&ap) == ESP_OK) {
|
||||
ESP_LOGV(TAG, "RSSI: %d", ap.rssi);
|
||||
}
|
||||
|
||||
//TODO: manage data send rate if with slow network
|
||||
// or just let mqtt know (useful for making a notice on home manager)
|
||||
|
||||
ESP_ERROR_CHECK(esp_task_wdt_reset());
|
||||
ESP_LOGI(TAG, "Wi-Fi task reset");
|
||||
vTaskDelay(pdMS_TO_TICKS(WIFI_TIMEOUT_TICKS));
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
PROJECT = plant-manager
|
||||
|
||||
# Flags
|
||||
MCU = atmega328p
|
||||
F_CPU = 16000000UL
|
||||
|
||||
CC = avr-gcc
|
||||
OBJCOPY = avr-objcopy
|
||||
AVRDUDE = avrdude
|
||||
CFLAGS = -Wall -Os -DF_CPU=$(F_CPU) -mmcu=$(MCU)
|
||||
|
||||
PROGRAMMER = arduino
|
||||
PORT = /dev/ttyACM0
|
||||
|
||||
SRC = main.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
# Default target
|
||||
all: $(PROJECT).hex
|
||||
|
||||
# Compiler
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# Linker
|
||||
$(PROJECT).elf: $(OBJ)
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
# Create hex file
|
||||
$(PROJECT).hex: $(PROJECT).elf
|
||||
$(OBJCOPY) -O ihex -R .eeprom $< $@
|
||||
|
||||
# Uploader
|
||||
upload: $(PROJECT).hex
|
||||
$(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -P $(PORT) -U flash:w:$<:i
|
||||
|
||||
# Cleaner
|
||||
clean:
|
||||
rm -f *.o *.elf *.hex
|
||||
|
||||
.PHONY: all upload clean
|
||||
@@ -1,7 +0,0 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define MOISTURE_SENSOR_A0 A0
|
||||
#define SENSOR_READINGS 3
|
||||
|
||||
#endif
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <avr/sleep.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "config.h"
|
||||
#include "moisture.h"
|
||||
|
||||
ISR(WDT_vect) {
|
||||
readSensors = true;
|
||||
}
|
||||
|
||||
void watchdogs(void) {
|
||||
cli();
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
WDTCSR |= (1 << WDCE) | (1 << WDE);
|
||||
WDTCSR = (1 << WDIE) | (1 << WDP3) | (1 << WDP0);
|
||||
sei();
|
||||
}
|
||||
|
||||
void enterSleep(void) {
|
||||
set_sleep_mode(SLEEP_MODE_IDLE);
|
||||
sleep_enable();
|
||||
sleep_cpu();
|
||||
sleep_disable();
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
Serial.begin(9600);
|
||||
initMoistureSensor();
|
||||
watchdogs();
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
if (readSensors) {
|
||||
int16_t result = readMoisture();
|
||||
if (result != -1) {
|
||||
Serial.println(result);
|
||||
readSensors = false;
|
||||
}
|
||||
}
|
||||
|
||||
enterSleep();
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#include <Arduino.h>
|
||||
#include <stdint.h>
|
||||
#include "moisture.h"
|
||||
#include "config.h"
|
||||
|
||||
static int16_t moistureReadingSum = 0;
|
||||
static int8_t moistureReadingCount = 0;
|
||||
|
||||
volatile bool readSensors = false;
|
||||
|
||||
void initMoistureSensor(void) {
|
||||
pinMode(MOISTURE_SENSOR_A0, INPUT);
|
||||
}
|
||||
|
||||
void triggerSensorRead(void) {
|
||||
readSensors = true;
|
||||
}
|
||||
|
||||
int16_t readMoisture(void) {
|
||||
if (!readSensors)
|
||||
return -1;
|
||||
|
||||
moistureReadingSum += analogRead(MOISTURE_SENSOR_A0);
|
||||
moistureReadingCount++;
|
||||
|
||||
if (moistureReadingCount >= SENSOR_READINGS) {
|
||||
int16_t avg = moistureReadingSum / SENSOR_READINGS;
|
||||
//Serial.println(avg);
|
||||
moistureReadingSum = 0;
|
||||
moistureReadingCount = 0;
|
||||
readSensors = false;
|
||||
return avg;
|
||||
} else readSensors = true;
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef MOISTURE_H
|
||||
#define MOISTURE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void initMoistureSensor(void);
|
||||
int16_t readMoisture(void);
|
||||
void triggerSensorRead(void);
|
||||
|
||||
extern volatile bool readSensors;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user