搜索
bottom↓
回复: 22

DIY mega328+1.3OLED+DS3231 可设置响闹钟时间表

[复制链接]

出0入104汤圆

发表于 2017-7-27 18:16:43 | 显示全部楼层 |阅读模式
本帖最后由 andy 于 2017-7-27 18:26 编辑

DIY mega328+1.3OLED+DS3231 可设置响闹钟时间表

将XX.Hex写入到mini328P就可以,方法参考以下网页。

https://www.amobbs.com/thread-5665432-1-1.html
将Arduino mini328P 变作 AVR 全系列编程器(下载线) 超简单

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出0入0汤圆

发表于 2017-7-27 18:30:09 | 显示全部楼层
想了解楼主图是怎么画出来的

出0入0汤圆

发表于 2017-7-27 18:53:28 | 显示全部楼层
外观还可以再优化优化

出0入0汤圆

发表于 2017-7-27 21:23:38 | 显示全部楼层
krdzw 发表于 2017-7-27 18:30
想了解楼主图是怎么画出来的

这应该是Fritzing画的

出0入104汤圆

 楼主| 发表于 2017-7-29 13:57:32 | 显示全部楼层
注意以下:
1 > 1.3寸/0.96寸OLED选用(SH1106)
2 > 蜂鸣器选用(有原的蜂鸣器)

出0入104汤圆

 楼主| 发表于 2017-8-22 10:40:46 来自手机 | 显示全部楼层
本帖最后由 andy 于 2017-8-22 13:34 编辑

重新制作外型增加多项功能

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2017-8-22 13:35:50 | 显示全部楼层
厉害了  这电池 充满  能续航多久?

出0入104汤圆

 楼主| 发表于 2017-8-22 17:45:29 | 显示全部楼层
一共用了10个部件。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2017-8-22 19:31:52 来自手机 | 显示全部楼层
ayumi8 发表于 2017-8-22 13:35
厉害了  这电池 充满  能续航多久?

+1
不错,时间精度可以吗?我想做一个。

出0入104汤圆

 楼主| 发表于 2017-8-22 19:39:52 来自手机 | 显示全部楼层
时间超准,因为DS3231是工业级的。

出0入104汤圆

 楼主| 发表于 2018-1-20 09:40:53 | 显示全部楼层
本帖最后由 andy 于 2018-1-20 14:35 编辑

将这个坐台钟升级,增加一个GY-9250模块(9轴 MPU9250),还增加一个BME280模块(气压、温度、湿度)。
可设置响闹钟时间表,步计器,电子指南针,气压高度计,温湿度显示器。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入104汤圆

 楼主| 发表于 2018-1-20 10:40:10 | 显示全部楼层
cc2666 发表于 2018-1-20 10:19
为什么不用个esp8266,把天气也加进来

要加都不加esp8266,真要加的话都是加ESP32这个模块。

这个内里放不下了。

出50入4汤圆

发表于 2018-1-20 10:42:44 | 显示全部楼层
分享个OLED程序和字库呗,字体感觉挺好看的

出0入104汤圆

 楼主| 发表于 2018-1-22 08:28:07 | 显示全部楼层
第一行显示(DS3231)实时时间及温度
第二行显示(BME280)实时温度及湿度
第三行显示(BME280)实时气压Pa值
第四行显示(BME280)实时海拔高度

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2018-1-22 14:10:39 | 显示全部楼层
andy 发表于 2018-1-22 08:28
第一行显示(DS3231)实时时间及温度
第二行显示(BME280)实时温度及湿度
第三行显示(BME280)实时气压Pa值

漂亮

出0入104汤圆

 楼主| 发表于 2018-1-24 07:14:46 | 显示全部楼层
本帖最后由 andy 于 2018-1-24 11:57 编辑

第一行显示DS3231实时(时、 分、秒 、温度)  
第二行显示BME280(湿度、温度、偏移量)
第三行显示气压数值xxxxxxPa
第四行显示高度米  



/***************************************************************************
  This is a library for the BME280 humidity, temperature & pressure sensor

  Designed specifically to work with the Adafruit BME280 Breakout
  ----> http://www.adafruit.com/products/2650

  These sensors use I2C or SPI to communicate, 2 or 4 pins are required
  to interface. The device's I2C address is either 0x76 or 0x77.

  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!

  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
***************************************************************************/
//BME280(运行SPI),SH1106(运行I2C)显示温湿度、气压Pa、高度
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <U8glib.h>
#include <DS3231.h>

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 6

//设置当地当时的参考气压值
#define SEALEVELPRESSURE_HPA (1010.00)

// Adafruit_BME280 bme;  // I2C
// Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
// 选用硬件SPI CS,MOSI,MISO,SCK
Adafruit_BME280 bme(BME_CS); // hardware SPI

U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE);  // I2C / TWI
DS3231 clock;
RTCDateTime dt;

unsigned long delayTime;

const int buttonUp   = 7;
const int buttonDown = 10;
int buttonUpState   = 0;
int buttonDownState = 0;
byte Old_key_Down=LOW;
byte Old_key_Up=LOW;
//偏移量
float count=25;

void draw()
{
  dt = clock.getDateTime();

  buttonUpState=digitalRead(buttonUp);
  buttonDownState=digitalRead(buttonDown);
  if (buttonUpState && buttonUpState != Old_key_Up)
  {  
      if (count < 99)
         count++;
  }
  Old_key_Up = buttonUpState;

  if (buttonDownState && buttonDownState != Old_key_Down)
  {  
      if (count > 0)
           count--;
  }
  Old_key_Down = buttonDownState;

  u8g.setFont(u8g_font_8x13B);
  u8g.drawRFrame(0, 0, 128, 64, 4);  //(0, 0, 128, 16, 4);设置外匡
//u8g.drawRFrame(0, 16, 128, 48, 4); // 设置外匡
  u8g.drawHLine(0,16,128);  //起点横坐标 x,起点纵坐标 y,线段长度 h(h个像素点)

//第一行显示DS3231实时(时、 分、秒 、温度)  
  u8g.setPrintPos(4, 13);
  u8g.print(dt.hour);
  u8g.print(":");
  if(dt.minute < 10)
    u8g.print("0");
  u8g.print(dt.minute);
  u8g.print(":");
  if(dt.second < 10)
    u8g.print("0");
  u8g.print(dt.second);
  u8g.print(" ");
  u8g.print(clock.readTemperature(), 1);
  u8g.print(char(176)); //温度符号
  u8g.print("C");
//第二行显示BME280(湿度、温度、偏移量)
  u8g.setPrintPos(4, 31);     //10 设置下文中print()的显示位置 x:横坐标 y:纵坐标
  u8g.print(bme.readHumidity(), 1);
  u8g.print("% ");
  u8g.print(bme.readTemperature(), 1);
  u8g.print(char(176));//温度符号 u8g.drawCircle(103, 22, 2); //Grau
  u8g.print("C ");
  u8g.print(byte(count), DEC);
//第三行显示气压数值xxxxxxPa
  //Mostra a pressao (em hPa)
  u8g.drawStr(10, 45, "Pres:");
  u8g.setPrintPos(55, 45);
  u8g.print(bme.readPressure(), 1);
//第四行显示高度米   
  //Mostra a altitude
  u8g.drawStr(10, 59, "Alt :          "); //drawStr 显示字符串
  u8g.setPrintPos(55, 59);//55
  u8g.print(bme.readAltitude((SEALEVELPRESSURE_HPA) + count / 4), 1);  //(偏移量/4)=0.25,(每级偏移量0.25)
  u8g.print("m");
}
void setup() {
  
    pinMode(buttonUp,INPUT_PULLUP);  
    pinMode(buttonDown,INPUT_PULLUP);
     
    Wire.begin();
    u8g.begin();
    clock.begin();
    Serial.begin(115200);
    Serial.println(F("BME280 test"));
    bool status;
    // default settings
    // (you can also pass in a Wire library object like &Wire2)
    status = bme.begin();  
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        while (1);
    }
    Serial.println("-- Default Test --");
    delayTime = 960;
    Serial.println();
   
  //*****Display Oled*********
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255, 255, 255);
  }
   
}

void loop() {
//    printValues();
  u8g.firstPage();
  do
  {
    draw();
  }
  while ( u8g.nextPage() );
    delay(700);
}

/*
void printValues() {
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println("°C");

    Serial.print("Pressure = ");

    Serial.print(bme.readPressure());// bme.readPressure() / 100.0F
    Serial.println("Pa");            // hPa

    Serial.print("Approx. Altitude = ");
    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");
    Serial.println();
}
*/

出0入0汤圆

发表于 2018-3-23 20:18:40 | 显示全部楼层
正用的上,谢了······

出215入118汤圆

发表于 2019-6-11 08:29:35 来自手机 | 显示全部楼层
主控换esp32 直接网络对时 获取天气

出0入0汤圆

发表于 2020-7-31 10:32:44 | 显示全部楼层
做的很漂亮,谢谢分享

出0入0汤圆

发表于 2020-9-10 11:45:08 | 显示全部楼层
谢谢分享  学习一下

出0入0汤圆

发表于 2020-9-10 14:18:41 | 显示全部楼层
赏心悦目

出0入0汤圆

发表于 2020-9-21 10:34:54 | 显示全部楼层
谢谢分享  学习一下!
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-25 13:07

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表