Peltier Controlled From An Android App
Arduino temperature control sketch, managed from an Android.
Components and supplies
1
4-CHANNEL RELAY CONTROLLER FOR I2C
1
NodeMCU ESP8266 Breakout Board
1
RGB Backlight LCD - 16x2
1
Arduino UNO
Apps and platforms
1
Abetoo IoT Framework
Project description
Code
tutorial_relays.ino
arduino
1/* 2 Sample program to manage relays a receive messages 3 Copyright (C) 2017 Chocron J. 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 <http://www.gnu.org/licenses/>. 17*/ 18#include <LiquidCrystal.h> 19#include "abtoo.h" 20 21// Relays 22int r1 = 16; // GPIO16 23int r2 = 5; // GPIO5 24int r3 = 4; // GPIO4 25 26// LCD 27int rs = 0; // GPIO0 28int en = 2; // GPIO2 29int d4 = 14; // GPIO14 30int d5 = 12; // GPIO12 31int d6 = 13; // GPIO13 32int d7 = 15; // GPIO15 33 34// initialize the library with the numbers of the interface pins 35LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 36 37// WiFi 38char* ssid = "MYSSID"; 39char* password = "MYPASSWORD"; 40AbetooIno abtoino; 41 42// Message received callback 43void messageReceived(String message) 44{ 45 if (message == "r1on") 46 { 47 digitalWrite(r1, LOW); 48 } 49 else if (message == "r1off") 50 { 51 digitalWrite(r1, HIGH); 52 } 53 else if (message == "r2on") 54 { 55 digitalWrite(r2, LOW); 56 } 57 else if (message == "r2off") 58 { 59 digitalWrite(r2, HIGH); 60 } 61 else // text message 62 { 63 lcd.setCursor(0,1); 64 lcd.print(message+" "); 65 } 66} 67 68void setup() { 69 // Initialize pins 70 pinMode(rs, OUTPUT); 71 pinMode(en, OUTPUT); 72 pinMode(d4, OUTPUT); 73 pinMode(d5, OUTPUT); 74 pinMode(d6, OUTPUT); 75 pinMode(d7, OUTPUT); 76 77 // Initialize LCD 78 lcd.begin(16, 2); 79 lcd.setCursor(0,0); 80 lcd.print("Abetoo IoT"); 81 lcd.setCursor(0,1); 82 lcd.print("Arduino Library"); 83 84 Serial.begin(9600); 85 delay(10); 86 87 // Initialize Relay's pins 88 pinMode(r1, OUTPUT); 89 pinMode(r2, OUTPUT); 90 pinMode(r3, OUTPUT); 91 digitalWrite(r1, HIGH); 92 digitalWrite(r2, HIGH); 93 digitalWrite(r3, HIGH); 94 95 // Connect to WiFi network 96 Serial.println(); 97 Serial.println(); 98 Serial.print("Connecting to "); 99 Serial.println(ssid); 100 101 WiFi.begin(ssid, password); 102 103 while (WiFi.status() != WL_CONNECTED) { 104 delay(500); 105 Serial.print("."); 106 } 107 Serial.println(""); 108 Serial.println("WiFi connected"); 109 110 abtoino.init("uuid1", "-TbVO-rqdA0iWg6-gWh0eeQ636243460528994051#735acf9cd6eda96e66ee3858496dca59d750aff1", 1, messageReceived); 111} 112 113void loop() 114{ 115 abtoino.abetooloop(); 116} 117 118 119
Downloadable files
Fritz
Fritz
Fritz
Fritz
Comments
Only logged in users can leave comments