You need a state vaiable than can remember what state you are in currently based on events in the past.
#define SENSOROFF 0
#define SENSORON 1
int sensorState = SENSOROFF;
void setup() {
... // keep as is
}
void loop()
{
...
switch(data)
{
case 's' : sensorState = SENSORON; break;
case 'z' : sensorState = SENSOROFF; break;
}
if (senssorState == SENSORON)
{
/Do something with your sensor here. when you send an 's' via serial, this part will continusly execute every time in the loop until you send a 'z'.
}
}