- Hamarosan megkezdődik a nubia 2,8K-s táblagépének szállítása
- Barátokká váltak az eddig rivális AI-óriások
- ASUS blog: Ideális olcsó utazós gép lett az új Vivobook S14
- Az Aura Displays hordozható monitorhármasa jól felturbózhatja a produktivitást
- Dual Mode-os IPS monitorral adott magáról életjelet a Gigabyte
- Fejhallgató erősítő és DAC topik
- Milyen pendrive-ot vegyek?
- ASUS blog: Ideális olcsó utazós gép lett az új Vivobook S14
- TCL LCD és LED TV-k
- Milyen széket vegyek?
- Azonnali alaplapos kérdések órája
- Kormányok / autós szimulátorok topikja
- Raspberry Pi
- Vezeték nélküli fülhallgatók
- AMD K6-III, és minden ami RETRO - Oldschool tuning
-
PROHARDVER!
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
olli
tag
[link] rtc_master
[link] oled könyvtár
[link] szintén,
ezek hiba nélkül fordítódnak esp32+ds3231 kódban.
Ami nem sikerül, az aktuális dátum/idő másnap, reset után, csak a fordítás időpontját mutatja.
25.50 C
20.25 C
32.00 C
Sending packet: 10
Saturday, March 04 2023 20:04:17
Mai állapot.
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 13
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress D0 = { 0x28, 0x31, 0xBF, 0x29, 0x07, 0x00, 0x00, 0x7D }; // "T1"
DeviceAddress D1 = { 0x28, 0x4F, 0x8E, 0x2A, 0x07, 0x00, 0x00, 0x37 }; // "T2"
/* for normal hardware wire use above */
#include <Wire.h>
#include <RtcDS3231.h>
RtcDS3231<TwoWire> Rtc(Wire);
// handy routine to return true if there was an error
// but it will also print out an error message with the given topic
bool wasError(const char* errorTopic = "")
{
uint8_t error = Rtc.LastError();
if (error != 0)
{
Serial.print("[");
Serial.print(errorTopic);
Serial.print("] WIRE communications error (");
Serial.print(error);
Serial.print(") : ");
switch (error)
{
case Rtc_Wire_Error_None:
Serial.println("(none?!)");
break;
case Rtc_Wire_Error_TxBufferOverflow:
Serial.println("transmit buffer overflow");
break;
case Rtc_Wire_Error_NoAddressableDevice:
Serial.println("no device responded");
break;
case Rtc_Wire_Error_UnsupportedRequest:
Serial.println("device doesn't support request");
break;
case Rtc_Wire_Error_Unspecific:
Serial.println("unspecified error");
break;
case Rtc_Wire_Error_CommunicationTimeout:
Serial.println("communications timed out");
break;
}
return true;
}
return false;
}
#include <Arduino.h>
#include "Wire.h"
#include "oled.h"
#include <WiFi.h>
#include "time.h"
#include <LoRa.h>
#include "secrets.h" // WiFi SSID & password
#define SCK 5 // GPIO5 -- SX1278's SCK
#define MISO 19 // GPIO19 -- SX1278's MISO
#define MOSI 27 // GPIO27 -- SX1278's MOSI
#define SS 18 // GPIO18 -- SX1278's CS
#define RST 14 // GPIO14 -- SX1278's RESET
#define DI0 26 // GPIO26 -- SX1278's IRQ(Interrupt Request)
#define BAND 433E6
unsigned int counter = 0;
#define RTC_ADDRESS 0x68 // I2C eszköz címe
String rssi = "RSSI --";
String packSize = "--";
String packet ;
struct tm timeinfo;
static char msg[20]; // character buffer
OLED display = OLED(4, 15, 16, 0x3C, 128, 32, true); // SSD1306
void setup() {
pinMode(16,OUTPUT);
pinMode(25,OUTPUT);
digitalWrite(16, LOW); // set GPIO16 low to reset OLED
delay(50);
digitalWrite(16, HIGH); // while OLED is running, must set GPIO16 in high
Serial.begin(115200);
while (!Serial);
SPI.begin(SCK,MISO,MOSI,SS);
LoRa.setPins(SS,RST,DI0);
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
Serial.println("init ok");
Wire.begin();
display.begin();
display.clear();
display.draw_string(4, 8, "RTC clock", OLED::DOUBLE_SIZE);
display.display();
//------- Initialize the Temperature measurement library--------------
sensors.begin();
sensors.setResolution(D0, 10); //T1
sensors.setResolution(D1, 10); //T2
}
void loop() {
sensors.requestTemperatures();
float T1 = sensors.getTempC(D0);
float T2 = sensors.getTempC(D1);
Serial.print("Sending packet: ");
Serial.println(counter);
// send packet
LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();
counter++;
digitalWrite(25, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(25, LOW); // turn the LED off by making the voltage LOW
delay(1000);
getTime(&timeinfo); // display time/date
Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
RtcTemperature temp = Rtc.GetTemperature();
if (!wasError("loop GetTemperature"))
{
temp.Print(Serial);
// you may also get the temperature as a float and print it
// Serial.print(temp.AsFloatDegC());
Serial.println(" C ");
}
display.clear();
strftime (msg, 15, "%Y-%b-%d %a ", &timeinfo);
display.draw_string(16, 1, msg); // Display date
strftime (msg, 10, "%T ", &timeinfo); // Display time
display.draw_string(8, 12, msg, OLED::DOUBLE_SIZE);
display.display(); // Refresh screen
delay(3000);
display.clear();
display.setCursor(8,0);
display.println("T1= ");
display.setCursor(30,0);
display.println(T1);
display.setCursor(60, 0);
display.println(" C");
display.setCursor(8,12);
display.println("T2= ");
display.setCursor(30,12);
display.println(T2);
display.setCursor(60, 12);
display.println(" C");
display.display();
Serial.print(sensors.getTempC(D0));
Serial.println(" C");
Serial.print(sensors.getTempC(D1));
Serial.println(" C ");
}
//--- Convert decimal numbers to BCD -----------------------
byte decToBcd(byte val) {
return ( (val / 10 * 16) + (val % 10) );
}
//--- Convert BCD numbers to decimal ----------------------
byte bcdToDec(byte val) {
return ( (val / 16 * 10) + (val % 16) );
}
/*--- Set RTC time/date ------------------------------------
void setTime(struct tm* time) {
Wire.beginTransmission(RTC_ADDRESS);
Wire.write(0); // set register pointer to 00h
Wire.write(decToBcd(time->tm_sec)); // set seconds
Wire.write(decToBcd(time->tm_min)); // set minutes
Wire.write(decToBcd(time->tm_hour)); // set hours
Wire.write(time->tm_wday + 1); // set day of week (1=Sun, 7=Sat)
Wire.write(decToBcd(time->tm_mday)); // set date (1 to 31)
Wire.write(decToBcd(time->tm_mon) + 1); // set month
Wire.write(decToBcd(time->tm_year - 100)); // year from 2000 (0 to 99)
Wire.endTransmission();
}*/
//--- Read time/date from RTC ------------------------------
void getTime(struct tm* time) {
Wire.beginTransmission(RTC_ADDRESS);
Wire.write(0); // a kiolvasás kezdőcímének beállítása
Wire.endTransmission(false);
Wire.requestFrom(RTC_ADDRESS, 7); // Hét bájt kiolvasása (time/date)
time->tm_sec = bcdToDec(Wire.read() & 0x7f); // Másodpercek (0-59)
time->tm_min = bcdToDec(Wire.read()); // Percek (0 - 59)
time->tm_hour = bcdToDec(Wire.read() & 0x3f); // Órák (24h kijelzéshez)
time->tm_wday = bcdToDec(Wire.read() - 1); // Hét napja (0 - 6)
time->tm_mday = bcdToDec(Wire.read()); // hónap napja (1 - 31)
time->tm_mon = bcdToDec(Wire.read() - 1); // hónap sorszáma (0 - 11)
time->tm_year = bcdToDec(Wire.read()) + 100; // 1900-tól eltelt évek
}
Új hozzászólás Aktív témák
- Hardcore café
- Anime filmek és sorozatok
- Clair Obscur: Expedition 33 teszt
- Fejhallgató erősítő és DAC topik
- ubyegon2: Airfryer XL XXL forrólevegős sütő gyakorlati tanácsok, ötletek, receptek
- BestBuy topik
- Path of Exile (ARPG)
- Kamionok, fuvarozás, logisztika topik
- Sub-ZeRo: Euro Truck Simulator 2 & American Truck Simulator 1 (esetleg 2 majd, ha lesz) :)
- Milyen pendrive-ot vegyek?
- További aktív témák...
- Apple iPhone 13 256GB Kártyafüggetlen, 1Év Garanciával
- Használt és ÚJ Gamer Monitor Felvásárlás Gyors és Korrekt Ügyintézés!
- Telefon felvásárlás!! iPhone 11/iPhone 11 Pro/iPhone 11 Pro Max
- AKCIÓ! MSI B450M R5 5600X 32GB DDR4 512GB SSD RTX 3060 12GB Rampage SHIVA Zalman 600W
- Lenovo ThinkStation P520 Workstation! W-2145, 64GB, 512 SSD /Quadro - Számla, garancia
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest