Add RSSI reading in Wifi and Bridge examples
This commit is contained in:
Binary file not shown.
@@ -47,7 +47,7 @@ Reading [EXAMPLES.md](EXAMPLES.md) will be helpful.
|
||||
|
||||
The *ArduinoProps library* allows to build *escape room 2.0 props* easily with Arduino and particularly with Arduino Yun or Arduino Mega 2560 + Dragino Yun shield however it works with Ethernet and Wifi shields too.
|
||||
|
||||
The *ArduinoProps library* relies on *<a href="https://github.com/knolleary/pubsubclient" target="_blank">Nick O'Leary PubSubClient</a>***** library for MQTT. MQTT is a lightweight
|
||||
The *ArduinoProps library* relies on *<a href="https://github.com/knolleary/pubsubclient" target="_blank">Nick O'Leary PubSubClient</a>* library for MQTT. MQTT is a lightweight
|
||||

|
||||
publish/subscribe messaging protocol designed for M2M (machine to machine) telemetry in low bandwidth environments.
|
||||
|
||||
@@ -211,7 +211,7 @@ You can build escape room 2.0 Arduino-based props just with Nick O'Leary PubSubC
|
||||
With *ArduinoProps library*:
|
||||
- create connected props quickly thanks to the application protocol and examples
|
||||
- targetted for escape room props, *ArduinoProps library* can be used for any IoT project
|
||||
- re-use your code when creating new escape rooms****
|
||||
- re-use your code when creating new escape rooms
|
||||
- rely on *ArduinoProps library* robustness: for example, ***the library handles the Arduino Yun Bridge transfer size limitation by smartly splitting large messages (only) when necessary***.
|
||||
|
||||
**Note:** sending too large messages to Arduino Bridge breaks the Arduino sketch. *ArduinoProps library* prevents this crash case.
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
Copy and change it to build your first Arduino connected props, you will
|
||||
only be limited by your imagination.
|
||||
|
||||
Requirements:
|
||||
Requirements:
|
||||
- install ArduinoProps.zip library and dependencies (https://github.com/fauresystems/ArduinoProps)
|
||||
*/
|
||||
#include <Bridge.h>
|
||||
@@ -26,10 +26,14 @@ BridgeProps props(u8"Arduino Contrôleur", // as MQTT client id, should be uniqu
|
||||
|
||||
PropsDataLogical clignoter(u8"clignote", u8"oui", u8"non", true);
|
||||
PropsDataLogical led(u8"led");
|
||||
PropsDataText rssi(u8"rssi");
|
||||
|
||||
void clignote(); // forward
|
||||
PropsAction clignoteAction = PropsAction(1000, clignote);
|
||||
|
||||
void lireRssi(); // forward
|
||||
PropsAction lireRssiAction = PropsAction(30000, lireRssi);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Bridge.begin();
|
||||
@@ -37,11 +41,14 @@ void setup()
|
||||
|
||||
props.addData(&clignoter);
|
||||
props.addData(&led);
|
||||
props.addData(&rssi);
|
||||
|
||||
props.begin(InboxMessage::run);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT); // initialize digital pin LED_BUILTIN as an output
|
||||
|
||||
lireRssi();
|
||||
|
||||
// At this point, the broker is not connected yet
|
||||
}
|
||||
|
||||
@@ -52,6 +59,7 @@ void loop()
|
||||
led.setValue(digitalRead(LED_BUILTIN)); // read I/O
|
||||
|
||||
clignoteAction.check(); // do your stuff, don't freeze the loop with delay() calls
|
||||
lireRssiAction.check();
|
||||
}
|
||||
|
||||
void clignote()
|
||||
@@ -62,6 +70,20 @@ void clignote()
|
||||
}
|
||||
}
|
||||
|
||||
void lireRssi()
|
||||
{
|
||||
Process _process;
|
||||
_process.runShellCommand("cat /proc/net/wireless | awk 'NR==3 {print $4}'");
|
||||
while (_process.running());
|
||||
String b;
|
||||
while (_process.available() > 0) {
|
||||
char c = _process.read();
|
||||
b += c;
|
||||
}
|
||||
b.trim();
|
||||
rssi.setValue(b + " dBm");
|
||||
}
|
||||
|
||||
void InboxMessage::run(String a) {
|
||||
|
||||
if (a == u8"app:startup")
|
||||
|
||||
@@ -27,6 +27,7 @@ InboxMessage KEYWORD1
|
||||
begin KEYWORD2
|
||||
addData KEYWORD2
|
||||
loop KEYWORD2
|
||||
resetMcu KEYWORD2
|
||||
run KEYWORD2
|
||||
sendAllData KEYWORD2
|
||||
sendDataChanges KEYWORD2
|
||||
@@ -37,6 +38,9 @@ sendOmit KEYWORD2
|
||||
sendOver KEYWORD2
|
||||
sendProg KEYWORD2
|
||||
sendRequ KEYWORD2
|
||||
inbox KEYWORD2
|
||||
outbox KEYWORD2
|
||||
clientId KEYWORD2
|
||||
reset KEYWORD2
|
||||
disable KEYWORD2
|
||||
enable KEYWORD2
|
||||
|
||||
Reference in New Issue
Block a user