TVShow S03E08 IoT Sit Counter
Once a luxury, sitting has now become an ailment. Have you yet wondered to just how many times in a day you sit or to what percentage of your day is consumed on bended knee? Making use of a resistance sensor and a NodeMCU ESP-12E, we are able to track our daily lethargy and display it in all of it's aggregated misery. Amend as needed.



Ingredients
1. NodeMCU ESP-12E
2. (2) LEDs
3. (4) 1K Resistor
4. Push Button
5. Slide Switch
6. 10K Pot

Butt-On State Code
// IoT Sit Counter
// Version 0.1
// VijeMiller

// NodeMCU ESP-12E 1.0
#include <ESP8266WiFi.h>

// WIFI Network Access
const char* ssid = "XXXXXX";
const char* password = "XXXXXXX";
WiFiServer server(80);

// ThingSpeak Access
char thingSpeakAddress[] = "api.thingspeak.com";
String APIKey = "XXXXXXXXXXX"; // API
const int updateThingSpeakInterval = 10 * 1000; // Interval
long lastConnectionTime = 0;
boolean lastConnected = false;
WiFiClient client;

// LEDs
int activeled = 13;
int wifiled = 12;

// Sensor
int sensor = A0;
int ssr = 0;
int sensorstart = 0;
int senres = 0;
int sensorstate = 0;

// Button
int button = 14;
int buttstate;

// Stats
int sitdown = 0;
int pretime = 0;
float dattime;
float runpert;

// States
int mainstate = 0;

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

pinMode(button, INPUT);
pinMode(activeled, OUTPUT);
pinMode(wifiled, OUTPUT);

digitalWrite(activeled, LOW);
digitalWrite(wifiled, LOW);

calibrate();
}

void loop() {

digitalWrite(activeled, HIGH);

// WIFI Button Pressed?
buttstate = digitalRead(button);

// WIFI Yes or No?
if (buttstate == HIGH) {
Serial.println("Connecting");
digitalWrite(wifiled, HIGH);

// Load WiFi
while (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid, password);
delay(10000);
}
Serial.println("Connected");
server.begin();

// Calculate Minutes Seated
dattime = pretime / 60.0;
// Truncate
dattime = (int) dattime;

// Calculate Percent Seated
runpert = millis();
// Convert to Seconds
runpert = runpert / 1000.0;
// Convert to Minutes
runpert = runpert / 60.0;
// Convert to Percent
runpert = dattime / runpert;
// Truncate
runpert = (int) runpert;

// Update ThingSpeak
String sitfinal = String(sitdown, DEC);
String timefinal = String(dattime, DEC);
String runfinal = String(runpert, DEC);
updateThingSpeak("field1=" + sitfinal + "&field2=" +
timefinal + "&field3=" + runfinal);
delay(3000);

// Reset Data
sitdown = 0;
pretime = 0;
dattime = 0;
runpert = 0;

} else {

// No WIFI
digitalWrite(wifiled, LOW);

// Read Sensor
sensorstate = analogRead(sensor);

// Sitting?
if (sensorstate > sensorstart) {
// Delay For 5 Seconds To Confirm Sit
if (mainstate == 0) {
delay(5000);
mainstate = 1;
goto escape;
} else if (mainstate == 1) {
// Add A Sit
sitdown = sitdown + 1;
// Run While Sitting To Track Time
// 1 Second Per Loop
while (sensorstate > sensorstart) {
sensorstate = analogRead(sensor);
pretime = pretime + 1;
delay(1000);
}
// Reset State
mainstate = 0;
}
}
}

delay(1000);
digitalWrite(activeled, LOW);
delay(1000);
escape:
}

// Calibrate While Standing
void calibrate() {
for (int x = 0; x < 10; x++) {
ssr = analogRead(sensor);
sensorstart = sensorstart + ssr;
delay(100);
digitalWrite(activeled, HIGH);
}
// sensorstart Equals Average Standing Value
sensorstart = sensorstart / 10;
// Add Leniency
sensorstart = sensorstart + 200;
digitalWrite(activeled, LOW);
}

// ThingSpeak
void updateThingSpeak(String tsData) {
if (client.connect(thingSpeakAddress, 80)) {
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + APIKey + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("\n\n");
client.print(tsData);
lastConnectionTime = millis();
}
}

Archive
https://hackaday.io/project/25152-iot-sit-counter
https://thingspeak.com/channels/281292
TVShow S03E07 Field Medic 101 Episode 4 "Triage"


TVShow S03E06 KNGI Roanoke


TVShow S03E05 Dogwalkers


A profession that shd be ridiculed and scorned is of course treated as more necessary than dignity in New York City. I for one welcome our climate change rising seas over lords.

Shd be noted, the quality is once again as result of a collaboration of absolutely NOT recommendable recording equipment; old Droid Razr -- and conditions; light bulbs, ambient light and a plastic green table cloth. These elements merge with an inescapable shrug while editing and my internal therapist rewards me with a treat, noting that we may ultimately move on. Moving on...
TVShow S03E04X76 Arduino Back Scratcher Plotter
Digitally ditch the itch --



Currently embracing a sans-work shop and poverty driven cardboard kick for the gluttony of least-interesting of novelty projects now done solely for critical thinking posterity -- other wise known as boredom.

Unable to reach that nook and/or cranny? Open the Back Scratcher Plotter app on your mobile device and identify the spot where then the X/Y axis is sent via bluetooth to the Arduino Uno affixed to the BSP prototype (sly analogy for rubbish) which then actuates to your -- you know what? Stop wasting your time sitting there even reading this nonsense and go some where -- like Typhoon Lagoon!

Ingredients
1. Arduino Uno
2. Bluetooth Module
3. (2) Servos
4. Motor
5. Cardboard
6. String
7. Masking Tape
8. Power Supply
9. Pulley
10. MIT App Inventor

Back-end Code
// Back Scratcher Plotter
// @VijeMiller
// TVMiller.com

#include <Servo.h>
#include <Stepper.h>

// Scratcher
const int stepsrev = 32;
Stepper scratch(stepsrev, 2, 4, 3, 5);

// For Bluetooth Data
String readString, xaxisdata, yaxisdata;

// X Axis
Servo xaxis;
// Y Axis
Servo yaxis;

int xpos = 90;
int ypos = 90; // Stall
int stall = 90;
int yup = 75;
int ydown = 105;
int pos = 90;

void setup() {
Serial.begin(9600);
// Max(?) Speed
scratch.setSpeed(800);
xaxis.attach(6);
yaxis.attach(7);
xaxis.write(xpos);
yaxis.write(ypos);
}

void loop() {

// Bluetooth Data X-Y Axis String?
while (Serial.available()) {
delay(10);
if (Serial.available() > 0) {
char c = Serial.read();
readString += c;
}
}

if (readString.length() > 0) {
// Serial.println(readString);
// X-Y Axis Combined Sent (ex. 368124)
// First 3 Digits
xaxisdata = readString.substring(0, 3);
// Next 3 Digits
yaxisdata = readString.substring(4, 6);

// Convert String to Int
int prexpos = xaxisdata.toInt();
int preypos = yaxisdata.toInt();

// X-Y Based on 480x800 Phone Dimension & MIT App
// X 100 to 350 High 170 to 320 Low
// Y 220 to 560
// Map X to xPos (Actual)
xpos = map(prexpos, 100, 350, 120, 60);
// Map Y to yPos (Delay)
ypos = map(preypos, 220, 560, 0, 6300);

}

// Final Routine
if (readString.length() > 0) {
if (xpos > 90) {
for (pos = 90; pos <= xpos; pos += 1) {
xaxis.write(pos);
delay(40);
}
}
else if (xpos < 90) {
for (pos = 90; pos >= xpos; pos -= 1) {
xaxis.write(pos);
delay(40);
}
}
yaxis.write(yup);
delay(ypos);
yaxis.write(stall);
// Scratch 2048 Steps = 1 Revolution (2 Up/Down)
// Used Stepper bcz Spare Parts -- Sigh!
// 2048 x 7 Seconds = 14336 Steps
scratch.step(14336);

// Return to Start
if (xpos > 90) {
for (pos = xpos; pos >= xpos; pos -= 1) {
xaxis.write(pos);
delay(40);
}
}
else if (xpos < 90) {
for (pos = xpos; pos <= xpos; pos += 1) {
xaxis.write(pos);
delay(40);
}
}
yaxis.write(ydown);
delay(ypos);
yaxis.write(stall);
}

// Reset
readString = "";
}

Archive
http://hackaday.com/2017/05/07/anatomic ... atch-fever
https://hackaday.io/project/21527-arduino-back-scratcher-plotter
https://vid.me/K3Tx
Last PageNext Page