<p>I'm using firmware Marlin 2.0.3 on an Anet A8 printer. I'm using a Roko SN04-N NPN bed leveller. I've managed to set up 3 points bed levelling but I wanted to try the bilinear levelling.</p>

<p>Issue is, the sensor goes out of the aluminum bed ever so slightly during levelling, resulting in the printing head crashing on the bed.</p>

<p>Where can I set the grid for the bilinear levelling in the config file? I didn't find the option in the file and Google wasn't of any help this time.</p>

If you have managed to setup 3-point levelling, you should be able to enable bi-linear levelling in the firmware.
From the
configuration.h
file for Marlin firmware you can find the following options:
```
/**
 * Choose one of the options below to enable G29 Bed Leveling. The parameters
 * and behavior of G29 will change depending on your selection.
 *
 *  If using a Probe for Z Homing, enable Z_SAFE_HOMING also!
 *
 * - AUTO_BED_LEVELING_3POINT
 *   Probe 3 arbitrary points on the bed (that aren't collinear)
 *   You specify the XY coordinates of all 3 points.
 *   The result is a single tilted plane. Best for a flat bed.
 *
 * - AUTO_BED_LEVELING_LINEAR
 *   Probe several points in a grid.
 *   You specify the rectangle and the density of sample points.
 *   The result is a single tilted plane. Best for a flat bed.
 *
 * - AUTO_BED_LEVELING_BILINEAR
 *   Probe several points in a grid.
 *   You specify the rectangle and the density of sample points.
 *   The result is a mesh, best for large or uneven beds.
 *
 * - AUTO_BED_LEVELING_UBL (Unified Bed Leveling)
 *   A comprehensive bed leveling system combining the features and benefits
 *   of other systems. UBL also includes integrated Mesh Generation, Mesh
 *   Validation and Mesh Editing systems.
 *
 * - MESH_BED_LEVELING
 *   Probe a grid manually
 *   The result is a mesh, suitable for large or uneven beds. (See BILINEAR.)
 *   For machines without a probe, Mesh Bed Leveling provides a method to perform
 *   leveling in steps so you can manually adjust the Z height at each grid-point.
 *   With an LCD controller the process is guided step-by-step.
 */
//#define AUTO_BED_LEVELING_3POINT
//#define AUTO_BED_LEVELING_LINEAR
//#define AUTO_BED_LEVELING_BILINEAR
//#define AUTO_BED_LEVELING_UBL
//#define MESH_BED_LEVELING
```
If you are using 3-point levelling you enabled constant
```
AUTO_BED_LEVELING_3POINT
```
by removing the comment characters (
```
//
```
):
```
```
#define AUTO_BED_LEVELING_3POINT
```
```
to enable bi-linear levelling, you should remove the comment characters before constant
```
#define AUTO_BED_LEVELING_BILINEAR
```
:
```
```
#define AUTO_BED_LEVELING_BILINEAR
```
```
Definition of the grid is done by specifying how many point you want to have using constants
```
GRID_MAX_POINTS_X
```
and
```
GRID_MAX_POINTS_Y
```
:
```
#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)

  // Set the number of grid points per dimension.
  #define GRID_MAX_POINTS_X 3
  #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
```
The code above shows the default definition of a 9 point (3 x 3) grid.
Note that this will only work well if the area for the sensor to reach safely is correctly defined. If the sensor is missing the build plate, you have not correctly defined the limits for the sensor. Question
"How to set Z-probe boundary limits in firmware when using automatic bed leveling?"
has an
accepted answer
that describes how to define an area on the plate that the sensor may reach (the answer on this question also discusses Marlin 2.x).
In the specific case of the OP (after posting the config files)
From the posted configuration files your probe position can be obtained:
```
```
#define NOZZLE_TO_PROBE_OFFSET { 25, 55, 0 }
```
```
So your probe is at the right-back when facing the printer. Also your bed area attempt (commented) and the current active bed area can be obtained:
```
#if PROBE_SELECTED && !IS_KINEMATIC
  //#define MIN_PROBE_EDGE_LEFT 5
  //#define MIN_PROBE_EDGE_RIGHT 200
  //#define MIN_PROBE_EDGE_FRONT 55
  //#define MIN_PROBE_EDGE_BACK 200
  #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_RIGHT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_FRONT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_BACK MIN_PROBE_EDGE
#endif
```
From these excerpts it is clear that the bed limits are incorrectly defined.
Following the theory from
this answer
the probe is only allowed to visit the following (dark red) area:
This area is defined as:
```
#define MIN_PROBE_EDGE_LEFT (PROBE_OFFSET_X_FROM_EXTRUDER + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_RIGHT (MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_FRONT (PROBE_OFFSET_Y_FROM_EXTRUDER + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_BACK (MIN_PROBE_EDGE)
```
which translates to:
```
#define MIN_PROBE_EDGE_LEFT (25 + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_RIGHT (MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_FRONT (55 + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_BACK (MIN_PROBE_EDGE)
```
As seen in the commented
```
//#define MIN_PROBE_EDGE_LEFT 5
```
and uncommented
```
#define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
```
(equals 10) left probe limits, you are at least respectively 20  or 15 mm short, hence the sensor is not on the plate on the left.