forked from YourproductSmarter/KISSLoRa-demo
-
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.
CayenneLPP improvements
- Loading branch information
Showing
21 changed files
with
90 additions
and
80 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
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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# Accelerometer | ||
|
||
The KISS LoRa board has an FXLS8471Q accelerometer. See [FXLS8471Q.pdf](FXLS8471Q.pdf) for technical details on this sensor. | ||
The KISS LoRa board has an FXLS8471Q accelerometer. See [FXLS8471Q.pdf](FXLS8471Q.pdf) for technical details on this sensor. | ||
|
||
Communication with the accelerometer is also via the I2C bus, just like with the temperature and humidity sensor. The difference is that we do not have a library to handle setting up and reading values from the accelerometer. This makes this example more complex. | ||
|
||
I2C communication is handled by the Wire library. At startup we initialise the accelerometer by firstly checking if the device responds correctly via I2C. We then change a few configuration bits to allow constant measurements. We also configure it to read acceleration in the range -2g to +2g. | ||
|
||
At this stage it is important to remember that gravity causes a 1g acceleration toward the centre of the earth. This means that we can only measure an extra 1g downward acceleration, but a 3g upward acceleration. In all other axes we can measure 2g of acceleration. This range is good enough for most uses, but if you know that you need a greater range, but at a lower resolution, you can change the range configuration to either -4g to +4g or -8g to +8g. |
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
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 |
---|---|---|
@@ -1,5 +1,40 @@ | ||
# CayenneLPP example | ||
|
||
See [this description](index.md) of what CayenneLPP is, and how you can use it via The Things Network. | ||
See [this description](https://www.thethingsnetwork.org/docs/applications/Cayenne/) of what CayenneLPP is, and how you can use it via The Things Network. | ||
|
||
This example reads all the sensors on the KISS LoRa device and sends the values using CayenneLPP format, so that you can easily visualise the data on myDevices Cayenne. | ||
|
||
Because this example reads all the sensors, it contains all the code that you have previously seen. The only new part is the encoding of the payload using CayenneLPP format. | ||
|
||
## Description | ||
|
||
The lines in this sketch that you have not yet seen are as follow: | ||
|
||
`#include <CayenneLPP.h>` | ||
|
||
Include the CayenneLPP library to do the encoding of the data payload for us. | ||
|
||
`CayenneLPP lpp(51);` | ||
|
||
Create an instance of the LPP library, passing it the maximum size a payload can be that we can transmit. That is 51 bytes for LoRaWAN packets. | ||
|
||
``` | ||
void sendData(uint8_t port) | ||
{ | ||
lpp.reset(); | ||
lpp.addDigitalInput(1, getButtonPressed()); | ||
lpp.addAnalogInput(2, getRotaryPosition()); | ||
lpp.addRelativeHumidity(3, sensor.getRH()); | ||
lpp.addTemperature(4, sensor.getTemp()); | ||
lpp.addLuminosity(5, get_lux_value()); | ||
float x,y,z; | ||
getAcceleration(&x, &y, &z); | ||
lpp.addAccelerometer(6, x, y, z); | ||
ttn.sendBytes(lpp.getBuffer(), lpp.getSize(), 2, false, getSF()); | ||
} | ||
``` | ||
|
||
We reset the lpp instance and that will clear all old values from the buffer. Then we add the sensor values to the payload, giving it the "channel number" as first parameter, and the sensor value as second parameter. At the end we send the payload bytes we get from the LPP library, on port 2, not asking for an ack, and on a random spreading factor. | ||
|
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Light Sensor | ||
|
||
The KISS LoRa board has an APDS-9007 ambient light sensor. See [AV02-0512EN0.pdf](AV02-0512EN0.pdf) for technical details on this sensor. | ||
The KISS LoRa board has an APDS-9007 ambient light sensor. See [AV02-0512EN0.pdf](AV02-0512EN0.pdf) for technical details on this sensor. | ||
|
||
The ambient light sensor outputs the light intensity as an analog value that is logarithmically proportionate to the light intensity. This example reads the analog value and converts it to light intensity. |
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
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
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# Push Button Switch | ||
|
||
The KISS LoRa board has one push button switch. This example polls the switch every second and prints out the state. It also uses an interrupt to detect when the switch was pressed and toggles the red LED. | ||
The KISS LoRa board has one push button switch. This example polls the switch every second and prints out the state. It also uses an interrupt to detect when the switch was pressed and toggles the red LED. | ||
|
||
In the schematic we can see that the switch will connect the pin on the microcontroller to 0V when it is pressed, but connected via a resistor to 3V3 when it is not pressed. This means that we will read a 0 on the digital input pin on the microcontroller when the button is pressed. On the other hand we will read a 1 when the button is not pressed. | ||
|
||
The button is also connected to a pin that supports an interrupt. This means that a specific Interrupt Service Routine (ISR) can be executed when the state of the input pin changes. This is used to toggle the LED when the button is pressed. |
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 |
---|---|---|
@@ -1,3 +1,18 @@ | ||
# Examples | ||
|
||
See the readme in every subdirectory for an explanation of what each example does, and how to use it. | ||
This directory contains some basic examples on how to read the sensors, or control the actuators on the KISS LoRa gadget. | ||
|
||
We recommend programming every example onto the KISS device to see how to use all the sensors. | ||
|
||
Our recommended order is: | ||
|
||
1. [Blink](Blink) | ||
2. [PushButton](PushButton) | ||
3. [RotarySwitch](RotarySwitch) | ||
4. [LightSensor](LightSensor) | ||
5. [ReadTemperatureHumidity](ReadTemperatureHumidity) | ||
6. [Accelerometer](Accelerometer) | ||
7. [LoRa_TX_RX](LoRa_TX_RX) | ||
8. [CayenneLPP](CayenneLPP) | ||
|
||
See the readme in every subdirectory for an explanation of what each example does, and how to use it. |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Temperature and Humidity | ||
|
||
The KISS LoRa board has a Silicon Labs Si7021 Temperature and Humidity sensor. See [Si7021-A20.pdf](Si7021-A20.pdf) for technical details on this sensor. | ||
The KISS LoRa board has a Silicon Labs Si7021 Temperature and Humidity sensor. See [Si7021-A20.pdf](Si7021-A20.pdf) for technical details on this sensor. | ||
|
||
Communication with the sensor is done via I2C. This example makes use of a SparkFun library for the Si7021 to setup and read the sensor. |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Rotary Switch | ||
|
||
The KISS LoRa board has a rotary switch with 10 different positions, marked 0 to 9. This example constantly polls the switch and print out the position of the switch. | ||
The KISS LoRa board has a rotary switch with 10 different positions, marked 0 to 9. This example constantly polls the switch and prints out the position of the switch. | ||
|
||
The rotary switch outputs the value that is selected in binary format, using 4 digital lines. If these 4 digital lines are read and interpreted in the correct order, the value can be calculated. |
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
Binary file not shown.