Skip to content

Instantly share code, notes, and snippets.

View Screen.cpp
#include "Screen.h"
Screen::~Screen()
{
delete this->screen;
}
@choonewza
choonewza / MemoryFree1.ino
Created Jan 26, 2020
Content CAT LoRa Lab 12 - Memory Free 1
View MemoryFree1.ino
#include <MemoryFree.h> //https://github.com/mpflaga/Arduino-MemoryFree
void setup() {
Serial.begin(115200);
while(!Serial);
}
void loop() {
String *msg = new String("55555");
showFreeMemory();
@choonewza
choonewza / size_of_datatype.ino
Last active Jan 26, 2020
Content CAT LoRa Lab13 - datatype size
View size_of_datatype.ino
void setup() {
Serial.begin(115200);
while(!Serial);
Serial.println("Size of Variable");
Serial.println();
Serial.println(String("char = ") + sizeof(char) + " Byte");
Serial.println(String("boolean = ") + sizeof(bool) + " Byte");
Serial.println(String("short int = ") + sizeof(short int) + " Byte");
Serial.println(String("long int = ") + sizeof(long int) + " Byte");
View content-catlora-lab12.ino
/*Downlink from Lora IoT by CAT is 012020012412105920200124143000 (00yyyyMMddhhmmssyyyyMMddhhmmss)
Device : RelayA => 01, RelayB => 02
Start : 2020-01-24 12:10:59 => 20200124121059
Stop : 2020-01-24 14:30:00 => 20200124143000
*/
#include <TimeLib.h>
#include <Wire.h>
#include <DS3231.h>
#include <DHT.h>
@choonewza
choonewza / sensor_comparing.ino
Last active Jan 26, 2020
Content CAT LoRa Lab11 - compare sensor
View sensor_comparing.ino
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <HTS221.h>
#include <DHT.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
View Screen.cpp
#include "Screen.h"
Screen::~Screen()
{
delete this->screen;
}
void Screen::begin()
{
Adafruit_SSD1306 *dis = new Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
@choonewza
choonewza / content-catlora-lab9-loraReceive.ino
Created Jan 25, 2020
Content CAT LoRa Lab 9 - loraReceive Function
View content-catlora-lab9-loraReceive.ino
void loraReceive() {
String receive = lora.receive();
if (receive != "") {
unsigned int rxPort = lora.getPortReceive(receive);
String rxPayload = lora.getPayloadReceive(receive);
if (rxPort != 0 && rxPayload != "") {
Serial.println("-----RX From CAT LORA-----");
Serial.println(String("Port = ") + rxPort);
Serial.println(String("Payload = ") + rxPayload);
@choonewza
choonewza / RelayModule.cpp
Last active Jan 25, 2020
Content CAT LORA LAB 9
View RelayModule.cpp
#include "RelayModule.h"
RelayModule::~RelayModule()
{
debug("is destroyed.");
}
RelayModule::RelayModule(uint8_t pin)
{
this->pin = pin;
}
RelayModule::RelayModule(uint8_t pin, uint8_t mode)
@choonewza
choonewza / DateTimeLib.cpp
Last active Jan 23, 2020
Content CAT LORA LAB 8
View DateTimeLib.cpp
#include "DateTimeLib.h"
const uint8_t daysArray[] PROGMEM = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
uint32_t DateTimeLib::unixtime(const char *datetime)
{
return DateTimeLib::unixtime(String(datetime));
}
uint32_t DateTimeLib::unixtime(String datetime)
@choonewza
choonewza / content-catlora-lab7.ino
Last active Jan 22, 2020
Content CatLoRa Lab 7
View content-catlora-lab7.ino
#include <TimeLib.h>
#include <Wire.h>
#include <DS3231.h>
DS3231 clock;
char datetimeBuffer[32];
uint8_t seconds = 0;