Santiago Munoz
Published

Mars Pressure Checker

See Mars's Average Pressure, visualized using a servo motor.

IntermediateWork in progress44
Mars Pressure Checker

Things used in this project

Hardware components

Photon
Particle Photon
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Jumper wires (generic)
Jumper wires (generic)
×3

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
NASA Mars Weather API

Hand tools and fabrication machines

Extraction Tool, 6 Piece Screw Extractor & Screwdriver Set
Extraction Tool, 6 Piece Screw Extractor & Screwdriver Set
Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Schematics

Schematics

Code

Code

C/C++
// This #include statement was automatically added by the Particle IDE.
#include <ArduinoJson.h>

// The number below has to be updated to the correct doc size
// Use the official ArduinoJSON Assistant below:
// https://arduinojson.org/v6/assistant/
StaticJsonDocument<6144> doc;

Servo myservo;  // create servo object to control a servo
int pos = 0;    // variable to store the servo position

String incomingJson = "";
int counter = 0;

void setup()
{
    myservo.attach(D2); // attaches the servo on the D0 pin to the servo object
    Particle.subscribe("hook-response/marsPressure", myHandler, MY_DEVICES); // Subscribe to the webhook response event
    myservo.write(0);
}

void loop() {
    String data = String(10); // Get some data
    Particle.publish("marsPressure", data, PRIVATE); // Trigger the integration
    delay(5000); // Wait 5 seconds
}

void myHandler(const char *event, const char *data)
{
    double marsPressure = atof(data);
    
    if(marsPressure > 625.00 && marsPressure < 805.00){
        int pos = (int) (marsPressure-625.00);
        myservo.write(pos);
        delay(200);
    }
}

Credits

Santiago Munoz

Santiago Munoz

1 project • 1 follower

Comments

Add projectSign up / Login