- How to connect sensors to ESP8266
- Simple web server programming
- Reading sensor data
- Creating basic web pages
- ESP8266 microcontroller (brain of the device)
- FSR sensor (detects inhaler puffs)
- BME280 sensor (temperature, humidity)
- OLED display (shows information)
- Buzzer (makes sounds for reminders)
You should know:
- Basic programming (variables, loops, functions)
- Simple electronics (connecting wires)
- How to use Arduino IDE
You'll need:
- Computer with Arduino IDE
- ESP8266 board and sensors (Check Readme.md)
- Breadboard and wires
The ESP8266 is like a small computer with WiFi. It can:
- Read sensors
- Connect to internet
- Run a simple website
- Store data
void setup() {
Serial.begin(115200); // Start communication
WiFi.begin(ssid, password); // Connect to WiFi
}Sensors give us numbers that represent real-world things:
// Read temperature sensor
float temperature = bme.readTemperature();
Serial.println("Temperature: " + String(temperature));
// Read puff sensor
int puffValue = analogRead(A0);
if (puffValue > 100) {
Serial.println("Puff detected!");
}Create a webpage that shows sensor data:
server.on("/", [](){
String webpage = "<h1>My Inhaler</h1>";
webpage += "<p>Temperature: " + String(temperature) + "</p>";
server.send(200, "text/html", webpage);
});Save information so it doesn't disappear when device restarts:
#include <EEPROM.h>
// Save puff count
int puffCount = 0;
EEPROM.put(0, puffCount); // Save to memory
EEPROM.get(0, puffCount); // Read from memory- Connect ESP8266 to computer
- Install Arduino IDE
- Upload simple "Hello World" program
- Check serial monitor for output
- Connect BME280 sensor
- Read temperature and humidity
- Print values to serial monitor
- Understand I2C communication
- Connect ESP8266 to WiFi
- Create simple web server
- Show sensor data on webpage
- Access from phone/computer browser
- Connect FSR sensor
- Detect when someone uses inhaler
- Count puffs
- Show count on display
- Add buzzer for reminders
- Store data permanently
- Create better web interface
- Add real-time updates
// Read and display sensor data every 2 seconds
void loop() {
float temp = bme.readTemperature();
Serial.println("Temperature: " + String(temp));
delay(2000);
}int puffCount = 0;
void loop() {
int sensor = analogRead(A0);
if (sensor > 100) {
puffCount++;
Serial.println("Puffs today: " + String(puffCount));
delay(1000); // Wait to avoid multiple counts
}
}void handleRoot() {
String html = "<html><body>";
html += "<h1>Smart Inhaler</h1>";
html += "<p>Puffs today: " + String(puffCount) + "</p>";
html += "<p>Temperature: " + String(temperature) + "°C</p>";
html += "</body></html>";
server.send(200, "text/html", html);
}- ESP8266: Main brain, handles WiFi and processing
- FSR Sensor: Detects when inhaler is pressed
- BME280: Measures temperature, humidity, air pressure
- OLED Display: Shows information on small screen
- Buzzer: Makes sounds for medication reminders
- Arduino Code: Instructions for the ESP8266
- Web Server: Creates a website hosted on the device
- Sensor Libraries: Pre-written code to read sensors
- WiFi Connection: Connects device to internet
- Check WiFi name and password
- Make sure device is close to router
- Restart ESP8266
- Check wire connections
- Verify sensor address (for I2C devices)
- Test with simple example code
- Check IP address in serial monitor
- Make sure computer is on same WiFi network
- Try restarting the ESP8266
Once you understand the basics:
- Add more sensors (air quality, light)
- Improve the website (add colors, graphs)
- Create mobile app (using simple tools)
- Add data logging (save data over time)
- Connect to cloud (send data to online service)
- Arduino IDE: Download from arduino.cc
- ESP8266 Guide: Basic tutorials online
- Sensor Datasheets: How to connect each sensor
- HTML Tutorial: To improve web interface
✓ ESP8266 connects to WiFi
✓ Sensors read data correctly
✓ Web page shows current data
✓ Puff detection works
✓ Data is saved between restarts
✓ Basic alerts/reminders work