Hi, I just started learning how to use the Arduino a week ago and am stuck with my project.
I am suppose to create a healthcare system for elderly who are living alone and all the data are to be sent to a social worker wirelessly. I have already done a temperature sensor monitoring as well as a sensor for taking of medication. The problem i face now is using the ESP8266 WiFi module in my programs and hardware for wireless transmission of data. I am currently using the RF 433MHz Transmitter and Receiver now and do not know how to proceed with the ESP8266.
Would appreciate if someone can help me with the programming and configuration on how to in-cooperate the ESP8266 into my project.
Attached is the hardware that I have done, as well as the text document for the coding of my medication sensor (there isn't enough space for the coding here)
Below is the transmitter and receiver coding for the temperature sensor.
TRANSMITTER CODING FOR TEMPERATURE
#include <LiquidCrystal.h>
#include <Wire.h>
LiquidCrystal lcd(10, 9, 5, 4, 3, 2);
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK rf_driver;
const int sensorPin = A0; // the pin that the temperature sensor is connected to
const int buttonPin = A2; // the pin that the 'Up' push button is connected to
const int buttonPin1 = A1; // the pin that the 'Down' push button is connected to
int buttonPushCounter = 26; // counter for the number of button presses
int buttonStateA2 = 0; // current state of the 'Up' button
int buttonStateA1 = 0; // current state of the 'Down' button
int lastButtonState = 0; // previous state of the button
const int redLED = 8; // the pin that the Red LED is connected to
const int greenLED = 7; // the pin that the Green LED is connected to
void setup(){
Serial.begin(9600); // open a serial port
pinMode(6, OUTPUT); // output of LCD
pinMode(greenLED, OUTPUT); // output of Green LED
pinMode(redLED, OUTPUT); // output of Red LED
pinMode(buttonPin, INPUT); // input from Up push button
pinMode(buttonPin1, INPUT); // input from Down push button
lcd.begin(16,2);
rf_driver.init();
}
void counter(){ // coding for the 'Up' and 'Down' buttons
buttonStateA2 = digitalRead(buttonPin);
if(buttonStateA2 != lastButtonState){
if(buttonStateA2 == HIGH){
buttonPushCounter++;
Serial.print("counter: ");
Serial.println(buttonPushCounter);
}
}
lastButtonState = buttonStateA2;
buttonStateA1 = digitalRead(buttonPin1);
if(buttonStateA1 != lastButtonState){
if(buttonStateA1 == HIGH){
buttonPushCounter-=1;
Serial.print("counter: ");
Serial.println(buttonPushCounter);
}
}
lastButtonState = buttonStateA1;
}
void temperature(){
//temperature for TMP36GZ formula can be found on the internet
int sensorVal = analogRead(sensorPin);
Serial.print("sensor Value: ");
Serial.print(sensorVal);
float voltage = (sensorVal/1024.0) * 5.0;
Serial.print(", Volts: ");
Serial.print(voltage);
float temperature = (voltage - .5) * 100;
Serial.print(", degrees C: ");
Serial.println(temperature);
Serial.print("counter: ");
Serial.println(buttonPushCounter);
if(temperature < buttonPushCounter){
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
lcd.setCursor(0,0);
lcd.print("Temp = ");
lcd.print(temperature);
lcd.setCursor(0,1);
lcd.print("Temp Set = ");
lcd.print(buttonPushCounter);
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp is ok");
delay(1000);
lcd.clear();
const char*msg = "Patient's temperature is ok!";
rf_driver.send((uint8_t *)msg, strlen(msg));
rf_driver.waitPacketSent();
delay(50);
}
else if(temperature > buttonPushCounter){
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
lcd.setCursor(0,0);
lcd.print("Temp = ");
lcd.print(temperature);
lcd.setCursor(0,1);
lcd.print("Temp Set = ");
lcd.print(buttonPushCounter);
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp is not ok");
lcd.setCursor(0,1);
lcd.print("Pls visit Doctor");
delay(1000);
lcd.clear();
const char*msg = "Patient's temperature is not ok!";
rf_driver.send((uint8_t *)msg, strlen(msg));
rf_driver.waitPacketSent();
delay(50);
}
}
void loop(){
counter();
temperature();
}
RECEIVER CODING FOR TEMPERATURE
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK rf_driver;
void setup()
{
rf_driver.init();
Serial.begin(9600);
}
void loop()
{
uint8_t buf[32]="";
uint8_t buflen = sizeof(buf);
if (rf_driver.recv(buf, &buflen))
{
Serial.print("Message Received: ");
Serial.println((char*)buf);
}
}
MedicationArduinoCoding.txt (7.42 KB)