-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
MedidorComunicador/build/** | ||
MedidorControlador/build/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"sketch": "MedidorComunicador.ino", | ||
"board": "esp8266:esp8266:nodemcu", | ||
"configuration": "CpuFrequency=80,UploadSpeed=115200,FlashSize=4M3M", | ||
"output": "./build", | ||
"port": "COM4" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Win32", | ||
"includePath": [ | ||
"C:\\Users\\DB1\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.3.0\\cores\\esp8266" | ||
], | ||
"browse": { | ||
"limitSymbolsToIncludedHeaders": false, | ||
"path": [ | ||
"C:\\Users\\DB1\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.3.0\\cores\\esp8266", | ||
"${workspaceRoot}" | ||
] | ||
}, | ||
"intelliSenseMode": "msvc-x64" | ||
} | ||
], | ||
"version": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include <ESP8266HTTPClient.h> | ||
|
||
#include <ESP8266WiFi.h> | ||
|
||
String inputString; | ||
const char* ssid = "FAST3184-567C"; | ||
const char* password = "LCNTJVJV1WHQ"; | ||
const int LED_BLOQUEADO = 0; | ||
const int LED_LIBERADO = 2; | ||
HTTPClient http; | ||
int areaSelecionada = -1; | ||
int votoSelecionado = -1; | ||
|
||
void bloquearMedidor(boolean pbBloquear){ | ||
digitalWrite(LED_BLOQUEADO, pbBloquear); | ||
digitalWrite(LED_LIBERADO, !pbBloquear); | ||
} | ||
|
||
void limparVariaveis(){ | ||
inputString.remove(0); | ||
inputString.trim(); | ||
} | ||
|
||
void setup() { | ||
pinMode(LED_BLOQUEADO, OUTPUT); | ||
pinMode(LED_LIBERADO, OUTPUT); | ||
Serial.begin(115200); | ||
bloquearMedidor(true); | ||
WiFi.begin(ssid, password); | ||
while(WiFi.status() != WL_CONNECTED){ | ||
delay(1000); | ||
Serial.println("Conectando..."); | ||
} | ||
bloquearMedidor(false); | ||
} | ||
|
||
void loop() { | ||
if (Serial.available()){ | ||
char inChar=(char)Serial.read(); | ||
inputString+=inChar; | ||
if (inChar == '&'){ | ||
if(inputString.lastIndexOf("I") >= 0){ | ||
carregarDadosAreas(); | ||
delay(1000); | ||
limparVariaveis(); | ||
} else if (inputString.lastIndexOf("A") >= 0) { | ||
areaSelecionada = inputString.substring(1).toInt(); | ||
limparVariaveis(); | ||
} else if (inputString.lastIndexOf("V") >= 0) { | ||
votoSelecionado = inputString.substring(1).toInt(); | ||
limparVariaveis(); | ||
} | ||
} | ||
} | ||
if((areaSelecionada >=0) && (votoSelecionado > 0)){ | ||
gravarDadosVoto(); | ||
areaSelecionada = -1; | ||
votoSelecionado = -1; | ||
} | ||
delay(100); | ||
} | ||
|
||
void carregarDadosAreas(){ | ||
bloquearMedidor(true); | ||
http.begin("http://jsonplaceholder.typicode.com/users/1"); | ||
int httpCode = http.GET(); | ||
String payload = http.getString(); | ||
Serial.println(payload); | ||
bloquearMedidor(false); | ||
} | ||
|
||
void gravarDadosVoto(){ | ||
bloquearMedidor(true); | ||
Serial.println("Gravando dados..."); | ||
bloquearMedidor(false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"sketch": "MedidorControlador.ino", | ||
"board": "arduino:avr:nano", | ||
"configuration": "cpu=atmega328", | ||
"output": "./build", | ||
"port": "COM4" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Win32", | ||
"includePath": [ | ||
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" | ||
], | ||
"browse": { | ||
"limitSymbolsToIncludedHeaders": false, | ||
"path": [ | ||
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino", | ||
"${workspaceRoot}" | ||
] | ||
}, | ||
"intelliSenseMode": "msvc-x64" | ||
} | ||
], | ||
"version": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
bool bProcessando = false; | ||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
} | ||
|
||
void loop() | ||
{ | ||
if(!bProcessando){ | ||
digitalWrite(13, !digitalRead(13)); | ||
delay(2000); | ||
} | ||
} | ||
|
||
void serialEvent(){ | ||
char inChar=(char)Serial.read(); | ||
Serial.println(inChar); | ||
bProcessando = inChar=='1'; | ||
Serial.println(bProcessando); | ||
} |