Megan OgleSam MalmfeltWilliam Heidtmann
Published

Power-Walking

Transform the energy you use while walking into useable electrical power and obtain real-time monitored data!

Advanced3 hours978
Power-Walking

Things used in this project

Hardware components

Piezoelectric Chip
×1
Particle Photon Maker Kit
×3
1N4001 Diode
×4

Software apps and online services

Particle IOT
ThingSpeak API
ThingSpeak API

Story

Read more

Schematics

Circuit Diagram

Circuit

Code

Photon 1 (kitty_dentist) Code

C/C++
This is the coding for the first photon, gathering raw data across the piezoelectric chip.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>
TCPClient client;

unsigned int myChannelNumber = 620537;
const char * myWriteAPIKey = "01DDNK01ER7LZPBG";

void setup() {

pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(D0, INPUT);
pinMode(D2, INPUT);
pinMode(D7, OUTPUT);
ThingSpeak.begin(client);
}

void loop() {

float vin = analogRead(A1);
float vout = analogRead(A2);
float potentialRaw = vin - vout;

  // Trigger the integration
  ThingSpeak.setField(1,potentialRaw);
  ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);
  // Wait 1 second
  delay(1000);
  
Particle.publish("sendraw", String(potentialRaw));


if ((digitalRead(D0) == 1))
 {
      if((digitalRead(D2) == 1))
     {
       digitalWrite(D7, HIGH);
     }
  }
}

Photon 2 (megans_photon) Code

C/C++
This is the coding for the second photon gathering smooth data across the capacitor.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>
TCPClient client;


unsigned int myChannelNumber = 620535; // replace with your ChannelID
const char * myWriteAPIKey = "7QN4O2ESE1FHURSQ"; // replace with your WriteAPIKey




void setup() {
    pinMode(A1,INPUT); //tells photon what the pins will be used for
    pinMode(A2,INPUT);
    pinMode(A3,OUTPUT);
    pinMode(A4,INPUT);
    pinMode(A5,OUTPUT);
    pinMode(D0,INPUT);
    pinMode(D1,OUTPUT);
    pinMode(D7,OUTPUT);
    ThingSpeak.begin(client);
}

void loop() {
float vin = analogRead(A1);
float vout = analogRead(A2);
float potentialSmooth = vin - vout;

Particle.publish("sendsmooth", String(potentialSmooth));
float potentialRaw;

potentialRaw = Particle.subscribe("sendraw",myhandler);
ThingSpeak.setField(1,potentialSmooth);

  delay(1000);


ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);  
  // Wait 1 second


if (digitalRead(D0) == 1)
 {
    digitalWrite(D1,HIGH);
    digitalWrite(D7,HIGH);
 }


}

void myhandler(const char *event, const char *potentialRaw)
{
    atof(potentialRaw);
    ThingSpeak.setField(2,potentialRaw);
}

Photon 3 (smalmfelt) Code

C/C++
This is the code for the third photon processing data and sending a stop function.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>
TCPClient client;

unsigned int myChannelNumber = 624233; //replace with ChannelID
const char * myWriteAPIKey = "7TTWBJLU6O5S1B2L"; //replace with writeAPIkey

void setup() {
    pinMode(D0,OUTPUT);
    pinMode(D1,OUTPUT);
    ThingSpeak.begin(client);
}

void loop() {
    float raw;
    float smooth;
    raw = Particle.subscribe("sendraw", myhandler1); 
    delay(1000);
    smooth = Particle.subscribe("sendsmooth", myhandler2); 

ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);
    
    if (smooth > 1)
    {
        digitalWrite(D0,HIGH); 
        digitalWrite(D1,HIGH);
    }
}
void myhandler1(const char *event, const char *raw)
{   atof(raw);
    ThingSpeak.setField(2,raw);
}
void myhandler2(const char *event, const char *smooth)
{   atof(smooth);
    ThingSpeak.setField(1,smooth);
}
    

Credits

Megan Ogle

Megan Ogle

1 project • 1 follower
Sam Malmfelt

Sam Malmfelt

1 project • 2 followers
William Heidtmann

William Heidtmann

1 project • 1 follower

Comments