├── 2X2_Keypad_Matrix └── keypad2x2.ino ├── Arduino_SIM808_Shield ├── README.md ├── examples │ ├── FileStorageOperations │ │ └── FileStorageOperations.ino │ ├── GNSSdata │ │ └── GNSSdata.ino │ ├── HTTPget │ │ └── HTTPget.ino │ ├── HTTPgetGNSS │ │ └── HTTPgetGNSS.ino │ ├── MakeCall │ │ └── MakeCall.ino │ ├── SMSsending │ │ └── SMSsending.ino │ ├── SendingMail │ │ └── SendingMail.ino │ └── SimpleATTest │ │ └── SimpleATTest.ino └── libraries │ ├── ElementzGSM.cpp │ └── ElementzGSM.h ├── Arduino_Sensor_Sheild ├── DHT11_elementz │ ├── DHT.cpp │ ├── DHT.h │ └── DHT11_elementz.ino ├── IR_elementz │ ├── IR_elementz.ino │ └── iR1 │ │ └── iR1.ino ├── PIR_elementz │ └── PIR_elementz.ino ├── Reedswitch_elementz │ └── Reedswitch_elementz.ino ├── adxl_elementz │ └── adxl_elementz.ino ├── gasSensor_elementz │ └── gasSensor_elementz.ino ├── ultrasonic_elementz.zip └── ultrasonic_elementz │ └── ultrasonic_elementz.ino ├── AutoSanitizer └── main │ └── main.ino ├── EM-18_RFID_Reader └── rfid_basic.ino ├── GSM_PPP_interface ├── Readme.md ├── install.sh └── rnet ├── GSM_Software_serial └── GSM_Call │ └── GSM_Call.ino ├── GSM_Uart_Test └── GSM_Uart_Test.ino ├── GestureController └── GestureController.ino ├── HeatRate_Sensor └── HeatRate_Sensor.ino ├── IOT_Kit ├── iot_control_pins │ ├── controlPin │ │ └── controlPin.ino │ ├── jquery.min.js │ └── myesp8266.html └── thingspeak_demo │ └── thingspeak_demo.ino ├── IR_Code └── IR_Code.ino ├── LICENSE ├── LoRa_RangeTest ├── RA02 │ ├── LoRaReceiver │ │ ├── LoRa.cpp │ │ ├── LoRa.h │ │ └── LoRaReceiver.ino │ ├── LoRaSender │ │ ├── LoRa.cpp │ │ ├── LoRa.h │ │ └── LoRaSender.ino │ └── Notes └── RAK811 │ ├── Readme.md │ ├── receiver.py │ └── sender.py ├── MAX7219_Matrix_Display └── max7219_smiling.ino ├── OLED_I2C_Sample └── OLED_I2C_Sample.ino ├── PIR_test └── PIR_test.ino ├── RC522_code └── RC522_code.ino ├── README.md ├── RGB_Module └── RGB_Module.ino ├── Relay_1_Channel └── Relay_1_Channel.ino ├── Relay_2_Channel_optocoupled └── Relay_2_Channel_optocoupled.ino ├── Relay_2_channel └── Relay_2_channel.ino ├── Relay_4_Channel └── Relay_4_Channel.ino ├── Relay_8_Channel └── Relay_8_Channel.ino ├── Relay_8_Channel_optocoupled └── Relay_8_Channel_optocoupled.ino ├── SIM7600 ├── Assisted_GPS_SIM7600 │ └── Assisted_GPS_SIM7600.ino └── Sim7600_MQTT │ └── Sim7600_MQTT.ino ├── SPFD5408_rotationtest └── spfd5408_rotationtest │ └── spfd5408_rotationtest.ino ├── SSD1306_SPI_Arduino └── SSD1306_SPI_Arduino.ino ├── TFT_TouchDisplay ├── ShowBMP │ └── ShowBMP.ino ├── phonecal │ └── phonecal.ino ├── tempDisplay │ ├── Adafruit_GFX.cpp │ ├── Adafruit_GFX.h │ ├── Adafruit_TFTLCD.cpp │ ├── Adafruit_TFTLCD.h │ ├── TouchScreen.cpp │ ├── TouchScreen.h │ ├── glcdfont.c │ ├── pin_magic.h │ ├── registers.h │ └── tempDisplay.ino └── tftpaint │ └── tftpaint.ino ├── Tutorials ├── ARDUINO BASED DESIGN.pptx ├── ARDUINO IDE.pdf ├── Arduino UNO.pptx ├── Arduino_ADC.pptx ├── IntroductionToArduino_2.pdf └── SERIAL COMMUNICATION.pptx ├── e-Tracker ├── README.md ├── examples │ ├── FileStorageOperations │ │ └── FileStorageOperations.ino │ ├── GNSSdata │ │ └── GNSSdata.ino │ ├── HTTPget │ │ └── HTTPget.ino │ ├── HTTPgetGNSS │ │ └── HTTPgetGNSS.ino │ ├── MakeCall │ │ └── MakeCall.ino │ ├── SMSsending │ │ └── SMSsending.ino │ ├── SendingMail │ │ └── SendingMail.ino │ └── SimpleATTest │ │ └── SimpleATTest.ino └── libraries │ ├── ElementzGSM.cpp │ └── ElementzGSM.h ├── ePaper_Elementz ├── ePaper_Elementz.ino ├── epd2in9.cpp ├── epd2in9.h ├── epdif.cpp ├── epdif.h ├── epdpaint.cpp ├── epdpaint.h ├── font12.c ├── font16.c ├── font20.c ├── font24.c ├── font8.c ├── fonts.h ├── imagedata.cpp └── imagedata.h ├── send_sms_with_esp32_sim800l_TTGO └── send_sms_with_esp32_sim800l │ └── send_sms_with_esp32_sim800l.ino └── utraq_module └── utraq_module.ino /2X2_Keypad_Matrix/keypad2x2.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | const byte ROWS = 2; //two rows 4 | const byte COLS = 2; //two columns 5 | char keys[ROWS][COLS] = { 6 | {'1','3'}, 7 | {'2','4'}, 8 | }; 9 | byte rowPins[ROWS] = {2, 3,}; //connect to the row pinouts of the keypad 10 | byte colPins[COLS] = {4, 5,}; //connect to the column pinouts of the keypad 11 | 12 | Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); 13 | 14 | void setup(){ 15 | Serial.begin(9600); 16 | } 17 | 18 | void loop(){ 19 | char key = keypad.getKey(); 20 | 21 | if (key != NO_KEY){ 22 | Serial.println(key); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Arduino_SIM808_Shield/README.md: -------------------------------------------------------------------------------- 1 | Arduino-Sample-Codes 2 | ==================== 3 | 4 | Arduino Sample for SIM808 module 5 | 6 | Required: Arduino IDE - 1.6.12 or above 7 | 8 | Also tested with Latest release of VisualMicro(use Arduino 1.6.12 or latter as IDE ) in Atmel Studio 7 -------------------------------------------------------------------------------- /Arduino_SIM808_Shield/examples/FileStorageOperations/FileStorageOperations.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | 6 | SoftwareSerial myserialOut(6, 7); 7 | ElementzGSMshield GSM(&myserialOut); 8 | char driveName; 9 | 10 | void setup() { 11 | // put your setup code here, to run once: 12 | Serial.begin(9600); 13 | GSM.begin(9600); 14 | delay(1500); 15 | 16 | if (GSM.checkSDmode())//Checking Whether SDMODE is activated 17 | { 18 | Serial.println("SDMODE activated"); 19 | } 20 | else 21 | { 22 | Serial.println("SDMODE is not activated"); 23 | GSM.prepareForSDcard();//if not activated preparing for SDcard. Do this only one time. 24 | delay(15000); 25 | if (GSM.checkSDmode()) 26 | { 27 | Serial.println("SDMDOE activation success"); 28 | } 29 | } 30 | 31 | 32 | GSM.viewFileStorageMemoryInfo();//You can get an info of memory using this function. This function returns nothing 33 | 34 | driveName = GSM.getDriveLabel(LOCAL);//LOCAL for local sotrage memory. 35 | Serial.println(driveName); 36 | driveName = GSM.getDriveLabel(SDCARD);//SDCARD for external drive 37 | Serial.println(driveName); 38 | 39 | //Use this function to get a list of files and folders inside the drive/path. 40 | GSM.viewFilelist(driveName, 3); //the second argument means how many files need to be listed 41 | GSM.createDirectory(driveName, "Test"); //Function for creating a directory 42 | GSM.viewFilelist(driveName, 4); // you can view the created directory using this function 43 | 44 | GSM.createFile("D:\\Test\\", "testing.txt"); //Function for creating a file 45 | GSM.viewFilelist("D:\\Test\\", 2); //you can view the created file using this function 46 | 47 | GSM.renameFile("D:\\Test\\testing.txt", "D:\\Test\\test.txt"); //function for renaming a file 48 | GSM.viewFilelist("D:\\Test\\", 2); //view the change in name 49 | 50 | uint16_t fileSize = GSM.getFileSize("D:\\Test\\test.txt"); //you can know the file size using this function 51 | Serial.print("File Size = "); 52 | Serial.println(fileSize); 53 | 54 | GSM.writeTotheBeginningofFile("D:\\Test\\test.txt", "Elementz Engineers", 18, 10); //To write to the beginning of the file use this function 55 | fileSize = GSM.getFileSize("D:\\Test\\test.txt"); //see the change in file size when data added 56 | Serial.print("File Size = "); 57 | Serial.println(fileSize); 58 | 59 | Serial.println(GSM.readFromtheBeginningOftheFile("D:\\Test\\test.txt", 20, 1)); //Use this function to read from thebeginning of a file 60 | 61 | GSM.appendContenttoTheEndoftheFile("D:\\Test\\test.txt", " Guild Pvt Ltd", 14, 10); //To append data to the end of the file use this function 62 | fileSize = GSM.getFileSize("D:\\Test\\test.txt");//see the change in file size 63 | Serial.print("File Size = "); 64 | Serial.println(fileSize); 65 | 66 | Serial.println(GSM.readFromtheBeginningOftheFile("D:\\Test\\test.txt", 40, 1)); 67 | 68 | Serial.println(GSM.readFromposition("D:\\Test\\test.txt", 40, 19, 1)); //to read froma particular position use this function. 69 | 70 | GSM.removeFile("D:\\Test\\test.txt"); // to remove any file use this function 71 | GSM.removeDirectory("D:\\Test");// to remove any directory use this function. Remove the file inside before removing the directory. 72 | } 73 | void loop() { 74 | 75 | } 76 | 77 | -------------------------------------------------------------------------------- /Arduino_SIM808_Shield/examples/GNSSdata/GNSSdata.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | SoftwareSerial myserialOut(6,7); 6 | ElementzGSMshield GSM(&myserialOut); 7 | String testString = ""; 8 | void setup() { 9 | 10 | Serial.begin(9600); 11 | GSM.begin(9600); 12 | Serial.println("Starting"); 13 | delay(1000); 14 | GSM.turnOnGNSS(); 15 | String testString = GSM.getGNSSInfo(); 16 | Serial.println(testString); 17 | GSM.turnOffGNSS(); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Arduino_SIM808_Shield/examples/HTTPget/HTTPget.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | 6 | SoftwareSerial myserialOut(6,7); 7 | ElementzGSMshield GSM(&myserialOut); 8 | 9 | void setup() { 10 | 11 | Serial.begin(9600); 12 | GSM.begin(9600); 13 | Serial.println("Starting"); 14 | delay(1000); 15 | 16 | GSM.turnOnGPRS("WWW.MYAIRTELGPRS.COM"); 17 | GSM.sendHTTPDATA("http://ec2-52-24-224-220.us-west-2.compute.amazonaws.com/tgps.php?Data=thisisanewdata"); 18 | //check this url to view data http://ec2-52-24-224-220.us-west-2.compute.amazonaws.com/tgps808log.txt 19 | 20 | } 21 | void loop() { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Arduino_SIM808_Shield/examples/HTTPgetGNSS/HTTPgetGNSS.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | String URL = "http://ec2-52-24-224-220.us-west-2.compute.amazonaws.com/tgps.php?Data="; 6 | SoftwareSerial myserialOut(6,7); 7 | ElementzGSMshield GSM(&myserialOut); 8 | String testString = ""; 9 | 10 | void setup() { 11 | // put your setup code here, to run once: 12 | Serial.begin(9600); 13 | GSM.begin(9600); 14 | Serial.println("Starting"); 15 | delay(1000); 16 | 17 | GSM.turnOnGPRS("WWW.MYAIRTELGPRS.COM"); 18 | GSM.turnOnGNSS(); 19 | testString = GSM.getProcessedGNSSInfo(); 20 | Serial.println(testString); 21 | GSM.sendHTTPDATA(URL + testString); 22 | //go to this url to view data http://ec2-52-24-224-220.us-west-2.compute.amazonaws.com/tgps808log.txt 23 | 24 | } 25 | void loop() { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Arduino_SIM808_Shield/examples/MakeCall/MakeCall.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | char phone_number[11] = "9605xxxxxx"; 6 | String phone2 = "7356xxxxxx"; 7 | SoftwareSerial myserialOut(6,7); 8 | ElementzGSMshield GSM(&myserialOut); 9 | String testString = ""; 10 | void setup() { 11 | Serial.begin(9600); 12 | GSM.begin(9600); 13 | Serial.println("Starting"); 14 | delay(1000); 15 | Serial.println("Calling First Number"); 16 | GSM.makeCall(phone_number);//number const char type 17 | delay(10000); 18 | Serial.println("Disconnecting First call"); 19 | GSM.hangUp(); 20 | Serial.println("Calling Second Number"); 21 | GSM.makeCall(phone2);//number is string type 22 | delay(10000); 23 | Serial.println("Disconnecting Second call"); 24 | GSM.hangUp(); 25 | 26 | 27 | 28 | } 29 | 30 | void loop() { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Arduino_SIM808_Shield/examples/SMSsending/SMSsending.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | 6 | SoftwareSerial myserialOut(6,7); 7 | ElementzGSMshield GSM(&myserialOut); 8 | String testString = ""; 9 | void setup() { 10 | Serial.begin(9600); 11 | GSM.begin(9600); 12 | Serial.println("Starting"); 13 | delay(1000); 14 | GSM.sendSMSintextFormat(); 15 | 16 | boolean sms_status = GSM.sendSms("7356xxxxxx", "Test Message");//you can input the number also as a String object 17 | if (sms_status == true) 18 | { 19 | Serial.println("SMS Send"); 20 | } 21 | else 22 | { 23 | Serial.println("SMS sending Failed"); 24 | } 25 | 26 | 27 | 28 | 29 | } 30 | 31 | void loop() { 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Arduino_SIM808_Shield/examples/SendingMail/SendingMail.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | 6 | char message[29] = "Sending from Arduino Success"; 7 | uint8_t email_timeout = 30;//in seconds 8 | SoftwareSerial myserialOut(6,7); 9 | ElementzGSMshield GSM(&myserialOut); 10 | String testString = ""; 11 | void setup() { 12 | 13 | Serial.begin(9600); 14 | GSM.begin(9600); 15 | Serial.println("Starting"); 16 | delay(1000); 17 | 18 | 19 | 20 | GSM.turnOnGPRS("WWW.MYAIRTELGPRS.COM"); 21 | GSM.setupEmailServer("xx-xx-x.xxxxxx.xxx", 25, email_timeout); //outgoing server address and port 25 is default port. You can get this from email client setup section of your mail 22 | GSM.setupEmailAuthorization("user@mail.com", "password", "Your Name"); //username(mail ID), password, Name; 23 | GSM.setupEmailToAddress("recepient@mail.com");//To address 24 | GSM.setEmailSubject("Testing from Arduino part2");//Subject 25 | GSM.sendEmailWithContent(message, 28); //Content 26 | 27 | //-------or send a string data as------------// 28 | 29 | GSM.turnOnGPRS("WWW.MYAIRTELGPRS.COM"); 30 | GSM.setupEmailServer("xx-xx-x.xxxxxx.xxx", 25, email_timeout); //outgoing server address and port 25 is default port. You can get this from email client setup section of your mail 31 | GSM.setupEmailAuthorization("user@mail.com", "password", "Your Name"); //username(mail ID), password, Name; 32 | GSM.setupEmailToAddress("recepient@mail.com");//To address 33 | GSM.setEmailSubject("Testing from Arduino part2");//Subject 34 | GSM.sendEmailWithContent("Sending from Arduino Success", 28); //Content 35 | 36 | 37 | } 38 | 39 | void loop() { 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Arduino_SIM808_Shield/examples/SimpleATTest/SimpleATTest.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SoftwareSerial.h" 3 | #include "ElementzGSM.h" 4 | 5 | SoftwareSerial myserialOut(6, 7); 6 | ElementzGSMshield GSM(&myserialOut); 7 | 8 | void setup(/* arguments */) { 9 | /* code */ 10 | Serial.begin(9600); 11 | GSM.begin(9600); 12 | Serial.println("Starting"); 13 | delay(2000); 14 | 15 | GSM.SendAT("AT", "OK", 1000, 2); 16 | GSM.SendAT("AT+CREG?", "+CREG: 0,0", 1000, 2); 17 | } 18 | 19 | 20 | 21 | void loop(/* arguments */) { 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Arduino_SIM808_Shield/libraries/ElementzGSM.h: -------------------------------------------------------------------------------- 1 | #ifndef ELEMENTZGSM_H 2 | #define ELEMENTZGSM_H 3 | #include 4 | #include "SoftwareSerial.h" 5 | 6 | #define MESSAGELINES 5 7 | //#define PinRX 2 8 | //#define PinTX 3 9 | 10 | #define DEBUG 1 11 | 12 | #define LOCAL 0 13 | #define SDCARD 1 14 | 15 | class ElementzGSMshield { 16 | public: 17 | ElementzGSMshield(SoftwareSerial *); 18 | // GSM(uint8_t PinRX, uint8_t PinTX); 19 | void begin(long ); 20 | void SendAT(String ATCommand); 21 | void SendAT(const char ATCommand); 22 | boolean SendAT(const char* ATCommand, const char* exptReply, uint32_t timeout, int retry); 23 | boolean SendAT(String ATCommand, const char* exptReply, uint32_t timeout, int retry); 24 | boolean SendAT(String ATCommand, const char* exptReply, uint32_t timeout, int retry, uint8_t noOflines); 25 | boolean waitResponse(const char* exptReply, uint32_t timeout); 26 | boolean waitResponse(const char* exptReply, uint32_t timeout, uint8_t noOflines); 27 | boolean EchoOFF(); 28 | boolean EchoON(); 29 | String readReply(uint32_t timeout); 30 | String readReply( uint32_t timeout, uint8_t expctd_num_of_lines); 31 | boolean makeCall(const char* phone_number); 32 | boolean makeCall(String phone_number); 33 | boolean hangUp(void); 34 | boolean sendSMSintextFormat(void); 35 | boolean sendSMSinPDUformat(void); 36 | boolean sendSms(const char* phone_number, const char* Content); 37 | boolean sendSms(String phone_number, String Content); 38 | String readSMS(uint8_t index); 39 | boolean checkGprsStatus(void); 40 | boolean turnOnGPRS(String APN); 41 | boolean turnOnGPRS(const char* APN); 42 | boolean turnOffGPRS(void); 43 | boolean setupEmailServer(String OutGoingServer, uint16_t Port, uint8_t timeout); 44 | boolean setupEmailAuthorization(String Username, String Password, String Name); 45 | boolean setupEmailAuthorization(String Username, String Password); 46 | boolean setupEmailToAddress(String mailId, String Name); 47 | boolean setupEmailToAddress(String mailId); 48 | boolean setupEmailCcAddress(String mailId, String Name); 49 | boolean setupEmailCcAddress(String mailId); 50 | boolean setupEmailBccAddress(String mailId, String Name); 51 | boolean setupEmailBccAddress(String mailId); 52 | boolean setEmailSubject(String Subject); 53 | boolean sendEmailWithContent(String Content, uint8_t length); 54 | boolean sendEmailWithContent(const char* Content, uint8_t length); 55 | boolean turnOnGNSS(void); 56 | boolean turnOffGNSS(void); 57 | String getGNSSInfo(void); 58 | boolean initializeHTTPService(void); 59 | boolean terminateHTTPService(void); 60 | boolean sendHTTPDATA(const char* URL_attached_with_data); 61 | boolean sendHTTPDATA(String URL_attached_with_data); 62 | String getProcessedGNSSInfo(void); 63 | boolean restartGSMmodem(void); 64 | boolean urgentPowerDown(void); 65 | boolean normalPowerDown(void); 66 | boolean writeTomemory(void); 67 | boolean checkSDmode(void); 68 | boolean prepareForSDcard(void); 69 | char getDriveLabel(char requiredDrive); 70 | void viewFileStorageMemoryInfo(void); 71 | boolean createFile(const char *path, const char *fileName); 72 | boolean createFile(char path, const char *fileName); 73 | boolean createDirectory(char path, const char *directoryname); 74 | boolean createDirectory(const char *path, const char *directoryname); 75 | void viewFilelist(char path, char noOffiles); 76 | void viewFilelist(const char *path, char noOffiles); 77 | boolean renameFile(const char *oldNamewithPath, const char *newNamewithPath); 78 | boolean removeDirectory(const char *directoryNameWithPath); 79 | boolean removeFile(const char *fileNameWithPath); 80 | boolean writeTotheBeginningofFile(const char *fileNameWithPath, const char *Content, uint16_t sizeOftheFile, uint8_t timeInSeconds); 81 | boolean appendContenttoTheEndoftheFile(const char *fileNameWithPath, const char *Content, uint16_t sizeOftheFile, uint8_t timeInSeconds); 82 | String readFromtheBeginningOftheFile(const char *fileNameWithPath, uint16_t sizeTobeRead, uint8_t linesTobeRead); 83 | String readFromposition(const char *fileNameWithPath, uint16_t sizeTobeRead, uint16_t position, uint8_t linesTobeRead); 84 | uint16_t getFileSize(const char *fileNameWithPath); 85 | 86 | 87 | private: 88 | boolean setupEmailFromAddress(String mailId, String Name); 89 | boolean setupEmailFromAddress(String mailId); 90 | boolean checkForExptReplyinRcvdString(String recvdString, const char* exptReply); 91 | 92 | Stream *mySerial; 93 | SoftwareSerial *gsmSerial; 94 | }; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/DHT11_elementz/DHT.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************** 2 | DHT Temperature & Humidity Sensor library for Arduino. 3 | 4 | Features: 5 | - Support for DHT11 and DHT22/AM2302/RHT03 6 | - Auto detect sensor model 7 | - Very low memory footprint 8 | - Very small code 9 | 10 | http://www.github.com/markruys/arduino-DHT 11 | 12 | Written by Mark Ruys, mark@paracas.nl. 13 | 14 | BSD license, check license.txt for more information. 15 | All text above must be included in any redistribution. 16 | 17 | Datasheets: 18 | - http://www.micro4you.com/files/sensor/DHT11.pdf 19 | - http://www.adafruit.com/datasheets/DHT22.pdf 20 | - http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Weather/RHT03.pdf 21 | - http://meteobox.tk/files/AM2302.pdf 22 | 23 | Changelog: 24 | 2013-06-10: Initial version 25 | 2013-06-12: Refactored code 26 | 2013-07-01: Add a resetTimer method 27 | ******************************************************************/ 28 | 29 | #include "DHT.h" 30 | 31 | void DHT::setup(uint8_t pin, DHT_MODEL_t model) 32 | { 33 | DHT::pin = pin; 34 | DHT::model = model; 35 | DHT::resetTimer(); // Make sure we do read the sensor in the next readSensor() 36 | 37 | if ( model == AUTO_DETECT) { 38 | DHT::model = DHT22; 39 | readSensor(); 40 | if ( error == ERROR_TIMEOUT ) { 41 | DHT::model = DHT11; 42 | // Warning: in case we auto detect a DHT11, you should wait at least 1000 msec 43 | // before your first read request. Otherwise you will get a time out error. 44 | } 45 | } 46 | } 47 | 48 | void DHT::resetTimer() 49 | { 50 | DHT::lastReadTime = millis() - 3000; 51 | } 52 | 53 | float DHT::getHumidity() 54 | { 55 | readSensor(); 56 | return humidity; 57 | } 58 | 59 | float DHT::getTemperature() 60 | { 61 | readSensor(); 62 | return temperature; 63 | } 64 | 65 | #ifndef OPTIMIZE_SRAM_SIZE 66 | 67 | const char* DHT::getStatusString() 68 | { 69 | switch ( error ) { 70 | case DHT::ERROR_TIMEOUT: 71 | return "TIMEOUT"; 72 | 73 | case DHT::ERROR_CHECKSUM: 74 | return "CHECKSUM"; 75 | 76 | default: 77 | return "OK"; 78 | } 79 | } 80 | 81 | #else 82 | 83 | // At the expense of 26 bytes of extra PROGMEM, we save 11 bytes of 84 | // SRAM by using the following method: 85 | 86 | prog_char P_OK[] PROGMEM = "OK"; 87 | prog_char P_TIMEOUT[] PROGMEM = "TIMEOUT"; 88 | prog_char P_CHECKSUM[] PROGMEM = "CHECKSUM"; 89 | 90 | const char *DHT::getStatusString() { 91 | prog_char *c; 92 | switch ( error ) { 93 | case DHT::ERROR_CHECKSUM: 94 | c = P_CHECKSUM; break; 95 | 96 | case DHT::ERROR_TIMEOUT: 97 | c = P_TIMEOUT; break; 98 | 99 | default: 100 | c = P_OK; break; 101 | } 102 | 103 | static char buffer[9]; 104 | strcpy_P(buffer, c); 105 | 106 | return buffer; 107 | } 108 | 109 | #endif 110 | 111 | void DHT::readSensor() 112 | { 113 | // Make sure we don't poll the sensor too often 114 | // - Max sample rate DHT11 is 1 Hz (duty cicle 1000 ms) 115 | // - Max sample rate DHT22 is 0.5 Hz (duty cicle 2000 ms) 116 | unsigned long startTime = millis(); 117 | if ( (unsigned long)(startTime - lastReadTime) < (model == DHT11 ? 999L : 1999L) ) { 118 | return; 119 | } 120 | lastReadTime = startTime; 121 | 122 | temperature = NAN; 123 | humidity = NAN; 124 | 125 | // Request sample 126 | 127 | digitalWrite(pin, LOW); // Send start signal 128 | pinMode(pin, OUTPUT); 129 | if ( model == DHT11 ) { 130 | delay(18); 131 | } 132 | else { 133 | // This will fail for a DHT11 - that's how we can detect such a device 134 | delayMicroseconds(800); 135 | } 136 | 137 | pinMode(pin, INPUT); 138 | digitalWrite(pin, HIGH); // Switch bus to receive data 139 | 140 | // We're going to read 83 edges: 141 | // - First a FALLING, RISING, and FALLING edge for the start bit 142 | // - Then 40 bits: RISING and then a FALLING edge per bit 143 | // To keep our code simple, we accept any HIGH or LOW reading if it's max 85 usecs long 144 | 145 | word rawHumidity; 146 | word rawTemperature; 147 | word data; 148 | 149 | for ( int8_t i = -3 ; i < 2 * 40; i++ ) { 150 | byte age; 151 | startTime = micros(); 152 | 153 | do { 154 | age = (unsigned long)(micros() - startTime); 155 | if ( age > 90 ) { 156 | error = ERROR_TIMEOUT; 157 | return; 158 | } 159 | } 160 | while ( digitalRead(pin) == (i & 1) ? HIGH : LOW ); 161 | 162 | if ( i >= 0 && (i & 1) ) { 163 | // Now we are being fed our 40 bits 164 | data <<= 1; 165 | 166 | // A zero max 30 usecs, a one at least 68 usecs. 167 | if ( age > 30 ) { 168 | data |= 1; // we got a one 169 | } 170 | } 171 | 172 | switch ( i ) { 173 | case 31: 174 | rawHumidity = data; 175 | break; 176 | case 63: 177 | rawTemperature = data; 178 | data = 0; 179 | break; 180 | } 181 | } 182 | 183 | // Verify checksum 184 | 185 | if ( (byte)(((byte)rawHumidity) + (rawHumidity >> 8) + ((byte)rawTemperature) + (rawTemperature >> 8)) != data ) { 186 | error = ERROR_CHECKSUM; 187 | return; 188 | } 189 | 190 | // Store readings 191 | 192 | if ( model == DHT11 ) { 193 | humidity = rawHumidity >> 8; 194 | temperature = rawTemperature >> 8; 195 | } 196 | else { 197 | humidity = rawHumidity * 0.1; 198 | 199 | if ( rawTemperature & 0x8000 ) { 200 | rawTemperature = -(int16_t)(rawTemperature & 0x7FFF); 201 | } 202 | temperature = ((int16_t)rawTemperature) * 0.1; 203 | } 204 | 205 | error = ERROR_NONE; 206 | } 207 | -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/DHT11_elementz/DHT.h: -------------------------------------------------------------------------------- 1 | /****************************************************************** 2 | DHT Temperature & Humidity Sensor library for Arduino. 3 | 4 | Features: 5 | - Support for DHT11 and DHT22/AM2302/RHT03 6 | - Auto detect sensor model 7 | - Very low memory footprint 8 | - Very small code 9 | 10 | http://www.github.com/markruys/arduino-DHT 11 | 12 | Written by Mark Ruys, mark@paracas.nl. 13 | 14 | BSD license, check license.txt for more information. 15 | All text above must be included in any redistribution. 16 | 17 | Datasheets: 18 | - http://www.micro4you.com/files/sensor/DHT11.pdf 19 | - http://www.adafruit.com/datasheets/DHT22.pdf 20 | - http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Weather/RHT03.pdf 21 | - http://meteobox.tk/files/AM2302.pdf 22 | 23 | Changelog: 24 | 2013-06-10: Initial version 25 | 2013-06-12: Refactored code 26 | 2013-07-01: Add a resetTimer method 27 | ******************************************************************/ 28 | 29 | #ifndef dht_h 30 | #define dht_h 31 | 32 | #if ARDUINO < 100 33 | #include 34 | #else 35 | #include 36 | #endif 37 | 38 | class DHT 39 | { 40 | public: 41 | 42 | typedef enum { 43 | AUTO_DETECT, 44 | DHT11, 45 | DHT22, 46 | AM2302, // Packaged DHT22 47 | RHT03 // Equivalent to DHT22 48 | } 49 | DHT_MODEL_t; 50 | 51 | typedef enum { 52 | ERROR_NONE = 0, 53 | ERROR_TIMEOUT, 54 | ERROR_CHECKSUM 55 | } 56 | DHT_ERROR_t; 57 | 58 | void setup(uint8_t pin, DHT_MODEL_t model=AUTO_DETECT); 59 | void resetTimer(); 60 | 61 | float getTemperature(); 62 | float getHumidity(); 63 | 64 | DHT_ERROR_t getStatus() { return error; }; 65 | const char* getStatusString(); 66 | 67 | DHT_MODEL_t getModel() { return model; } 68 | 69 | int getMinimumSamplingPeriod() { return model == DHT11 ? 1000 : 2000; } 70 | 71 | int8_t getNumberOfDecimalsTemperature() { return model == DHT11 ? 0 : 1; }; 72 | int8_t getLowerBoundTemperature() { return model == DHT11 ? 0 : -40; }; 73 | int8_t getUpperBoundTemperature() { return model == DHT11 ? 50 : 125; }; 74 | 75 | int8_t getNumberOfDecimalsHumidity() { return 0; }; 76 | int8_t getLowerBoundHumidity() { return model == DHT11 ? 20 : 0; }; 77 | int8_t getUpperBoundHumidity() { return model == DHT11 ? 90 : 100; }; 78 | 79 | static float toFahrenheit(float fromCelcius) { return 1.8 * fromCelcius + 32.0; }; 80 | static float toCelsius(float fromFahrenheit) { return (fromFahrenheit - 32.0) / 1.8; }; 81 | 82 | protected: 83 | void readSensor(); 84 | 85 | float temperature; 86 | float humidity; 87 | 88 | uint8_t pin; 89 | 90 | private: 91 | DHT_MODEL_t model; 92 | DHT_ERROR_t error; 93 | unsigned long lastReadTime; 94 | }; 95 | 96 | #endif /*dht_h*/ 97 | -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/DHT11_elementz/DHT11_elementz.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | DHT11 Sample Code 4 | Author : Jayasenan 5 | Company : Elementz Engineers Guild Pvt Ltd 6 | 7 | Website: http://www.elementzonline.com 8 | */ 9 | 10 | 11 | 12 | #include "DHT.h" 13 | 14 | DHT dht; 15 | 16 | void setup() 17 | { 18 | Serial.begin(9600); 19 | 20 | dht.setup(5); // data pin 5 21 | } 22 | 23 | void loop() 24 | { 25 | delay(dht.getMinimumSamplingPeriod()); 26 | 27 | Serial.print(dht.getHumidity()); 28 | Serial.print("\t"); 29 | Serial.println(dht.getTemperature()); 30 | } 31 | -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/IR_elementz/IR_elementz.ino: -------------------------------------------------------------------------------- 1 | /* 2 | IR Sensor Sample Code 3 | Author : Jayasenan 4 | Company : Elementz Engineers Guild Pvt Ltd 5 | 6 | Website: http://www.elementzonline.com 7 | */ 8 | 9 | 10 | #define OUTPin 13 // Onboard LED 11 | #define INPin1 2 // 2 for IR1 12 | #define INPin2 10 // 10 for IR2 13 | 14 | void setup() { 15 | Serial.begin (9600); 16 | 17 | pinMode(OUTPin, OUTPUT); // Use LED indicator (if required) 18 | pinMode(INPin1, INPUT); // Use LED indicator (if required) 19 | pinMode(INPin2, INPUT); // Use LED indicator (if required) 20 | } 21 | int OUT; 22 | void loop() 23 | { 24 | delay(500); 25 | digitalWrite(OUTPin,LOW); 26 | // print the sensor values: 27 | OUT=digitalRead(INPin1); 28 | Serial.print(OUT); 29 | Serial.print("\t"); 30 | OUT=digitalRead(INPin2); 31 | Serial.print(OUT); 32 | // print a tab between values: 33 | Serial.print("\n"); 34 | if(OUT==1){ 35 | digitalWrite(OUTPin,HIGH); 36 | } } 37 | 38 | -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/IR_elementz/iR1/iR1.ino: -------------------------------------------------------------------------------- 1 | #define INPin A1 // Onboard LED 2 | void setup() { 3 | Serial.begin (9600); 4 | 5 | 6 | pinMode(INPin, INPUT); // Use LED indicator (if required) 7 | } 8 | int OUT; 9 | void loop() 10 | { 11 | 12 | OUT=analogRead(INPin); 13 | Serial.print(OUT); 14 | // print a tab between values: 15 | Serial.print("\n"); 16 | } 17 | -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/PIR_elementz/PIR_elementz.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | PIR Sensor Sample Code 4 | Author : Dhanish 5 | Company : Elementz Engineers Guild Pvt Ltd 6 | Website: http://www.elementzonline.com 7 | */ 8 | 9 | // set pin numbers: 10 | const int PIRPin = 8; // the number of the pushbutton pin 11 | const int ledPin = 13; // the number of the LED pin 12 | 13 | 14 | int sensorState = 0; 15 | 16 | void setup() { 17 | Serial.begin(9600); 18 | // initialize the LED pin as an output: 19 | pinMode(ledPin, OUTPUT); 20 | 21 | pinMode(PIRPin, INPUT); 22 | } 23 | 24 | void loop(){ 25 | 26 | sensorState = digitalRead(PIRPin); 27 | 28 | if (sensorState == HIGH) { 29 | Serial.println("High"); 30 | digitalWrite(ledPin, HIGH); 31 | } 32 | else { 33 | Serial.println("Low"); 34 | digitalWrite(ledPin, LOW); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/Reedswitch_elementz/Reedswitch_elementz.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Reed Sensor Sample Code 4 | Author : Dhanish 5 | Company : Elementz Engineers Guild Pvt Ltd 6 | Website: http://www.elementzonline.com 7 | */ 8 | 9 | // set pin numbers: 10 | const int PIRPin = 6; // the number of the pushbutton pin 11 | const int ledPin = 13; // the number of the LED pin 12 | 13 | 14 | int sensorState = 0; 15 | 16 | void setup() { 17 | Serial.begin(9600); 18 | // initialize the LED pin as an output: 19 | pinMode(ledPin, OUTPUT); 20 | 21 | pinMode(PIRPin, INPUT); 22 | } 23 | 24 | void loop(){ 25 | 26 | sensorState = digitalRead(PIRPin); 27 | 28 | if (sensorState == HIGH) { 29 | Serial.println("High"); 30 | digitalWrite(ledPin, HIGH); 31 | } 32 | else { 33 | Serial.println("Low"); 34 | digitalWrite(ledPin, LOW); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/adxl_elementz/adxl_elementz.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ADXL335 Sample Code 3 | Author : Jayasenan 4 | Company : Elementz Engineers Guild Pvt Ltd 5 | 6 | Website: http://www.elementzonline.com 7 | */ 8 | 9 | 10 | 11 | #define XPin A2// X Pin 12 | #define YPin A3// Y Pin 13 | #define ZPin A4// Z Pin 14 | 15 | void setup() { 16 | Serial.begin (9600); 17 | pinMode(XPin, INPUT); 18 | pinMode(YPin, INPUT); 19 | pinMode(ZPin, INPUT); 20 | } 21 | 22 | 23 | void loop() 24 | { 25 | // print the sensor values: 26 | Serial.print(analogRead(XPin)); 27 | // print a tab between values: 28 | Serial.print("\t"); 29 | Serial.print(analogRead(YPin)); 30 | // print a tab between values: 31 | Serial.print("\t"); 32 | Serial.print(analogRead(ZPin)); 33 | Serial.println(); 34 | // delay before next reading: 35 | delay(1000); 36 | } 37 | -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/gasSensor_elementz/gasSensor_elementz.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Gas sensor Sample Code 3 | Author : Dhanish 4 | Company : Elementz Engineers Guild Pvt Ltd 5 | 6 | Website: http://www.elementzonline.com 7 | */ 8 | 9 | 10 | 11 | #define SensorPin A5// Gas sensor input 12 | 13 | void setup() { 14 | Serial.begin (9600); 15 | pinMode(SensorPin, INPUT); 16 | } 17 | 18 | 19 | void loop() 20 | { 21 | // print the sensor values: 22 | Serial.println(analogRead(SensorPin)); 23 | // delay before next reading: 24 | delay(1000); 25 | } 26 | -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/ultrasonic_elementz.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elementzonline/Arduino-Sample-Codes/95555cc74db6fe2744a93e509737359df05a6a14/Arduino_Sensor_Sheild/ultrasonic_elementz.zip -------------------------------------------------------------------------------- /Arduino_Sensor_Sheild/ultrasonic_elementz/ultrasonic_elementz.ino: -------------------------------------------------------------------------------- 1 | /* 2 | HCSR04 -- Ultrasonic Sensor Sample Code 3 | Author : Jayasenan 4 | Company : Elementz Engineers Guild Pvt Ltd 5 | 6 | Website: http://www.elementzonline.com 7 | 8 | HC-SR04 Ping distance sensor: 9 | VCC to arduino 5v 10 | GND to arduino GND 11 | Echo to Arduino pin 12 12 | Trig to Arduino pin 11 13 | 14 | */ 15 | 16 | 17 | #define echoPin 12 // Echo Pin 18 | #define trigPin 11 // Trigger Pin 19 | #define LEDPin 13 // Onboard LED 20 | 21 | int maximumRange = 200; // Maximum range needed 22 | int minimumRange = 0; // Minimum range needed 23 | long duration, distance; // Duration used to calculate distance 24 | 25 | void setup() { 26 | Serial.begin (9600); 27 | pinMode(trigPin, OUTPUT); 28 | pinMode(echoPin, INPUT); 29 | pinMode(LEDPin, OUTPUT); // Use LED indicator (if required) 30 | } 31 | 32 | void loop() { 33 | /* The following trigPin/echoPin cycle is used to determine the 34 | distance of the nearest object by bouncing soundwaves off of it. */ 35 | digitalWrite(trigPin, LOW); 36 | delayMicroseconds(2); 37 | 38 | digitalWrite(trigPin, HIGH); 39 | delayMicroseconds(10); 40 | 41 | digitalWrite(trigPin, LOW); 42 | duration = pulseIn(echoPin, HIGH); 43 | 44 | //Calculate the distance (in cm) based on the speed of sound. 45 | distance = duration/58.2; 46 | 47 | Serial.println(distance); 48 | digitalWrite(LEDPin, LOW); 49 | 50 | 51 | //Delay 50ms before next reading. 52 | delay(100); 53 | } 54 | -------------------------------------------------------------------------------- /AutoSanitizer/main/main.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define DEBUG 4 | 5 | int IRData = 10; //PB2 6 | int R_Out = 9; //PB1 7 | int Debug_Led = 8; //PB0 8 | int Relay_ON_Time = 500; 9 | int Wait_Time = 1500; 10 | 11 | /* sets pin 3 going at the IR modulation rate 12 | */ 13 | void setIrModOutput(){ 14 | pinMode(3, OUTPUT); 15 | 16 | // Just enable output on Pin 3 and disable it on Pin 11 17 | TCCR2A = _BV(COM2B1) | _BV(WGM21) | _BV(WGM20); 18 | TCCR2B = _BV(WGM22) | _BV(CS22); 19 | 20 | // defines the frequency 51 = 38.4 KHz, 54 = 36.2 KHz, 58 = 34 KHz, 62 = 32 KHz 21 | OCR2A = 51; 22 | 23 | // defines the duty cycle - Half the OCR2A value for 50% 24 | OCR2B = 25; 25 | 26 | // select a prescale value of 8:1 of the system clock 27 | TCCR2B = (TCCR2B & 0b00111000) | 0x2; 28 | } 29 | 30 | void setup(){ 31 | 32 | setIrModOutput(); 33 | // initialize the digital pins. 34 | pinMode(R_Out, OUTPUT); 35 | pinMode(IRData, INPUT); 36 | 37 | #ifdef DEBUG 38 | Serial.begin(9600); 39 | pinMode(Debug_Led, OUTPUT); 40 | digitalWrite(Debug_Led, HIGH); 41 | Serial.println("Initialising..."); 42 | delay(1000); 43 | digitalWrite(Debug_Led, LOW); 44 | #endif 45 | } 46 | 47 | void loop(){ 48 | 49 | if(digitalRead(IRData) == LOW){ 50 | digitalWrite(R_Out, HIGH); // turn the Relay on 51 | #ifdef DEBUG 52 | Serial.println("Relay ON"); 53 | digitalWrite(Debug_Led, HIGH); 54 | #endif 55 | delay(Relay_ON_Time); // wait for a Relay_ON_Time 56 | digitalWrite(R_Out, LOW); // turn the Relay off 57 | #ifdef DEBUG 58 | Serial.println("Relay OFF"); 59 | digitalWrite(Debug_Led, LOW); 60 | #endif 61 | delay(Wait_Time); // wait for a Wait_Time 62 | 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /EM-18_RFID_Reader/rfid_basic.ino: -------------------------------------------------------------------------------- 1 | 2 | String voice; 3 | void setup() { 4 | Serial.begin(9600); 5 | 6 | // put your setup code here, to run once: 7 | 8 | } 9 | 10 | void loop() { 11 | while(Serial.available()>0) 12 | { 13 | delay(10); 14 | char a=Serial.read(); 15 | voice+=a; 16 | 17 | } 18 | if(voice.length()>0) 19 | 20 | { 21 | delay(10); 22 | voice.remove(voice.length()-2); 23 | Serial.println(voice); 24 | 25 | 26 | if(voice=="0013947845") 27 | { 28 | Serial.println("person1"); 29 | delay(1000); 30 | } 31 | else if(voice=="0013950454") 32 | { 33 | Serial.println("person2"); 34 | delay(1000); 35 | } 36 | else 37 | { 38 | Serial.println("unknown"); 39 | delay(1000); 40 | } 41 | 42 | 43 | } 44 | voice=""; 45 | // put your main code here, to run repeatedly: 46 | 47 | } 48 | -------------------------------------------------------------------------------- /GSM_PPP_interface/Readme.md: -------------------------------------------------------------------------------- 1 | ## Install the required application using the following commands 2 | 3 | `sudo apt-get update` 4 | 5 | `sudo apt-get install ppp` 6 | 7 | ## Now we want to configure the ppp interface to communicate with our GSM modem. This can be done using the following instructions 8 | 9 | `cd /etc/ppp/peers/ ` 10 | 11 | `sudo nano rnet` 12 | 13 | Then include the following contents to the rnet file 14 | 15 | ``` 16 | ### File Begin ### 17 | #imis/internet is the apn for idea connection 18 | connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T imis/internet" 19 | 20 | # For Raspberry Pi3 use /dev/ttyS0 as the communication port: 21 | /dev/ttyUSB0 22 | 23 | # Baudrate 24 | 115200 25 | 26 | # Assumes that your IP address is allocated dynamically by the ISP. 27 | noipdefault 28 | 29 | # Try to get the name server addresses from the ISP. 30 | usepeerdns 31 | 32 | # Use this connection as the default route to the internet. 33 | defaultroute 34 | 35 | # Makes PPPD "dial again" when the connection is lost. 36 | persist 37 | 38 | # Do not ask the remote to authenticate. 39 | noauth 40 | 41 | # No hardware flow control on the serial link with GSM Modem 42 | nocrtscts 43 | 44 | # No modem control lines with GSM Modem 45 | local 46 | ### File End ### 47 | ``` 48 | 49 | > Special note: Here we assume that the modem can be communicated using ttyUSB0 interface and baudrate 115200. Please ensure this beforehand and then try the instructions in the blog post. 50 | 51 | Edit the following file if the SIM is protected by a PIN 52 | 53 | `nano /etc/chatscripts/gprs` 54 | 55 | Finally type the following command to activate the new interface 56 | 57 | `sudo pon rnet` 58 | 59 | > At this point you will be noticing a fast blink rate of network led in our GSM module which represents the GPRS activity. 60 | 61 | We can also deactivate the PPP interface if required using the following command 62 | 63 | `sudo poff rnet` 64 | 65 | -------------------------------------------------------------------------------- /GSM_PPP_interface/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "====Installing required packages=======" 4 | echo "" 5 | echo "" 6 | sudo apt-get update 7 | sudo apt-get install -y ppp 8 | 9 | 10 | 11 | echo "=====copying configuration script to /etc/ppp/peers/=======" 12 | echo "Make sure that the serial port and baudrate are correct" 13 | echo "" 14 | sudo cp -f rnet /etc/ppp/peers/ 15 | 16 | 17 | echo "========================================= " 18 | echo " If SIM pin is set edit the following file using the command " 19 | echo "nano /etc/chatscripts/gprs" 20 | echo " ========================================= " 21 | echo "" 22 | echo "" 23 | 24 | echo "=======Finally activating the new interface========" 25 | echo "" 26 | echo "" 27 | sudo pon rnet 28 | 29 | echo "=======You can turn off the interface using the following comamnd ========" 30 | echo "sudo poff rnet" -------------------------------------------------------------------------------- /GSM_PPP_interface/rnet: -------------------------------------------------------------------------------- 1 | ### File Begin ### 2 | #imis/internet is the apn for idea connection 3 | connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T imis/internet" 4 | 5 | # For Raspberry Pi3 use /dev/ttyS0 as the communication port: 6 | /dev/ttyUSB0 7 | 8 | # Baudrate 9 | 115200 10 | 11 | # Assumes that your IP address is allocated dynamically by the ISP. 12 | noipdefault 13 | 14 | # Try to get the name server addresses from the ISP. 15 | usepeerdns 16 | 17 | # Use this connection as the default route to the internet. 18 | defaultroute 19 | 20 | # Makes PPPD "dial again" when the connection is lost. 21 | persist 22 | 23 | # Do not ask the remote to authenticate. 24 | noauth 25 | 26 | # No hardware flow control on the serial link with GSM Modem 27 | nocrtscts 28 | 29 | # No modem control lines with GSM Modem 30 | local 31 | ### File End ### -------------------------------------------------------------------------------- /GSM_Software_serial/GSM_Call/GSM_Call.ino: -------------------------------------------------------------------------------- 1 | /* 2 | The circuit: 3 | * RX is digital pin 10 (connect to TX of GSM Modem) 4 | * TX is digital pin 11 (connect to RX of GSM Modem) 5 | */ 6 | #include 7 | 8 | SoftwareSerial mySerial(10, 11); // RX, TX 9 | 10 | void setup() 11 | { 12 | // Open serial communications and wait for port to open: 13 | Serial.begin(9600); 14 | 15 | Serial.println("Calling through GSM Modem"); 16 | 17 | // set the data rate for the SoftwareSerial port 18 | mySerial.begin(9600); 19 | delay(2000); 20 | mySerial.println("ATD81290255XX;"); //watch out here for semicolon at the end!! 21 | 22 | Serial.println("Called ATD81290255XX"); 23 | } 24 | 25 | void loop() // run over and over 26 | { 27 | // print response over serial port 28 | if (mySerial.available()) 29 | Serial.write(mySerial.read()); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /GSM_Uart_Test/GSM_Uart_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Dhanish 3 | Created on: 19-08-2014 4 | Company: Elementz Engineers Guild Pvt Ltd 5 | 6 | 7 | Run this code only after SIM900A Module has powered and connected to a Network. 8 | Please make a call to the module knowing whether the connect is established. 9 | If connected a ring will be heard at the caller end 10 | */ 11 | 12 | void setup() { 13 | // initialize serial communications at 9600 bps: 14 | Serial.begin(9600); 15 | 16 | // print the serial data to GSM 17 | Serial.print("ATD9020XXXXXX;" ); // change here to call a number using SIM900A 18 | // wait 10 seconds before the next loop 19 | delay(10000); 20 | Serial.print("ATH" ); // hold the call 21 | } 22 | 23 | void loop() { 24 | } 25 | -------------------------------------------------------------------------------- /GestureController/GestureController.ino: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor 3 | 4 | To perform a NEAR gesture, hold your hand 5 | far above the sensor and move it close to the sensor (within 2 6 | inches). Hold your hand there for at least 1 second and move it 7 | away. 8 | 9 | To perform a FAR gesture, hold your hand within 2 inches of the 10 | sensor for at least 1 second and then move it above (out of 11 | range) of the sensor. 12 | 13 | Hardware Connections: 14 | 15 | IMPORTANT: The APDS-9960 can only accept 3.3V! 16 | 17 | Arduino Pin APDS-9960 Board Function 18 | 19 | 3.3V VCC Power 20 | GND GND Ground 21 | A4 SDA I2C Data 22 | A5 SCL I2C Clock 23 | 2 INT Interrupt 24 | 25 | ****************************************************************/ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #define SCREEN_WIDTH 128 // OLED display width, in pixels 37 | #define SCREEN_HEIGHT 64 // OLED display height, in pixels 38 | 39 | // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) 40 | #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) 41 | Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); 42 | 43 | // Pins 44 | #define APDS9960_INT 25 // Needs to be an interrupt pin 45 | #define DATA_PIN 26 46 | 47 | // Constants 48 | 49 | // Global Variables 50 | SparkFun_APDS9960 apds = SparkFun_APDS9960(); 51 | int isr_flag = 0; 52 | 53 | const int NUM_LEDS = 24; 54 | CRGB leds[NUM_LEDS]; 55 | int LEDCoordinateX = 12; 56 | bool Gesture_Up, Gesture_Down, Gesture_Left, Gesture_Right, Gesture_Far, Gesture_Near; 57 | 58 | // Functions 59 | void interruptRoutine(); 60 | void handleGesture(); 61 | void ControlLEDStrip(); 62 | void UpdateI2CDisplay(); 63 | 64 | void setup() 65 | { 66 | Serial.begin(115200); 67 | delay(2000); 68 | 69 | // ----------------I2C DISPLAY---------------- 70 | // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally 71 | if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) 72 | { 73 | Serial.println(F("SSD1306 allocation failed")); 74 | } 75 | else 76 | { 77 | Serial.println("---------I2C Display - 0x3C----------"); 78 | } 79 | 80 | // Show initial display buffer contents on the screen -- 81 | // the library initializes this with an Adafruit splash screen. 82 | display.display(); 83 | delay(2000); // Pause for 2 seconds 84 | 85 | // Clear the buffer 86 | // display.clearDisplay(); 87 | // UpdateI2CDisplay(); 88 | display.clearDisplay(); 89 | 90 | // ------------------------------------------- 91 | 92 | // ---------------- APDS 9960 ---------------- 93 | // Set interrupt pin as input 94 | pinMode(APDS9960_INT, INPUT); 95 | 96 | // Initialize Serial port 97 | Serial.println(); 98 | Serial.println(F("--------------------------------")); 99 | Serial.println(F("SparkFun APDS-9960 - GestureTest")); 100 | Serial.println(F("--------------------------------")); 101 | 102 | // Initialize interrupt service routine 103 | attachInterrupt(APDS9960_INT, interruptRoutine, FALLING); 104 | 105 | // Initialize APDS-9960 (configure I2C and initial values) 106 | if (apds.init()) 107 | { 108 | Serial.println(F("APDS-9960 initialization complete")); 109 | } 110 | else 111 | { 112 | Serial.println(F("Something went wrong during APDS-9960 init!")); 113 | } 114 | 115 | // Start running the APDS-9960 gesture sensor engine 116 | if (apds.enableGestureSensor(true)) 117 | { 118 | Serial.println(F("Gesture sensor is now running")); 119 | 120 | // if (apds.setLEDDrive(0)) 121 | // { 122 | // Serial.println("LED Drive Set"); 123 | // } 124 | if (apds.setGestureGain(GGAIN_2X)) 125 | { 126 | Serial.println("Gesture Gain Set"); 127 | } 128 | } 129 | else 130 | { 131 | Serial.println(F("Something went wrong during gesture sensor init!")); 132 | } 133 | // ------------------------------------------- 134 | 135 | // ----------------WS2812B LED---------------- 136 | FastLED.addLeds(leds, NUM_LEDS); 137 | // for (int i; i < NUM_LEDS; i++) 138 | // { 139 | // leds[i] = CRGB::White; 140 | // } 141 | // FastLED.show(); 142 | } 143 | 144 | void loop() 145 | { 146 | if (isr_flag == 1) 147 | { 148 | detachInterrupt(APDS9960_INT); 149 | // Serial.println("Interrupt Function"); 150 | handleGesture(); 151 | ControlLEDStrip(); 152 | isr_flag = 0; 153 | attachInterrupt(APDS9960_INT, interruptRoutine, FALLING); 154 | } 155 | } 156 | 157 | void interruptRoutine() 158 | { 159 | isr_flag = 1; 160 | } 161 | 162 | void handleGesture() 163 | { 164 | bool GestureAvailability = apds.isGestureAvailable(); 165 | // Serial.print("Gesture Avail : "); 166 | // Serial.println(GestureAvailability); 167 | 168 | if (GestureAvailability) 169 | { 170 | int GestureType = apds.readGesture(); 171 | // Serial.print("Gesture Type : "); 172 | // Serial.println(GestureType); 173 | 174 | switch (GestureType) 175 | { 176 | case DIR_UP: 177 | Serial.println("UP"); 178 | Gesture_Up = true; 179 | break; 180 | case DIR_DOWN: 181 | Serial.println("DOWN"); 182 | Gesture_Down = true; 183 | break; 184 | case DIR_LEFT: 185 | Serial.println("LEFT"); 186 | Gesture_Left = true; 187 | break; 188 | case DIR_RIGHT: 189 | Serial.println("RIGHT"); 190 | Gesture_Right = true; 191 | break; 192 | case DIR_NEAR: 193 | Serial.println("NEAR"); 194 | Gesture_Near = true; 195 | break; 196 | case DIR_FAR: 197 | Serial.println("FAR"); 198 | Gesture_Far = true; 199 | break; 200 | default: 201 | Serial.println("NONE"); 202 | } 203 | } 204 | } 205 | 206 | void UpdateI2CDisplay() 207 | { 208 | display.clearDisplay(); 209 | display.setTextSize(1); // Normal 1:1 pixel scale 210 | display.setTextColor(WHITE); // Draw white text 211 | display.setCursor(1, 1); // Start at top-left corner 212 | display.println(F("APDS 9960 & WS2812B")); 213 | 214 | display.setCursor(0, 24); 215 | display.setTextSize(3); // Draw 2X-scale text 216 | display.setTextColor(WHITE); 217 | display.print(F("X : ")); 218 | if (LEDCoordinateX <= 9) 219 | { 220 | display.print("0"); 221 | display.println(LEDCoordinateX); 222 | } 223 | else 224 | { 225 | display.println(LEDCoordinateX); 226 | } 227 | 228 | display.display(); 229 | } 230 | 231 | void ControlLEDStrip() 232 | { 233 | // --------------GESTURE UP-------------- 234 | if (Gesture_Up) 235 | { 236 | if (LEDCoordinateX < NUM_LEDS - 1) 237 | { 238 | leds[LEDCoordinateX] = CRGB::Black; 239 | for (int i = 0; i <= 2; i++) 240 | { 241 | if (!(LEDCoordinateX >= NUM_LEDS - 1)) 242 | { 243 | LEDCoordinateX++; 244 | leds[LEDCoordinateX] = CRGB::Red; 245 | FastLED.show(); 246 | FastLED.delay(30); 247 | leds[LEDCoordinateX] = CRGB::Black; 248 | } 249 | } 250 | if (LEDCoordinateX >= NUM_LEDS - 1) 251 | { 252 | LEDCoordinateX = NUM_LEDS - 1; 253 | leds[LEDCoordinateX] = CRGB::Red; 254 | } 255 | else 256 | { 257 | LEDCoordinateX++; 258 | leds[LEDCoordinateX] = CRGB::Red; 259 | } 260 | UpdateI2CDisplay(); 261 | } 262 | Gesture_Up = false; 263 | } 264 | 265 | // -------------GESTURE DOWN------------- 266 | if (Gesture_Down) 267 | { 268 | if (LEDCoordinateX > 0) 269 | { 270 | leds[LEDCoordinateX] = CRGB::Black; 271 | for (int j = 0; j <= 2; j++) 272 | { 273 | if (!(LEDCoordinateX - 1 <= 0)) 274 | { 275 | LEDCoordinateX--; 276 | leds[LEDCoordinateX] = CRGB::Red; 277 | FastLED.show(); 278 | FastLED.delay(30); 279 | leds[LEDCoordinateX] = CRGB::Black; 280 | } 281 | } 282 | 283 | if (LEDCoordinateX <= 0) 284 | { 285 | LEDCoordinateX = 0; 286 | leds[LEDCoordinateX] = CRGB::Red; 287 | } 288 | else 289 | { 290 | LEDCoordinateX--; 291 | leds[LEDCoordinateX] = CRGB::Red; 292 | } 293 | UpdateI2CDisplay(); 294 | } 295 | Gesture_Down = false; 296 | } 297 | 298 | // -------------GESTURE LEFT------------- 299 | if (Gesture_Left) 300 | { 301 | if (LEDCoordinateX > 0) 302 | { 303 | leds[LEDCoordinateX] = CRGB::Black; 304 | LEDCoordinateX--; 305 | leds[LEDCoordinateX] = CRGB::Red; 306 | FastLED.show(); 307 | UpdateI2CDisplay(); 308 | } 309 | Gesture_Left = false; 310 | } 311 | 312 | // ------------GESTURE RIGHT------------- 313 | if (Gesture_Right) 314 | { 315 | if (LEDCoordinateX < NUM_LEDS - 1) 316 | { 317 | leds[LEDCoordinateX] = CRGB::Black; 318 | LEDCoordinateX++; 319 | leds[LEDCoordinateX] = CRGB::Red; 320 | FastLED.show(); 321 | UpdateI2CDisplay(); 322 | } 323 | Gesture_Right = false; 324 | } 325 | 326 | // -------------GESTURE NEAR------------- 327 | if (Gesture_Near) 328 | { 329 | for (int k = 0; k < NUM_LEDS; k++) 330 | { 331 | leds[k] = CRGB::Black; 332 | } 333 | FastLED.show(); 334 | Gesture_Near = false; 335 | } 336 | 337 | // -------------GESTURE FAR------------- 338 | if (Gesture_Far) 339 | { 340 | for (int i = 0; i < NUM_LEDS; i++) 341 | { 342 | leds[i] = CRGB::Green; 343 | } 344 | FastLED.show(); 345 | Gesture_Far = false; 346 | } 347 | } -------------------------------------------------------------------------------- /HeatRate_Sensor/HeatRate_Sensor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Hardware used : https://www.elementzonline.com/pulse-sensor-amped-heart-rate-sensor-for-arduino-raspberry-pi 4 | ReadHearRate Sensor 5 | Connection - 6 | 7 | Arduino pin -- Sensor PIN 8 | 3.3V -- V+ (+ marking) 9 | GND -- V- (- marking) 10 | A0 -- S (S marking) 11 | 12 | 13 | Instructions: 14 | 15 | Open serial monitor with baud rate 115200, 16 | 17 | At first you will not see anything in serial monitor, 18 | 19 | Place the sensor on a flat surface with LED facing upwards ( Heart sysmbol faces on top ) 20 | Sit on a seat such that the heart and finger are on same level. 21 | Gently place the finger tip covering the led and sensor. 22 | No need to apply more pressure with the finger. Only a gentle contact will be enough. 23 | Now observe the serial monitor for the BPM to be printed. 24 | 25 | */ 26 | 27 | 28 | int peak=0; 29 | int bottom = 1023; 30 | int sample_count = 0; 31 | 32 | long previousMillis = 0; 33 | long previousPeakMillis = 0; 34 | long previousLowMillis = 0; 35 | long newPeakMillis = 0; 36 | long newLowMillis = 0; 37 | long peakDiff = 0; 38 | long lowDiff = 0; 39 | 40 | // the setup routine runs once when you press reset: 41 | void setup() { 42 | // initialize serial communication at 9600 bits per second: 43 | Serial.begin(115200); 44 | } 45 | 46 | // the loop routine runs over and over again forever: 47 | void loop() { 48 | 49 | long nextMillis = millis(); 50 | sample_count++; 51 | // read the input on analog pin 0: 52 | int sensorValue = analogRead(A0); 53 | 54 | // if a new peak is found, update the peak variable and save the time in which the peak is obtained 55 | if (sensorValue > peak){ 56 | peak = sensorValue; // update new peak 57 | newPeakMillis = nextMillis; 58 | 59 | } 60 | 61 | // if a new low is found, update the bottom variable and save the time in which the low is obtained 62 | if (sensorValue < bottom){ 63 | bottom = sensorValue; 64 | newLowMillis = nextMillis; 65 | } 66 | 67 | if ((nextMillis - previousMillis) > 750) // Find the alternate peak difference every 750 milli seconds 68 | { 69 | // Serial.print("Bottom: "); 70 | // Serial.println(peak); 71 | // Serial.print("Peak: "); 72 | // Serial.println(bottom); 73 | 74 | 75 | 76 | // Serial.print("previousPeakMillis: "); 77 | // Serial.println(previousPeakMillis); 78 | // Serial.print("previousLowMillis: "); 79 | // Serial.println(previousLowMillis); 80 | 81 | peakDiff = newPeakMillis - previousPeakMillis; // Find the difference between consecutive peaks 82 | lowDiff = newLowMillis - previousLowMillis; // Find the difference between consecutive lows/bottom 83 | // Serial.print("PeakDiff: "); 84 | // Serial.println(peakDiff); 85 | // Serial.print("LowDiff: "); 86 | // Serial.println(lowDiff); 87 | 88 | // If the consecutive lowDifference of peak and bottom are more or less same, then we can consider the we get two valid heart pulses. 89 | // If two valid heart pulses are obtained satisfying the above condition, we can calculate the BPM(Beats per minute), note that all timing are in Milliseconds 90 | if (abs(peakDiff - lowDiff) < 25){ 91 | Serial.println("Valid beat found: "); 92 | 93 | // Take the average of the peak and low differences and save this to "value" 94 | long value = (peakDiff + lowDiff)/2; 95 | 96 | // BPM is caluclated as (1000 milliseconds / value in milliseconds) * 60 97 | Serial.print("BPM = "); 98 | Serial.println((float)1000/(float)value * 60); 99 | } 100 | 101 | 102 | // Save the previous peak and low millis to a variable for next calculation 103 | previousPeakMillis = newPeakMillis; 104 | previousLowMillis = newLowMillis; 105 | 106 | // reset the peak and bottom variables to find new peak and bottom 107 | peak = 0; 108 | bottom = 1024; 109 | 110 | // reset previousMillis to enter this loop after 750 ms 111 | previousMillis = nextMillis; 112 | } 113 | 114 | // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): 115 | // float voltage = sensorValue * (5.0 / 1023.0); 116 | // print out the value you read: 117 | // Serial.println(sensorValue); 118 | delay(2); // read every 2 ms 119 | } 120 | -------------------------------------------------------------------------------- /IOT_Kit/iot_control_pins/controlPin/controlPin.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define DEBUG true 4 | 5 | SoftwareSerial esp8266(10,11); // make RX Arduino line is pin 10, make TX Arduino line is pin 11. 6 | // This means that you need to connect the TX line from the esp to the Arduino's pin 2 7 | // and the RX line from the esp to the Arduino's pin 3 8 | void setup() 9 | { 10 | Serial.begin(9600); 11 | esp8266.begin(9600); // your esp's baud rate might be different 12 | 13 | pinMode(2,OUTPUT); 14 | digitalWrite(2,LOW); 15 | 16 | pinMode(3,OUTPUT); 17 | digitalWrite(3,LOW); 18 | 19 | pinMode(4,OUTPUT); 20 | digitalWrite(4,LOW); 21 | 22 | sendData("AT+RST\r\n",2000,DEBUG); // reset module 23 | sendData("AT+CWMODE=2\r\n",1000,DEBUG); // configure as access point 24 | sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address 25 | sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections 26 | sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // turn on server on port 80 27 | } 28 | 29 | void loop() 30 | { 31 | if(esp8266.available()) // check if the esp is sending a message 32 | { 33 | 34 | 35 | if(esp8266.find("+IPD,")) 36 | { 37 | Serial.println("listening"); 38 | delay(1000); // wait for the serial buffer to fill up (read all the serial data) 39 | // get the connection id so that we can then disconnect 40 | int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns 41 | // the ASCII decimal value and 0 (the first decimal number) starts at 48 42 | 43 | esp8266.find("pin="); // advance cursor to "pin=" 44 | 45 | int pinNumber = (esp8266.read()-48)*10; // get first number i.e. if the pin 13 then the 1st number is 1, then multiply to get 10 46 | pinNumber += (esp8266.read()-48); // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number 47 | 48 | digitalWrite(pinNumber, !digitalRead(pinNumber)); // toggle pin 49 | 50 | // make close command 51 | String closeCommand = "AT+CIPCLOSE="; 52 | closeCommand+=connectionId; // append connection id 53 | closeCommand+="\r\n"; 54 | 55 | sendData(closeCommand,1000,DEBUG); // close connection 56 | } 57 | } 58 | } 59 | 60 | /* 61 | * Name: sendData 62 | * Description: Function used to send data to ESP8266. 63 | * Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no) 64 | * Returns: The response from the esp8266 (if there is a reponse) 65 | */ 66 | String sendData(String command, const int timeout, boolean debug) 67 | { 68 | String response = ""; 69 | 70 | esp8266.print(command); // send the read character to the esp8266 71 | 72 | long int time = millis(); 73 | 74 | while( (time+timeout) > millis()) 75 | { 76 | while(esp8266.available()) 77 | { 78 | 79 | // The esp has data so display its output to the serial window 80 | char c = esp8266.read(); // read the next character. 81 | response+=c; 82 | } 83 | } 84 | 85 | if(debug) 86 | { 87 | Serial.print(response); 88 | } 89 | 90 | return response; 91 | } 92 | -------------------------------------------------------------------------------- /IOT_Kit/iot_control_pins/myesp8266.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | ESP8266 LED Control 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 23 | 24 | -------------------------------------------------------------------------------- /IOT_Kit/thingspeak_demo/thingspeak_demo.ino: -------------------------------------------------------------------------------- 1 | // esp8266_test.ino 2 | // 3 | // Plot LM35 data on thingspeak.com using an Arduino and an ESP8266 WiFi 4 | // module. 5 | 6 | 7 | #include 8 | #include 9 | 10 | // LED 11 | int ledPin = 13; 12 | // LM35 analog input 13 | int lm35Pin = A0; 14 | 15 | // replace with your channel's thingspeak API key 16 | String apiKey = "ZP1PZO62773HXWVU"; 17 | 18 | // connect 10 to TX of Serial USB 19 | // connect 11 to RX of serial USB 20 | SoftwareSerial ser(10, 11); // RX, TX 21 | 22 | // this runs once 23 | void setup() { 24 | // initialize the digital pin as an output. 25 | pinMode(ledPin, OUTPUT); 26 | 27 | // enable debug serial 28 | Serial.begin(9600); 29 | // enable software serial 30 | ser.begin(9600); 31 | 32 | // reset ESP8266 33 | ser.println("AT+RST"); 34 | } 35 | 36 | 37 | // the loop 38 | void loop() { 39 | 40 | // blink LED on board 41 | digitalWrite(ledPin, HIGH); 42 | delay(200); 43 | digitalWrite(ledPin, LOW); 44 | 45 | // read the value from LM35. 46 | // read 10 values for averaging. 47 | int val = 0; 48 | for(int i = 0; i < 10; i++) { 49 | val += analogRead(lm35Pin); 50 | delay(500); 51 | } 52 | 53 | // convert to temp: 54 | // temp value is in 0-1023 range 55 | // LM35 outputs 10mV/degree C. ie, 1 Volt => 100 degrees C 56 | // So Temp = (avg_val/1023)*5 Volts * 100 degrees/Volt 57 | float temp = val*50.0f/1023.0f; 58 | 59 | // convert to string 60 | char buf[16]; 61 | String strTemp = dtostrf(temp, 4, 1, buf); 62 | 63 | Serial.println(strTemp); 64 | 65 | // TCP connection 66 | String cmd = "AT+CIPSTART=\"TCP\",\""; 67 | cmd += "184.106.153.149"; // api.thingspeak.com 68 | cmd += "\",80"; 69 | ser.println(cmd); 70 | 71 | if(ser.find("Error")){ 72 | Serial.println("AT+CIPSTART error"); 73 | return; 74 | } 75 | 76 | // prepare GET string 77 | String getStr = "GET /update?api_key="; 78 | getStr += apiKey; 79 | getStr +="&field1="; 80 | getStr += String(strTemp); 81 | getStr += "\r\n\r\n"; 82 | 83 | // send data length 84 | cmd = "AT+CIPSEND="; 85 | cmd += String(getStr.length()); 86 | ser.println(cmd); 87 | 88 | if(ser.find(">")){ 89 | ser.print(getStr); 90 | } 91 | else{ 92 | ser.println("AT+CIPCLOSE"); 93 | // alert user 94 | Serial.println("AT+CIPCLOSE"); 95 | } 96 | 97 | // thingspeak needs 15 sec delay between updates 98 | delay(16000); 99 | } 100 | -------------------------------------------------------------------------------- /IR_Code/IR_Code.ino: -------------------------------------------------------------------------------- 1 | int obstaclePin = 2; // This is our input pin 2 | void setup() 3 | { 4 | pinMode(obstaclePin, INPUT); 5 | Serial.begin(9600); 6 | } 7 | void loop() 8 | { 9 | int hasObstacle = digitalRead(obstaclePin); 10 | 11 | if (hasObstacle == HIGH) 12 | 13 | { 14 | Serial.print( "Stop something is ahead!! "); 15 | Serial.println(hasObstacle); 16 | } 17 | else 18 | { 19 | Serial.print("Path is clear "); 20 | Serial.println(hasObstacle); 21 | } 22 | delay(1000); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /LoRa_RangeTest/RA02/LoRaReceiver/LoRa.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Sandeep Mistry. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #ifndef LORA_H 5 | #define LORA_H 6 | 7 | #include 8 | #include 9 | 10 | #ifdef ARDUINO_SAMD_MKRWAN1300 11 | #define LORA_DEFAULT_SPI SPI1 12 | #define LORA_DEFAULT_SPI_FREQUENCY 250000 13 | #define LORA_DEFAULT_SS_PIN LORA_IRQ_DUMB 14 | #define LORA_DEFAULT_RESET_PIN -1 15 | #define LORA_DEFAULT_DIO0_PIN -1 16 | #else 17 | #define LORA_DEFAULT_SPI SPI 18 | #define LORA_DEFAULT_SPI_FREQUENCY 8E6 19 | #define LORA_DEFAULT_SS_PIN 10 20 | #define LORA_DEFAULT_RESET_PIN 9 21 | #define LORA_DEFAULT_DIO0_PIN 2 22 | #endif 23 | 24 | #define PA_OUTPUT_RFO_PIN 0 25 | #define PA_OUTPUT_PA_BOOST_PIN 1 26 | 27 | class LoRaClass : public Stream { 28 | public: 29 | LoRaClass(); 30 | 31 | int begin(long frequency); 32 | void end(); 33 | 34 | int beginPacket(int implicitHeader = false); 35 | int endPacket(); 36 | 37 | int parsePacket(int size = 0); 38 | int packetRssi(); 39 | float packetSnr(); 40 | long packetFrequencyError(); 41 | 42 | // from Print 43 | virtual size_t write(uint8_t byte); 44 | virtual size_t write(const uint8_t *buffer, size_t size); 45 | 46 | // from Stream 47 | virtual int available(); 48 | virtual int read(); 49 | virtual int peek(); 50 | virtual void flush(); 51 | 52 | #ifndef ARDUINO_SAMD_MKRWAN1300 53 | void onReceive(void(*callback)(int)); 54 | 55 | void receive(int size = 0); 56 | #endif 57 | void idle(); 58 | void sleep(); 59 | 60 | void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN); 61 | void setFrequency(long frequency); 62 | void setSpreadingFactor(int sf); 63 | void setSignalBandwidth(long sbw); 64 | void setCodingRate4(int denominator); 65 | void setPreambleLength(long length); 66 | void setSyncWord(int sw); 67 | void enableCrc(); 68 | void disableCrc(); 69 | 70 | // deprecated 71 | void crc() { enableCrc(); } 72 | void noCrc() { disableCrc(); } 73 | 74 | byte random(); 75 | 76 | void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN); 77 | void setSPI(SPIClass& spi); 78 | void setSPIFrequency(uint32_t frequency); 79 | 80 | void dumpRegisters(Stream& out); 81 | 82 | 83 | long getSignalBandwidth(); 84 | 85 | int getSpreadingFactor(); 86 | 87 | private: 88 | void explicitHeaderMode(); 89 | void implicitHeaderMode(); 90 | 91 | void handleDio0Rise(); 92 | 93 | 94 | void setLdoFlag(); 95 | 96 | uint8_t readRegister(uint8_t address); 97 | void writeRegister(uint8_t address, uint8_t value); 98 | uint8_t singleTransfer(uint8_t address, uint8_t value); 99 | 100 | static void onDio0Rise(); 101 | 102 | private: 103 | SPISettings _spiSettings; 104 | SPIClass* _spi; 105 | int _ss; 106 | int _reset; 107 | int _dio0; 108 | long _frequency; 109 | int _packetIndex; 110 | int _implicitHeaderMode; 111 | void (*_onReceive)(int); 112 | }; 113 | 114 | extern LoRaClass LoRa; 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /LoRa_RangeTest/RA02/LoRaReceiver/LoRaReceiver.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Developed by Dhanish Vijayan - Elementz Engineers Guild Pvt. Ltd. 3 | Instructions 4 | 5 | Tested with the Elementz Lora board with Arduino Pro mini 8 MHz bootloader 6 | Led blinks at every packet reception 7 | 8 | ToDo: 9 | // Receive from multiple clients 10 | // Parameter tuning to achive more range 11 | 12 | */ 13 | 14 | #include 15 | #include "LoRa.h" 16 | 17 | int LED_BUILTIN1 = 3; 18 | int SyncWord = 0x22; 19 | 20 | void setup() { 21 | Serial.begin(9600); 22 | while (!Serial); 23 | pinMode(LED_BUILTIN1, OUTPUT); 24 | Serial.println("LoRa Receiver"); 25 | 26 | if (!LoRa.begin(433E6)) { 27 | Serial.println("Starting LoRa failed!"); 28 | while (1); 29 | } 30 | 31 | LoRa.setSpreadingFactor(12); // ranges from 6-12,default 7 see API docs 32 | LoRa.setSignalBandwidth(62.5E3); // for -139dB (page - 112) 33 | LoRa.setCodingRate4(8); // for -139dB (page - 112) 34 | LoRa.setSyncWord(SyncWord); // ranges from 0-0xFF, default 0x12, see API docs 35 | 36 | Serial.print("current spreading factor : "); 37 | Serial.println(LoRa.getSpreadingFactor()); 38 | Serial.print("current bandwidth : "); 39 | Serial.println(LoRa.getSignalBandwidth()); 40 | Serial.println("LoRa init succeeded."); 41 | } 42 | 43 | void loop() { 44 | // try to parse packet 45 | // if (SyncWord == 0x22) SyncWord = 0x11; else SyncWord = 0x22; 46 | // LoRa.setSyncWord(SyncWord); 47 | int packetSize = LoRa.parsePacket(); 48 | if (packetSize) { 49 | // received a packet 50 | Serial.print("Received packet '"); 51 | 52 | // read packet 53 | while (LoRa.available()) { 54 | Serial.print((char)LoRa.read()); 55 | } 56 | 57 | // print RSSI of packet 58 | Serial.print("' with RSSI "); 59 | Serial.print(LoRa.packetRssi()); 60 | Serial.println(" Snr: " + String(LoRa.packetSnr())); 61 | digitalWrite(LED_BUILTIN1, HIGH); // turn the LED on (HIGH is the voltage level) 62 | delay(200); // wait for a second 63 | digitalWrite(LED_BUILTIN1, LOW); // turn the LED off by making the voltage LOW 64 | delay(200); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /LoRa_RangeTest/RA02/LoRaSender/LoRa.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Sandeep Mistry. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #ifndef LORA_H 5 | #define LORA_H 6 | 7 | #include 8 | #include 9 | 10 | #ifdef ARDUINO_SAMD_MKRWAN1300 11 | #define LORA_DEFAULT_SPI SPI1 12 | #define LORA_DEFAULT_SPI_FREQUENCY 250000 13 | #define LORA_DEFAULT_SS_PIN LORA_IRQ_DUMB 14 | #define LORA_DEFAULT_RESET_PIN -1 15 | #define LORA_DEFAULT_DIO0_PIN -1 16 | #else 17 | #define LORA_DEFAULT_SPI SPI 18 | #define LORA_DEFAULT_SPI_FREQUENCY 8E6 19 | #define LORA_DEFAULT_SS_PIN 10 20 | #define LORA_DEFAULT_RESET_PIN 9 21 | #define LORA_DEFAULT_DIO0_PIN 2 22 | #endif 23 | 24 | #define PA_OUTPUT_RFO_PIN 0 25 | #define PA_OUTPUT_PA_BOOST_PIN 1 26 | 27 | class LoRaClass : public Stream { 28 | public: 29 | LoRaClass(); 30 | 31 | int begin(long frequency); 32 | void end(); 33 | 34 | int beginPacket(int implicitHeader = false); 35 | int endPacket(); 36 | 37 | int parsePacket(int size = 0); 38 | int packetRssi(); 39 | float packetSnr(); 40 | long packetFrequencyError(); 41 | 42 | // from Print 43 | virtual size_t write(uint8_t byte); 44 | virtual size_t write(const uint8_t *buffer, size_t size); 45 | 46 | // from Stream 47 | virtual int available(); 48 | virtual int read(); 49 | virtual int peek(); 50 | virtual void flush(); 51 | 52 | #ifndef ARDUINO_SAMD_MKRWAN1300 53 | void onReceive(void(*callback)(int)); 54 | 55 | void receive(int size = 0); 56 | #endif 57 | void idle(); 58 | void sleep(); 59 | 60 | void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN); 61 | void setFrequency(long frequency); 62 | void setSpreadingFactor(int sf); 63 | void setSignalBandwidth(long sbw); 64 | void setCodingRate4(int denominator); 65 | void setPreambleLength(long length); 66 | void setSyncWord(int sw); 67 | void enableCrc(); 68 | void disableCrc(); 69 | 70 | // deprecated 71 | void crc() { enableCrc(); } 72 | void noCrc() { disableCrc(); } 73 | 74 | byte random(); 75 | 76 | void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN); 77 | void setSPI(SPIClass& spi); 78 | void setSPIFrequency(uint32_t frequency); 79 | 80 | void dumpRegisters(Stream& out); 81 | 82 | 83 | long getSignalBandwidth(); 84 | 85 | int getSpreadingFactor(); 86 | 87 | private: 88 | void explicitHeaderMode(); 89 | void implicitHeaderMode(); 90 | 91 | void handleDio0Rise(); 92 | 93 | 94 | void setLdoFlag(); 95 | 96 | uint8_t readRegister(uint8_t address); 97 | void writeRegister(uint8_t address, uint8_t value); 98 | uint8_t singleTransfer(uint8_t address, uint8_t value); 99 | 100 | static void onDio0Rise(); 101 | 102 | private: 103 | SPISettings _spiSettings; 104 | SPIClass* _spi; 105 | int _ss; 106 | int _reset; 107 | int _dio0; 108 | long _frequency; 109 | int _packetIndex; 110 | int _implicitHeaderMode; 111 | void (*_onReceive)(int); 112 | }; 113 | 114 | extern LoRaClass LoRa; 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /LoRa_RangeTest/RA02/LoRaSender/LoRaSender.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Developed by Dhanish Vijayan - Elementz Engineers Guild Pvt. Ltd. 3 | Instructions 4 | 5 | Tested with the Elementz Lora board with Arduino Pro mini 8 MHz bootloader 6 | Led blink on every packet transmit 7 | 8 | */ 9 | 10 | #include 11 | #include "LoRa.h" 12 | 13 | int counter = 0; 14 | int LED_BUILTIN1 = 3; 15 | int ID = 2; // 0x11 for 1 and 0x22 for 2 16 | int SyncWord = 0x22; 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | while (!Serial); 21 | 22 | Serial.println("LoRa Sender"); 23 | 24 | 25 | if (!LoRa.begin(433E6)) { 26 | Serial.println("Starting LoRa failed!"); 27 | while (1); 28 | } 29 | 30 | LoRa.setSpreadingFactor(12); // ranges from 6-12,default 7 see API docs 31 | LoRa.setSignalBandwidth(62.5E3 ); // for -139dB (page - 112) 32 | LoRa.setCodingRate4(8); // for -139dB (page - 112) 33 | LoRa.setSyncWord(SyncWord); 34 | 35 | Serial.print("current spreading factor : "); 36 | Serial.println(LoRa.getSpreadingFactor()); 37 | Serial.print("current bandwidth : "); 38 | Serial.println(LoRa.getSignalBandwidth()); 39 | Serial.println("LoRa init succeeded."); 40 | } 41 | 42 | void loop() { 43 | //LoRa.setSyncWord(1); 44 | LoRa.idle(); 45 | Serial.print("Sending packet: "); 46 | Serial.println(counter); 47 | 48 | // send packet 49 | LoRa.beginPacket(); 50 | LoRa.print("ID: "); 51 | LoRa.print(ID); 52 | LoRa.print(" HELLO "); 53 | LoRa.print(counter); 54 | LoRa.endPacket(); 55 | LoRa.sleep(); 56 | counter++; 57 | digitalWrite(LED_BUILTIN1, HIGH); // turn the LED on (HIGH is the voltage level) 58 | delay(200); // wait for a second 59 | digitalWrite(LED_BUILTIN1, LOW); // turn the LED off by making the voltage LOW 60 | delay(200); 61 | delay(5000); 62 | } 63 | -------------------------------------------------------------------------------- /LoRa_RangeTest/RA02/Notes: -------------------------------------------------------------------------------- 1 | 3.3 Supply from Arduino boards are not sufficient (100 mA for transmission) - PA_BOOST 2 | 3 | Frequency to be set to ISM band only (410-525 MHz) 4 | 5 | 6 | Spread Factor 12 --> -141 dBm(bandwidth 7.8KHz kHz) 7 | 8 | LoRa specifications : Page 18 in SX1278 datasheet 9 | 10 | RF sensitivity, Long-Range Mode, highest LNA gain, Band 2 or 3, using split Rx/Tx path 11 | 7.8 kHz bandwidth --> -148 dBm (Table 10) 12 | 13 | 14 | //////////////////// 15 | 16 | LoRa is a new, private and spread-spectrum modulation technique which allows sending data at extremely low data-rates to extremely long ranges. The low data-rate (down to few bytes per second) and LoRa modulation lead to very low receiver sensitivity (down to -134 dBm), which combined to an output power of +14 dBm means extremely large link budgets: up to 148 dB., what means more than 22km (13.6 miles) in LOS links and up to 2km (1.2miles) in NLOS links in urban environment (going through buildings). 17 | 18 | https://www.cooking-hacks.com/documentation/tutorials/extreme-range-lora-sx1272-module-shield-arduino-raspberry-pi-intel-galileo -------------------------------------------------------------------------------- /LoRa_RangeTest/RAK811/Readme.md: -------------------------------------------------------------------------------- 1 | # Range test using RAK811 in P2P mode 2 | 3 | ## Run receiver.py and obtain the console output with the received timestamp and RSSI value 4 | 5 | ## Run sender.py in a RPI connected with RAK811 using serial port -------------------------------------------------------------------------------- /LoRa_RangeTest/RAK811/receiver.py: -------------------------------------------------------------------------------- 1 | import serial 2 | import time 3 | import sys 4 | import datetime 5 | import paho.mqtt.client as mqtt 6 | 7 | PORT = '/dev/ttyUSB0' 8 | baud = 115200 9 | 10 | mqttc = mqtt.Client() 11 | mqttc.connect("iot.eclipse.org", 1883) 12 | mqttc.loop_start() 13 | 14 | def sendCommand(at_com): 15 | print(time.time(),"send:",at_com) 16 | lora_serial.flushInput() 17 | lora_serial.flushOutput() 18 | lora_serial.write(at_com + '\r\n') 19 | 20 | 21 | def getResponse(required_response="",timeout_in_seconds=10): 22 | lora_serial.flushInput() 23 | lora_serial.flushOutput() 24 | seconds_elapsed = 0 25 | while seconds_elapsed < timeout_in_seconds: 26 | response = lora_serial.readline().rstrip() # comment this line if echo off 27 | if (len(response)) > 0: 28 | print(time.time(),"recv:",response) 29 | if response == required_response: 30 | return True 31 | seconds_elapsed = seconds_elapsed+1 32 | return False 33 | 34 | 35 | def parseResponse(timeout_in_seconds=10): 36 | lora_serial.flushInput() 37 | lora_serial.flushOutput() 38 | seconds_elapsed = 0 39 | while seconds_elapsed < timeout_in_seconds: 40 | response = lora_serial.readline().rstrip() # comment this line if echo off 41 | if (len(response)) > 0: 42 | # print(time.time(),"recv:",response) 43 | data = response.split(",") 44 | if len(data) == 6: 45 | data = "{} Port: {}, RSSI: {}, SNR: {}, LEN: {}, DATA: {}".format(datetime.datetime.now(), data[1],data[2],data[3],data[4],data[5].decode("hex")) 46 | print(data) 47 | 48 | file = open("datalog.txt", "a") 49 | file.write(data+'\n') 50 | file.close() 51 | 52 | mqttc.publish("Elementz/rangetest/RAK811", data) 53 | seconds_elapsed = seconds_elapsed+1 54 | return False 55 | 56 | 57 | print("Trying with baudrate {}".format(baud)) 58 | 59 | lora_serial = serial.Serial() 60 | lora_serial.port = PORT 61 | lora_serial.baudrate = baud 62 | lora_serial.timeout = 1 63 | lora_serial.xonxoff = False 64 | lora_serial.rtscts = False 65 | lora_serial.bytesize = serial.EIGHTBITS 66 | lora_serial.parity = serial.PARITY_NONE 67 | lora_serial.stopbits = serial.STOPBITS_ONE 68 | 69 | try: 70 | lora_serial.open() 71 | lora_serial.flushInput() 72 | lora_serial.flushOutput() 73 | except: 74 | print ('Cannot open serial port') 75 | sys.exit() 76 | 77 | status = False 78 | while not status: 79 | status = False 80 | sendCommand("at+rx_stop") 81 | status = getResponse("OK",2) 82 | 83 | status = False 84 | while not status: 85 | status = False 86 | sendCommand("at+mode=1") 87 | status = getResponse("OK",2) 88 | 89 | status = False 90 | while not status: 91 | status = False 92 | sendCommand("at+rf_config=865700000,12,0,4,8,20") 93 | status = getResponse("OK",2) 94 | 95 | status = False 96 | while not status: 97 | status = False 98 | sendCommand("at+rxc=1") 99 | status = getResponse("OK",2) 100 | 101 | 102 | status = False 103 | while not status: 104 | status = parseResponse(120) 105 | -------------------------------------------------------------------------------- /LoRa_RangeTest/RAK811/sender.py: -------------------------------------------------------------------------------- 1 | import serial 2 | import time 3 | import sys 4 | 5 | PORT = '/dev/ttyUSB2' 6 | baud = 9600 7 | 8 | def sendCommand(at_com): 9 | print(time.time(),"send:",at_com) 10 | lora_serial.flushInput() 11 | lora_serial.flushOutput() 12 | lora_serial.write(at_com + '\r\n') 13 | 14 | 15 | def getResponse(required_response="",timeout_in_seconds=10): 16 | lora_serial.flushInput() 17 | lora_serial.flushOutput() 18 | seconds_elapsed = 0 19 | while seconds_elapsed < timeout_in_seconds: 20 | response = lora_serial.readline().rstrip() # comment this line if echo off 21 | if (len(response)) > 0: 22 | print(time.time(),"recv:",response) 23 | if response == required_response: 24 | return True 25 | seconds_elapsed = seconds_elapsed+1 26 | return False 27 | 28 | 29 | 30 | print("Trying with baudrate {}".format(baud)) 31 | 32 | lora_serial = serial.Serial() 33 | lora_serial.port = PORT 34 | lora_serial.baudrate = baud 35 | lora_serial.timeout = 1 36 | lora_serial.xonxoff = False 37 | lora_serial.rtscts = False 38 | lora_serial.bytesize = serial.EIGHTBITS 39 | lora_serial.parity = serial.PARITY_NONE 40 | lora_serial.stopbits = serial.STOPBITS_ONE 41 | 42 | try: 43 | lora_serial.open() 44 | lora_serial.flushInput() 45 | lora_serial.flushOutput() 46 | except: 47 | print ('Cannot open serial port') 48 | sys.exit() 49 | 50 | # sendCommand("at+uart=9600,8,0,1,0") 51 | # status = getResponse("OK",2) 52 | 53 | 54 | # try: 55 | # lora_serial.close() 56 | # except: 57 | # print ('Cannot close serial port') 58 | # sys.exit() 59 | 60 | # baud = 9600 61 | # lora_serial = serial.Serial() 62 | # lora_serial.port = PORT 63 | # lora_serial.baudrate = baud 64 | # lora_serial.timeout = 1 65 | # lora_serial.xonxoff = False 66 | # lora_serial.rtscts = False 67 | # lora_serial.bytesize = serial.EIGHTBITS 68 | # lora_serial.parity = serial.PARITY_NONE 69 | # lora_serial.stopbits = serial.STOPBITS_ONE 70 | 71 | # try: 72 | # lora_serial.open() 73 | # lora_serial.flushInput() 74 | # lora_serial.flushOutput() 75 | # except: 76 | # print ('Cannot open serial port') 77 | # sys.exit() 78 | 79 | status = False 80 | while not status: 81 | status = False 82 | sendCommand("at+tx_stop") 83 | status = getResponse("OK",2) 84 | 85 | status = False 86 | while not status: 87 | status = False 88 | sendCommand("at+mode=1") 89 | status = getResponse("OK",2) 90 | 91 | status = False 92 | while not status: 93 | status = False 94 | sendCommand("at+rf_config=865700000,12,0,1,8,20") 95 | status = getResponse("OK",2) 96 | 97 | # status = False 98 | # while not status: 99 | # status = False 100 | # sendCommand("at+txc=5,1000,800100000600010002da9557e142d9") 101 | # status = getResponse("OK",2) 102 | 103 | payload = 1 104 | pktCounter = 0 105 | while pktCounter < 100: 106 | payload_data = "%02X" % payload 107 | sendCommand("at+txc=1,1000,{}".format(str(payload).encode("hex"))) 108 | status = getResponse("at+recv=9,0,0",5) 109 | payload = payload + 1 110 | 111 | status = False 112 | while not status: 113 | status = False 114 | sendCommand("at+tx_stop") 115 | status = getResponse("OK",2) 116 | -------------------------------------------------------------------------------- /MAX7219_Matrix_Display/max7219_smiling.ino: -------------------------------------------------------------------------------- 1 | #include "LedControl.h" 2 | #include "binary.h" 3 | 4 | /* 5 | DIN connects to pin 8 6 | CLK connects to pin 10 7 | CS connects to pin 9 8 | STATE can be either 0 or 1 9 | */ 10 | LedControl lc=LedControl(8,10,9,1); 11 | 12 | // delay time between faces 13 | unsigned long delaytime=1000; 14 | 15 | // happy face 16 | byte hf[8]= {B00111100,B01000010,B10100101,B10000001,B10100101,B10011001,B01000010,B00111100}; 17 | // neutral face 18 | byte nf[8]={B00111100, B01000010,B10100101,B10000001,B10111101,B10000001,B01000010,B00111100}; 19 | // sad face 20 | byte sf[8]= {B00111100,B01000010,B10100101,B10000001,B10011001,B10100101,B01000010,B00111100}; 21 | 22 | void setup() { 23 | lc.shutdown(0,false); 24 | // Set brightness to a medium value 25 | lc.setIntensity(0,8); 26 | // Clear the display 27 | lc.clearDisplay(0); 28 | } 29 | 30 | void drawFaces(){ 31 | // Display sad face 32 | lc.setRow(0,0,sf[0]); 33 | lc.setRow(0,1,sf[1]); 34 | lc.setRow(0,2,sf[2]); 35 | lc.setRow(0,3,sf[3]); 36 | lc.setRow(0,4,sf[4]); 37 | lc.setRow(0,5,sf[5]); 38 | lc.setRow(0,6,sf[6]); 39 | lc.setRow(0,7,sf[7]); 40 | delay(delaytime); 41 | 42 | // Display neutral face 43 | lc.setRow(0,0,nf[0]); 44 | lc.setRow(0,1,nf[1]); 45 | lc.setRow(0,2,nf[2]); 46 | lc.setRow(0,3,nf[3]); 47 | lc.setRow(0,4,nf[4]); 48 | lc.setRow(0,5,nf[5]); 49 | lc.setRow(0,6,nf[6]); 50 | lc.setRow(0,7,nf[7]); 51 | delay(delaytime); 52 | 53 | // Display happy face 54 | lc.setRow(0,0,hf[0]); 55 | lc.setRow(0,1,hf[1]); 56 | lc.setRow(0,2,hf[2]); 57 | lc.setRow(0,3,hf[3]); 58 | lc.setRow(0,4,hf[4]); 59 | lc.setRow(0,5,hf[5]); 60 | lc.setRow(0,6,hf[6]); 61 | lc.setRow(0,7,hf[7]); 62 | delay(delaytime); 63 | } 64 | 65 | void loop(){ 66 | drawFaces(); 67 | } 68 | -------------------------------------------------------------------------------- /PIR_test/PIR_test.ino: -------------------------------------------------------------------------------- 1 | //Sample Code to check the working of PIR sensor 2 | /* 3 | Code revision -- 02,November,2014 4 | Author -- Jayasenen 5 | 6 | Website: http://www.elementzonline.com 7 | 8 | */ 9 | void setup() 10 | { 11 | pinMode(13,OUTPUT);//define pin 13 as output LED pin 12 | pinMode(10,INPUT);//define pin 10 as input pin 13 | Serial.begin(9600);// initialize serial communications: 14 | } 15 | bool PIRValue;// variable to read the PIR sensor value 16 | void loop() 17 | { 18 | PIRValue=digitalRead(10);// read value from pin no:10 19 | Serial.println(PIRValue);// print value from pin no:10 20 | if(PIRValue==1)//check the condition for LED blinking 21 | { 22 | digitalWrite(13,HIGH);//set pin 13 to HIGH for switch on LED 23 | delay(1000); 24 | digitalWrite(13,LOW);//set pin 13 to LOW for switch off LED 25 | delay(1000); 26 | digitalWrite(13,HIGH);//set pin 13 to HIGH for switch on LED 27 | delay(1000); 28 | digitalWrite(13,LOW);//set pin 13 to LOW for switch off LED 29 | } 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /RC522_code/RC522_code.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------------------------------------------------- 3 | * Example sketch/program showing how to read data from a PICC to serial. 4 | * -------------------------------------------------------------------------------------------------------------------- 5 | * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid 6 | * 7 | * Example sketch/program showing how to read data from a PICC (that is: a RFID Tag or Card) using a MFRC522 based RFID 8 | * Reader on the Arduino SPI interface. 9 | * 10 | * When the Arduino and the MFRC522 module are connected (see the pin layout below), load this sketch into Arduino IDE 11 | * then verify/compile and upload it. To see the output: use Tools, Serial Monitor of the IDE (hit Ctrl+Shft+M). When 12 | * you present a PICC (that is: a RFID Tag or Card) at reading distance of the MFRC522 Reader/PCD, the serial output 13 | * will show the ID/UID, type and any data blocks it can read. Note: you may see "Timeout in communication" messages 14 | * when removing the PICC from reading distance too early. 15 | * 16 | * If your reader supports it, this sketch/program will read all the PICCs presented (that is: multiple tag reading). 17 | * So if you stack two or more PICCs on top of each other and present them to the reader, it will first output all 18 | * details of the first and then the next PICC. Note that this may take some time as all data blocks are dumped, so 19 | * keep the PICCs at reading distance until complete. 20 | * 21 | * @license Released into the public domain. 22 | * 23 | * Typical pin layout used: 24 | * ----------------------------------------------------------------------------------------- 25 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 26 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 27 | * Signal Pin Pin Pin Pin Pin Pin 28 | * ----------------------------------------------------------------------------------------- 29 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 30 | * SPI SS SDA(SS) 10 53 D10 10 10 31 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 32 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 33 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 34 | */ 35 | 36 | #include 37 | #include 38 | 39 | #define RST_PIN 9 // Configurable, see typical pin layout above 40 | #define SS_PIN 10 // Configurable, see typical pin layout above 41 | 42 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance 43 | 44 | void setup() { 45 | Serial.begin(9600); // Initialize serial communications with the PC 46 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 47 | SPI.begin(); // Init SPI bus 48 | mfrc522.PCD_Init(); // Init MFRC522 49 | delay(4); // Optional delay. Some board do need more time after init to be ready, see Readme 50 | mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details 51 | Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks...")); 52 | } 53 | 54 | void loop() { 55 | // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle. 56 | if ( ! mfrc522.PICC_IsNewCardPresent()) { 57 | return; 58 | } 59 | 60 | // Select one of the cards 61 | if ( ! mfrc522.PICC_ReadCardSerial()) { 62 | return; 63 | } 64 | 65 | // Dump debug info about the card; PICC_HaltA() is automatically called 66 | mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); 67 | } 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Arduino-Sample-Codes 2 | ==================== 3 | 4 | Arduino Sample Codes for Elementz products 5 | 6 | ElementzOnline - Product Cart 7 | ===================== 8 | https://www.elementzonline.com/ 9 | 10 | Wiki page 11 | ==================== 12 | https://wiki.elementzonline.com/ 13 | -------------------------------------------------------------------------------- /RGB_Module/RGB_Module.ino: -------------------------------------------------------------------------------- 1 | int redpin = 11; // select the pin for the red LED 2 | int bluepin =10; // select the pin for the blue LED 3 | int greenpin =9; // select the pin for the green LED 4 | 5 | int val; 6 | 7 | void setup() { 8 | pinMode(redpin, OUTPUT); 9 | pinMode(bluepin, OUTPUT); 10 | pinMode(greenpin, OUTPUT); 11 | Serial.begin(9600); 12 | } 13 | 14 | void loop() { 15 | for(val = 255; val > 0; val--) 16 | { 17 | analogWrite(11, val); 18 | analogWrite(10, 255 - val); 19 | analogWrite(9, 128 - val); 20 | 21 | Serial.println(val, DEC); 22 | delay(5); 23 | } 24 | for(val = 0; val < 255; val++) 25 | { 26 | analogWrite(11, val); 27 | analogWrite(10, 255 - val); 28 | analogWrite(9, 128 - val); 29 | 30 | Serial.println(val, DEC); 31 | delay(5); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Relay_1_Channel/Relay_1_Channel.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Dhanish 3 | Created on: 19-08-2014 4 | Company: Elementz Engineers Guild Pvt Ltd 5 | */ 6 | 7 | // constants won't change. They're used here to 8 | // set pin numbers: 9 | const int buttonPin = 7; // the number of the pushbutton pin 10 | const int relay1 = 13; // the number of the relay1 pin 11 | 12 | // variables will change: 13 | int buttonState = 0; // variable for reading the pushbutton status 14 | 15 | void setup() { 16 | // initialize the relay pin as an output: 17 | pinMode(relay1, OUTPUT); 18 | // initialize the pushbutton pin as an input: 19 | pinMode(buttonPin, INPUT); 20 | } 21 | 22 | void loop(){ 23 | // read the state of the pushbutton value: 24 | buttonState = digitalRead(buttonPin); 25 | 26 | // check if the pushbutton is pressed. 27 | // if it is, the buttonState is HIGH: 28 | if (buttonState == HIGH) { 29 | // turn relays on: 30 | digitalWrite(relay1, HIGH); 31 | 32 | } 33 | else { 34 | // turn relays off: 35 | digitalWrite(relay1, LOW); 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Relay_2_Channel_optocoupled/Relay_2_Channel_optocoupled.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Created by: Dhanish Vijayan 4 | Company: Elementz Engineers Guild Pvt Ltd ( http://www.elementzonline.com ) 5 | 6 | This code demosntrate the interfacing and control of 2-Channel optocoupled relay board 7 | 8 | Las Modified Date: 17/07/2016 9 | 10 | */ 11 | 12 | 13 | int RelayControlPin1 = 2; 14 | int RelayControlPin2 = 3; 15 | 16 | 17 | void setup() { 18 | // put your setup code here, to run once: 19 | pinMode(RelayControlPin1, OUTPUT); 20 | pinMode(RelayControlPin2, OUTPUT); 21 | 22 | } 23 | 24 | void loop() { 25 | /* 26 | * Turn ON all relays 27 | * Note: The control logic should be LOW for the optocoupler relay to be turned on 28 | */ 29 | 30 | digitalWrite(RelayControlPin1, LOW); 31 | digitalWrite(RelayControlPin2, LOW); 32 | 33 | 34 | delay(10000); /* 10 seconds delay */ 35 | 36 | /* 37 | * Turn OFF all relays 38 | * Note: The control logic should be HIGH for the optocoupler relay to be turned off 39 | */ 40 | 41 | digitalWrite(RelayControlPin1, HIGH); 42 | digitalWrite(RelayControlPin2, HIGH); 43 | 44 | 45 | delay(10000); /* 10 seconds delay */ 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Relay_2_channel/Relay_2_channel.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Dhanish 3 | Created on: 19-08-2014 4 | Company: Elementz Engineers Guild Pvt Ltd 5 | */ 6 | 7 | // constants won't change. They're used here to 8 | // set pin numbers: 9 | const int buttonPin = 7; // the number of the pushbutton pin 10 | const int relay1 = 12; // the number of the relay1 pin 11 | const int relay2 = 13; 12 | 13 | // variables will change: 14 | int buttonState = 0; // variable for reading the pushbutton status 15 | 16 | void setup() { 17 | // initialize the relay1,2 pins as an output: 18 | pinMode(relay1, OUTPUT); 19 | pinMode(relay2, OUTPUT); 20 | // initialize the pushbutton pin as an input: 21 | pinMode(buttonPin, INPUT); 22 | } 23 | 24 | void loop(){ 25 | // read the state of the pushbutton value: 26 | buttonState = digitalRead(buttonPin); 27 | 28 | // check if the pushbutton is pressed. 29 | // if it is, the buttonState is HIGH: 30 | if (buttonState == HIGH) { 31 | // turn relays on: 32 | digitalWrite(relay1, HIGH); 33 | digitalWrite(relay2, HIGH); 34 | } 35 | else { 36 | // turn relays off: 37 | digitalWrite(relay1, LOW); 38 | digitalWrite(relay2, LOW); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Relay_4_Channel/Relay_4_Channel.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Dhanish 3 | Created on: 19-08-2014 4 | Company: Elementz Engineers Guild Pvt Ltd 5 | */ 6 | 7 | // constants won't change. They're used here to 8 | // set pin numbers: 9 | const int buttonPin = 7; // the number of the pushbutton pin 10 | const int relay1 = 2; // the number of the relay1 pin 11 | const int relay2 = 3; 12 | const int relay3 = 4; 13 | const int relay4 = 5; 14 | 15 | // variables will change: 16 | int buttonState = 0; // variable for reading the pushbutton status 17 | 18 | void setup() { 19 | // initialize the relay1,2,3,4 pins as an output: 20 | pinMode(relay1, OUTPUT); 21 | pinMode(relay2, OUTPUT); 22 | pinMode(relay3, OUTPUT); 23 | pinMode(relay4, OUTPUT); 24 | // initialize the pushbutton pin as an input: 25 | pinMode(buttonPin, INPUT); 26 | } 27 | 28 | void loop(){ 29 | // read the state of the pushbutton value: 30 | buttonState = digitalRead(buttonPin); 31 | 32 | // check if the pushbutton is pressed. 33 | // if it is, the buttonState is HIGH: 34 | if (buttonState == HIGH) { 35 | // turn relays on: 36 | digitalWrite(relay1, HIGH); 37 | digitalWrite(relay2, HIGH); 38 | digitalWrite(relay3, HIGH); 39 | digitalWrite(relay4, HIGH); 40 | } 41 | else { 42 | // turn relays off: 43 | digitalWrite(relay1, LOW); 44 | digitalWrite(relay2, LOW); 45 | digitalWrite(relay3, LOW); 46 | digitalWrite(relay4, LOW); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Relay_8_Channel/Relay_8_Channel.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Dhanish 3 | Created on: 19-08-2014 4 | Company: Elementz Engineers Guild Pvt Ltd 5 | */ 6 | 7 | // constants won't change. They're used here to 8 | // set pin numbers: 9 | const int buttonPin = 8; // the number of the pushbutton pin 10 | const int relay1 = 0; // the number of the relay1 pin 11 | const int relay2 = 1; 12 | const int relay3 = 2; 13 | const int relay4 = 3; 14 | const int relay5 = 4; 15 | const int relay6 = 5; 16 | const int relay7 = 6; 17 | const int relay8 = 7; 18 | 19 | // variables will change: 20 | int buttonState = 0; // variable for reading the pushbutton status 21 | 22 | void setup() { 23 | // initialize the relay1,2,3,4 pins as an output: 24 | pinMode(relay1, OUTPUT); 25 | pinMode(relay2, OUTPUT); 26 | pinMode(relay3, OUTPUT); 27 | pinMode(relay4, OUTPUT); 28 | pinMode(relay5, OUTPUT); 29 | pinMode(relay6, OUTPUT); 30 | pinMode(relay7, OUTPUT); 31 | pinMode(relay8, OUTPUT); 32 | // initialize the pushbutton pin as an input: 33 | pinMode(buttonPin, INPUT); 34 | } 35 | 36 | void loop(){ 37 | // read the state of the pushbutton value: 38 | buttonState = digitalRead(buttonPin); 39 | 40 | // check if the pushbutton is pressed. 41 | // if it is, the buttonState is HIGH: 42 | if (buttonState == HIGH) { 43 | // turn relays on: 44 | digitalWrite(relay1, HIGH); 45 | digitalWrite(relay2, HIGH); 46 | digitalWrite(relay3, HIGH); 47 | digitalWrite(relay4, HIGH); 48 | digitalWrite(relay5, HIGH); 49 | digitalWrite(relay6, HIGH); 50 | digitalWrite(relay7, HIGH); 51 | digitalWrite(relay8, HIGH); 52 | } 53 | else { 54 | // turn relays off: 55 | digitalWrite(relay1, LOW); 56 | digitalWrite(relay2, LOW); 57 | digitalWrite(relay3, LOW); 58 | digitalWrite(relay4, LOW); 59 | digitalWrite(relay5, LOW); 60 | digitalWrite(relay6, LOW); 61 | digitalWrite(relay7, LOW); 62 | digitalWrite(relay8, LOW); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Relay_8_Channel_optocoupled/Relay_8_Channel_optocoupled.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Created by: Dhanish Vijayan 4 | Company: Elementz Engineers Guild Pvt Ltd ( http://www.elementzonline.com ) 5 | 6 | This code demosntrate the interfacing and control of 8-Channel optocoupled relay board 7 | 8 | Product Link: http://elementzonline.com/8-channel-relay-board-with-optocoupler-254 9 | 10 | Las Modified Date: 17/07/2016 11 | 12 | */ 13 | 14 | 15 | int RelayControlPin1 = 2; 16 | int RelayControlPin2 = 3; 17 | int RelayControlPin3 = 4; 18 | int RelayControlPin4 = 5; 19 | int RelayControlPin5 = 6; 20 | int RelayControlPin6 = 7; 21 | int RelayControlPin7 = 8; 22 | int RelayControlPin8 = 9; 23 | 24 | void setup() { 25 | // put your setup code here, to run once: 26 | pinMode(RelayControlPin1, OUTPUT); 27 | pinMode(RelayControlPin2, OUTPUT); 28 | pinMode(RelayControlPin3, OUTPUT); 29 | pinMode(RelayControlPin4, OUTPUT); 30 | pinMode(RelayControlPin5, OUTPUT); 31 | pinMode(RelayControlPin6, OUTPUT); 32 | pinMode(RelayControlPin7, OUTPUT); 33 | pinMode(RelayControlPin8, OUTPUT); 34 | } 35 | 36 | void loop() { 37 | /* 38 | * Turn ON all relays 39 | * Note: The control logic should be LOW for the optocoupler relay to be turned on 40 | */ 41 | 42 | digitalWrite(RelayControlPin1, LOW); 43 | digitalWrite(RelayControlPin2, LOW); 44 | digitalWrite(RelayControlPin3, LOW); 45 | digitalWrite(RelayControlPin4, LOW); 46 | digitalWrite(RelayControlPin5, LOW); 47 | digitalWrite(RelayControlPin6, LOW); 48 | digitalWrite(RelayControlPin7, LOW); 49 | digitalWrite(RelayControlPin8, LOW); 50 | 51 | delay(10000); /* 10 seconds delay */ 52 | 53 | /* 54 | * Turn OFF all relays 55 | * Note: The control logic should be HIGH for the optocoupler relay to be turned off 56 | */ 57 | 58 | digitalWrite(RelayControlPin1, HIGH); 59 | digitalWrite(RelayControlPin2, HIGH); 60 | digitalWrite(RelayControlPin3, HIGH); 61 | digitalWrite(RelayControlPin4, HIGH); 62 | digitalWrite(RelayControlPin5, HIGH); 63 | digitalWrite(RelayControlPin6, HIGH); 64 | digitalWrite(RelayControlPin7, HIGH); 65 | digitalWrite(RelayControlPin8, HIGH); 66 | 67 | delay(10000); /* 10 seconds delay */ 68 | 69 | } 70 | -------------------------------------------------------------------------------- /SIM7600/Assisted_GPS_SIM7600/Assisted_GPS_SIM7600.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L. 3 | * http://www.libelium.com 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Version 0.1 19 | * Author: Alejandro Gállego 20 | */ 21 | 22 | #include 23 | 24 | int led = 13; 25 | int onModulePin = 2; // the pin to switch on the module (without press on button) 26 | char data[255]; 27 | char latitude[11], longitude[12]; 28 | char date[6], UTC_time[8]; 29 | char speed_OG[6], altitude[6]; 30 | char response[128]; 31 | 32 | int x, y; 33 | void switchModule() 34 | { 35 | digitalWrite(onModulePin, HIGH); 36 | delay(2000); 37 | digitalWrite(onModulePin, LOW); 38 | } 39 | 40 | void setup() 41 | { 42 | Serial.begin(115200); // UART baud rate 43 | delay(2000); 44 | pinMode(led, OUTPUT); 45 | pinMode(onModulePin, OUTPUT); 46 | switchModule(); // switches the module ON 47 | for (int i = 0; i < 5; i++) 48 | { 49 | delay(5000); 50 | } 51 | Serial.println("AT+CGSOCKCONT=1,\"IP\",\"myapn\""); 52 | Serial.flush(); 53 | x = 0; 54 | do 55 | { 56 | while (Serial.available() == 0) 57 | ; 58 | response[x] = Serial.read(); 59 | x++; 60 | } while (!check_response("OK")); 61 | Serial.println("AT+CGPSURL=\"supl.google.com:7276\""); // sets GPS server 62 | delay(100); 63 | while (Serial.read() != 'K') 64 | ; 65 | Serial.println("AT+CGPSSSL=0"); // without certificate 66 | delay(100); 67 | while (Serial.read() != 'K') 68 | ; 69 | Serial.println("AT+CGPS=1,2"); // starts GPS session in based mode 70 | delay(100); 71 | while (Serial.read() != 'K') 72 | ; 73 | } 74 | void loop() 75 | { 76 | delay(5000); 77 | Serial.println("AT+CGPSINFO"); // request GPS info 78 | Serial.flush(); 79 | for (x = 0; x < 255; x++) 80 | { 81 | data[x] = '\0'; 82 | } 83 | x = 0; 84 | do 85 | { 86 | do 87 | { 88 | digitalWrite(led, HIGH); 89 | } while (Serial.available() == 0); 90 | 91 | digitalWrite(led, LOW); 92 | data[x] = Serial.read(); 93 | x++; 94 | } while (Serial.read() != 'K'); 95 | x = 24; 96 | y = 0; 97 | if (data[x] != ',') 98 | { 99 | Serial.print("Latitude: "); //shows actual latitude 100 | do 101 | { 102 | latitude[y] = data[x]; 103 | Serial.print(data[x]); 104 | y++; 105 | x++; 106 | if (y == 2) 107 | { 108 | Serial.print(0xF8); 109 | } 110 | if (y == 4) 111 | { 112 | Serial.print("."); 113 | } 114 | } while (data[x] != ','); 115 | x++; 116 | Serial.print(" "); 117 | Serial.println(data[x]); //north or south 118 | x += 2; 119 | y = 0; 120 | Serial.print("Longitude: "); //shows actual longitude 121 | do 122 | { 123 | longitude[y] = data[x]; 124 | Serial.print(data[x]); 125 | y++; 126 | x++; 127 | if (y == 3) 128 | { 129 | Serial.print(0xF8); 130 | } 131 | if (y == 5) 132 | { 133 | Serial.print("."); 134 | } 135 | } while (data[x] != ','); 136 | x++; 137 | Serial.print(" "); 138 | Serial.println(data[x]); //west or east 139 | x += 2; 140 | y = 0; 141 | Serial.print("Date: "); //shows date 142 | do 143 | { 144 | date[y] = data[x]; 145 | Serial.print(data[x]); 146 | y++; 147 | x++; 148 | } while (data[x] != ','); 149 | x++; 150 | 151 | y = 0; 152 | Serial.print("\r\nUTC time: "); //shows UTC time 153 | do 154 | { 155 | UTC_time[y] = data[x]; 156 | Serial.print(data[x]); 157 | y++; 158 | x++; 159 | } while (data[x] != ','); 160 | x++; 161 | y = 0; 162 | Serial.print("\r\nAltitude: "); //shows altitude 163 | do 164 | { 165 | UTC_time[y] = data[x]; 166 | Serial.print(data[x]); 167 | y++; 168 | x++; 169 | } while (data[x] != ','); 170 | Serial.println(" m"); 171 | x++; 172 | y = 0; 173 | Serial.print("Speed: "); //shows speed 174 | do 175 | { 176 | speed_OG[y] = data[x]; 177 | Serial.print(data[x]); 178 | y++; 179 | x++; 180 | } while (data[x] != 0x0D); 181 | Serial.println(" knots"); 182 | } 183 | else 184 | { 185 | Serial.println("GPS information not available, please wait..."); 186 | } 187 | } 188 | 189 | boolean check_response(char *str) 190 | { 191 | 192 | int i = 0; 193 | int j = 0; 194 | char b[10]; 195 | // reading the message and cutting 196 | // initials and finals 197 | while (Serial.available() > 0) 198 | { 199 | if (j == 0 || j == 1) 200 | { 201 | Serial.read(); 202 | j++; 203 | } 204 | else if (Serial.peek() == 13) 205 | { 206 | b[i] = 0; 207 | Serial.read(); 208 | } 209 | else if (Serial.peek() == 10) 210 | { 211 | Serial.read(); 212 | } 213 | else 214 | { 215 | b[i++] = Serial.read(); 216 | } 217 | } 218 | // comparing 219 | int cont = 0; 220 | int cont2 = 0; 221 | boolean ok = false; 222 | while (b[cont] != -1) 223 | { 224 | if (b[cont] == str[cont2]) 225 | { 226 | while (str[cont2] != -1) 227 | { 228 | if (b[cont + cont2] != b[cont2]) 229 | { 230 | cont2++; 231 | ok = true; 232 | } 233 | else 234 | { 235 | ok = false; 236 | break; 237 | } 238 | } 239 | } 240 | if (ok) 241 | break; 242 | cont++; 243 | } 244 | 245 | if (ok) 246 | { 247 | return true; 248 | } 249 | 250 | return false; 251 | } -------------------------------------------------------------------------------- /SIM7600/Sim7600_MQTT/Sim7600_MQTT.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Developed by Nandu, Anandu, Unnikrishnan 3 | Company: Elementz Engineers Guild Pvt Ltd 4 | */ 5 | #include 6 | SoftwareSerial mySerial(3,2); 7 | #define sw 5 8 | #define led 7 9 | int flag = 1; 10 | int flag1 = 0; 11 | int state=0; 12 | String Publish = "led/publish"; //Publish Topic 13 | String Subscribe = "led/subscribe"; //Subscribe Topic 14 | 15 | void setup() 16 | { 17 | Serial.begin(9600); 18 | mySerial.begin(9600); 19 | pinMode(sw, INPUT_PULLUP); 20 | pinMode(led, OUTPUT); 21 | digitalWrite(led, LOW); 22 | 23 | //AT Commands for setting up the client id and Server 24 | //Need to be executed once -- Open serial terminal doe seeing the debug messages 25 | Serial.println("Connecting To Server........"); 26 | mySerial.println("ATE0"); 27 | delay(2000); 28 | mySerial.println("AT+CMQTTSTART"); //Establishing MQTT Connection 29 | delay(2000); 30 | mySerial.println("AT+CMQTTACCQ=0,\"elementz/123\""); //Client ID - change this for each client as this need to be unique 31 | delay(2000); 32 | mySerial.println("AT+CMQTTCONNECT=0,\"tcp://test.mosquitto.org:1883\",90,1"); //MQTT Server Name for connecting this client 33 | delay(2000); 34 | 35 | //SUBSCRIBE MESSAGE 36 | //Need to be executed once 37 | mySerial.println("AT+CMQTTSUBTOPIC=0,9,1"); //AT Command for Setting up the Subscribe Topic Name 38 | delay(2000); 39 | mySerial.println(Subscribe); //Topic Name 40 | delay(2000); 41 | mySerial.println("AT+CMQTTSUB=0,4,1,1"); //Length of message 42 | delay(2000); 43 | mySerial.println("HAII"); //message 44 | delay(2000); 45 | Serial.println("Done"); 46 | } 47 | 48 | void loop() 49 | { 50 | String a; 51 | if(state==0) 52 | { 53 | 54 | if(digitalRead(sw) == 0 && flag1 == 0) 55 | { 56 | //PUBLISH MESSAGE 57 | flag1 = 1; 58 | digitalWrite(led, HIGH); 59 | Serial.println("Publishing Message: LED ON"); 60 | mySerial.println("AT+CMQTTTOPIC=0,8"); //AT Command for Setting up the Publish Topic Name 61 | delay(1000); 62 | mySerial.println(Publish); //Topic Name 63 | delay(1000); 64 | mySerial.println("AT+CMQTTPAYLOAD=0,1"); //Payload length 65 | delay(1000); 66 | mySerial.println("a"); //Payload message 67 | delay(1000); 68 | mySerial.println("AT+CMQTTPUB=0,1,60"); //Acknowledgment 69 | delay(1000); 70 | } 71 | else if(digitalRead(sw) == 0 && flag1 == 1) 72 | { 73 | flag1 = 0; 74 | digitalWrite(led, LOW); 75 | Serial.println("Publishing Message: LED OFF"); 76 | mySerial.println("AT+CMQTTTOPIC=0,8"); //AT Command for Setting up the Publish Topic Name 77 | delay(1000); 78 | mySerial.println(Publish); //Topic Name 79 | delay(1000); 80 | mySerial.println("AT+CMQTTPAYLOAD=0,1"); //Payload length 81 | delay(1000); 82 | mySerial.println("b"); //Payload message 83 | delay(1000); 84 | mySerial.println("AT+CMQTTPUB=0,1,60"); //Acknowledgment 85 | delay(1000); 86 | } 87 | } 88 | if(state==1) 89 | { 90 | if(digitalRead(sw) == 0 && flag1 == 0) 91 | { 92 | //PUBLISH MESSAGE 93 | flag1 = 1; 94 | digitalWrite(led, LOW); 95 | Serial.println("Publishing Message: LED OFF"); 96 | mySerial.println("AT+CMQTTTOPIC=0,8"); //AT Command for Setting up the Publish Topic Name 97 | delay(1000); 98 | mySerial.println(Publish); //Topic Name 99 | delay(1000); 100 | mySerial.println("AT+CMQTTPAYLOAD=0,1"); //Payload length 101 | delay(1000); 102 | mySerial.println("b"); //Payload message 103 | delay(1000); 104 | mySerial.println("AT+CMQTTPUB=0,1,60"); //Acknowledgment 105 | delay(1000); 106 | } 107 | else if(digitalRead(sw) == 0 && flag1 == 1) 108 | { 109 | flag1 = 0; 110 | digitalWrite(led,HIGH); 111 | Serial.println("Publishing Message: LED ON"); 112 | mySerial.println("AT+CMQTTTOPIC=0,8"); //AT Command for Setting up the Publish Topic Name 113 | delay(1000); 114 | mySerial.println(Publish); //Topic Name 115 | delay(1000); 116 | mySerial.println("AT+CMQTTPAYLOAD=0,1"); //Payload length 117 | delay(1000); 118 | mySerial.println("a"); //Payload message 119 | delay(1000); 120 | mySerial.println("AT+CMQTTPUB=0,1,60"); //Acknowledgment 121 | delay(1000); 122 | } 123 | } 124 | 125 | //Receiving MODEM Response 126 | while(mySerial.available()>0) 127 | { 128 | delay(10); 129 | a = mySerial.readString(); 130 | if(flag==0) 131 | { 132 | //Serial.println(a); 133 | flag = 1; 134 | } 135 | //Serial.println(b); 136 | if(a.indexOf("PAYLOAD") != -1) 137 | { 138 | flag = 0; 139 | int new1 = a.indexOf("PAYLOAD"); 140 | String neww = a.substring(new1); 141 | int new2 = neww.indexOf('\n'); 142 | String new3 = neww.substring(new2+1); 143 | int new4 = new3.indexOf('\n'); 144 | String new5 = new3.substring(0,new4); 145 | 146 | Serial.println("Topic: led/subscribe"); 147 | Serial.print("Message is: "); 148 | Serial.println(new5); 149 | new5.remove(new5.length()-1); 150 | if(new5 == "a") 151 | { 152 | state=1; 153 | Serial.println("LED ON"); 154 | digitalWrite(led, HIGH); 155 | } 156 | else if(new5 == "b") 157 | { 158 | state=0; 159 | flag1=0; 160 | Serial.println("LED OFF"); 161 | digitalWrite(led, LOW); 162 | } 163 | } 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /SPFD5408_rotationtest/spfd5408_rotationtest/spfd5408_rotationtest.ino: -------------------------------------------------------------------------------- 1 | // IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY 2 | // CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD. 3 | // SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP. 4 | 5 | // Modified for SPFD5408 Library by Joao Lopes 6 | // and touch instead serial !!!! 7 | // Too much modifications, so not: begins e ends 8 | // Version 0.9.2 - Rotation for Mega and screen initial 9 | 10 | // Requires https://github.com/JoaoLopesF/SPFD5408 11 | 12 | #include // Core graphics library 13 | #include // Hardware-specific library 14 | #include // Touch library 15 | 16 | // The control pins for the LCD can be assigned to any digital or 17 | // analog pins...but we'll use the analog pins as this allows us to 18 | // double up the pins with the touch screen (see the TFT paint example). 19 | #define LCD_CS A3 // Chip Select goes to Analog 3 20 | #define LCD_CD A2 // Command/Data goes to Analog 2 21 | #define LCD_WR A1 // LCD Write goes to Analog 1 22 | #define LCD_RD A0 // LCD Read goes to Analog 0 23 | 24 | #define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin 25 | 26 | // When using the BREAKOUT BOARD only, use these 8 data lines to the LCD: 27 | // For the Arduino Uno, Duemilanove, Diecimila, etc.: 28 | // D0 connects to digital pin 8 (Notice these are 29 | // D1 connects to digital pin 9 NOT in order!) 30 | // D2 connects to digital pin 2 31 | // D3 connects to digital pin 3 32 | // D4 connects to digital pin 4 33 | // D5 connects to digital pin 5 34 | // D6 connects to digital pin 6 35 | // D7 connects to digital pin 7 36 | // For the Arduino Mega, use digital pins 22 through 29 37 | // (on the 2-row header at the end of the board). 38 | 39 | // Assign human-readable names to some common 16-bit color values: 40 | #define BLACK 0x0000 41 | #define BLUE 0x001F 42 | #define RED 0xF800 43 | #define GREEN 0x07E0 44 | #define CYAN 0x07FF 45 | #define MAGENTA 0xF81F 46 | #define YELLOW 0xFFE0 47 | #define WHITE 0xFFFF 48 | 49 | Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); 50 | // If using the shield, all control and data lines are fixed, and 51 | // a simpler declaration can optionally be used: 52 | // Adafruit_TFTLCD tft; 53 | 54 | // Calibrates value 55 | 56 | #define SENSIBILITY 300 57 | #define MINPRESSURE 10 58 | #define MAXPRESSURE 1000 59 | 60 | //These are the pins for the shield! 61 | #define YP A1 62 | #define XM A2 63 | #define YM 7 64 | #define XP 6 65 | 66 | // Calibrate values 67 | 68 | #define TS_MINX 125 69 | #define TS_MINY 85 70 | #define TS_MAXX 965 71 | #define TS_MAXY 905 72 | 73 | // Init TouchScreen: 74 | 75 | TouchScreen ts = TouchScreen(XP, YP, XM, YM, SENSIBILITY); 76 | 77 | void setup(void) { 78 | 79 | tft.reset(); 80 | tft.begin(0x9341); // SDFP5408 81 | 82 | tft.setRotation(0); // Need for the Mega, please changed for your choice or rotation initial 83 | 84 | // Border 85 | 86 | drawBorder(); 87 | 88 | // Initial screen 89 | 90 | tft.setCursor (55, 50); 91 | tft.setTextSize (3); 92 | tft.setTextColor(RED); 93 | tft.println("SPFD5408"); 94 | tft.setCursor (65, 85); 95 | tft.println("Library"); 96 | tft.setCursor (25, 150); 97 | tft.setTextSize (2); 98 | tft.setTextColor(BLACK); 99 | tft.println("Test of rotation"); 100 | 101 | // Wait touch 102 | 103 | waitOneTouch(true); 104 | 105 | // Draw border 106 | 107 | drawBorder(); 108 | 109 | tft.setTextSize (1); 110 | tft.setTextColor(BLACK); 111 | tft.setCursor (20, 80); 112 | tft.println("This is a test of the rotation"); 113 | tft.setCursor (20, 100); 114 | tft.println("capabilities of the TFT library!"); 115 | tft.setCursor (20, 160); 116 | tft.println("Touch to advance each test"); 117 | 118 | // Wait touch 119 | 120 | waitOneTouch(true); 121 | 122 | } 123 | 124 | void loop(void) { 125 | 126 | // Tests 127 | 128 | //rotatePixel(); 129 | rotateLine(); 130 | rotateFastline(); 131 | rotateDrawrect(); 132 | rotateFillrect(); 133 | rotateDrawcircle(); 134 | rotateFillcircle(); 135 | rotateText(); 136 | 137 | // Complete 138 | 139 | drawBorder(); 140 | 141 | tft.setCursor (35, 50); 142 | tft.setTextSize (3); 143 | tft.setTextColor(RED); 144 | tft.println("Completed"); 145 | 146 | waitOneTouch(true); 147 | 148 | } 149 | 150 | void rotateText() { 151 | for (uint8_t i=0; i<4; i++) { 152 | tft.fillScreen(WHITE); 153 | 154 | tft.setCursor(0, 30); 155 | tft.setTextColor(RED); 156 | tft.setTextSize(1); 157 | tft.println("Hello World!"); 158 | tft.setTextColor(YELLOW); 159 | tft.setTextSize(2); 160 | tft.println("Hello World!"); 161 | tft.setTextColor(GREEN); 162 | tft.setTextSize(3); 163 | tft.println("Hello World!"); 164 | tft.setTextColor(BLUE); 165 | tft.setTextSize(4); 166 | tft.print(1234.567); 167 | 168 | waitOneTouch(true); // Wait touch 169 | 170 | tft.setRotation(tft.getRotation()+1); 171 | } 172 | } 173 | 174 | void rotateFillcircle(void) { 175 | for (uint8_t i=0; i<4; i++) { 176 | tft.fillScreen(WHITE); 177 | 178 | tft.fillCircle(10, 30, 10, YELLOW); 179 | 180 | tft.setRotation(tft.getRotation()+1); 181 | 182 | waitOneTouch(true); // Wait touch 183 | 184 | } 185 | } 186 | 187 | void rotateDrawcircle(void) { 188 | for (uint8_t i=0; i<4; i++) { 189 | tft.fillScreen(WHITE); 190 | 191 | tft.drawCircle(10, 30, 10, YELLOW); 192 | 193 | waitOneTouch(true); // Wait touch 194 | 195 | tft.setRotation(tft.getRotation()+1); 196 | } 197 | } 198 | 199 | void rotateFillrect(void) { 200 | for (uint8_t i=0; i<4; i++) { 201 | tft.fillScreen(WHITE); 202 | 203 | tft.fillRect(10, 20, 10, 20, GREEN); 204 | 205 | waitOneTouch(true); // Wait touch 206 | 207 | tft.setRotation(tft.getRotation()+1); 208 | } 209 | } 210 | 211 | void rotateDrawrect(void) { 212 | for (uint8_t i=0; i<4; i++) { 213 | tft.fillScreen(WHITE); 214 | 215 | tft.drawRect(10, 20, 10, 20, GREEN); 216 | 217 | waitOneTouch(true); // Wait touch 218 | 219 | tft.setRotation(tft.getRotation()+1); 220 | } 221 | } 222 | 223 | void rotateFastline(void) { 224 | for (uint8_t i=0; i<4; i++) { 225 | tft.fillScreen(WHITE); 226 | tft.drawFastHLine(0, 20, tft.width(), RED); 227 | tft.drawFastVLine(20, 0, tft.height(), BLUE); 228 | 229 | waitOneTouch(true); // Wait touch 230 | 231 | tft.setRotation(tft.getRotation()+1); 232 | } 233 | } 234 | 235 | void rotateLine(void) { 236 | for (uint8_t i=0; i<4; i++) { 237 | tft.fillScreen(WHITE); 238 | 239 | tft.drawLine(tft.width()/2, tft.height()/2, 0, 0, RED); 240 | 241 | waitOneTouch(true); // Wait touch 242 | 243 | tft.setRotation(tft.getRotation()+1); 244 | } 245 | } 246 | 247 | void rotatePixel(void) { 248 | for (uint8_t i=0; i<4; i++) { 249 | tft.fillScreen(WHITE); 250 | 251 | tft.drawPixel(10,20, RED); 252 | 253 | waitOneTouch(true); // Wait touch 254 | 255 | tft.setRotation(tft.getRotation()+1); 256 | } 257 | } 258 | 259 | TSPoint waitOneTouch(boolean showMessage) { 260 | 261 | // wait 1 touch to exit function 262 | 263 | uint8_t save = 0; 264 | 265 | if (showMessage) { 266 | 267 | save = tft.getRotation(); // Save it 268 | tft.setRotation(0); // Show in normal 269 | 270 | tft.setCursor (80, 250); 271 | tft.setTextSize (1); 272 | tft.setTextColor(BLACK); 273 | tft.println("Touch to proceed"); 274 | 275 | } 276 | 277 | // Wait a touch 278 | 279 | TSPoint p; 280 | 281 | do { 282 | p= ts.getPoint(); 283 | 284 | pinMode(XM, OUTPUT); //Pins configures again for TFT control 285 | pinMode(YP, OUTPUT); 286 | 287 | } while((p.z < MINPRESSURE )|| (p.z > MAXPRESSURE)); 288 | 289 | if (showMessage) { 290 | tft.setRotation(save); 291 | } 292 | 293 | return p; 294 | } 295 | 296 | void drawBorder () { 297 | 298 | // Draw a border 299 | 300 | uint16_t width = tft.width() - 1; 301 | uint16_t height = tft.height() - 1; 302 | uint8_t border = 10; 303 | 304 | tft.fillScreen(RED); 305 | tft.fillRect(border, border, (width - border * 2), (height - border * 2), WHITE); 306 | 307 | } 308 | 309 | -------------------------------------------------------------------------------- /SSD1306_SPI_Arduino/SSD1306_SPI_Arduino.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Developed By Dhanish Vijayan @ Elementz Engineers Guild Pvt Ltd 3 | * 4 | * Demo for SSD1306 based 128x64 OLED module using Adafruit SSD1306 and SPI 5 | * library (https://github.com/adafruit/Adafruit_SSD1306). 6 | * 7 | * See https://github.com/pacodelgado/arduino/wiki/SSD1306-based-OLED-connected-to-Arduino 8 | * for more information. 9 | * 10 | * Pin Alternate Names Description Arduino PINOUT 11 | * VCC Power supply VCC(5V) 12 | * GND Ground GND 13 | * D0 SCL,CLK,SCK Clock 11 14 | * D1 SDA,MOSI Data 12 15 | * RES RST,RESET Rest 9 16 | * DC A0 Data/Command 8 17 | * CS Chip Select 10 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | // If using software SPI (the default case): 26 | #define OLED_MOSI 11 //D1 27 | #define OLED_CLK 12 //D0 28 | #define OLED_DC 9 29 | #define OLED_CS 8 30 | #define OLED_RESET 10 31 | 32 | Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); 33 | 34 | void setup() { 35 | // Serial.begin(9600); 36 | display.begin(SSD1306_SWITCHCAPVCC); 37 | display.display(); 38 | delay(1000); 39 | display.clearDisplay(); 40 | display.setTextSize(1); 41 | display.setTextColor(WHITE); 42 | } 43 | 44 | void loop() 45 | { 46 | static unsigned long thisMicros = 0; 47 | static unsigned long lastMicros = 0; 48 | display.clearDisplay(); 49 | display.setCursor(0,0); 50 | display.print("Elementz Engineers Guild Pvt Ltd \n"); 51 | display.print("Kudos!! It works... \n"); 52 | display.print(thisMicros - lastMicros); 53 | display.print(" microseconds"); 54 | display.display(); 55 | lastMicros = thisMicros; 56 | thisMicros = micros(); 57 | } 58 | -------------------------------------------------------------------------------- /TFT_TouchDisplay/ShowBMP/ShowBMP.ino: -------------------------------------------------------------------------------- 1 | // IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY 2 | // CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD. 3 | // SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP. 4 | //Technical support:goodtft@163.com 5 | 6 | #include // Core graphics library 7 | #include // Hardware-specific library 8 | #include 9 | #include 10 | 11 | 12 | // The control pins for the LCD can be assigned to any digital or 13 | // analog pins...but we'll use the analog pins as this allows us to 14 | // double up the pins with the touch screen (see the TFT paint example). 15 | #define LCD_CS A3 // Chip Select goes to Analog 3 16 | #define LCD_CD A2 // Command/Data goes to Analog 2 17 | #define LCD_WR A1 // LCD Write goes to Analog 1 18 | #define LCD_RD A0 // LCD Read goes to Analog 0 19 | #define PIN_SD_CS 10 // Adafruit SD shields and modules: pin 10 20 | 21 | #define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin 22 | 23 | // When using the BREAKOUT BOARD only, use these 8 data lines to the LCD: 24 | // For the Arduino Uno, Duemilanove, Diecimila, etc.: 25 | // D0 connects to digital pin 8 (Notice these are 26 | // D1 connects to digital pin 9 NOT in order!) 27 | // D2 connects to digital pin 2 28 | // D3 connects to digital pin 3 29 | // D4 connects to digital pin 4 30 | // D5 connects to digital pin 5 31 | // D6 connects to digital pin 6 32 | // D7 connects to digital pin 7 33 | // For the Arduino Mega, use digital pins 22 through 29 34 | // (on the 2-row header at the end of the board). 35 | 36 | // Assign human-readable names to some common 16-bit color values: 37 | #define BLACK 0x0000 38 | #define BLUE 0x001F 39 | #define RED 0xF800 40 | #define GREEN 0x07E0 41 | #define CYAN 0x07FF 42 | #define MAGENTA 0xF81F 43 | #define YELLOW 0xFFE0 44 | #define WHITE 0xFFFF 45 | 46 | Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); 47 | // If using the shield, all control and data lines are fixed, and 48 | // a simpler declaration can optionally be used: 49 | // Adafruit_TFTLCD tft; 50 | 51 | 52 | #define MAX_BMP 10 // bmp file num 53 | #define FILENAME_LEN 20 // max file name length 54 | 55 | const int __Gnbmp_height = 320; // bmp hight 56 | const int __Gnbmp_width = 240; // bmp width 57 | 58 | unsigned char __Gnbmp_image_offset = 0; // offset 59 | 60 | int __Gnfile_num = 4; // num of file 61 | 62 | char __Gsbmp_files[4][FILENAME_LEN] = // add file name here 63 | { 64 | "flower.bmp", 65 | "tiger.bmp", 66 | "tree.bmp", 67 | "RedRose.bmp", 68 | }; 69 | File bmpFile; 70 | 71 | /*********************************************/ 72 | // This procedure reads a bitmap and draws it to the screen 73 | // its sped up by reading many pixels worth of data at a time 74 | // instead of just one pixel at a time. increading the buffer takes 75 | // more RAM but makes the drawing a little faster. 20 pixels' worth 76 | // is probably a good place 77 | 78 | #define BUFFPIXEL 60 // must be a divisor of 240 79 | #define BUFFPIXEL_X3 180 // BUFFPIXELx3 80 | 81 | void bmpdraw(File f, int x, int y) 82 | { 83 | bmpFile.seek(__Gnbmp_image_offset); 84 | 85 | uint32_t time = millis(); 86 | 87 | uint8_t sdbuffer[BUFFPIXEL_X3]; // 3 * pixels to buffer 88 | 89 | for (int i=0; i< __Gnbmp_height; i++) { 90 | for(int j=0; j<(240/BUFFPIXEL); j++) { 91 | bmpFile.read(sdbuffer, BUFFPIXEL_X3); 92 | 93 | uint8_t buffidx = 0; 94 | int offset_x = j*BUFFPIXEL; 95 | unsigned int __color[BUFFPIXEL]; 96 | 97 | for(int k=0; k>3; // read 99 | __color[k] = __color[k]<<6 | (sdbuffer[buffidx+1]>>2); // green 100 | __color[k] = __color[k]<<5 | (sdbuffer[buffidx+0]>>3); // blue 101 | 102 | buffidx += 3; 103 | } 104 | 105 | for (int m = 0; m < BUFFPIXEL; m ++) { 106 | tft.drawPixel(m+offset_x, i,__color[m]); 107 | } 108 | } 109 | } 110 | 111 | Serial.print(millis() - time, DEC); 112 | Serial.println(" ms"); 113 | } 114 | 115 | boolean bmpReadHeader(File f) 116 | { 117 | // read header 118 | uint32_t tmp; 119 | uint8_t bmpDepth; 120 | 121 | if (read16(f) != 0x4D42) { 122 | // magic bytes missing 123 | return false; 124 | } 125 | 126 | // read file size 127 | tmp = read32(f); 128 | Serial.print("size 0x"); 129 | Serial.println(tmp, HEX); 130 | 131 | // read and ignore creator bytes 132 | read32(f); 133 | 134 | __Gnbmp_image_offset = read32(f); 135 | Serial.print("offset "); 136 | Serial.println(__Gnbmp_image_offset, DEC); 137 | 138 | // read DIB header 139 | tmp = read32(f); 140 | Serial.print("header size "); 141 | Serial.println(tmp, DEC); 142 | 143 | int bmp_width = read32(f); 144 | int bmp_height = read32(f); 145 | 146 | if(bmp_width != __Gnbmp_width || bmp_height != __Gnbmp_height) { // if image is not 320x240, return false 147 | return false; 148 | } 149 | 150 | if (read16(f) != 1) 151 | return false; 152 | 153 | bmpDepth = read16(f); 154 | Serial.print("bitdepth "); 155 | Serial.println(bmpDepth, DEC); 156 | 157 | if (read32(f) != 0) { 158 | // compression not supported! 159 | return false; 160 | } 161 | 162 | Serial.print("compression "); 163 | Serial.println(tmp, DEC); 164 | 165 | return true; 166 | } 167 | 168 | /*********************************************/ 169 | // These read data from the SD card file and convert them to big endian 170 | // (the data is stored in little endian format!) 171 | 172 | // LITTLE ENDIAN! 173 | uint16_t read16(File f) 174 | { 175 | uint16_t d; 176 | uint8_t b; 177 | b = f.read(); 178 | d = f.read(); 179 | d <<= 8; 180 | d |= b; 181 | return d; 182 | } 183 | 184 | // LITTLE ENDIAN! 185 | uint32_t read32(File f) 186 | { 187 | uint32_t d; 188 | uint16_t b; 189 | 190 | b = read16(f); 191 | d = read16(f); 192 | d <<= 16; 193 | d |= b; 194 | return d; 195 | } 196 | 197 | void setup(void) { 198 | Serial.begin(9600); 199 | Serial.println(F("TFT LCD test")); 200 | 201 | #ifdef USE_ADAFRUIT_SHIELD_PINOUT 202 | Serial.println(F("Using Adafruit 2.4\" TFT Arduino Shield Pinout")); 203 | #else 204 | Serial.println(F("Using Adafruit 2.4\" TFT Breakout Board Pinout")); 205 | #endif 206 | 207 | Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height()); 208 | 209 | tft.reset(); 210 | 211 | uint16_t identifier = tft.readID(); 212 | if(identifier==0x0101) 213 | identifier=0x9341; 214 | 215 | if(identifier == 0x9325) { 216 | Serial.println(F("Found ILI9325 LCD driver")); 217 | } else if(identifier == 0x4535) { 218 | Serial.println(F("Found LGDP4535 LCD driver")); 219 | }else if(identifier == 0x9328) { 220 | Serial.println(F("Found ILI9328 LCD driver")); 221 | } else if(identifier == 0x7575) { 222 | Serial.println(F("Found HX8347G LCD driver")); 223 | } else if(identifier == 0x9341) { 224 | Serial.println(F("Found ILI9341 LCD driver")); 225 | } else if(identifier == 0x8357) { 226 | Serial.println(F("Found HX8357D LCD driver")); 227 | } else { 228 | Serial.print(F("Unknown LCD driver chip: ")); 229 | Serial.println(identifier, HEX); 230 | Serial.println(F("If using the Adafruit 2.4\" TFT Arduino shield, the line:")); 231 | Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT")); 232 | Serial.println(F("should appear in the library header (Adafruit_TFT.h).")); 233 | Serial.println(F("If using the breakout board, it should NOT be #defined!")); 234 | Serial.println(F("Also if using the breakout, double-check that all wiring")); 235 | Serial.println(F("matches the tutorial.")); 236 | return; 237 | } 238 | 239 | tft.begin(identifier); 240 | tft.fillScreen(BLUE); 241 | 242 | 243 | 244 | //Init SD_Card 245 | pinMode(10, OUTPUT); 246 | 247 | if (!SD.begin(10)) { 248 | Serial.println("initialization failed!"); 249 | tft.setCursor(0, 0); 250 | tft.setTextColor(WHITE); 251 | tft.setTextSize(1); 252 | tft.println("SD Card Init fail."); 253 | }else 254 | Serial.println("initialization done."); 255 | } 256 | 257 | void loop(void) { 258 | for(unsigned char i=0; i<__Gnfile_num; i++) { 259 | bmpFile = SD.open(__Gsbmp_files[i]); 260 | if (! bmpFile) { 261 | Serial.println("didnt find image"); 262 | tft.setTextColor(WHITE); tft.setTextSize(1); 263 | tft.println("didnt find BMPimage"); 264 | while (1); 265 | } 266 | 267 | if(! bmpReadHeader(bmpFile)) { 268 | Serial.println("bad bmp"); 269 | tft.setTextColor(WHITE); tft.setTextSize(1); 270 | tft.println("bad bmp"); 271 | return; 272 | } 273 | 274 | bmpdraw(bmpFile, 0, 0); 275 | bmpFile.close(); 276 | delay(1000); 277 | delay(1000); 278 | } 279 | 280 | } 281 | 282 | 283 | -------------------------------------------------------------------------------- /TFT_TouchDisplay/tempDisplay/Adafruit_GFX.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAFRUIT_GFX_H 2 | #define _ADAFRUIT_GFX_H 3 | 4 | #if ARDUINO >= 100 5 | #include "Arduino.h" 6 | #include "Print.h" 7 | #else 8 | #include "WProgram.h" 9 | #endif 10 | 11 | #define swap(a, b) { int16_t t = a; a = b; b = t; } 12 | 13 | class Adafruit_GFX : public Print { 14 | 15 | public: 16 | 17 | Adafruit_GFX(int16_t w, int16_t h); // Constructor 18 | 19 | // This MUST be defined by the subclass: 20 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; 21 | 22 | // These MAY be overridden by the subclass to provide device-specific 23 | // optimized code. Otherwise 'generic' versions are used. 24 | virtual void 25 | drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), 26 | drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), 27 | drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), 28 | drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 29 | fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 30 | fillScreen(uint16_t color), 31 | invertDisplay(boolean i); 32 | 33 | // These exist only with Adafruit_GFX (no subclass overrides) 34 | void 35 | drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 36 | drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 37 | uint16_t color), 38 | fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 39 | fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 40 | int16_t delta, uint16_t color), 41 | drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 42 | int16_t x2, int16_t y2, uint16_t color), 43 | fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 44 | int16_t x2, int16_t y2, uint16_t color), 45 | drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 46 | int16_t radius, uint16_t color), 47 | fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 48 | int16_t radius, uint16_t color), 49 | drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, 50 | int16_t w, int16_t h, uint16_t color), 51 | drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, 52 | int16_t w, int16_t h, uint16_t color, uint16_t bg), 53 | drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, 54 | int16_t w, int16_t h, uint16_t color), 55 | drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, 56 | uint16_t bg, uint8_t size), 57 | setCursor(int16_t x, int16_t y), 58 | setTextColor(uint16_t c), 59 | setTextColor(uint16_t c, uint16_t bg), 60 | setTextSize(uint8_t s), 61 | setTextWrap(boolean w), 62 | setRotation(uint8_t r), 63 | cp437(boolean x=true); 64 | 65 | #if ARDUINO >= 100 66 | virtual size_t write(uint8_t); 67 | #else 68 | virtual void write(uint8_t); 69 | #endif 70 | 71 | int16_t height(void) const; 72 | int16_t width(void) const; 73 | 74 | uint8_t getRotation(void) const; 75 | 76 | // get current cursor position (get rotation safe maximum values, using: width() for x, height() for y) 77 | int16_t getCursorX(void) const; 78 | int16_t getCursorY(void) const; 79 | 80 | protected: 81 | const int16_t 82 | WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes 83 | int16_t 84 | _width, _height, // Display w/h as modified by current rotation 85 | cursor_x, cursor_y; 86 | uint16_t 87 | textcolor, textbgcolor; 88 | uint8_t 89 | textsize, 90 | rotation; 91 | boolean 92 | wrap, // If set, 'wrap' text at right edge of display 93 | _cp437; // If set, use correct CP437 charset (default is off) 94 | }; 95 | 96 | class Adafruit_GFX_Button { 97 | 98 | public: 99 | Adafruit_GFX_Button(void); 100 | void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, 101 | uint8_t w, uint8_t h, 102 | uint16_t outline, uint16_t fill, uint16_t textcolor, 103 | char *label, uint8_t textsize); 104 | void drawButton(boolean inverted = false); 105 | boolean contains(int16_t x, int16_t y); 106 | 107 | void press(boolean p); 108 | boolean isPressed(); 109 | boolean justPressed(); 110 | boolean justReleased(); 111 | 112 | private: 113 | Adafruit_GFX *_gfx; 114 | int16_t _x, _y; 115 | uint16_t _w, _h; 116 | uint8_t _textsize; 117 | uint16_t _outlinecolor, _fillcolor, _textcolor; 118 | char _label[10]; 119 | 120 | boolean currstate, laststate; 121 | }; 122 | 123 | #endif // _ADAFRUIT_GFX_H 124 | -------------------------------------------------------------------------------- /TFT_TouchDisplay/tempDisplay/Adafruit_TFTLCD.h: -------------------------------------------------------------------------------- 1 | // IMPORTANT: SEE COMMENTS @ LINE 15 REGARDING SHIELD VS BREAKOUT BOARD USAGE. 2 | 3 | // Graphics library by ladyada/adafruit with init code from Rossum 4 | // MIT license 5 | 6 | #ifndef _ADAFRUIT_TFTLCD_H_ 7 | #define _ADAFRUIT_TFTLCD_H_ 8 | 9 | #if ARDUINO >= 100 10 | #include "Arduino.h" 11 | #else 12 | #include "WProgram.h" 13 | #endif 14 | 15 | #include "Adafruit_GFX.h" 16 | 17 | // **** IF USING THE LCD BREAKOUT BOARD, COMMENT OUT THIS NEXT LINE. **** 18 | // **** IF USING THE LCD SHIELD, LEAVE THE LINE ENABLED: **** 19 | 20 | //#define USE_ADAFRUIT_SHIELD_PINOUT 1 21 | 22 | class Adafruit_TFTLCD : public Adafruit_GFX { 23 | 24 | public: 25 | 26 | Adafruit_TFTLCD(uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t rst); 27 | Adafruit_TFTLCD(void); 28 | 29 | void begin(uint16_t id = 0x9325); 30 | void drawPixel(int16_t x, int16_t y, uint16_t color); 31 | void drawFastHLine(int16_t x0, int16_t y0, int16_t w, uint16_t color); 32 | void drawFastVLine(int16_t x0, int16_t y0, int16_t h, uint16_t color); 33 | void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t c); 34 | void fillScreen(uint16_t color); 35 | void reset(void); 36 | void setRegisters8(uint8_t *ptr, uint8_t n); 37 | void setRegisters16(uint16_t *ptr, uint8_t n); 38 | void setRotation(uint8_t x); 39 | // These methods are public in order for BMP examples to work: 40 | void setAddrWindow(int x1, int y1, int x2, int y2); 41 | void pushColors(uint16_t *data, uint8_t len, boolean first); 42 | 43 | uint16_t color565(uint8_t r, uint8_t g, uint8_t b), 44 | readPixel(int16_t x, int16_t y), 45 | readID(void); 46 | uint32_t readReg(uint8_t r); 47 | 48 | private: 49 | 50 | void init(), 51 | // These items may have previously been defined as macros 52 | // in pin_magic.h. If not, function versions are declared: 53 | #ifndef write8 54 | write8(uint8_t value), 55 | #endif 56 | #ifndef setWriteDir 57 | setWriteDir(void), 58 | #endif 59 | #ifndef setReadDir 60 | setReadDir(void), 61 | #endif 62 | #ifndef writeRegister8 63 | writeRegister8(uint8_t a, uint8_t d), 64 | #endif 65 | #ifndef writeRegister16 66 | writeRegister16(uint16_t a, uint16_t d), 67 | #endif 68 | writeRegister24(uint8_t a, uint32_t d), 69 | writeRegister32(uint8_t a, uint32_t d), 70 | #ifndef writeRegisterPair 71 | writeRegisterPair(uint8_t aH, uint8_t aL, uint16_t d), 72 | #endif 73 | setLR(void), 74 | flood(uint16_t color, uint32_t len); 75 | uint8_t driver; 76 | 77 | #ifndef read8 78 | uint8_t read8fn(void); 79 | #define read8isFunctionalized 80 | #endif 81 | 82 | #ifndef USE_ADAFRUIT_SHIELD_PINOUT 83 | 84 | #ifdef __AVR__ 85 | volatile uint8_t *csPort , *cdPort , *wrPort , *rdPort; 86 | uint8_t csPinSet , cdPinSet , wrPinSet , rdPinSet , 87 | csPinUnset, cdPinUnset, wrPinUnset, rdPinUnset, 88 | _reset; 89 | #endif 90 | #if defined(__SAM3X8E__) 91 | Pio *csPort , *cdPort , *wrPort , *rdPort; 92 | uint32_t csPinSet , cdPinSet , wrPinSet , rdPinSet , 93 | csPinUnset, cdPinUnset, wrPinUnset, rdPinUnset, 94 | _reset; 95 | #endif 96 | 97 | #endif 98 | }; 99 | 100 | // For compatibility with sketches written for older versions of library. 101 | // Color function name was changed to 'color565' for parity with 2.2" LCD 102 | // library. 103 | #define Color565 color565 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /TFT_TouchDisplay/tempDisplay/TouchScreen.cpp: -------------------------------------------------------------------------------- 1 | // Touch screen library with X Y and Z (pressure) readings as well 2 | // as oversampling to avoid 'bouncing' 3 | // (c) ladyada / adafruit 4 | // Code under MIT License 5 | 6 | #include "pins_arduino.h" 7 | #include "wiring_private.h" 8 | #include 9 | #include "TouchScreen.h" 10 | 11 | // increase or decrease the touchscreen oversampling. This is a little different than you make think: 12 | // 1 is no oversampling, whatever data we get is immediately returned 13 | // 2 is double-sampling and we only return valid data if both points are the same 14 | // 3+ uses insert sort to get the median value. 15 | // We found 2 is precise yet not too slow so we suggest sticking with it! 16 | 17 | #define NUMSAMPLES 2 18 | 19 | TSPoint::TSPoint(void) { 20 | x = y = 0; 21 | } 22 | 23 | TSPoint::TSPoint(int16_t x0, int16_t y0, int16_t z0) { 24 | x = x0; 25 | y = y0; 26 | z = z0; 27 | } 28 | 29 | bool TSPoint::operator==(TSPoint p1) { 30 | return ((p1.x == x) && (p1.y == y) && (p1.z == z)); 31 | } 32 | 33 | bool TSPoint::operator!=(TSPoint p1) { 34 | return ((p1.x != x) || (p1.y != y) || (p1.z != z)); 35 | } 36 | 37 | #if (NUMSAMPLES > 2) 38 | static void insert_sort(int array[], uint8_t size) { 39 | uint8_t j; 40 | int save; 41 | 42 | for (int i = 1; i < size; i++) { 43 | save = array[i]; 44 | for (j = i; j >= 1 && save < array[j - 1]; j--) 45 | array[j] = array[j - 1]; 46 | array[j] = save; 47 | } 48 | } 49 | #endif 50 | 51 | TSPoint TouchScreen::getPoint(void) { 52 | int x, y, z; 53 | int samples[NUMSAMPLES]; 54 | uint8_t i, valid; 55 | 56 | 57 | uint8_t xp_port = digitalPinToPort(_xp); 58 | uint8_t yp_port = digitalPinToPort(_yp); 59 | uint8_t xm_port = digitalPinToPort(_xm); 60 | uint8_t ym_port = digitalPinToPort(_ym); 61 | 62 | uint8_t xp_pin = digitalPinToBitMask(_xp); 63 | uint8_t yp_pin = digitalPinToBitMask(_yp); 64 | uint8_t xm_pin = digitalPinToBitMask(_xm); 65 | uint8_t ym_pin = digitalPinToBitMask(_ym); 66 | 67 | 68 | valid = 1; 69 | 70 | pinMode(_yp, INPUT); 71 | pinMode(_ym, INPUT); 72 | 73 | *portOutputRegister(yp_port) &= ~yp_pin; 74 | *portOutputRegister(ym_port) &= ~ym_pin; 75 | //digitalWrite(_yp, LOW); 76 | //digitalWrite(_ym, LOW); 77 | 78 | pinMode(_xp, OUTPUT); 79 | pinMode(_xm, OUTPUT); 80 | //digitalWrite(_xp, HIGH); 81 | //digitalWrite(_xm, LOW); 82 | *portOutputRegister(xp_port) |= xp_pin; 83 | *portOutputRegister(xm_port) &= ~xm_pin; 84 | 85 | for (i=0; i 2 89 | insert_sort(samples, NUMSAMPLES); 90 | #endif 91 | #if NUMSAMPLES == 2 92 | if (samples[0] != samples[1]) { valid = 0; } 93 | #endif 94 | x = (1023-samples[NUMSAMPLES/2]); 95 | 96 | pinMode(_xp, INPUT); 97 | pinMode(_xm, INPUT); 98 | *portOutputRegister(xp_port) &= ~xp_pin; 99 | //digitalWrite(_xp, LOW); 100 | 101 | pinMode(_yp, OUTPUT); 102 | *portOutputRegister(yp_port) |= yp_pin; 103 | //digitalWrite(_yp, HIGH); 104 | pinMode(_ym, OUTPUT); 105 | 106 | for (i=0; i 2 111 | insert_sort(samples, NUMSAMPLES); 112 | #endif 113 | #if NUMSAMPLES == 2 114 | if (samples[0] != samples[1]) { valid = 0; } 115 | #endif 116 | 117 | y = (1023-samples[NUMSAMPLES/2]); 118 | 119 | // Set X+ to ground 120 | pinMode(_xp, OUTPUT); 121 | *portOutputRegister(xp_port) &= ~xp_pin; 122 | //digitalWrite(_xp, LOW); 123 | 124 | // Set Y- to VCC 125 | *portOutputRegister(ym_port) |= ym_pin; 126 | //digitalWrite(_ym, HIGH); 127 | 128 | // Hi-Z X- and Y+ 129 | *portOutputRegister(yp_port) &= ~yp_pin; 130 | //digitalWrite(_yp, LOW); 131 | pinMode(_yp, INPUT); 132 | 133 | int z1 = analogRead(_xm); 134 | int z2 = analogRead(_yp); 135 | 136 | if (_rxplate != 0) { 137 | // now read the x 138 | float rtouch; 139 | rtouch = z2; 140 | rtouch /= z1; 141 | rtouch -= 1; 142 | rtouch *= x; 143 | rtouch *= _rxplate; 144 | rtouch /= 1024; 145 | 146 | z = rtouch; 147 | } else { 148 | z = (1023-(z2-z1)); 149 | } 150 | 151 | if (! valid) { 152 | z = 0; 153 | } 154 | 155 | return TSPoint(x, y, z); 156 | } 157 | 158 | TouchScreen::TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym) { 159 | _yp = yp; 160 | _xm = xm; 161 | _ym = ym; 162 | _xp = xp; 163 | _rxplate = 0; 164 | pressureThreshhold = 10; 165 | } 166 | 167 | 168 | TouchScreen::TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym, 169 | uint16_t rxplate) { 170 | _yp = yp; 171 | _xm = xm; 172 | _ym = ym; 173 | _xp = xp; 174 | _rxplate = rxplate; 175 | 176 | pressureThreshhold = 10; 177 | } 178 | 179 | int TouchScreen::readTouchX(void) { 180 | pinMode(_yp, INPUT); 181 | pinMode(_ym, INPUT); 182 | digitalWrite(_yp, LOW); 183 | digitalWrite(_ym, LOW); 184 | 185 | pinMode(_xp, OUTPUT); 186 | digitalWrite(_xp, HIGH); 187 | pinMode(_xm, OUTPUT); 188 | digitalWrite(_xm, LOW); 189 | 190 | return (1023-analogRead(_yp)); 191 | } 192 | 193 | 194 | int TouchScreen::readTouchY(void) { 195 | pinMode(_xp, INPUT); 196 | pinMode(_xm, INPUT); 197 | digitalWrite(_xp, LOW); 198 | digitalWrite(_xm, LOW); 199 | 200 | pinMode(_yp, OUTPUT); 201 | digitalWrite(_yp, HIGH); 202 | pinMode(_ym, OUTPUT); 203 | digitalWrite(_ym, LOW); 204 | 205 | return (1023-analogRead(_xm)); 206 | } 207 | 208 | 209 | uint16_t TouchScreen::pressure(void) { 210 | // Set X+ to ground 211 | pinMode(_xp, OUTPUT); 212 | digitalWrite(_xp, LOW); 213 | 214 | // Set Y- to VCC 215 | pinMode(_ym, OUTPUT); 216 | digitalWrite(_ym, HIGH); 217 | 218 | // Hi-Z X- and Y+ 219 | digitalWrite(_xm, LOW); 220 | pinMode(_xm, INPUT); 221 | digitalWrite(_yp, LOW); 222 | pinMode(_yp, INPUT); 223 | 224 | int z1 = analogRead(_xm); 225 | int z2 = analogRead(_yp); 226 | 227 | if (_rxplate != 0) { 228 | // now read the x 229 | float rtouch; 230 | rtouch = z2; 231 | rtouch /= z1; 232 | rtouch -= 1; 233 | rtouch *= readTouchX(); 234 | rtouch *= _rxplate; 235 | rtouch /= 1024; 236 | 237 | return rtouch; 238 | } else { 239 | return (1023-(z2-z1)); 240 | } 241 | } 242 | -------------------------------------------------------------------------------- /TFT_TouchDisplay/tempDisplay/TouchScreen.h: -------------------------------------------------------------------------------- 1 | // Touch screen library with X Y and Z (pressure) readings as well 2 | // as oversampling to avoid 'bouncing' 3 | // (c) ladyada / adafruit 4 | // Code under MIT License 5 | 6 | #ifndef _ADAFRUIT_TOUCHSCREEN_H_ 7 | #define _ADAFRUIT_TOUCHSCREEN_H_ 8 | #include 9 | 10 | class TSPoint { 11 | public: 12 | TSPoint(void); 13 | TSPoint(int16_t x, int16_t y, int16_t z); 14 | 15 | bool operator==(TSPoint); 16 | bool operator!=(TSPoint); 17 | 18 | int16_t x, y, z; 19 | }; 20 | 21 | class TouchScreen { 22 | public: 23 | TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym); 24 | TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym, uint16_t rx); 25 | 26 | bool isTouching(void); 27 | uint16_t pressure(void); 28 | int readTouchY(); 29 | int readTouchX(); 30 | TSPoint getPoint(); 31 | int16_t pressureThreshhold; 32 | 33 | private: 34 | uint8_t _yp, _ym, _xm, _xp; 35 | uint16_t _rxplate; 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /TFT_TouchDisplay/tempDisplay/glcdfont.c: -------------------------------------------------------------------------------- 1 | #ifndef FONT5X7_H 2 | #define FONT5X7_H 3 | 4 | #ifdef __AVR__ 5 | #include 6 | #include 7 | #elif defined(ESP8266) 8 | #include 9 | #else 10 | #define PROGMEM 11 | #endif 12 | 13 | // Standard ASCII 5x7 font 14 | 15 | static const unsigned char font[] PROGMEM = { 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 18 | 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 19 | 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 20 | 0x18, 0x3C, 0x7E, 0x3C, 0x18, 21 | 0x1C, 0x57, 0x7D, 0x57, 0x1C, 22 | 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 23 | 0x00, 0x18, 0x3C, 0x18, 0x00, 24 | 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 25 | 0x00, 0x18, 0x24, 0x18, 0x00, 26 | 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 27 | 0x30, 0x48, 0x3A, 0x06, 0x0E, 28 | 0x26, 0x29, 0x79, 0x29, 0x26, 29 | 0x40, 0x7F, 0x05, 0x05, 0x07, 30 | 0x40, 0x7F, 0x05, 0x25, 0x3F, 31 | 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 32 | 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 33 | 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 34 | 0x14, 0x22, 0x7F, 0x22, 0x14, 35 | 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 36 | 0x06, 0x09, 0x7F, 0x01, 0x7F, 37 | 0x00, 0x66, 0x89, 0x95, 0x6A, 38 | 0x60, 0x60, 0x60, 0x60, 0x60, 39 | 0x94, 0xA2, 0xFF, 0xA2, 0x94, 40 | 0x08, 0x04, 0x7E, 0x04, 0x08, 41 | 0x10, 0x20, 0x7E, 0x20, 0x10, 42 | 0x08, 0x08, 0x2A, 0x1C, 0x08, 43 | 0x08, 0x1C, 0x2A, 0x08, 0x08, 44 | 0x1E, 0x10, 0x10, 0x10, 0x10, 45 | 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 46 | 0x30, 0x38, 0x3E, 0x38, 0x30, 47 | 0x06, 0x0E, 0x3E, 0x0E, 0x06, 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x5F, 0x00, 0x00, 50 | 0x00, 0x07, 0x00, 0x07, 0x00, 51 | 0x14, 0x7F, 0x14, 0x7F, 0x14, 52 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, 53 | 0x23, 0x13, 0x08, 0x64, 0x62, 54 | 0x36, 0x49, 0x56, 0x20, 0x50, 55 | 0x00, 0x08, 0x07, 0x03, 0x00, 56 | 0x00, 0x1C, 0x22, 0x41, 0x00, 57 | 0x00, 0x41, 0x22, 0x1C, 0x00, 58 | 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 59 | 0x08, 0x08, 0x3E, 0x08, 0x08, 60 | 0x00, 0x80, 0x70, 0x30, 0x00, 61 | 0x08, 0x08, 0x08, 0x08, 0x08, 62 | 0x00, 0x00, 0x60, 0x60, 0x00, 63 | 0x20, 0x10, 0x08, 0x04, 0x02, 64 | 0x3E, 0x51, 0x49, 0x45, 0x3E, 65 | 0x00, 0x42, 0x7F, 0x40, 0x00, 66 | 0x72, 0x49, 0x49, 0x49, 0x46, 67 | 0x21, 0x41, 0x49, 0x4D, 0x33, 68 | 0x18, 0x14, 0x12, 0x7F, 0x10, 69 | 0x27, 0x45, 0x45, 0x45, 0x39, 70 | 0x3C, 0x4A, 0x49, 0x49, 0x31, 71 | 0x41, 0x21, 0x11, 0x09, 0x07, 72 | 0x36, 0x49, 0x49, 0x49, 0x36, 73 | 0x46, 0x49, 0x49, 0x29, 0x1E, 74 | 0x00, 0x00, 0x14, 0x00, 0x00, 75 | 0x00, 0x40, 0x34, 0x00, 0x00, 76 | 0x00, 0x08, 0x14, 0x22, 0x41, 77 | 0x14, 0x14, 0x14, 0x14, 0x14, 78 | 0x00, 0x41, 0x22, 0x14, 0x08, 79 | 0x02, 0x01, 0x59, 0x09, 0x06, 80 | 0x3E, 0x41, 0x5D, 0x59, 0x4E, 81 | 0x7C, 0x12, 0x11, 0x12, 0x7C, 82 | 0x7F, 0x49, 0x49, 0x49, 0x36, 83 | 0x3E, 0x41, 0x41, 0x41, 0x22, 84 | 0x7F, 0x41, 0x41, 0x41, 0x3E, 85 | 0x7F, 0x49, 0x49, 0x49, 0x41, 86 | 0x7F, 0x09, 0x09, 0x09, 0x01, 87 | 0x3E, 0x41, 0x41, 0x51, 0x73, 88 | 0x7F, 0x08, 0x08, 0x08, 0x7F, 89 | 0x00, 0x41, 0x7F, 0x41, 0x00, 90 | 0x20, 0x40, 0x41, 0x3F, 0x01, 91 | 0x7F, 0x08, 0x14, 0x22, 0x41, 92 | 0x7F, 0x40, 0x40, 0x40, 0x40, 93 | 0x7F, 0x02, 0x1C, 0x02, 0x7F, 94 | 0x7F, 0x04, 0x08, 0x10, 0x7F, 95 | 0x3E, 0x41, 0x41, 0x41, 0x3E, 96 | 0x7F, 0x09, 0x09, 0x09, 0x06, 97 | 0x3E, 0x41, 0x51, 0x21, 0x5E, 98 | 0x7F, 0x09, 0x19, 0x29, 0x46, 99 | 0x26, 0x49, 0x49, 0x49, 0x32, 100 | 0x03, 0x01, 0x7F, 0x01, 0x03, 101 | 0x3F, 0x40, 0x40, 0x40, 0x3F, 102 | 0x1F, 0x20, 0x40, 0x20, 0x1F, 103 | 0x3F, 0x40, 0x38, 0x40, 0x3F, 104 | 0x63, 0x14, 0x08, 0x14, 0x63, 105 | 0x03, 0x04, 0x78, 0x04, 0x03, 106 | 0x61, 0x59, 0x49, 0x4D, 0x43, 107 | 0x00, 0x7F, 0x41, 0x41, 0x41, 108 | 0x02, 0x04, 0x08, 0x10, 0x20, 109 | 0x00, 0x41, 0x41, 0x41, 0x7F, 110 | 0x04, 0x02, 0x01, 0x02, 0x04, 111 | 0x40, 0x40, 0x40, 0x40, 0x40, 112 | 0x00, 0x03, 0x07, 0x08, 0x00, 113 | 0x20, 0x54, 0x54, 0x78, 0x40, 114 | 0x7F, 0x28, 0x44, 0x44, 0x38, 115 | 0x38, 0x44, 0x44, 0x44, 0x28, 116 | 0x38, 0x44, 0x44, 0x28, 0x7F, 117 | 0x38, 0x54, 0x54, 0x54, 0x18, 118 | 0x00, 0x08, 0x7E, 0x09, 0x02, 119 | 0x18, 0xA4, 0xA4, 0x9C, 0x78, 120 | 0x7F, 0x08, 0x04, 0x04, 0x78, 121 | 0x00, 0x44, 0x7D, 0x40, 0x00, 122 | 0x20, 0x40, 0x40, 0x3D, 0x00, 123 | 0x7F, 0x10, 0x28, 0x44, 0x00, 124 | 0x00, 0x41, 0x7F, 0x40, 0x00, 125 | 0x7C, 0x04, 0x78, 0x04, 0x78, 126 | 0x7C, 0x08, 0x04, 0x04, 0x78, 127 | 0x38, 0x44, 0x44, 0x44, 0x38, 128 | 0xFC, 0x18, 0x24, 0x24, 0x18, 129 | 0x18, 0x24, 0x24, 0x18, 0xFC, 130 | 0x7C, 0x08, 0x04, 0x04, 0x08, 131 | 0x48, 0x54, 0x54, 0x54, 0x24, 132 | 0x04, 0x04, 0x3F, 0x44, 0x24, 133 | 0x3C, 0x40, 0x40, 0x20, 0x7C, 134 | 0x1C, 0x20, 0x40, 0x20, 0x1C, 135 | 0x3C, 0x40, 0x30, 0x40, 0x3C, 136 | 0x44, 0x28, 0x10, 0x28, 0x44, 137 | 0x4C, 0x90, 0x90, 0x90, 0x7C, 138 | 0x44, 0x64, 0x54, 0x4C, 0x44, 139 | 0x00, 0x08, 0x36, 0x41, 0x00, 140 | 0x00, 0x00, 0x77, 0x00, 0x00, 141 | 0x00, 0x41, 0x36, 0x08, 0x00, 142 | 0x02, 0x01, 0x02, 0x04, 0x02, 143 | 0x3C, 0x26, 0x23, 0x26, 0x3C, 144 | 0x1E, 0xA1, 0xA1, 0x61, 0x12, 145 | 0x3A, 0x40, 0x40, 0x20, 0x7A, 146 | 0x38, 0x54, 0x54, 0x55, 0x59, 147 | 0x21, 0x55, 0x55, 0x79, 0x41, 148 | 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut 149 | 0x21, 0x55, 0x54, 0x78, 0x40, 150 | 0x20, 0x54, 0x55, 0x79, 0x40, 151 | 0x0C, 0x1E, 0x52, 0x72, 0x12, 152 | 0x39, 0x55, 0x55, 0x55, 0x59, 153 | 0x39, 0x54, 0x54, 0x54, 0x59, 154 | 0x39, 0x55, 0x54, 0x54, 0x58, 155 | 0x00, 0x00, 0x45, 0x7C, 0x41, 156 | 0x00, 0x02, 0x45, 0x7D, 0x42, 157 | 0x00, 0x01, 0x45, 0x7C, 0x40, 158 | 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut 159 | 0xF0, 0x28, 0x25, 0x28, 0xF0, 160 | 0x7C, 0x54, 0x55, 0x45, 0x00, 161 | 0x20, 0x54, 0x54, 0x7C, 0x54, 162 | 0x7C, 0x0A, 0x09, 0x7F, 0x49, 163 | 0x32, 0x49, 0x49, 0x49, 0x32, 164 | 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut 165 | 0x32, 0x4A, 0x48, 0x48, 0x30, 166 | 0x3A, 0x41, 0x41, 0x21, 0x7A, 167 | 0x3A, 0x42, 0x40, 0x20, 0x78, 168 | 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 169 | 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut 170 | 0x3D, 0x40, 0x40, 0x40, 0x3D, 171 | 0x3C, 0x24, 0xFF, 0x24, 0x24, 172 | 0x48, 0x7E, 0x49, 0x43, 0x66, 173 | 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 174 | 0xFF, 0x09, 0x29, 0xF6, 0x20, 175 | 0xC0, 0x88, 0x7E, 0x09, 0x03, 176 | 0x20, 0x54, 0x54, 0x79, 0x41, 177 | 0x00, 0x00, 0x44, 0x7D, 0x41, 178 | 0x30, 0x48, 0x48, 0x4A, 0x32, 179 | 0x38, 0x40, 0x40, 0x22, 0x7A, 180 | 0x00, 0x7A, 0x0A, 0x0A, 0x72, 181 | 0x7D, 0x0D, 0x19, 0x31, 0x7D, 182 | 0x26, 0x29, 0x29, 0x2F, 0x28, 183 | 0x26, 0x29, 0x29, 0x29, 0x26, 184 | 0x30, 0x48, 0x4D, 0x40, 0x20, 185 | 0x38, 0x08, 0x08, 0x08, 0x08, 186 | 0x08, 0x08, 0x08, 0x08, 0x38, 187 | 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 188 | 0x2F, 0x10, 0x28, 0x34, 0xFA, 189 | 0x00, 0x00, 0x7B, 0x00, 0x00, 190 | 0x08, 0x14, 0x2A, 0x14, 0x22, 191 | 0x22, 0x14, 0x2A, 0x14, 0x08, 192 | 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code 193 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block 194 | 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block 195 | 0x00, 0x00, 0x00, 0xFF, 0x00, 196 | 0x10, 0x10, 0x10, 0xFF, 0x00, 197 | 0x14, 0x14, 0x14, 0xFF, 0x00, 198 | 0x10, 0x10, 0xFF, 0x00, 0xFF, 199 | 0x10, 0x10, 0xF0, 0x10, 0xF0, 200 | 0x14, 0x14, 0x14, 0xFC, 0x00, 201 | 0x14, 0x14, 0xF7, 0x00, 0xFF, 202 | 0x00, 0x00, 0xFF, 0x00, 0xFF, 203 | 0x14, 0x14, 0xF4, 0x04, 0xFC, 204 | 0x14, 0x14, 0x17, 0x10, 0x1F, 205 | 0x10, 0x10, 0x1F, 0x10, 0x1F, 206 | 0x14, 0x14, 0x14, 0x1F, 0x00, 207 | 0x10, 0x10, 0x10, 0xF0, 0x00, 208 | 0x00, 0x00, 0x00, 0x1F, 0x10, 209 | 0x10, 0x10, 0x10, 0x1F, 0x10, 210 | 0x10, 0x10, 0x10, 0xF0, 0x10, 211 | 0x00, 0x00, 0x00, 0xFF, 0x10, 212 | 0x10, 0x10, 0x10, 0x10, 0x10, 213 | 0x10, 0x10, 0x10, 0xFF, 0x10, 214 | 0x00, 0x00, 0x00, 0xFF, 0x14, 215 | 0x00, 0x00, 0xFF, 0x00, 0xFF, 216 | 0x00, 0x00, 0x1F, 0x10, 0x17, 217 | 0x00, 0x00, 0xFC, 0x04, 0xF4, 218 | 0x14, 0x14, 0x17, 0x10, 0x17, 219 | 0x14, 0x14, 0xF4, 0x04, 0xF4, 220 | 0x00, 0x00, 0xFF, 0x00, 0xF7, 221 | 0x14, 0x14, 0x14, 0x14, 0x14, 222 | 0x14, 0x14, 0xF7, 0x00, 0xF7, 223 | 0x14, 0x14, 0x14, 0x17, 0x14, 224 | 0x10, 0x10, 0x1F, 0x10, 0x1F, 225 | 0x14, 0x14, 0x14, 0xF4, 0x14, 226 | 0x10, 0x10, 0xF0, 0x10, 0xF0, 227 | 0x00, 0x00, 0x1F, 0x10, 0x1F, 228 | 0x00, 0x00, 0x00, 0x1F, 0x14, 229 | 0x00, 0x00, 0x00, 0xFC, 0x14, 230 | 0x00, 0x00, 0xF0, 0x10, 0xF0, 231 | 0x10, 0x10, 0xFF, 0x10, 0xFF, 232 | 0x14, 0x14, 0x14, 0xFF, 0x14, 233 | 0x10, 0x10, 0x10, 0x1F, 0x00, 234 | 0x00, 0x00, 0x00, 0xF0, 0x10, 235 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 236 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 237 | 0xFF, 0xFF, 0xFF, 0x00, 0x00, 238 | 0x00, 0x00, 0x00, 0xFF, 0xFF, 239 | 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 240 | 0x38, 0x44, 0x44, 0x38, 0x44, 241 | 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta 242 | 0x7E, 0x02, 0x02, 0x06, 0x06, 243 | 0x02, 0x7E, 0x02, 0x7E, 0x02, 244 | 0x63, 0x55, 0x49, 0x41, 0x63, 245 | 0x38, 0x44, 0x44, 0x3C, 0x04, 246 | 0x40, 0x7E, 0x20, 0x1E, 0x20, 247 | 0x06, 0x02, 0x7E, 0x02, 0x02, 248 | 0x99, 0xA5, 0xE7, 0xA5, 0x99, 249 | 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 250 | 0x4C, 0x72, 0x01, 0x72, 0x4C, 251 | 0x30, 0x4A, 0x4D, 0x4D, 0x30, 252 | 0x30, 0x48, 0x78, 0x48, 0x30, 253 | 0xBC, 0x62, 0x5A, 0x46, 0x3D, 254 | 0x3E, 0x49, 0x49, 0x49, 0x00, 255 | 0x7E, 0x01, 0x01, 0x01, 0x7E, 256 | 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 257 | 0x44, 0x44, 0x5F, 0x44, 0x44, 258 | 0x40, 0x51, 0x4A, 0x44, 0x40, 259 | 0x40, 0x44, 0x4A, 0x51, 0x40, 260 | 0x00, 0x00, 0xFF, 0x01, 0x03, 261 | 0xE0, 0x80, 0xFF, 0x00, 0x00, 262 | 0x08, 0x08, 0x6B, 0x6B, 0x08, 263 | 0x36, 0x12, 0x36, 0x24, 0x36, 264 | 0x06, 0x0F, 0x09, 0x0F, 0x06, 265 | 0x00, 0x00, 0x18, 0x18, 0x00, 266 | 0x00, 0x00, 0x10, 0x10, 0x00, 267 | 0x30, 0x40, 0xFF, 0x01, 0x01, 268 | 0x00, 0x1F, 0x01, 0x01, 0x1E, 269 | 0x00, 0x19, 0x1D, 0x17, 0x12, 270 | 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 271 | 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP 272 | }; 273 | #endif // FONT5X7_H 274 | -------------------------------------------------------------------------------- /TFT_TouchDisplay/tempDisplay/registers.h: -------------------------------------------------------------------------------- 1 | // Register names from Peter Barrett's Microtouch code 2 | #define ILI932X_START_OSC 0x00 3 | #define ILI932X_DRIV_OUT_CTRL 0x01 4 | #define ILI932X_DRIV_WAV_CTRL 0x02 5 | #define ILI932X_ENTRY_MOD 0x03 6 | #define ILI932X_RESIZE_CTRL 0x04 7 | #define ILI932X_DISP_CTRL1 0x07 8 | #define ILI932X_DISP_CTRL2 0x08 9 | #define ILI932X_DISP_CTRL3 0x09 10 | #define ILI932X_DISP_CTRL4 0x0A 11 | #define ILI932X_RGB_DISP_IF_CTRL1 0x0C 12 | #define ILI932X_FRM_MARKER_POS 0x0D 13 | #define ILI932X_RGB_DISP_IF_CTRL2 0x0F 14 | #define ILI932X_POW_CTRL1 0x10 15 | #define ILI932X_POW_CTRL2 0x11 16 | #define ILI932X_POW_CTRL3 0x12 17 | #define ILI932X_POW_CTRL4 0x13 18 | #define ILI932X_GRAM_HOR_AD 0x20 19 | #define ILI932X_GRAM_VER_AD 0x21 20 | #define ILI932X_RW_GRAM 0x22 21 | #define ILI932X_POW_CTRL7 0x29 22 | #define ILI932X_FRM_RATE_COL_CTRL 0x2B 23 | #define ILI932X_GAMMA_CTRL1 0x30 24 | #define ILI932X_GAMMA_CTRL2 0x31 25 | #define ILI932X_GAMMA_CTRL3 0x32 26 | #define ILI932X_GAMMA_CTRL4 0x35 27 | #define ILI932X_GAMMA_CTRL5 0x36 28 | #define ILI932X_GAMMA_CTRL6 0x37 29 | #define ILI932X_GAMMA_CTRL7 0x38 30 | #define ILI932X_GAMMA_CTRL8 0x39 31 | #define ILI932X_GAMMA_CTRL9 0x3C 32 | #define ILI932X_GAMMA_CTRL10 0x3D 33 | #define ILI932X_HOR_START_AD 0x50 34 | #define ILI932X_HOR_END_AD 0x51 35 | #define ILI932X_VER_START_AD 0x52 36 | #define ILI932X_VER_END_AD 0x53 37 | #define ILI932X_GATE_SCAN_CTRL1 0x60 38 | #define ILI932X_GATE_SCAN_CTRL2 0x61 39 | #define ILI932X_GATE_SCAN_CTRL3 0x6A 40 | #define ILI932X_PART_IMG1_DISP_POS 0x80 41 | #define ILI932X_PART_IMG1_START_AD 0x81 42 | #define ILI932X_PART_IMG1_END_AD 0x82 43 | #define ILI932X_PART_IMG2_DISP_POS 0x83 44 | #define ILI932X_PART_IMG2_START_AD 0x84 45 | #define ILI932X_PART_IMG2_END_AD 0x85 46 | #define ILI932X_PANEL_IF_CTRL1 0x90 47 | #define ILI932X_PANEL_IF_CTRL2 0x92 48 | #define ILI932X_PANEL_IF_CTRL3 0x93 49 | #define ILI932X_PANEL_IF_CTRL4 0x95 50 | #define ILI932X_PANEL_IF_CTRL5 0x97 51 | #define ILI932X_PANEL_IF_CTRL6 0x98 52 | 53 | #define HX8347G_COLADDRSTART_HI 0x02 54 | #define HX8347G_COLADDRSTART_LO 0x03 55 | #define HX8347G_COLADDREND_HI 0x04 56 | #define HX8347G_COLADDREND_LO 0x05 57 | #define HX8347G_ROWADDRSTART_HI 0x06 58 | #define HX8347G_ROWADDRSTART_LO 0x07 59 | #define HX8347G_ROWADDREND_HI 0x08 60 | #define HX8347G_ROWADDREND_LO 0x09 61 | #define HX8347G_MEMACCESS 0x16 62 | 63 | 64 | 65 | #define ILI9341_SOFTRESET 0x01 66 | #define ILI9341_SLEEPIN 0x10 67 | #define ILI9341_SLEEPOUT 0x11 68 | #define ILI9341_NORMALDISP 0x13 69 | #define ILI9341_INVERTOFF 0x20 70 | #define ILI9341_INVERTON 0x21 71 | #define ILI9341_GAMMASET 0x26 72 | #define ILI9341_DISPLAYOFF 0x28 73 | #define ILI9341_DISPLAYON 0x29 74 | #define ILI9341_COLADDRSET 0x2A 75 | #define ILI9341_PAGEADDRSET 0x2B 76 | #define ILI9341_MEMORYWRITE 0x2C 77 | #define ILI9341_PIXELFORMAT 0x3A 78 | #define ILI9341_FRAMECONTROL 0xB1 79 | #define ILI9341_DISPLAYFUNC 0xB6 80 | #define ILI9341_ENTRYMODE 0xB7 81 | #define ILI9341_POWERCONTROL1 0xC0 82 | #define ILI9341_POWERCONTROL2 0xC1 83 | #define ILI9341_VCOMCONTROL1 0xC5 84 | #define ILI9341_VCOMCONTROL2 0xC7 85 | #define ILI9341_MEMCONTROL 0x36 86 | #define ILI9341_MADCTL 0x36 87 | 88 | #define ILI9341_MADCTL_MY 0x80 89 | #define ILI9341_MADCTL_MX 0x40 90 | #define ILI9341_MADCTL_MV 0x20 91 | #define ILI9341_MADCTL_ML 0x10 92 | #define ILI9341_MADCTL_RGB 0x00 93 | #define ILI9341_MADCTL_BGR 0x08 94 | #define ILI9341_MADCTL_MH 0x04 95 | 96 | 97 | 98 | #define HX8357_NOP 0x00 99 | #define HX8357_SWRESET 0x01 100 | #define HX8357_RDDID 0x04 101 | #define HX8357_RDDST 0x09 102 | 103 | #define HX8357B_RDPOWMODE 0x0A 104 | #define HX8357B_RDMADCTL 0x0B 105 | #define HX8357B_RDCOLMOD 0x0C 106 | #define HX8357B_RDDIM 0x0D 107 | #define HX8357B_RDDSDR 0x0F 108 | 109 | #define HX8357_SLPIN 0x10 110 | #define HX8357_SLPOUT 0x11 111 | #define HX8357B_PTLON 0x12 112 | #define HX8357B_NORON 0x13 113 | 114 | #define HX8357_INVOFF 0x20 115 | #define HX8357_INVON 0x21 116 | #define HX8357_DISPOFF 0x28 117 | #define HX8357_DISPON 0x29 118 | 119 | #define HX8357_CASET 0x2A 120 | #define HX8357_PASET 0x2B 121 | #define HX8357_RAMWR 0x2C 122 | #define HX8357_RAMRD 0x2E 123 | 124 | #define HX8357B_PTLAR 0x30 125 | #define HX8357_TEON 0x35 126 | #define HX8357_TEARLINE 0x44 127 | #define HX8357_MADCTL 0x36 128 | #define HX8357_COLMOD 0x3A 129 | 130 | #define HX8357_SETOSC 0xB0 131 | #define HX8357_SETPWR1 0xB1 132 | #define HX8357B_SETDISPLAY 0xB2 133 | #define HX8357_SETRGB 0xB3 134 | #define HX8357D_SETCOM 0xB6 135 | 136 | #define HX8357B_SETDISPMODE 0xB4 137 | #define HX8357D_SETCYC 0xB4 138 | #define HX8357B_SETOTP 0xB7 139 | #define HX8357D_SETC 0xB9 140 | 141 | #define HX8357B_SET_PANEL_DRIVING 0xC0 142 | #define HX8357D_SETSTBA 0xC0 143 | #define HX8357B_SETDGC 0xC1 144 | #define HX8357B_SETID 0xC3 145 | #define HX8357B_SETDDB 0xC4 146 | #define HX8357B_SETDISPLAYFRAME 0xC5 147 | #define HX8357B_GAMMASET 0xC8 148 | #define HX8357B_SETCABC 0xC9 149 | #define HX8357_SETPANEL 0xCC 150 | 151 | 152 | #define HX8357B_SETPOWER 0xD0 153 | #define HX8357B_SETVCOM 0xD1 154 | #define HX8357B_SETPWRNORMAL 0xD2 155 | 156 | #define HX8357B_RDID1 0xDA 157 | #define HX8357B_RDID2 0xDB 158 | #define HX8357B_RDID3 0xDC 159 | #define HX8357B_RDID4 0xDD 160 | 161 | #define HX8357D_SETGAMMA 0xE0 162 | 163 | #define HX8357B_SETGAMMA 0xC8 164 | #define HX8357B_SETPANELRELATED 0xE9 165 | 166 | #define HX8357B_MADCTL_MY 0x80 167 | #define HX8357B_MADCTL_MX 0x40 168 | #define HX8357B_MADCTL_MV 0x20 169 | #define HX8357B_MADCTL_ML 0x10 170 | #define HX8357B_MADCTL_RGB 0x00 171 | #define HX8357B_MADCTL_BGR 0x08 172 | #define HX8357B_MADCTL_MH 0x04 173 | -------------------------------------------------------------------------------- /TFT_TouchDisplay/tftpaint/tftpaint.ino: -------------------------------------------------------------------------------- 1 | // Paint example specifically for the TFTLCD breakout board. 2 | // If using the Arduino shield, use the tftpaint_shield.pde sketch instead! 3 | // DOES NOT CURRENTLY WORK ON ARDUINO LEONARDO 4 | //Technical support:goodtft@163.com 5 | 6 | #include // Core graphics library 7 | #include // Hardware-specific library 8 | #include 9 | 10 | #if defined(__SAM3X8E__) 11 | #undef __FlashStringHelper::F(string_literal) 12 | #define F(string_literal) string_literal 13 | #endif 14 | 15 | // When using the BREAKOUT BOARD only, use these 8 data lines to the LCD: 16 | // For the Arduino Uno, Duemilanove, Diecimila, etc.: 17 | // D0 connects to digital pin 8 (Notice these are 18 | // D1 connects to digital pin 9 NOT in order!) 19 | // D2 connects to digital pin 2 20 | // D3 connects to digital pin 3 21 | // D4 connects to digital pin 4 22 | // D5 connects to digital pin 5 23 | // D6 connects to digital pin 6 24 | // D7 connects to digital pin 7 25 | 26 | // For the Arduino Mega, use digital pins 22 through 29 27 | // (on the 2-row header at the end of the board). 28 | // D0 connects to digital pin 22 29 | // D1 connects to digital pin 23 30 | // D2 connects to digital pin 24 31 | // D3 connects to digital pin 25 32 | // D4 connects to digital pin 26 33 | // D5 connects to digital pin 27 34 | // D6 connects to digital pin 28 35 | // D7 connects to digital pin 29 36 | 37 | // For the Arduino Due, use digital pins 33 through 40 38 | // (on the 2-row header at the end of the board). 39 | // D0 connects to digital pin 33 40 | // D1 connects to digital pin 34 41 | // D2 connects to digital pin 35 42 | // D3 connects to digital pin 36 43 | // D4 connects to digital pin 37 44 | // D5 connects to digital pin 38 45 | // D6 connects to digital pin 39 46 | // D7 connects to digital pin 40 47 | 48 | /* 49 | #define YP A2 // must be an analog pin, use "An" notation! 50 | #define XM A1 // must be an analog pin, use "An" notation! 51 | #define YM 6 // can be a digital pin 52 | #define XP 7 // can be a digital pin 53 | */ 54 | 55 | 56 | #define XM A2 // must be an analog pin, use "An" notation! 57 | #define YP A1 // must be an analog pin, use "An" notation! 58 | #define XP 6 // can be a digital pin 59 | #define YM 7 // can be a digital pin 60 | 61 | #define TS_MINX 160 62 | #define TS_MINY 160 63 | #define TS_MAXX 900 64 | #define TS_MAXY 900 65 | 66 | // For better pressure precision, we need to know the resistance 67 | // between X+ and X- Use any multimeter to read it 68 | // For the one we're using, its 300 ohms across the X plate 69 | TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); 70 | 71 | #define LCD_CS A3 72 | #define LCD_CD A2 73 | #define LCD_WR A1 74 | #define LCD_RD A0 75 | // optional 76 | #define LCD_RESET A4 77 | 78 | // Assign human-readable names to some common 16-bit color values: 79 | #define BLACK 0x0000 80 | #define BLUE 0x001F 81 | #define RED 0xF800 82 | #define GREEN 0x07E0 83 | #define CYAN 0x07FF 84 | #define MAGENTA 0xF81F 85 | #define YELLOW 0xFFE0 86 | #define WHITE 0xFFFF 87 | 88 | 89 | Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); 90 | 91 | #define BOXSIZE 40 92 | #define PENRADIUS 3 93 | int oldcolor, currentcolor; 94 | 95 | void setup(void) { 96 | Serial.begin(9600); 97 | Serial.println(F("Paint!")); 98 | 99 | tft.reset(); 100 | 101 | uint16_t identifier = tft.readID(); 102 | if(identifier==0x0101) 103 | identifier=0x9341; 104 | if(identifier == 0x9325) { 105 | Serial.println(F("Found ILI9325 LCD driver")); 106 | } else if(identifier == 0x9328) { 107 | Serial.println(F("Found ILI9328 LCD driver")); 108 | } else if(identifier == 0x4535) { 109 | Serial.println(F("Found LGDP4535 LCD driver")); 110 | }else if(identifier == 0x7575) { 111 | Serial.println(F("Found HX8347G LCD driver")); 112 | } else if(identifier == 0x9341) { 113 | Serial.println(F("Found ILI9341 LCD driver")); 114 | } else if(identifier == 0x8357) { 115 | Serial.println(F("Found HX8357D LCD driver")); 116 | } else { 117 | Serial.print(F("Unknown LCD driver chip: ")); 118 | Serial.println(identifier, HEX); 119 | Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:")); 120 | Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT")); 121 | Serial.println(F("should appear in the library header (Adafruit_TFT.h).")); 122 | Serial.println(F("If using the breakout board, it should NOT be #defined!")); 123 | Serial.println(F("Also if using the breakout, double-check that all wiring")); 124 | Serial.println(F("matches the tutorial.")); 125 | return; 126 | } 127 | 128 | tft.begin(identifier); 129 | 130 | tft.fillScreen(BLACK); 131 | 132 | 133 | tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED); 134 | tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW); 135 | tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, GREEN); 136 | tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, CYAN); 137 | tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, BLUE); 138 | tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, MAGENTA); 139 | 140 | 141 | tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE); 142 | currentcolor = RED; 143 | 144 | pinMode(13, OUTPUT); 145 | } 146 | 147 | #define MINPRESSURE 10 148 | #define MAXPRESSURE 1000 149 | 150 | void loop() 151 | { 152 | digitalWrite(13, HIGH); 153 | TSPoint p = ts.getPoint(); 154 | digitalWrite(13, LOW); 155 | 156 | // if sharing pins, you'll need to fix the directions of the touchscreen pins 157 | pinMode(XP, OUTPUT); 158 | pinMode(XM, OUTPUT); 159 | pinMode(YP, OUTPUT); 160 | pinMode(YM, OUTPUT); 161 | 162 | // we have some minimum pressure we consider 'valid' 163 | // pressure of 0 means no pressing! 164 | 165 | Serial.print("X = "); Serial.print(p.x); 166 | Serial.print("\tY = "); Serial.print(p.y); 167 | Serial.print("\tPressure = "); Serial.println(p.z); 168 | 169 | if (p.z > MINPRESSURE && p.z < MAXPRESSURE) { 170 | /* 171 | Serial.print("X = "); Serial.print(p.x); 172 | Serial.print("\tY = "); Serial.print(p.y); 173 | Serial.print("\tPressure = "); Serial.println(p.z); 174 | */ 175 | 176 | 177 | if (p.y < (TS_MINY-5)) { 178 | Serial.println("erase"); 179 | // press the bottom of the screen to erase 180 | tft.fillRect(0, BOXSIZE, tft.width(), tft.height()-BOXSIZE, BLACK); 181 | } 182 | // scale from 0->1023 to tft.width 183 | p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0); 184 | p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0); 185 | /* 186 | Serial.print("("); Serial.print(p.x); 187 | Serial.print(", "); Serial.print(p.y); 188 | Serial.println(")"); 189 | */ 190 | if (p.y < BOXSIZE) { 191 | oldcolor = currentcolor; 192 | 193 | if ((tft.width() - p.x) < BOXSIZE) { 194 | currentcolor = RED; 195 | tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE); 196 | } else if ((tft.width() - p.x) < BOXSIZE*2) { 197 | currentcolor = YELLOW; 198 | tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE); 199 | } else if ((tft.width() - p.x) < BOXSIZE*3) { 200 | currentcolor = GREEN; 201 | tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, WHITE); 202 | } else if ((tft.width() - p.x) < BOXSIZE*4) { 203 | currentcolor = CYAN; 204 | tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, WHITE); 205 | } else if ((tft.width() - p.x) < BOXSIZE*5) { 206 | currentcolor = BLUE; 207 | tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, WHITE); 208 | } else if ((tft.width() - p.x) < BOXSIZE*6) { 209 | currentcolor = MAGENTA; 210 | tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, WHITE); 211 | } 212 | 213 | 214 | if (oldcolor != currentcolor) { 215 | 216 | if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED); 217 | if (oldcolor == YELLOW) tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW); 218 | if (oldcolor == GREEN) tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, GREEN); 219 | if (oldcolor == CYAN) tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, CYAN); 220 | if (oldcolor == BLUE) tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, BLUE); 221 | if (oldcolor == MAGENTA) tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, MAGENTA); 222 | 223 | } 224 | } 225 | if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) { 226 | tft.fillCircle((tft.width() - p.x), p.y, PENRADIUS, currentcolor); 227 | } 228 | } 229 | } 230 | 231 | -------------------------------------------------------------------------------- /Tutorials/ARDUINO BASED DESIGN.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elementzonline/Arduino-Sample-Codes/95555cc74db6fe2744a93e509737359df05a6a14/Tutorials/ARDUINO BASED DESIGN.pptx -------------------------------------------------------------------------------- /Tutorials/ARDUINO IDE.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elementzonline/Arduino-Sample-Codes/95555cc74db6fe2744a93e509737359df05a6a14/Tutorials/ARDUINO IDE.pdf -------------------------------------------------------------------------------- /Tutorials/Arduino UNO.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elementzonline/Arduino-Sample-Codes/95555cc74db6fe2744a93e509737359df05a6a14/Tutorials/Arduino UNO.pptx -------------------------------------------------------------------------------- /Tutorials/Arduino_ADC.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elementzonline/Arduino-Sample-Codes/95555cc74db6fe2744a93e509737359df05a6a14/Tutorials/Arduino_ADC.pptx -------------------------------------------------------------------------------- /Tutorials/IntroductionToArduino_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elementzonline/Arduino-Sample-Codes/95555cc74db6fe2744a93e509737359df05a6a14/Tutorials/IntroductionToArduino_2.pdf -------------------------------------------------------------------------------- /Tutorials/SERIAL COMMUNICATION.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elementzonline/Arduino-Sample-Codes/95555cc74db6fe2744a93e509737359df05a6a14/Tutorials/SERIAL COMMUNICATION.pptx -------------------------------------------------------------------------------- /e-Tracker/README.md: -------------------------------------------------------------------------------- 1 | Arduino-Sample-Codes 2 | ==================== 3 | 4 | Arduino Sample for eTracker module 5 | 6 | Required: Arduino IDE - 1.6.12 or above 7 | 8 | Also tested with Latest release of VisualMicro(use Arduino 1.6.12 or latter as IDE ) in Atmel Studio 7 -------------------------------------------------------------------------------- /e-Tracker/examples/FileStorageOperations/FileStorageOperations.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | 6 | SoftwareSerial myserialOut(3, 2); 7 | ElementzGSMshield GSM(&myserialOut); 8 | char driveName; 9 | 10 | void setup() { 11 | // put your setup code here, to run once: 12 | Serial.begin(9600); 13 | GSM.begin(9600); 14 | delay(1500); 15 | 16 | if (GSM.checkSDmode())//Checking Whether SDMODE is activated 17 | { 18 | Serial.println("SDMODE activated"); 19 | } 20 | else 21 | { 22 | Serial.println("SDMODE is not activated"); 23 | GSM.prepareForSDcard();//if not activated preparing for SDcard. Do this only one time. 24 | delay(15000); 25 | if (GSM.checkSDmode()) 26 | { 27 | Serial.println("SDMDOE activation success"); 28 | } 29 | } 30 | 31 | 32 | GSM.viewFileStorageMemoryInfo();//You can get an info of memory using this function. This function returns nothing 33 | 34 | driveName = GSM.getDriveLabel(LOCAL);//LOCAL for local sotrage memory. 35 | Serial.println(driveName); 36 | driveName = GSM.getDriveLabel(SDCARD);//SDCARD for external drive 37 | Serial.println(driveName); 38 | 39 | //Use this function to get a list of files and folders inside the drive/path. 40 | GSM.viewFilelist(driveName, 3); //the second argument means how many files need to be listed 41 | GSM.createDirectory(driveName, "Test"); //Function for creating a directory 42 | GSM.viewFilelist(driveName, 4); // you can view the created directory using this function 43 | 44 | GSM.createFile("D:\\Test\\", "testing.txt"); //Function for creating a file 45 | GSM.viewFilelist("D:\\Test\\", 2); //you can view the created file using this function 46 | 47 | GSM.renameFile("D:\\Test\\testing.txt", "D:\\Test\\test.txt"); //function for renaming a file 48 | GSM.viewFilelist("D:\\Test\\", 2); //view the change in name 49 | 50 | uint16_t fileSize = GSM.getFileSize("D:\\Test\\test.txt"); //you can know the file size using this function 51 | Serial.print("File Size = "); 52 | Serial.println(fileSize); 53 | 54 | GSM.writeTotheBeginningofFile("D:\\Test\\test.txt", "Elementz Engineers", 18, 10); //To write to the beginning of the file use this function 55 | fileSize = GSM.getFileSize("D:\\Test\\test.txt"); //see the change in file size when data added 56 | Serial.print("File Size = "); 57 | Serial.println(fileSize); 58 | 59 | Serial.println(GSM.readFromtheBeginningOftheFile("D:\\Test\\test.txt", 20, 1)); //Use this function to read from thebeginning of a file 60 | 61 | GSM.appendContenttoTheEndoftheFile("D:\\Test\\test.txt", " Guild Pvt Ltd", 14, 10); //To append data to the end of the file use this function 62 | fileSize = GSM.getFileSize("D:\\Test\\test.txt");//see the change in file size 63 | Serial.print("File Size = "); 64 | Serial.println(fileSize); 65 | 66 | Serial.println(GSM.readFromtheBeginningOftheFile("D:\\Test\\test.txt", 40, 1)); 67 | 68 | Serial.println(GSM.readFromposition("D:\\Test\\test.txt", 40, 19, 1)); //to read froma particular position use this function. 69 | 70 | GSM.removeFile("D:\\Test\\test.txt"); // to remove any file use this function 71 | GSM.removeDirectory("D:\\Test");// to remove any directory use this function. Remove the file inside before removing the directory. 72 | } 73 | void loop() { 74 | 75 | } 76 | 77 | -------------------------------------------------------------------------------- /e-Tracker/examples/GNSSdata/GNSSdata.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | SoftwareSerial myserialOut(3,2); 6 | ElementzGSMshield GSM(&myserialOut); 7 | String testString = ""; 8 | void setup() { 9 | 10 | Serial.begin(9600); 11 | GSM.begin(9600); 12 | Serial.println("Starting"); 13 | delay(1000); 14 | GSM.turnOnGNSS(); 15 | String testString = GSM.getGNSSInfo(); 16 | Serial.println(testString); 17 | GSM.turnOffGNSS(); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /e-Tracker/examples/HTTPget/HTTPget.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | 6 | SoftwareSerial myserialOut(3,2); 7 | ElementzGSMshield GSM(&myserialOut); 8 | 9 | void setup() { 10 | 11 | Serial.begin(9600); 12 | GSM.begin(9600); 13 | Serial.println("Starting"); 14 | delay(1000); 15 | 16 | GSM.turnOnGPRS("WWW.MYAIRTELGPRS.COM"); 17 | GSM.sendHTTPDATA("http://ec2-52-24-224-220.us-west-2.compute.amazonaws.com/tgps.php?Data=thisisanewdata"); 18 | //check this url to view data http://ec2-52-24-224-220.us-west-2.compute.amazonaws.com/tgps808log.txt 19 | 20 | } 21 | void loop() { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /e-Tracker/examples/HTTPgetGNSS/HTTPgetGNSS.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | String URL = "http://ec2-52-24-224-220.us-west-2.compute.amazonaws.com/tgps.php?Data="; 6 | SoftwareSerial myserialOut(3,2); 7 | ElementzGSMshield GSM(&myserialOut); 8 | String testString = ""; 9 | 10 | void setup() { 11 | // put your setup code here, to run once: 12 | Serial.begin(9600); 13 | GSM.begin(9600); 14 | Serial.println("Starting"); 15 | delay(1000); 16 | 17 | GSM.turnOnGPRS("WWW.MYAIRTELGPRS.COM"); 18 | GSM.turnOnGNSS(); 19 | testString = GSM.getProcessedGNSSInfo(); 20 | Serial.println(testString); 21 | GSM.sendHTTPDATA(URL + testString); 22 | //go to this url to view data http://ec2-52-24-224-220.us-west-2.compute.amazonaws.com/tgps808log.txt 23 | 24 | } 25 | void loop() { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /e-Tracker/examples/MakeCall/MakeCall.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | char phone_number[11] = "9605xxxxxx"; 6 | String phone2 = "7356xxxxxx"; 7 | SoftwareSerial myserialOut(3,2); 8 | ElementzGSMshield GSM(&myserialOut); 9 | String testString = ""; 10 | void setup() { 11 | Serial.begin(9600); 12 | GSM.begin(9600); 13 | Serial.println("Starting"); 14 | delay(1000); 15 | Serial.println("Calling First Number"); 16 | GSM.makeCall(phone_number);//number const char type 17 | delay(10000); 18 | Serial.println("Disconnecting First call"); 19 | GSM.hangUp(); 20 | Serial.println("Calling Second Number"); 21 | GSM.makeCall(phone2);//number is string type 22 | delay(10000); 23 | Serial.println("Disconnecting Second call"); 24 | GSM.hangUp(); 25 | 26 | 27 | 28 | } 29 | 30 | void loop() { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /e-Tracker/examples/SMSsending/SMSsending.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | 6 | SoftwareSerial myserialOut(3,2); 7 | ElementzGSMshield GSM(&myserialOut); 8 | String testString = ""; 9 | void setup() { 10 | Serial.begin(9600); 11 | GSM.begin(9600); 12 | Serial.println("Starting"); 13 | delay(1000); 14 | GSM.sendSMSintextFormat(); 15 | 16 | boolean sms_status = GSM.sendSms("7356xxxxxx", "Test Message");//you can input the number also as a String object 17 | if (sms_status == true) 18 | { 19 | Serial.println("SMS Send"); 20 | } 21 | else 22 | { 23 | Serial.println("SMS sending Failed"); 24 | } 25 | 26 | 27 | 28 | 29 | } 30 | 31 | void loop() { 32 | 33 | } 34 | -------------------------------------------------------------------------------- /e-Tracker/examples/SendingMail/SendingMail.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ElementzGSM.h" 4 | 5 | 6 | char message[29] = "Sending from Arduino Success"; 7 | uint8_t email_timeout = 30;//in seconds 8 | SoftwareSerial myserialOut(3,2); 9 | ElementzGSMshield GSM(&myserialOut); 10 | String testString = ""; 11 | void setup() { 12 | 13 | Serial.begin(9600); 14 | GSM.begin(9600); 15 | Serial.println("Starting"); 16 | delay(1000); 17 | 18 | 19 | 20 | GSM.turnOnGPRS("WWW.MYAIRTELGPRS.COM"); 21 | GSM.setupEmailServer("xx-xx-x.xxxxxx.xxx", 25, email_timeout); //outgoing server address and port 25 is default port. You can get this from email client setup section of your mail 22 | GSM.setupEmailAuthorization("user@mail.com", "password", "Your Name"); //username(mail ID), password, Name; 23 | GSM.setupEmailToAddress("recepient@mail.com");//To address 24 | GSM.setEmailSubject("Testing from Arduino part2");//Subject 25 | GSM.sendEmailWithContent(message, 28); //Content 26 | 27 | //-------or send a string data as------------// 28 | 29 | GSM.turnOnGPRS("WWW.MYAIRTELGPRS.COM"); 30 | GSM.setupEmailServer("xx-xx-x.xxxxxx.xxx", 25, email_timeout); //outgoing server address and port 25 is default port. You can get this from email client setup section of your mail 31 | GSM.setupEmailAuthorization("user@mail.com", "password", "Your Name"); //username(mail ID), password, Name; 32 | GSM.setupEmailToAddress("recepient@mail.com");//To address 33 | GSM.setEmailSubject("Testing from Arduino part2");//Subject 34 | GSM.sendEmailWithContent("Sending from Arduino Success", 28); //Content 35 | 36 | 37 | } 38 | 39 | void loop() { 40 | 41 | } 42 | -------------------------------------------------------------------------------- /e-Tracker/examples/SimpleATTest/SimpleATTest.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SoftwareSerial.h" 3 | #include "ElementzGSM.h" 4 | 5 | SoftwareSerial myserialOut(3, 2); 6 | ElementzGSMshield GSM(&myserialOut); 7 | 8 | void setup(/* arguments */) { 9 | /* code */ 10 | Serial.begin(9600); 11 | GSM.begin(9600); 12 | Serial.println("Starting"); 13 | delay(2000); 14 | 15 | GSM.SendAT("AT", "OK", 1000, 2); 16 | GSM.SendAT("AT+CREG?", "+CREG: 0,0", 1000, 2); 17 | } 18 | 19 | 20 | 21 | void loop(/* arguments */) { 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /e-Tracker/libraries/ElementzGSM.h: -------------------------------------------------------------------------------- 1 | #ifndef ELEMENTZGSM_H 2 | #define ELEMENTZGSM_H 3 | #include 4 | #include "SoftwareSerial.h" 5 | 6 | #define MESSAGELINES 5 7 | //#define PinRX 2 8 | //#define PinTX 3 9 | 10 | #define DEBUG 1 11 | 12 | #define LOCAL 0 13 | #define SDCARD 1 14 | 15 | class ElementzGSMshield { 16 | public: 17 | ElementzGSMshield(SoftwareSerial *); 18 | // GSM(uint8_t PinRX, uint8_t PinTX); 19 | void begin(long ); 20 | void SendAT(String ATCommand); 21 | void SendAT(const char ATCommand); 22 | boolean SendAT(const char* ATCommand, const char* exptReply, uint32_t timeout, int retry); 23 | boolean SendAT(String ATCommand, const char* exptReply, uint32_t timeout, int retry); 24 | boolean SendAT(String ATCommand, const char* exptReply, uint32_t timeout, int retry, uint8_t noOflines); 25 | boolean waitResponse(const char* exptReply, uint32_t timeout); 26 | boolean waitResponse(const char* exptReply, uint32_t timeout, uint8_t noOflines); 27 | boolean EchoOFF(); 28 | boolean EchoON(); 29 | String readReply(uint32_t timeout); 30 | String readReply( uint32_t timeout, uint8_t expctd_num_of_lines); 31 | boolean makeCall(const char* phone_number); 32 | boolean makeCall(String phone_number); 33 | boolean hangUp(void); 34 | boolean sendSMSintextFormat(void); 35 | boolean sendSMSinPDUformat(void); 36 | boolean sendSms(const char* phone_number, const char* Content); 37 | boolean sendSms(String phone_number, String Content); 38 | String readSMS(uint8_t index); 39 | boolean checkGprsStatus(void); 40 | boolean turnOnGPRS(String APN); 41 | boolean turnOnGPRS(const char* APN); 42 | boolean turnOffGPRS(void); 43 | boolean setupEmailServer(String OutGoingServer, uint16_t Port, uint8_t timeout); 44 | boolean setupEmailAuthorization(String Username, String Password, String Name); 45 | boolean setupEmailAuthorization(String Username, String Password); 46 | boolean setupEmailToAddress(String mailId, String Name); 47 | boolean setupEmailToAddress(String mailId); 48 | boolean setupEmailCcAddress(String mailId, String Name); 49 | boolean setupEmailCcAddress(String mailId); 50 | boolean setupEmailBccAddress(String mailId, String Name); 51 | boolean setupEmailBccAddress(String mailId); 52 | boolean setEmailSubject(String Subject); 53 | boolean sendEmailWithContent(String Content, uint8_t length); 54 | boolean sendEmailWithContent(const char* Content, uint8_t length); 55 | boolean turnOnGNSS(void); 56 | boolean turnOffGNSS(void); 57 | String getGNSSInfo(void); 58 | boolean initializeHTTPService(void); 59 | boolean terminateHTTPService(void); 60 | boolean sendHTTPDATA(const char* URL_attached_with_data); 61 | boolean sendHTTPDATA(String URL_attached_with_data); 62 | String getProcessedGNSSInfo(void); 63 | boolean restartGSMmodem(void); 64 | boolean urgentPowerDown(void); 65 | boolean normalPowerDown(void); 66 | boolean writeTomemory(void); 67 | boolean checkSDmode(void); 68 | boolean prepareForSDcard(void); 69 | char getDriveLabel(char requiredDrive); 70 | void viewFileStorageMemoryInfo(void); 71 | boolean createFile(const char *path, const char *fileName); 72 | boolean createFile(char path, const char *fileName); 73 | boolean createDirectory(char path, const char *directoryname); 74 | boolean createDirectory(const char *path, const char *directoryname); 75 | void viewFilelist(char path, char noOffiles); 76 | void viewFilelist(const char *path, char noOffiles); 77 | boolean renameFile(const char *oldNamewithPath, const char *newNamewithPath); 78 | boolean removeDirectory(const char *directoryNameWithPath); 79 | boolean removeFile(const char *fileNameWithPath); 80 | boolean writeTotheBeginningofFile(const char *fileNameWithPath, const char *Content, uint16_t sizeOftheFile, uint8_t timeInSeconds); 81 | boolean appendContenttoTheEndoftheFile(const char *fileNameWithPath, const char *Content, uint16_t sizeOftheFile, uint8_t timeInSeconds); 82 | String readFromtheBeginningOftheFile(const char *fileNameWithPath, uint16_t sizeTobeRead, uint8_t linesTobeRead); 83 | String readFromposition(const char *fileNameWithPath, uint16_t sizeTobeRead, uint16_t position, uint8_t linesTobeRead); 84 | uint16_t getFileSize(const char *fileNameWithPath); 85 | 86 | 87 | private: 88 | boolean setupEmailFromAddress(String mailId, String Name); 89 | boolean setupEmailFromAddress(String mailId); 90 | boolean checkForExptReplyinRcvdString(String recvdString, const char* exptReply); 91 | 92 | Stream *mySerial; 93 | SoftwareSerial *gsmSerial; 94 | }; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /ePaper_Elementz/ePaper_Elementz.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Modified by Navaneeth Krishnan, For Elementz Engineers Guild Pvt Ltd 3 | */ 4 | #include 5 | #include "epd2in9.h" 6 | #include "epdpaint.h" 7 | #include "imagedata.h" 8 | 9 | #define COLORED 1 10 | #define UNCOLORED 0 11 | 12 | unsigned char image[1024]; 13 | Paint paint(image, 0, 0); 14 | Epd epd; 15 | 16 | void setup() { 17 | // put your setup code here, to run once: 18 | Serial.begin(9600); 19 | if (epd.Init(lut_full_update) != 0) { 20 | Serial.print("e-Paper init failed"); 21 | return; 22 | } 23 | epd.ClearFrameMemory(0xFF); // bit set = white, bit reset = black 24 | epd.DisplayFrame(); 25 | epd.ClearFrameMemory(0xFF); // bit set = white, bit reset = black 26 | epd.DisplayFrame(); 27 | 28 | epd.SetFrameMemory(IMAGE_DATA); 29 | epd.DisplayFrame(); 30 | epd.SetFrameMemory(IMAGE_DATA); 31 | epd.DisplayFrame(); 32 | 33 | paint.SetRotate(ROTATE_90); 34 | paint.SetWidth(20); 35 | paint.SetHeight(30); 36 | 37 | paint.Clear(COLORED); 38 | paint.DrawStringAt(0, 0, "DEMO", &Font12, UNCOLORED); 39 | epd.SetFrameMemory(paint.GetImage(), 75, 250, paint.GetWidth(), paint.GetHeight()); 40 | epd.DisplayFrame(); 41 | } 42 | void loop() { 43 | // put your main code here, to run repeatedly: 44 | 45 | } 46 | -------------------------------------------------------------------------------- /ePaper_Elementz/epd2in9.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @filename : epd2in9.cpp 3 | * @brief : Implements for e-paper library 4 | * @author : Yehui from Waveshare 5 | * 6 | * Copyright (C) Waveshare September 9 2017 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documnetation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #include 28 | #include "epd2in9.h" 29 | 30 | Epd::~Epd() { 31 | }; 32 | 33 | Epd::Epd() { 34 | reset_pin = RST_PIN; 35 | dc_pin = DC_PIN; 36 | cs_pin = CS_PIN; 37 | busy_pin = BUSY_PIN; 38 | width = EPD_WIDTH; 39 | height = EPD_HEIGHT; 40 | }; 41 | 42 | int Epd::Init(const unsigned char* lut) { 43 | /* this calls the peripheral hardware interface, see epdif */ 44 | if (IfInit() != 0) { 45 | return -1; 46 | } 47 | /* EPD hardware init start */ 48 | this->lut = lut; 49 | Reset(); 50 | SendCommand(DRIVER_OUTPUT_CONTROL); 51 | SendData((EPD_HEIGHT - 1) & 0xFF); 52 | SendData(((EPD_HEIGHT - 1) >> 8) & 0xFF); 53 | SendData(0x00); // GD = 0; SM = 0; TB = 0; 54 | SendCommand(BOOSTER_SOFT_START_CONTROL); 55 | SendData(0xD7); 56 | SendData(0xD6); 57 | SendData(0x9D); 58 | SendCommand(WRITE_VCOM_REGISTER); 59 | SendData(0xA8); // VCOM 7C 60 | SendCommand(SET_DUMMY_LINE_PERIOD); 61 | SendData(0x1A); // 4 dummy lines per gate 62 | SendCommand(SET_GATE_TIME); 63 | SendData(0x08); // 2us per line 64 | SendCommand(DATA_ENTRY_MODE_SETTING); 65 | SendData(0x03); // X increment; Y increment 66 | SetLut(this->lut); 67 | /* EPD hardware init end */ 68 | return 0; 69 | } 70 | 71 | /** 72 | * @brief: basic function for sending commands 73 | */ 74 | void Epd::SendCommand(unsigned char command) { 75 | DigitalWrite(dc_pin, LOW); 76 | SpiTransfer(command); 77 | } 78 | 79 | /** 80 | * @brief: basic function for sending data 81 | */ 82 | void Epd::SendData(unsigned char data) { 83 | DigitalWrite(dc_pin, HIGH); 84 | SpiTransfer(data); 85 | } 86 | 87 | /** 88 | * @brief: Wait until the busy_pin goes LOW 89 | */ 90 | void Epd::WaitUntilIdle(void) { 91 | while(DigitalRead(busy_pin) == HIGH) { //LOW: idle, HIGH: busy 92 | DelayMs(100); 93 | } 94 | } 95 | 96 | /** 97 | * @brief: module reset. 98 | * often used to awaken the module in deep sleep, 99 | * see Epd::Sleep(); 100 | */ 101 | void Epd::Reset(void) { 102 | DigitalWrite(reset_pin, LOW); //module reset 103 | DelayMs(200); 104 | DigitalWrite(reset_pin, HIGH); 105 | DelayMs(200); 106 | } 107 | 108 | /** 109 | * @brief: set the look-up table register 110 | */ 111 | void Epd::SetLut(const unsigned char* lut) { 112 | this->lut = lut; 113 | SendCommand(WRITE_LUT_REGISTER); 114 | /* the length of look-up table is 30 bytes */ 115 | for (int i = 0; i < 30; i++) { 116 | SendData(this->lut[i]); 117 | } 118 | } 119 | 120 | /** 121 | * @brief: put an image buffer to the frame memory. 122 | * this won't update the display. 123 | */ 124 | void Epd::SetFrameMemory( 125 | const unsigned char* image_buffer, 126 | int x, 127 | int y, 128 | int image_width, 129 | int image_height 130 | ) { 131 | int x_end; 132 | int y_end; 133 | 134 | if ( 135 | image_buffer == NULL || 136 | x < 0 || image_width < 0 || 137 | y < 0 || image_height < 0 138 | ) { 139 | return; 140 | } 141 | /* x point must be the multiple of 8 or the last 3 bits will be ignored */ 142 | x &= 0xF8; 143 | image_width &= 0xF8; 144 | if (x + image_width >= this->width) { 145 | x_end = this->width - 1; 146 | } else { 147 | x_end = x + image_width - 1; 148 | } 149 | if (y + image_height >= this->height) { 150 | y_end = this->height - 1; 151 | } else { 152 | y_end = y + image_height - 1; 153 | } 154 | SetMemoryArea(x, y, x_end, y_end); 155 | SetMemoryPointer(x, y); 156 | SendCommand(WRITE_RAM); 157 | /* send the image data */ 158 | for (int j = 0; j < y_end - y + 1; j++) { 159 | for (int i = 0; i < (x_end - x + 1) / 8; i++) { 160 | SendData(image_buffer[i + j * (image_width / 8)]); 161 | } 162 | } 163 | } 164 | 165 | /** 166 | * @brief: put an image buffer to the frame memory. 167 | * this won't update the display. 168 | * 169 | * Question: When do you use this function instead of 170 | * void SetFrameMemory( 171 | * const unsigned char* image_buffer, 172 | * int x, 173 | * int y, 174 | * int image_width, 175 | * int image_height 176 | * ); 177 | * Answer: SetFrameMemory with parameters only reads image data 178 | * from the RAM but not from the flash in AVR chips (for AVR chips, 179 | * you have to use the function pgm_read_byte to read buffers 180 | * from the flash). 181 | */ 182 | void Epd::SetFrameMemory(const unsigned char* image_buffer) { 183 | SetMemoryArea(0, 0, this->width - 1, this->height - 1); 184 | SetMemoryPointer(0, 0); 185 | SendCommand(WRITE_RAM); 186 | /* send the image data */ 187 | for (int i = 0; i < this->width / 8 * this->height; i++) { 188 | SendData(pgm_read_byte(&image_buffer[i])); 189 | } 190 | } 191 | 192 | /** 193 | * @brief: clear the frame memory with the specified color. 194 | * this won't update the display. 195 | */ 196 | void Epd::ClearFrameMemory(unsigned char color) { 197 | SetMemoryArea(0, 0, this->width - 1, this->height - 1); 198 | SetMemoryPointer(0, 0); 199 | SendCommand(WRITE_RAM); 200 | /* send the color data */ 201 | for (int i = 0; i < this->width / 8 * this->height; i++) { 202 | SendData(color); 203 | } 204 | } 205 | 206 | /** 207 | * @brief: update the display 208 | * there are 2 memory areas embedded in the e-paper display 209 | * but once this function is called, 210 | * the the next action of SetFrameMemory or ClearFrame will 211 | * set the other memory area. 212 | */ 213 | void Epd::DisplayFrame(void) { 214 | SendCommand(DISPLAY_UPDATE_CONTROL_2); 215 | SendData(0xC4); 216 | SendCommand(MASTER_ACTIVATION); 217 | SendCommand(TERMINATE_FRAME_READ_WRITE); 218 | WaitUntilIdle(); 219 | } 220 | 221 | /** 222 | * @brief: private function to specify the memory area for data R/W 223 | */ 224 | void Epd::SetMemoryArea(int x_start, int y_start, int x_end, int y_end) { 225 | SendCommand(SET_RAM_X_ADDRESS_START_END_POSITION); 226 | /* x point must be the multiple of 8 or the last 3 bits will be ignored */ 227 | SendData((x_start >> 3) & 0xFF); 228 | SendData((x_end >> 3) & 0xFF); 229 | SendCommand(SET_RAM_Y_ADDRESS_START_END_POSITION); 230 | SendData(y_start & 0xFF); 231 | SendData((y_start >> 8) & 0xFF); 232 | SendData(y_end & 0xFF); 233 | SendData((y_end >> 8) & 0xFF); 234 | } 235 | 236 | /** 237 | * @brief: private function to specify the start point for data R/W 238 | */ 239 | void Epd::SetMemoryPointer(int x, int y) { 240 | SendCommand(SET_RAM_X_ADDRESS_COUNTER); 241 | /* x point must be the multiple of 8 or the last 3 bits will be ignored */ 242 | SendData((x >> 3) & 0xFF); 243 | SendCommand(SET_RAM_Y_ADDRESS_COUNTER); 244 | SendData(y & 0xFF); 245 | SendData((y >> 8) & 0xFF); 246 | WaitUntilIdle(); 247 | } 248 | 249 | /** 250 | * @brief: After this command is transmitted, the chip would enter the 251 | * deep-sleep mode to save power. 252 | * The deep sleep mode would return to standby by hardware reset. 253 | * You can use Epd::Init() to awaken 254 | */ 255 | void Epd::Sleep() { 256 | SendCommand(DEEP_SLEEP_MODE); 257 | WaitUntilIdle(); 258 | } 259 | 260 | const unsigned char lut_full_update[] = 261 | { 262 | 0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 263 | 0x66, 0x69, 0x69, 0x59, 0x58, 0x99, 0x99, 0x88, 264 | 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB4, 0x13, 0x51, 265 | 0x35, 0x51, 0x51, 0x19, 0x01, 0x00 266 | }; 267 | 268 | const unsigned char lut_partial_update[] = 269 | { 270 | 0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00, 271 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 272 | 0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, 273 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 274 | }; 275 | 276 | 277 | /* END OF FILE */ 278 | 279 | 280 | -------------------------------------------------------------------------------- /ePaper_Elementz/epd2in9.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @filename : epd2in9.h 3 | * @brief : Header file for e-paper display library epd2in9.cpp 4 | * @author : Yehui from Waveshare 5 | * 6 | * Copyright (C) Waveshare September 5 2017 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documnetation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #ifndef EPD2IN9_H 28 | #define EPD2IN9_H 29 | 30 | #include "epdif.h" 31 | 32 | // Display resolution 33 | #define EPD_WIDTH 128 34 | #define EPD_HEIGHT 296 35 | 36 | // EPD2IN9 commands 37 | #define DRIVER_OUTPUT_CONTROL 0x01 38 | #define BOOSTER_SOFT_START_CONTROL 0x0C 39 | #define GATE_SCAN_START_POSITION 0x0F 40 | #define DEEP_SLEEP_MODE 0x10 41 | #define DATA_ENTRY_MODE_SETTING 0x11 42 | #define SW_RESET 0x12 43 | #define TEMPERATURE_SENSOR_CONTROL 0x1A 44 | #define MASTER_ACTIVATION 0x20 45 | #define DISPLAY_UPDATE_CONTROL_1 0x21 46 | #define DISPLAY_UPDATE_CONTROL_2 0x22 47 | #define WRITE_RAM 0x24 48 | #define WRITE_VCOM_REGISTER 0x2C 49 | #define WRITE_LUT_REGISTER 0x32 50 | #define SET_DUMMY_LINE_PERIOD 0x3A 51 | #define SET_GATE_TIME 0x3B 52 | #define BORDER_WAVEFORM_CONTROL 0x3C 53 | #define SET_RAM_X_ADDRESS_START_END_POSITION 0x44 54 | #define SET_RAM_Y_ADDRESS_START_END_POSITION 0x45 55 | #define SET_RAM_X_ADDRESS_COUNTER 0x4E 56 | #define SET_RAM_Y_ADDRESS_COUNTER 0x4F 57 | #define TERMINATE_FRAME_READ_WRITE 0xFF 58 | 59 | extern const unsigned char lut_full_update[]; 60 | extern const unsigned char lut_partial_update[]; 61 | 62 | class Epd : EpdIf { 63 | public: 64 | unsigned long width; 65 | unsigned long height; 66 | 67 | Epd(); 68 | ~Epd(); 69 | int Init(const unsigned char* lut); 70 | void SendCommand(unsigned char command); 71 | void SendData(unsigned char data); 72 | void WaitUntilIdle(void); 73 | void Reset(void); 74 | void SetFrameMemory( 75 | const unsigned char* image_buffer, 76 | int x, 77 | int y, 78 | int image_width, 79 | int image_height 80 | ); 81 | void SetFrameMemory(const unsigned char* image_buffer); 82 | void ClearFrameMemory(unsigned char color); 83 | void DisplayFrame(void); 84 | void Sleep(void); 85 | 86 | private: 87 | unsigned int reset_pin; 88 | unsigned int dc_pin; 89 | unsigned int cs_pin; 90 | unsigned int busy_pin; 91 | const unsigned char* lut; 92 | 93 | void SetLut(const unsigned char* lut); 94 | void SetMemoryArea(int x_start, int y_start, int x_end, int y_end); 95 | void SetMemoryPointer(int x, int y); 96 | }; 97 | 98 | #endif /* EPD2IN9_H */ 99 | 100 | /* END OF FILE */ 101 | -------------------------------------------------------------------------------- /ePaper_Elementz/epdif.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @filename : epdif.cpp 3 | * @brief : Implements EPD interface functions 4 | * Users have to implement all the functions in epdif.cpp 5 | * @author : Yehui from Waveshare 6 | * 7 | * Copyright (C) Waveshare August 10 2017 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documnetation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | 28 | #include "epdif.h" 29 | #include 30 | 31 | EpdIf::EpdIf() { 32 | }; 33 | 34 | EpdIf::~EpdIf() { 35 | }; 36 | 37 | void EpdIf::DigitalWrite(int pin, int value) { 38 | digitalWrite(pin, value); 39 | } 40 | 41 | int EpdIf::DigitalRead(int pin) { 42 | return digitalRead(pin); 43 | } 44 | 45 | void EpdIf::DelayMs(unsigned int delaytime) { 46 | delay(delaytime); 47 | } 48 | 49 | void EpdIf::SpiTransfer(unsigned char data) { 50 | digitalWrite(CS_PIN, LOW); 51 | SPI.transfer(data); 52 | digitalWrite(CS_PIN, HIGH); 53 | } 54 | 55 | int EpdIf::IfInit(void) { 56 | pinMode(CS_PIN, OUTPUT); 57 | pinMode(RST_PIN, OUTPUT); 58 | pinMode(DC_PIN, OUTPUT); 59 | pinMode(BUSY_PIN, INPUT); 60 | SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0)); 61 | SPI.begin(); 62 | return 0; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /ePaper_Elementz/epdif.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @filename : epdif.h 3 | * @brief : Header file of epdif.cpp providing EPD interface functions 4 | * Users have to implement all the functions in epdif.cpp 5 | * @author : Yehui from Waveshare 6 | * 7 | * Copyright (C) Waveshare August 10 2017 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documnetation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | 28 | #ifndef EPDIF_H 29 | #define EPDIF_H 30 | 31 | #include 32 | 33 | // Pin definition 34 | #define RST_PIN 8 35 | #define DC_PIN 9 36 | #define CS_PIN 10 37 | #define BUSY_PIN 7 38 | 39 | class EpdIf { 40 | public: 41 | EpdIf(void); 42 | ~EpdIf(void); 43 | 44 | static int IfInit(void); 45 | static void DigitalWrite(int pin, int value); 46 | static int DigitalRead(int pin); 47 | static void DelayMs(unsigned int delaytime); 48 | static void SpiTransfer(unsigned char data); 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /ePaper_Elementz/epdpaint.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @filename : epdpaint.h 3 | * @brief : Header file for epdpaint.cpp 4 | * @author : Yehui from Waveshare 5 | * 6 | * Copyright (C) Waveshare July 28 2017 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documnetation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #ifndef EPDPAINT_H 28 | #define EPDPAINT_H 29 | 30 | // Display orientation 31 | #define ROTATE_0 0 32 | #define ROTATE_90 1 33 | #define ROTATE_180 2 34 | #define ROTATE_270 3 35 | 36 | // Color inverse. 1 or 0 = set or reset a bit if set a colored pixel 37 | #define IF_INVERT_COLOR 1 38 | 39 | #include "fonts.h" 40 | 41 | class Paint { 42 | public: 43 | Paint(unsigned char* image, int width, int height); 44 | ~Paint(); 45 | void Clear(int colored); 46 | int GetWidth(void); 47 | void SetWidth(int width); 48 | int GetHeight(void); 49 | void SetHeight(int height); 50 | int GetRotate(void); 51 | void SetRotate(int rotate); 52 | unsigned char* GetImage(void); 53 | void DrawAbsolutePixel(int x, int y, int colored); 54 | void DrawPixel(int x, int y, int colored); 55 | void DrawCharAt(int x, int y, char ascii_char, sFONT* font, int colored); 56 | void DrawStringAt(int x, int y, const char* text, sFONT* font, int colored); 57 | void DrawLine(int x0, int y0, int x1, int y1, int colored); 58 | void DrawHorizontalLine(int x, int y, int width, int colored); 59 | void DrawVerticalLine(int x, int y, int height, int colored); 60 | void DrawRectangle(int x0, int y0, int x1, int y1, int colored); 61 | void DrawFilledRectangle(int x0, int y0, int x1, int y1, int colored); 62 | void DrawCircle(int x, int y, int radius, int colored); 63 | void DrawFilledCircle(int x, int y, int radius, int colored); 64 | 65 | private: 66 | unsigned char* image; 67 | int width; 68 | int height; 69 | int rotate; 70 | }; 71 | 72 | #endif 73 | 74 | /* END OF FILE */ 75 | 76 | -------------------------------------------------------------------------------- /ePaper_Elementz/fonts.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file fonts.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 18-February-2014 7 | * @brief Header for fonts.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2014 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __FONTS_H 40 | #define __FONTS_H 41 | 42 | /* Max size of bitmap will based on a font24 (17x24) */ 43 | #define MAX_HEIGHT_FONT 24 44 | #define MAX_WIDTH_FONT 17 45 | #define OFFSET_BITMAP 54 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /* Includes ------------------------------------------------------------------*/ 52 | #include 53 | 54 | typedef struct _tFont 55 | { 56 | const uint8_t *table; 57 | uint16_t Width; 58 | uint16_t Height; 59 | 60 | } sFONT; 61 | 62 | extern sFONT Font24; 63 | extern sFONT Font20; 64 | extern sFONT Font16; 65 | extern sFONT Font12; 66 | extern sFONT Font8; 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __FONTS_H */ 73 | 74 | 75 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 76 | -------------------------------------------------------------------------------- /ePaper_Elementz/imagedata.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @filename : imagedata.h 3 | * @brief : head file for imagedata.cpp 4 | * 5 | * Copyright (C) Waveshare September 5 2017 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documnetation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | extern const unsigned char IMAGE_DATA[]; 27 | 28 | /* FILE END */ 29 | 30 | 31 | -------------------------------------------------------------------------------- /send_sms_with_esp32_sim800l_TTGO/send_sms_with_esp32_sim800l/send_sms_with_esp32_sim800l.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | // SIM card PIN (leave empty, if not defined) 4 | const char simPIN[] = ""; 5 | 6 | // Your phone number to send SMS: + (plus sign) and country code, for Portugal +351, followed by phone number 7 | // SMS_TARGET Example for India +91XXXXXXXXX 8 | #define SMS_TARGET "+91xxxxxxxx" 9 | 10 | // Configure TinyGSM library 11 | #define TINY_GSM_MODEM_SIM800 // Modem is SIM800 12 | #define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb 13 | 14 | #include 15 | #include 16 | 17 | // TTGO T-Call pins 18 | #define MODEM_RST 5 19 | #define MODEM_PWKEY 4 20 | #define MODEM_POWER_ON 23 21 | #define MODEM_TX 27 22 | #define MODEM_RX 26 23 | #define I2C_SDA 21 24 | #define I2C_SCL 22 25 | 26 | // Set serial for debug console (to Serial Monitor, default speed 115200) 27 | #define SerialMon Serial 28 | // Set serial for AT commands (to SIM800 module) 29 | #define SerialAT Serial1 30 | 31 | // Define the serial console for debug prints, if needed 32 | //#define DUMP_AT_COMMANDS 33 | 34 | #ifdef DUMP_AT_COMMANDS 35 | #include 36 | StreamDebugger debugger(SerialAT, SerialMon); 37 | TinyGsm modem(debugger); 38 | #else 39 | TinyGsm modem(SerialAT); 40 | #endif 41 | 42 | #define IP5306_ADDR 0x75 43 | #define IP5306_REG_SYS_CTL0 0x00 44 | 45 | bool setPowerBoostKeepOn(int en){ 46 | Wire.beginTransmission(IP5306_ADDR); 47 | Wire.write(IP5306_REG_SYS_CTL0); 48 | if (en) { 49 | Wire.write(0x37); // Set bit1: 1 enable 0 disable boost keep on 50 | } else { 51 | Wire.write(0x35); // 0x37 is default reg value 52 | } 53 | return Wire.endTransmission() == 0; 54 | } 55 | 56 | void setup() { 57 | // Set console baud rate 58 | SerialMon.begin(115200); 59 | 60 | // Keep power when running from battery 61 | Wire.begin(I2C_SDA, I2C_SCL); 62 | bool isOk = setPowerBoostKeepOn(1); 63 | SerialMon.println(String("IP5306 KeepOn ") + (isOk ? "OK" : "FAIL")); 64 | 65 | // Set modem reset, enable, power pins 66 | pinMode(MODEM_PWKEY, OUTPUT); 67 | pinMode(MODEM_RST, OUTPUT); 68 | pinMode(MODEM_POWER_ON, OUTPUT); 69 | digitalWrite(MODEM_PWKEY, LOW); 70 | digitalWrite(MODEM_RST, HIGH); 71 | digitalWrite(MODEM_POWER_ON, HIGH); 72 | 73 | // Set GSM module baud rate and UART pins 74 | SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX); 75 | delay(3000); 76 | 77 | // Restart SIM800 module, it takes quite some time 78 | // To skip it, call init() instead of restart() 79 | SerialMon.println("Initializing modem..."); 80 | modem.restart(); 81 | // use modem.init() if you don't need the complete restart 82 | 83 | // Unlock your SIM card with a PIN if needed 84 | if (strlen(simPIN) && modem.getSimStatus() != 3 ) { 85 | modem.simUnlock(simPIN); 86 | } 87 | 88 | // To send an SMS, call modem.sendSMS(SMS_TARGET, smsMessage) 89 | String smsMessage = "Hello from ESP32!"; 90 | if(modem.sendSMS(SMS_TARGET, smsMessage)){ 91 | SerialMon.println(smsMessage); 92 | } 93 | else{ 94 | SerialMon.println("SMS failed to send"); 95 | } 96 | } 97 | 98 | void loop() { 99 | delay(1); 100 | } 101 | -------------------------------------------------------------------------------- /utraq_module/utraq_module.ino: -------------------------------------------------------------------------------- 1 | 2 | /* Sample Code to check the working of UTRAQ Module: used for vehicle tracking and Geodetic data. 3 | * Company : Elementz Engineers Guild Pvt Ltd 4 | * Website: http://www.elementzonline.com 5 | * Model:U-TRAQ L100 Module 6 | * Product Link: https://www.elementzonline.com/u-traq-l100-irnss-navic-gagan-sbas-egnos-epotm-waas-msas-gnss-glonass-stagnss-l1-l5-nmea-gps-receiver-module 7 | * Basic working of UTRAQ Module: https://www.elementzonline.com/blog/utraq-gps-l100-module-based-on-irnss-supported-by-gagan-navic 8 | 9 | 10 | * Add Library 11 | * Here we used TinyGPS library 12 | */ 13 | 14 | #include 15 | TinyGPS gps; 16 | 17 | void gpsdump(TinyGPS &gps); 18 | void printFloat(double f, int digits = 2); 19 | 20 | void setup() 21 | { 22 | Serial.begin(115200); // initialize serial communications: 23 | delay(1000); 24 | Serial.println(); 25 | Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS)); 26 | Serial.println(); 27 | } 28 | 29 | void loop() 30 | { 31 | bool newdata = false; 32 | unsigned long start = millis(); 33 | 34 | // Every 5 seconds we print an update 35 | while (millis() - start < 5000) { 36 | if (Serial.available()) { 37 | char c = Serial.read(); 38 | // Serial.print(c); // uncomment to see raw GPS data 39 | if (gps.encode(c)) { 40 | newdata = true; 41 | // break; // uncomment to print new data immediately! 42 | } 43 | } 44 | } 45 | 46 | if (newdata) { 47 | Serial.println("Acquired Data"); 48 | Serial.println("-------------"); 49 | gpsdump(gps); 50 | Serial.println("-------------"); 51 | Serial.println(); 52 | } 53 | } 54 | 55 | void gpsdump(TinyGPS &gps) 56 | { 57 | long lat, lon; 58 | float flat, flon; 59 | unsigned long age, date, time, chars; 60 | int year; 61 | byte month, day, hour, minute, second, hundredths; 62 | unsigned short sentences, failed; 63 | 64 | gps.get_position(&lat, &lon, &age); 65 | Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon); 66 | Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); 67 | 68 | // On Arduino, GPS characters may be lost during lengthy Serial.print() 69 | // On Teensy, Serial prints to USB, which has large output buffering and 70 | // runs very fast, so it's not necessary to worry about missing 4800 71 | // baud GPS characters. 72 | 73 | gps.f_get_position(&flat, &flon, &age); 74 | Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5); 75 | Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); 76 | 77 | gps.get_datetime(&date, &time, &age); 78 | Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print(" Time(hhmmsscc): "); 79 | Serial.print(time); 80 | Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); 81 | 82 | gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age); 83 | Serial.print("Date: "); Serial.print(static_cast(month)); Serial.print("/"); 84 | Serial.print(static_cast(day)); Serial.print("/"); Serial.print(year); 85 | Serial.print(" Time: "); Serial.print(static_cast(hour)); Serial.print(":"); 86 | Serial.print(static_cast(minute)); Serial.print(":"); Serial.print(static_cast(second)); 87 | Serial.print("."); Serial.print(static_cast(hundredths)); 88 | Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); 89 | 90 | Serial.print("Alt(cm): "); Serial.print(gps.altitude()); Serial.print(" Course(10^-2 deg): "); 91 | Serial.print(gps.course()); Serial.print(" Speed(10^-2 knots): "); Serial.println(gps.speed()); 92 | Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): "); 93 | printFloat(gps.f_course()); Serial.println(); 94 | Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): "); 95 | printFloat(gps.f_speed_mph()); 96 | Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): "); 97 | printFloat(gps.f_speed_kmph()); Serial.println(); 98 | 99 | gps.stats(&chars, &sentences, &failed); 100 | Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: "); 101 | Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed); 102 | } 103 | 104 | void printFloat(double number, int digits) 105 | { 106 | // Handle negative numbers 107 | if (number < 0.0) { 108 | Serial.print('-'); 109 | number = -number; 110 | } 111 | 112 | // Round correctly so that print(1.999, 2) prints as "2.00" 113 | double rounding = 0.5; 114 | for (uint8_t i=0; i 0) 126 | Serial.print("."); 127 | 128 | // Extract digits from the remainder one at a time 129 | while (digits-- > 0) { 130 | remainder *= 10.0; 131 | int toPrint = int(remainder); 132 | Serial.print(toPrint); 133 | remainder -= toPrint; 134 | } 135 | } 136 | --------------------------------------------------------------------------------