I have developed two codes but while combining both of them is not giving me the desired result.
The following code correctly displays the text message input of keypad on the LCD and prints it perfectly as a text message.
#include <SoftwareSerial.h> // serial software library for interfacing gsm module
SoftwareSerial Serial1(2, 3); // RX, TX // connect gsm Tx at D2 and Rx at D3
#include<LiquidCrystal.h> // LCD library for interfacing LCD
LiquidCrystal lcd(14,15,16,17,18,19); // connect rs,en,d4,d5,d6,d7 respectevely
int i=0;
#include <Keypad.h> // keypad library for interfacing keypad
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
int x=0;
int y=0;
int n=0;
int minValue=0;
int maxValue=0;
char keyPress=0;
int keyPressTime=100;
String msg="";
char hexaKeys[ROWS][COLS] =
{
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {11, 10, 9, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
String alpha="1!#_$%? ABC2 DEF3 GHI4 JKL5 MNO6 PQRS7 TUV8 WXYZ9 * 0# ";
void setup()
{
Serial1.begin(9600); // init serial1 for GSM
lcd.begin(16,2); // init LCD
delay(2000);
lcd.clear();
lcd.print("Initializing GSM");
delay(2000);
/*Serial1.print("\r");
delay(1000);*/
Serial1.print("AT+CMGF=1\r");
delay(1000);
Serial1.print("AT+CMGS=\"+91**********\"\r");
delay(1000);
lcd.clear();
lcd.print("Wallet Ready");
delay(2000);
}
void loop()
{
int n=0;
lcd.clear();
lcd.noCursor();
while(1)
{
lcd.cursor();
char key = customKeypad.getKey();
if(key=='1')
getkey(0, 7, key);
if(key=='2')
getkey(8, 12, key);
else if(key=='3')
getkey(13, 17, key);
else if(key=='4')
getkey(18, 22, key);
else if(key=='5')
getkey(23, 27, key);
else if(key=='6')
getkey(28, 32, key);
else if(key=='7')
getkey(33, 38, key);
else if(key=='8')
getkey(39,43, key);
else if(key=='9')
getkey(44, 49, key);
else if(key=='*')
getkey(50, 51, key);
else if(key=='0')
getkey(52, 54, key);
else if(key=='#')
getkey(55, 56, key);
else if(key == 'C')
{
x--;
lcd.setCursor(x,y);
lcd.print(" ");
n--;
msg[n]=' ';
lcd.setCursor(x,y);
}
else if(key == 'D')
{
lcd.clear();
lcd.noBlink();
lcd.print("Sending Data");
lcd.setCursor(0,1);
lcd.print("To Phone");
/*Serial1.print("\r");
delay(1000);*/
Serial1.print("AT+CMGF=1\r");
delay(1000);
Serial1.print("AT+CMGS=\"+91**********\"\r");
delay(1000);
Serial1.println(msg);
delay(1000);
Serial1.write(0x1A);
delay(1000);
lcd.clear();
lcd_status();
// clearmsg();
n=0;
i=0;
x=0;
y=0;
msg="";
}
}
}
void getkey(int minValue, int maxValue, char keyPress)
{
int ch=minValue;
int pressed=1;
char key=keyPress;
lcd.noBlink();
for(int i=0;i<keyPressTime;i++)
{
if(key==keyPress)
{
lcd.setCursor(x,y);
lcd.print(alpha[ch]);
ch++;
if(ch>maxValue)
ch=minValue;
i=0;
}
key=customKeypad.getKey();
delay(10);
}
if(pressed)
{
x++;
msg+=alpha[ch-1];
n++;
if(x>15)
{
x=0;
y=1;
}
}
pressed=0;
lcd.blink();
}
void lcd_status()
{
lcd.clear();
lcd.print("Transaction Sent");
lcd.setCursor(0,1);
lcd.print("Successfully");
delay(2000);
lcd.clear();
}
And this code gives me correct GPS location value stored in the string Message.
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
It requires the use of SoftwareSerial, and assumes that you have a
9600-baud serial GPS device hooked up on pins 12(rx) and 13(tx).
*/
static const int RXPin = 12, TXPin = 13;
static const uint32_t GPSBaud = 9600;
boolean sent = false;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
String message="";
void setup()
{
Serial.begin(9600);
ss.begin(GPSBaud);
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
if (ss.available()>0 && sent == false){
if (gps.encode(ss.read())){
displayInfo();
if(message!=""){
Serial.print(message);
sent=true;
}
}
}
}
void displayInfo()
{
if (gps.location.isValid())
{
String lati=String(gps.location.lat(), 4);
String longi=String(gps.location.lng(), 4);
message="location: "+lati+","+longi+"\n";
}
}
But the issue comes when I am trying to combine the two codes such that I get the correct keypad input and GPS location on printing the text message through GSM module.
Related
I am working on a project with wemos, Nokia 5110 lcd and matric keypad 3x4.
I want to go to another screen on a specific key. The keyEvent() is the function I want to call when I trigger a key. The function is called correctly as it turns the led on when I press 3 on keypad, but the screen does not change.
Here is my code:
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <Keypad.h>
Adafruit_PCD8544 display = Adafruit_PCD8544(D7, D6, D5, D4, D3);
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {D6, D5, D4, D3};
byte colPins[COLS] = {D2, D1, D0};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void keyEvent(int page, char key)
{
if(page == 1 && key == '3')
{
digitalWrite(D8, HIGH); //This line works fine. But the below code is not executed.
display.begin();
display.clearDisplay();
display.setCursor(0, 0);
display.println("Line 4");
display.println("Line 5");
display.println("Line 6");
display.display();
}
}
int list = 1;
void setup()
{
pinMode(D8, OUTPUT);
Serial.begin(9600);
}
void loop()
{
char key = keypad.getKey();
if (key)
{
keyEvent(list, key);
}
display.begin();
display.setContrast(100);
display.clearDisplay();
display.setTextSize(0);
display.setTextColor(BLACK);
display.setCursor(0, 0);
display.println("Line 1");
display.println("Line 2");
display.println("Line 3");
display.display();
}
I'm working on Galileo gen 2;
And I'm trying to use the following two web services:
POST /dashboard/read_write_ard.php?temp="+tempValue
POST /dashboard/appinsert.php?valeur="+tempValue
The first one inserts into table one...
and the second one will be used only if (tempValue < 24).
This is my code so far:
#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
const int pinLight = A1;
const int pinLed = 13;
const int thresholdvalue = 400;
const int idealLightValue = 400 ;
const int pinTemp = A0;
const int B = 3975;
int etat=0;
const int pinSound = A2;
byte mac[] = {
0x98, 0x4F, 0xEE, 0x05, 0x37, 0x33
};//adress mac du carte
EthernetClient client;
IPAddress server(192,168, 1,7);
void setup() {
Serial.begin(9600);
pinMode(pinLed, OUTPUT);
lcd.begin(16, 2);
delay(1000);
system("ifup eth0");
if (Ethernet.begin(mac) == 0) {
Serial.println("\nFailed to configure Ethernet using DHCP");
delay(500);
}
delay(1000);
Serial.println(Ethernet.localIP());
}
void loop() {
system("ifup eth0");
digitalWrite(pinLed, HIGH);
lcd.print("Starting to loop ");
delay(1000);
lcd.clear();
int TempSensorValue = analogRead(pinTemp);
int LightSensorValue = analogRead(pinLight);
int SoundSensorValue = analogRead(pinSound);
float resistance = (float)(1023-TempSensorValue)*10000/TempSensorValue;
int temperature = 1/(log(resistance/10000)/B+1/298.15)-273.15;
Serial.println( temperature);
Serial.println(SoundSensorValue);
Serial.println( LightSensorValue);
delay(1000);
String chEtat = "POST /dashboard/read_write_ard.php?temp=";
chEtat += temperature ;
chEtat += "&light=";
chEtat += LightSensorValue;
chEtat +="&sound=";
chEtat +=SoundSensorValue;
if (client.connect(server, 80) ) {
Serial.println("connected");
lcd.print("Connected ");
delay(500);
lcd.clear();
if (temperature <= 40 ){
String chEtat2 = "POST /dashboard/appinsert.php?valeur=";
chEtat2 += temperature ;
chEtat2 += "&type=temperature" ;
client.println(chEtat2);
client.println(chEtat);
}else{
client.println(chEtat);
client.println();
}
}
while (client.available()) {
char c = client.read();
Serial.print(c);
}
if(client.connected()) {
Serial.println();
Serial.println("disconnecting.");
lcd.print("Dissconnecting");
delay(1000);
lcd.clear();
client.stop();
for (;;);
}
}
I have a database containing 2 tables - one for alert values like temperature and the other for normal cases - so I want to put a code when my cart Galileo can add in table 1 : the normal one.
And in case of temperature, let's say more than 24, the value of that temperature will be added to the second table using the web service created for that.
I'd like to know how to get these data soon.
I have an access control system that retrieves data from the database, the problem is if the RFID is not registered on the database, it gets stuck there and it does not scan for the RFID card anymore.
The same scenario when both the RFID and PIN Code matches with the database.
The loop stopped working after I have used Ethernet and HttpClient libraries.
Here's is my program code:
#include <SPI.h>
#include <Ethernet.h>
#include <ArduinoHttpClient.h>
#include <Keypad.h>
#include <MFRC522.h>
#include <Servo.h>
/////// RFID Settings ///////
#define SS_PIN 53
#define RST_PIN 10
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
/////// Ethernet Settings ///////
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 222);
char serverAddress[] = "192.168.1.51"; // server address
int port = 80;
/////// HttpClient Settings ///////
EthernetClient ethr;
HttpClient client = HttpClient(ethr, serverAddress, port);
int statusCode = 0;
/////// Keypad Settings ///////
char key[4];
int i = 0;
String pass;
const byte ROWS = 4; // Four rows
const byte COLS = 4; // columnsffff
// Define the Keymap
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {29, 28, 27, 26}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {25, 24, 23, 22}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
/////// Servo Settings ///////
Servo lock; //declares servo
/////// Status Variables & Strings ///////
int rStatus = 0; // RFID Status
int pStatus = 0; // PIN Status
String getReq, tag, rfid, pincode;
void setup() {
/////// Starting Serial ///////
Serial.begin(9600);
delay(1000);
/////// Ethernet Setup ///////
Serial.println("Initializing Ethernet.");
Ethernet.begin(mac, ip);
Serial.println("Connection Success.");
Serial.println("");
delay(1000);
/////// RFID Setup ///////
Serial.println("Initializing RFID Module.");
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println("RFID Ready.");
Serial.println("");
delay(1000);
/////// Keypad Setup ///////
Serial.println("Initializing Keypad Module...");
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
Serial.println("Keypad Ready.");
Serial.println("");
delay(1000);
/////// Servo Setup ///////
Serial.println("Setting up servo motor...");
lock.attach(13);
Serial.println("Servo Motor Ready.");
Serial.println("");
delay(1000);
/////// R E A D Y ///////
Serial.println("Please tap RFID Card.");
}
void loop() {
if (rStatus == 0)
{
readRFID();
}
else if (rStatus == 1)
{
keypad.getKey();
}
if (rStatus == 1 && pStatus == 1)
{
Serial.println("Door Unlocked.");
lock.write(5);
delay(5000);
lock.write(0);
rStatus = 0;
pStatus = 0;
delay(1000);
loop();
}
}
/////// Module Methods - RFID ///////
void readRFID()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("RFID UID : ");
String content = "";
for (byte i = 0; i < mfrc522.uid.size; i++)
{
content.concat(String(mfrc522.uid.uidByte[i]));
}
Serial.println(content);
tag = String(content);
getTagRequest();
Serial.print("DB UID : ");
Serial.println(rfid);
if (tag == rfid) //change here the UID of the card/cards that you want to give access
{
Serial.print("Message : ");
Serial.println("UID Found.");
Serial.println();
delay(3000);
rStatus = 1;
Serial.println("Please enter 4 digit PIN.");
}
else {
Serial.println(" Access denied");
delay(3000);
rStatus = 0;
}
}
/////// Module Methods - Keypad ///////
void keypadEvent(KeypadEvent eKey)
{
switch (keypad.getState())
{
case PRESSED:
key[i] = eKey;
Serial.print("Enter: ");
Serial.println(eKey);
delay(10);
i++;
switch (eKey)
{
case '#': checkPassword(); delay(1); break;
case '*': i = 0; delay(1); break;
default: delay(1);
}
}
}
void checkPassword()
{
pass = "";
pass.concat(key[0]);
pass.concat(key[1]);
pass.concat(key[2]);
pass.concat(key[3]);
delay(1000);
getPinRequest();
Serial.print("Input PIN: ");
Serial.println(pass);
Serial.print("DB PIN: ");
Serial.println(pincode);
if (pass == pincode)
{
Serial.println("Message: PIN Accepted");
Serial.println("");
i = 0;
pStatus = 1;
delay(10);
} else
{
Serial.println("Message: PIN Denied"); //if passwords wrong keep box locked
i = 0;
pStatus = 0;
delay(10);
}
}
/////// Database Transactions via PHP ///////
void getTagRequest() {
//Making GET Request
getReq = "";
getReq.concat("/getTag.php?tag=");
getReq.concat(tag);
client.get(getReq);
rfid = client.responseBody();
client.stop();
delay(1000);
}
void getPinRequest() {
//Making GET Request
getReq = "";
getReq.concat("/getPin.php?tag=");
getReq.concat(tag);
getReq.concat("&pin=");
getReq.concat(pass);
client.get(getReq);
pincode = client.responseBody();
client.stop();
delay(1000);
}
So how do I fix this? I want the system to ask again for an RFID Card after having matched results from the db.
I figured this one out by not using any pins on my ethernet shield except for the 5v/3.3v and the GND only. It now works again and loops the whole program
I'm trying to send the x and y values of a joystick between two arduino mega 2560 with an nrf24l01. So far I have a transmitter and reciever code but I get wrong values on the reciever.
Transmitter:
#include <SPI.h>
#include <RF24.h>
RF24 radio(7,8);
byte addresses[][6] = {"0x115331","0x222331"};
typedef struct{
int X;
int Y;
int K;
}
Values;
Values v;
void setup() {
pinMode(10, INPUT);
Serial.begin(115200);
radio.begin();
radio.setPALevel(RF24_PA_LOW);
radio.setChannel(108);
radio.setPayloadSize(32);
radio.openWritingPipe(addresses[1]);
radio.openReadingPipe(1,addresses[0]);
}
void loop() {
radio.stopListening();
v.X = analogRead(A0);
v.Y = analogRead(A1);
v.K = digitalRead(10);
Serial.print("X = ");
Serial.println(v.X);
Serial.print("Y = ");
Serial.println(v.Y);
Serial.print("Button status: ");
if (v.K == HIGH)
{
Serial.println("pressed");
}
else
{
Serial.println("not pressed");
}
radio.write(&v,sizeof(v));
delay(500);
}
Reciever:
#include <SPI.h>
#include <RF24.h>
RF24 radio(7,8);
byte addresses[][6] = {"0x115331","0x222331"};
typedef struct{
int X;
int Y;
int K;
}
Values;
Values v;
void setup() {
Serial.begin(115200);
radio.begin();
radio.setPALevel(RF24_PA_LOW);
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1,addresses[1]);
radio.setChannel(108);
radio.setPayloadSize(32);
radio.startListening();
}
void loop() {
radio.startListening();
if ( radio.available() )
{
while(radio.available())
{
radio.read(&v, sizeof(v));
}
}
radio.stopListening();
Serial.println(v.X);
Serial.println(v.Y);
Serial.println(v.K);
delay(1000);
}
I'm using the pin configuration from this website: https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
I have just made an account because of this particular problem I'm having with OpenHAB. I was following a tutorial from this https://openhardwarecoza.wordpress.com/2015/03/29/openhab-mqtt-arduino-and-esp8266-part-3-hardware-arduino-with-ethernet-shield/ site but since the reply there didn't help me. I decided to go to this site.
I have successfully installed OpenHAB and use it. When I turn the switch off and on from both the HTTP page and android device, It works just fine. But when I tried to manual override using a push button on an Arduino. It didn't update the state of the switch in both of them. I'm using windows with OpenHAB version 1.71
The Openhab server notices that there is an update of the state from the push button, but the button in the HTTP page and android device didn't change at all.
I have tested the connection using MQTTlens and it works just fine.
Below is my code
items configuration
Group All
Switch mqttsw1 "Switch 1" (all) {mqtt=">[mymosquitto:/arduino/l1/com:command:off:0],>[mymosquitto:/arduino/l1/com:command:on:1],<[mymosquitto:/arduino/l1/state:state:default]"}
Switch mqttsw2 "Switch 2" (all) {mqtt=">[mymosquitto:/arduino/l2/com:command:off:0],>[mymosquitto:/arduino/l2/com:command:on:1],<[mymosquitto:/arduino/l2/state:state:default]"}
Number temp "Temperature [%.1f °C]" <temperature> {mqtt="<[mymosquitto:/arduino/temp/state:state:default]"}
Number hum "Humidity [%.1f %]" <temperature> {mqtt="<[mymosquitto:/arduino/hum/state:state:default]"}
Sitemap configuration
sitemap dolphin label="Main Menu"
{
Frame label="Switch" {
Switch item=mqttsw1 label="Switch 1"
Switch item=mqttsw2 label="Switch 2"
}
Frame label="Weather" {
Text item=temp
Text item=hum
}
The Arduino Code
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <DHT.h>
const int butt1 = 3;// the pin that the pushbutton is attached to
const int butt2 = 2;
const int ledPin1 = 5;
const int ledPin2 = 4;
int ledState1 = HIGH;
int buttonState1;
int lastButtonState1 = LOW;
int ledState2 = HIGH;
int buttonState2;
int lastButtonState2 = LOW;
long previousMillis = 0;
unsigned long currentMillis = 0;
long interval = 60000; // READING INTERVAL
int t = 0; // TEMPERATURE VAR
int h = 0; // HUMIDITY VAR
#define DHTPIN 24 // SENSOR PIN
#define DHTTYPE DHT11 // SENSOR TYPE - THE ADAFRUIT LIBRARY OFFERS SUPPORT FOR MORE MODELS
DHT dht(DHTPIN, DHTTYPE);
// Update these with values suitable for your network.
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xEF };
IPAddress ip(192, 168, 1, 103);
IPAddress server(192, 168, 1, 100);
void callback(char* topic, byte* payload, unsigned int length);
EthernetClient ethClient;
PubSubClient client(server, 1883, callback, ethClient);
void callback(char* topic, byte* payload, unsigned int length) {
Serial.println();
Serial.println("Callback");
Serial.print("Topic = ");
Serial.println(topic);
Serial.print("Payload = ");
for (int i=0;i<length;i++){
Serial.print((char)payload[i]);
}
Serial.println();
if (strcmp(topic,"/esp1/l1/com")==0) {
if (payload[0] == '0')
{
digitalWrite(ledPin1, LOW);
delay(100);
client.publish("/esp1/l1/state","0");
}
else if (payload[0] == '1')
{
digitalWrite(ledPin1, HIGH);
delay(100);
client.publish("/esp1/l1/state","1");
}
}
if (strcmp(topic,"/esp1/l2/com")==0) {
if (payload[0] == '0')
{
digitalWrite(ledPin2, LOW);
delay(100);
client.publish("/esp1/l2/state","0");
}
else if (payload[0] == '1')
{
digitalWrite(ledPin2, HIGH);
delay(100);
client.publish("/esp1/l2/state","1");
}
}
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("arduinoClient")) {
Serial.println("connected");
client.subscribe("/esp1/#");
client.publish("conn","Connected");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
void push1() {
int reading1 = digitalRead(butt1);
buttonState1 = reading1;
if (buttonState1 == HIGH) {
ledState1 = !ledState1;
if (ledState1 < 1)
{
digitalWrite(ledPin1, LOW);
delay(100);
client.publish("/esp1/l1/com","0");
client.publish("/esp1/l1/state","0");
}
else
{
digitalWrite(ledPin1, HIGH);
delay(100);
client.publish("/esp1/l1/com","1");
client.publish("/esp1/l1/state","1");
}
}
}
void push2() {
int reading2 = digitalRead(butt2);
buttonState2 = reading2;
if (buttonState2 == HIGH) {
ledState2 = !ledState2;
if (ledState2 < 1)
{
digitalWrite(ledPin2, LOW);
delay(100);
client.publish("/esp1/l2/com","0");
client.publish("/esp1/l2/state","0");
}
else
{
digitalWrite(ledPin2, HIGH);
delay(100);
client.publish("/esp1/l2/com","1");
client.publish("/esp1/l2/state","1");
}
}
}
void temp() {
h = (int)dht.readHumidity();
t = (int)dht.readTemperature();
char temp[2];
char hum[3];
sprintf(hum, "%d", h);
sprintf(temp, "%d", t);
client.publish("/esp1/temp/state", temp);
client.publish("/esp1/hum/state", hum);
}
void setup() {
// put your setup code here, to run once:
pinMode(butt1, INPUT);
pinMode(butt2, INPUT);
// initialize the LED as an output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
Serial.begin(9600);
Ethernet.begin(mac, ip);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
pinMode(26, OUTPUT); // sets the digital pin as output
pinMode(22, OUTPUT); // sets the digital pin as output
digitalWrite(26, HIGH); // sets +5v for the sensor
digitalWrite(22, LOW); // sets gnd for the sensor
h = (int)dht.readHumidity();
t = (int) dht.readTemperature();
if (client.connect("arduinoClient")) {
client.publish("conn","Connected");
client.subscribe("/esp1/#");
}
}
void loop() {
// put your main code here, to run repeatedly:
if (!client.connected()) {
reconnect();
}
currentMillis = millis();
if (currentMillis - previousMillis > interval) { // READ ONLY ONCE PER INTERVAL
previousMillis = currentMillis;
temp();
}
int reading1 = digitalRead(butt1);
int reading2 = digitalRead(butt2);
if (reading1 != buttonState1) {
push1();
}
if (reading2 != buttonState2){
push2();
}
client.loop();
}
If there are anybody who can help me I would be very grateful. Thank you for your attention !
Best Regards,
Aldi
If I remember correctly you should post back a status of ON or OFF instead of 1 or 0.
Could you change your arduino code to publish back ON and OFF and test that?
e.g.
client.publish("/esp1/l1/state","ON");