Projects / Bed position turn reminder

Bed position turn reminder

Intermediate3 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. ESP32FSR402

    Wire one pad

    Wire an FSR with its 10 kΩ and print the reading while pressing it.

  2. ESP32

    Wire all four

    Repeat for the other pads and print all four numbers.

  3. ESP32

    Find the levels

    Lie on the pads in left, back and right positions and note the readings.

  4. ESP32

    Set EMPTY_LEVEL

    Use a value just above the empty-bed noise.

  5. ESP32

    Upload

    Check the screen changes position after a minute in a new position.

  6. ESP32

    Add the reminder

    Set TURN_MS to your care plan and test with a short time first.

In short

How do you build a bed position turn reminder?

Pressure pads under a mattress track how long a patient has lain in one position and remind carers to turn them. A prompt for carers, not a medical device. You need ESP32 DevKit V1, Force sensitive resistor FSR 402 × 4, Resistor 10 kΩ × 4, Active buzzer 5 V and SSD1306 OLED Display. It takes 6 steps and about 180 minutes.

Level
Intermediate
Time
About 180 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Each FSR 402 leg 1ESP32 3V3Top of each divider
FSR 1 leg 2 (left pad)ESP32 GPIO34 and 10 kΩ to GNDLeft
FSR 2 leg 2 (centre pad)ESP32 GPIO35 and 10 kΩ to GNDCentre
FSR 3 leg 2 (right pad)ESP32 GPIO32 and 10 kΩ to GNDRight
FSR 4 leg 2 (spare pad)ESP32 GPIO33 and 10 kΩ to GNDHead or foot end
Active buzzer +ESP32 GPIO4Reminder
Active buzzer -ESP32 GNDReturn
OLED SDA, SCLESP32 GPIO21, GPIO22I2C
OLED VCC, GNDESP32 3V3, GNDPower

Code

Arduino IDE with the ESP32 boards package, board "ESP32 Dev Module". Install "U8g2". The FSR 402 is a small sensor, so put each one under a stiff 6 cm square of card or plastic on a firm base so the load spreads onto it; thick mattresses make the readings unreliable and you must calibrate the thresholds for your own bed and the person using it. This is a prompt for carers and does not replace the turning schedule from a clinician or nurse. Never rely on it for a patient at risk of pressure injuries, and check the skin by hand as advised.

Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <U8x8lib.h>

U8X8_SSD1306_128X64_NONAME_HW_I2C oled(U8X8_PIN_NONE);
const byte PADS[4] = { 34, 35, 32, 33 };
const int EMPTY_LEVEL = 150;                       // total reading below this means nobody in bed
const unsigned long TURN_MS = 2UL * 3600UL * 1000UL;   // remind after 2 hours; set to your care plan
const unsigned long CONFIRM_MS = 60000UL;          // position must hold for a minute to count as a change
byte position = 0, candidate = 0;                  // 0 empty, 1 left, 2 back, 3 right
unsigned long positionSince = 0, candidateSince = 0, lastBeep = 0;
const char* NAMES[4] = { "Empty ", "Left  ", "Back  ", "Right " };

int readPad(byte i) {
  long s = 0;
  for (byte k = 0; k < 8; k++) { s += analogRead(PADS[i]); delay(2); }
  return s / 8;
}

byte classify() {
  int l = readPad(0), c = readPad(1), r = readPad(2), x = readPad(3);
  if (l + c + r + x < EMPTY_LEVEL) return 0;
  if (l > c && l > r) return 1;
  if (r > c && r > l) return 3;
  return 2;
}

void setup() {
  pinMode(4, OUTPUT);
  oled.begin();
  oled.setFont(u8x8_font_chroma48medium8_r);
  positionSince = millis();
}

void loop() {
  byte now = classify();
  if (now != position) {
    if (now != candidate) { candidate = now; candidateSince = millis(); }
    else if (millis() - candidateSince > CONFIRM_MS) {   // a change that lasted
      position = now; positionSince = millis();
      if (position) { /* a turn: record it here, for example print to Serial for a log */ }
    }
  } else candidate = position;

  unsigned long held = millis() - positionSince;
  char b[17];
  oled.drawString(0, 1, NAMES[position]);
  snprintf(b, sizeof b, "%3lu min        ", held / 60000UL);
  oled.drawString(0, 3, b);
  bool due = position != 0 && held > TURN_MS;
  oled.drawString(0, 5, due ? "TURN PATIENT  " : "OK            ");
  if (due && millis() - lastBeep > 30000UL) { digitalWrite(4, HIGH); delay(300); digitalWrite(4, LOW); lastBeep = millis(); }
  delay(1000);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Empty bedEmpty
Lying on the leftLeft after a minute
Turning to the rightRight and the timer restarts
Held for the reminder timeTURN PATIENT and a beep every 30 seconds

If it does not work

Always empty

Pads are not loaded enough. Use stiffer plates or raise the pad sensitivity.

Wrong position

Re-check which pad is which and the readings in each position.

Timer never resets

The change must last the confirm time.

Noisy readings

Seat the sensors flat and keep wires short.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the bed position turn reminder?

ESP32 DevKit V1, Force sensitive resistor FSR 402 × 4, Resistor 10 kΩ × 4, Active buzzer 5 V and SSD1306 OLED Display.

How long does the bed position turn reminder take to build?

About 180 minutes for a intermediate maker, in 6 steps.

How do I know the bed position turn reminder works?

Empty bed: Empty. Lying on the left: Left after a minute. Turning to the right: Right and the timer restarts.

Always empty: what should I check?

Pads are not loaded enough. Use stiffer plates or raise the pad sensitivity.

Wrong position: what should I check?

Re-check which pad is which and the readings in each position.

Timer never resets: what should I check?

The change must last the confirm time.

Noisy readings: what should I check?

Seat the sensors flat and keep wires short.