Shahariar
Published © GPL3+

Arduino: 4-Ch Wave'O-Scope/Data Logging Voltmeter (EEPROM)

A 4-channel slowpoke oscilloscope and voltmeter up to 25 Volt DC (single ended) with data logging capabilities.

AdvancedShowcase (no instructions)12 hours2,193
Arduino: 4-Ch Wave'O-Scope/Data Logging Voltmeter (EEPROM)

Things used in this project

Hardware components

SparkFun MC 34063
×1
Real Time Clock (RTC)
Real Time Clock (RTC)
×1
ICStation UNO
ICStation UNO
×1
Adafruit TFT 1.8 Inch LCD
×1

Story

Read more

Schematics

RTC

Clock

Power Supply

LiPO 3v7 to 5v0 boost converter

Analog Front End

Charger

Code

_1_TFT_Clock+OScope+VM+Datalogger.ino

Arduino
main
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;
uint8_t x=0;

volatile uint8_t S1=1;
volatile uint8_t S2=1;


// For the breakout, you can use any 2 or 3 pins
// These pins will also work for the 1.8" TFT shield
#define TFT_CS     10
#define TFT_RST    9  // you can also connect this to the Arduino reset
                      // in which case, set this #define pin to 0!
#define TFT_DC     8
#define YELLOW_LED 4
// Option 1 (recommended): must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

#define TFT_SCLK 13   // set these to be whatever pins you like!
#define TFT_MOSI 11   // set these to be whatever pins you like!
#define OFFSET 120
int Ch0[160];
int Ch1[160];
int Ch2[160];
int Ch3[160];
int i=0;



void setup(void) {
  pinMode(4,OUTPUT);
  digitalWrite(4,0);
 button_init(); 
 adc_init();
  
  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
tft.setRotation(3);
#ifdef AVR
  Wire.begin();
#else
  Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
  rtc.begin();
  if (! rtc.isrunning()) {
    tft.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
     rtc.adjust(DateTime(2016, 10, 11, 00, 7, 00));
  }
  tft.fillScreen(ST7735_BLACK);
  tft.fillScreen(ST7735_BLACK);

}

void loop() 

  {
tftPrintTime();
tftPrintWave();
tft.fillScreen(ST7735_BLACK);

   }

void tftPrintTime() {
 DateTime now = rtc.now();
  
 // tft.setTextWrap(false);
 // tft.fillScreen(ST7735_BLACK);
  
  tft.setTextColor(ST7735_YELLOW);
  tft.setTextSize(1);
  
  tft.setCursor(2, 10);
  tft.print(now.year(), DEC);
  tft.print('/');
  tft.print(now.month(), DEC);
  tft.print('/');
  tft.print(now.day(), DEC);
 tft.print("      ");
  
  tft.setTextColor(ST7735_GREEN);
  tft.setTextSize(1);
 
  tft.print(now.hour(), DEC);
  tft.print(':');
  tft.print(now.minute(), DEC);
  tft.print(':');
  tft.println(now.second(), DEC);
 
  tft.setTextColor(ST7735_CYAN);
  tft.setTextSize(1);
/* tft.println("  " );
 tft.print("Channel 0 : ");
 tft.println(analogRead(A0));
 tft.println("  " );
 
 tft.print("Channel 1 : ");
 tft.println(analogRead(A1));
 tft.println("  " );
 
 tft.print("Channel 2 : ");
 tft.println(analogRead(A2));
 tft.println("  " );
 
 tft.print("Channel 3 : "); 
 tft.println(analogRead(A3));
 tft.println("  " );
 */
 
 
  
}


void tftPrintWave()
{
//  tft.fillScreen(ST7735_BLACK);
 tft.setCursor(0,120);
  tft.drawFastHLine(0, 120, tft.width(), ST7735_WHITE);
for (i=0;i<160;i++)
{
  Ch0[i]=OFFSET-analogRead(A0)/10;
  Ch1[i]=OFFSET-analogRead(A1)/10;
  Ch2[i]=OFFSET-analogRead(A2)/10;
  Ch3[i]=OFFSET-analogRead(A3)/10;
}
 
for (i=0;i<160;i++)
{
 tft.drawLine(i,Ch0[i],1+i,Ch0[i+1],ST7735_RED);
 tft.drawLine(i,Ch1[i],1+i,Ch1[i+1],ST7735_BLUE);
 tft.drawLine(i,Ch2[i],1+i,Ch2[i+1],ST7735_GREEN);
 tft.drawLine(i,Ch3[i],1+i,Ch3[i+1],ST7735_YELLOW);

//tft.drawPixel(i,Ch0[i],ST7735_RED);
//tft.drawPixel(i,Ch1[i],ST7735_BLUE);
//tft.drawPixel(i,Ch2[i],ST7735_GREEN);
//tft.drawPixel(i,Ch3[i],ST7735_YELLOW);

}
  

}



void adc_init (void)
{
//  analogReference(INTERNAL);
}

Credits

Shahariar

Shahariar

71 projects • 260 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"
Thanks to Limor Fried & Adafruit Staffs.

Comments