Need Help with Microcontroller Coding

Hello, I'm not good at ENG please forgive me.

I'm making the watering system by soil conditions.
I'm using 10 reed switch to get water level in crop area.
And I have to get a sensor value and send it to Raspberry PI 3(Model B) via WIFI.
My reed switches connected with Arduino UNO + NodeMCU.
I'm using 74HC165(PISO) x2 for 10 water level.
I also can get the sensor value by using this code.

/*
 * SN74HC165N_shift_reg
 *
 * Program to shift in the bit values from a SN74HC165N 8-bit
 * parallel-in/serial-out shift register.
 *
 * This sketch demonstrates reading in 16 digital states from a
 * pair of daisy-chained SN74HC165N shift registers while using
 * only 4 digital pins on the Arduino.
 *
 * You can daisy-chain these chips by connecting the serial-out
 * (Q7 pin) on one shift register to the serial-in (Ds pin) of
 * the other.
 * 
 * Of course you can daisy chain as many as you like while still
 * using only 4 Arduino pins (though you would have to process
 * them 4 at a time into separate unsigned long variables).
 * 
*/

/* How many shift register chips are daisy-chained.
*/
#define NUMBER_OF_SHIFT_CHIPS   2

/* Width of data (how many ext lines).
*/
#define DATA_WIDTH   NUMBER_OF_SHIFT_CHIPS * 8

/* Width of pulse to trigger the shift register to read and latch.
*/
#define PULSE_WIDTH_USEC   5

/* Optional delay between shift register reads.
*/
#define POLL_DELAY_MSEC   1

/* You will need to change the "int" to "long" If the
 * NUMBER_OF_SHIFT_CHIPS is higher than 2.
*/
#define BYTES_VAL_T unsigned int

int ploadPin        = 8;  // Connects to Parallel load pin the 165
int clockEnablePin  = 9;  // Connects to Clock Enable pin the 165
int dataPin         = 11; // Connects to the Q7 pin the 165
int clockPin        = 12; // Connects to the Clock pin the 165

BYTES_VAL_T pinValues;
BYTES_VAL_T oldPinValues;

/* This function is essentially a "shift-in" routine reading the
 * serial Data from the shift register chips and representing
 * the state of those pins in an unsigned integer (or long).
*/
BYTES_VAL_T read_shift_regs()
{
    long bitVal;
    BYTES_VAL_T bytesVal = 0;

    /* Trigger a parallel Load to latch the state of the data lines,
    */
    digitalWrite(clockEnablePin, HIGH);
    digitalWrite(ploadPin, LOW);
    delayMicroseconds(PULSE_WIDTH_USEC);
    digitalWrite(ploadPin, HIGH);
    digitalWrite(clockEnablePin, LOW);

    /* Loop to read each bit value from the serial out line
     * of the SN74HC165N.
    */
    for(int i = 0; i < DATA_WIDTH; i++)
    {
        bitVal = digitalRead(dataPin);

        /* Set the corresponding bit in bytesVal.
        */
        bytesVal |= (bitVal << ((DATA_WIDTH-1) - i));

        /* Pulse the Clock (rising edge shifts the next bit).
        */
        digitalWrite(clockPin, HIGH);
        delayMicroseconds(PULSE_WIDTH_USEC);
        digitalWrite(clockPin, LOW);
    }

    return(bytesVal);
}

/* Dump the list of zones along with their current status.
*/
void display_pin_values()
{
    Serial.print("Pin States:\r\n");

    for(int i = 0; i < DATA_WIDTH; i++)
    {
        Serial.print("  Pin-");
        Serial.print(i);
        Serial.print(": ");

        if((pinValues >> i) & 1)
            Serial.print("HIGH");
        else
            Serial.print("LOW");

        Serial.print("\r\n");
    }

    Serial.print("\r\n");
}

void setup()
{
    Serial.begin(9600);

    /* Initialize our digital pins...
    */
    pinMode(ploadPin, OUTPUT);
    pinMode(clockEnablePin, OUTPUT);
    pinMode(clockPin, OUTPUT);
    pinMode(dataPin, INPUT);

    digitalWrite(clockPin, LOW);
    digitalWrite(ploadPin, HIGH);

    /* Read in and display the pin states at startup.
    */
    pinValues = read_shift_regs();
    display_pin_values();
    oldPinValues = pinValues;
}

void loop()
{
    /* Read the state of all zones.
    */
    pinValues = read_shift_regs();

    /* If there was a chage in state, display which ones changed.
    */
    if(pinValues != oldPinValues)
    {
        Serial.print("*Pin value change detected*\r\n");
        display_pin_values();
        oldPinValues = pinValues;
    }

    delay(POLL_DELAY_MSEC);
}

My Professor said I have to set start/stop bit to sent the data but I don't really know anything about it.
So what do I have to do in Arduino and NodeMCU coding?
or it is another way to make it work i want to learn it.

PS. There are other sensor to calculate the watering.

Many Thanks for any help.
LuridAngus.

My Professor said I have to set start/stop bit to sent the data but I don't really know anything about it.

Your Professor hasn't a clue what he/she is talking about.

    if(pinValues != oldPinValues)
    {
        Serial.print("*Pin value change detected*\r\n");
        display_pin_values();
        oldPinValues = pinValues;
    }

Seems to me that you'd want to do more than write the current values to the serial port. Unless that is where the Pi is connected.

How IS the Pi involved? How IS the NodeMCU connected/involved?

LuridAngus:
My Professor said I have to set start/stop bit to sent the data but I don't really know anything about it.
So what do I have to do in Arduino and NodeMCU coding?
or it is another way to make it work i want to learn it.

Like @PaulS, I can't make sense of that.

What does your existing program actually do and what do you want it to do that is different? Give as much detail as possible,

...R

There seems to be a terminology issue. It's confusing to say

LuridAngus:
using 10 reed switch...

get a sensor value...

I also can get the sensor value by using this code.

and the code following deals only with the shift register.

In your context exactly what is a sensor ?

1. I have understood this much from your post:
reedsw.png

(1) You have 10 'Reed Switches' connected with two 74HC165 shift registers in daisy chain fahion.

(2) You are collecting the serial data from the shift registers by the Arduino UNO.

2. Queries:
(1) After that the data is going to where from UNO? Is it going to NodeMCU? If so, via which communication line -- UART ?

(2) After receiving the data from Arduino UNO, the NodeMCU is doing what with this data?

(3) I know that Reed Switch is one kind of magnetic proximity switch and it works (activates) by a nearby magnetic field. How are you going to sense water level/water presence with this switch?

reedsw.png