Paolo Gentilematteo_milloneGiulioMhilli
Published

PistoncINO @vallauri

Remote control and monitoring of a pneumatic piston, using Blynk app

BeginnerWork in progress5 hours65
PistoncINO @vallauri

Things used in this project

Hardware components

Wemos D1 Mini
Espressif Wemos D1 Mini
×1
relay D1 mini Shield
×1
micro SD D1 mini Shield
×1
RGB LED D1 mini Shield
×1
Pneumatic Piston
×1
Pneumatic Electrovalve
×1
Power Generator 220 AC -24 DC
×1
Reed Switch, SPST-NO
Reed Switch, SPST-NO
×2
Pressure Switch, Air Compressor
Pressure Switch, Air Compressor
×1
Resistor, 10 kohm
Resistor, 10 kohm
×2

Software apps and online services

Blynk
Blynk
AutoCAD
Google Sheets
Google Sheets
Just for reading SD data.
Arduino IDE
Arduino IDE
ThingsBoard

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver
Laser cutter (generic)
Laser cutter (generic)
Soldering Station, 110 V
Soldering Station, 110 V

Story

Read more

Custom parts and enclosures

Wooden Box

Schematics

PistoncINO Video

Here it is a video that prove the functioning about this project

PistoncINO schematic

We used Fritzing App

Technical Report

Here it is the technical report that we made for this project

Code

PistoncINO code

Arduino
PAY ATTENTION: change before using auth Blynk token, and Wi-Fi ssid and password
#include <Adafruit_NeoPixel.h>
#include <NTPClient_Generic.h>
#include <WiFiUdp.h>
#include <SPI.h>
#include <SD.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial // You should get Auth Token in the Blynk  App.Go to the Project Settings (nut icon).

char auth[] = "xxxxxxxxxx_xxxxxxxxx-xxxxxxxxxxx";
char ssid[] = "xxxxxxxxxxxxx"; // Your WiFi credentials.
char password[] = "xxxxxxxxxxx"; // Set password to "" for open networks.
const int chipSelect = D4;
const long utcOffsetInSeconds = 3600;
String weekDays[7]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
String months[12]={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

WiFiUDP ntpUDP;// Define NTP Client to get time
NTPClient timeClient(ntpUDP, "pool.ntp.org");
BlynkTimer timer;

int StrokesBlynk = 0;
int InitialDelayBlynk = 0;
int PauseBlynk = 0;

int Aplus = D2;
int Amenus = D3;

int VButton = D0;
int relay = D1;
int Strokes = 0;

int trueStrokes = 0;
int truePause = 0;

#define PIN   D8 //RGB
#define LED_NUM 7 //RGB

Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_NUM, PIN, NEO_GRB + NEO_KHZ800); //RGB

//boolean state = LOW;

void setup()
{
  leds.begin(); //RGB
  //Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, password);
  pinMode(VButton, INPUT);
  pinMode(relay, OUTPUT);
  pinMode(Aplus, INPUT);
  pinMode(Amenus, INPUT);
  timer.setInterval(300L, finecorsa);
  //while (!Serial) { ; } wait for serial port to connect. Needed for Leonardo only
  Serial.print("Initializing SD card...");
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    return;
  }
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }

  timeClient.begin();// Set offset time in seconds to adjust for your timezone
  timeClient.setTimeOffset(3600);// In Italy, There is a GMT offset of +1 hour
}

void led_set(uint8 R, uint8 G, uint8 B) {
  for (int i = 0; i < LED_NUM; i++) {
    leds.setPixelColor(i, leds.Color(R, G, B));
    leds.show();
    delay(50);
  }
}

BLYNK_WRITE(V0) //done strokes from Blynk to Wemos
{
  StrokesBlynk = param.asInt();
  Serial.print("Strokes: ");
  Serial.println(StrokesBlynk);
}

BLYNK_WRITE(V1) //initial delay from Blynk to Wemos
{
  InitialDelayBlynk = param.asInt();
  Serial.print("InitialDelay : ");
  Serial.println(InitialDelayBlynk);
}

BLYNK_WRITE(V2) //Pause between 2 strokes
{
  PauseBlynk = param.asInt();
  Serial.print("Pause : ");
  Serial.println(PauseBlynk);
}

void loop() {
  File dataFile = SD.open("datalog.odf", FILE_WRITE);
  Blynk.run();
  timer.run();
  if (digitalRead(VButton) && (digitalRead(Amenus))) {
    Strokes = 0;
    truePause = PauseBlynk;
    trueStrokes = StrokesBlynk;
    delay(InitialDelayBlynk * 1000);
    digitalWrite(relay, HIGH);
    dataFile.print(" requested stroke: ");
    dataFile.println(trueStrokes);
    dataFile.close();
  }
}

void finecorsa () {
  timeClient.update();  //String dataString = "";
  File dataFile = SD.open("datalog.odf", FILE_WRITE);
  if (digitalRead(Aplus)) {
    digitalWrite(relay, LOW);
    led_set(100, 0, 0); //red
    Strokes = Strokes + 1;
    Serial.print("done strokes: ");//Serial.print(daysOfTheWeek[timeClient.getDay()]);
    Serial.println(Strokes);
    Blynk.virtualWrite(V3, Strokes);
    unsigned long epochTime = timeClient.getEpochTime();
    Serial.print("Epoch Time: ");
    Serial.println(epochTime);    
    dataFile.print("Epoch Time; ");
    dataFile.print(epochTime);
    dataFile.print("; ");
    dataFile.print(timeClient.getFormattedTime());
    dataFile.print("; ");
    dataFile.print("done strokes: ");
    dataFile.print(Strokes);
    dataFile.println(";");
    dataFile.close();
  }
  else if (digitalRead(Amenus) && (Strokes < trueStrokes)) {
    led_set(100, 100, 0); //yellow
    delay(truePause * 1000);
    digitalWrite(relay, HIGH);
    led_set(100, 0, 0); //red
  }
  else if (digitalRead(Amenus) && (Strokes >= trueStrokes)) {
    Strokes = 0;
    trueStrokes = 0;
    Blynk.virtualWrite(V3, Strokes);
    led_set(0, 100, 0); //green
  }
}

Credits

Paolo Gentile

Paolo Gentile

1 project • 0 followers
matteo_millone

matteo_millone

1 project • 0 followers
GiulioMhilli

GiulioMhilli

1 project • 0 followers

Comments

Add projectSign up / Login