Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SensorNode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Proof of Concept
SensorNode
Commits
79dc1fc3
Commit
79dc1fc3
authored
Nov 08, 2015
by
PhiBo
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support mode switch
parent
d10bb93f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
15 deletions
+35
-15
src/main.ino
src/main.ino
+35
-15
No files found.
src/main.ino
View file @
79dc1fc3
...
...
@@ -9,6 +9,11 @@
#define RPC_NUM_HANDLERS 20
#define RPC_NUM_FUNCTIONS 0
#define PIN_NODE_MODE 4
#define NODE_MODE_ACTIVE 0
#define NODE_MODE_CONFIG 1
#define PIN_ESP8266_SET 2
#define PIN_ESP8266_MODE 3
#define PIN_ESP8266_CH_PD 7
...
...
@@ -26,19 +31,31 @@ SensorWifiModuleRemote sensor_remote = SensorWifiModuleRemote(rpc_request, 0x00)
SensorNode
sensor_node
=
SensorNode
();
uint8_t
sensor_node_mode
=
NODE_MODE_ACTIVE
;
void
setup
()
{
pinMode
(
PIN_NODE_MODE
,
INPUT
);
pinMode
(
PIN_ESP8266_SET
,
OUTPUT
);
pinMode
(
PIN_ESP8266_MODE
,
OUTPUT
);
pinMode
(
PIN_ESP8266_CH_PD
,
OUTPUT
);
digitalWrite
(
PIN_ESP8266_CH_PD
,
LOW
);
RPC_SERIAL_PORT
.
begin
(
RPC_SERIAL_BAUD
);
if
(
digitalRead
(
PIN_NODE_MODE
)
==
HIGH
)
{
sensor_node_mode
=
NODE_MODE_CONFIG
;
}
if
(
sensor_node_mode
==
NODE_MODE_ACTIVE
)
{
sensor_node
.
loadConfig
();
}
else
{
}
/*sensor_dht = new DHT(6, DHT22);
sensor_dht->begin();*/
//mySerial.begin(9600);
//rpc.connectHandler(&sensor_node, 0x10);
// put your setup code here, to run once:
sensor_node
.
loadConfig
();
Serial
.
println
(
"foo"
);
}
...
...
@@ -46,18 +63,21 @@ void loop() {
//a->writeValue();
//rpc_serial.readData();
//sensor_dht->readTemperature();
sensor_node
.
run
();
digitalWrite
(
PIN_ESP8266_SET
,
HIGH
);
digitalWrite
(
PIN_ESP8266_MODE
,
HIGH
);
digitalWrite
(
PIN_ESP8266_CH_PD
,
HIGH
);
// Wait for bootloader
delay
(
250
);
digitalWrite
(
PIN_ESP8266_MODE
,
LOW
);
digitalWrite
(
PIN_ESP8266_SET
,
LOW
);
// Wait until boot
delay
(
250
);
sensor_node
.
submitValues
(
&
sensor_remote
);
digitalWrite
(
PIN_ESP8266_CH_PD
,
LOW
);
delay
(
5000
);
if
(
sensor_node_mode
==
NODE_MODE_ACTIVE
)
{
sensor_node
.
run
();
digitalWrite
(
PIN_ESP8266_SET
,
HIGH
);
digitalWrite
(
PIN_ESP8266_MODE
,
HIGH
);
digitalWrite
(
PIN_ESP8266_CH_PD
,
HIGH
);
// Wait for bootloader
delay
(
250
);
digitalWrite
(
PIN_ESP8266_MODE
,
LOW
);
digitalWrite
(
PIN_ESP8266_SET
,
LOW
);
// Wait until boot
delay
(
250
);
sensor_node
.
submitValues
(
&
sensor_remote
);
digitalWrite
(
PIN_ESP8266_CH_PD
,
LOW
);
delay
(
5000
);
}
else
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment