Skip to content

Commit 2c2ee73

Browse files
committed
mkr fox 1200 tutorials
1 parent 63ac1c8 commit 2c2ee73

27 files changed

+245
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: "MKR FOX 1200 Movement Trigger"
3+
description: "Use your MKR FOX 1200 as a movement trigger to keep an eye on your belongings."
4+
coverImage: "assets/img_0186_a3yjVyo0kX.JPG"
5+
tags: [geolocation]
6+
author: "Arduino_Genuino, Andrea Richetta"
7+
difficulty: intermediate
8+
source: "https://create.arduino.cc/projecthub/45374/mkr-fox-1200-movement-trigger-dacbe0"
9+
---
10+
11+
## Components and Supplies
12+
13+
- [Arduino MKR Fox 1200](https://store.arduino.cc/arduino-mkrfox1200)
14+
- [Jumper wires (generic)](https://www.newark.com/88W2571?COM=ref_hackster)
15+
- [AA Batteries](http://www.amazon.com/dp/B00451SSBI/?tag=octopart00-20)
16+
- 2 x AA battery holder
17+
- [Adafruit MMA8451 3 Axis accelerometer](https://www.adafruit.com/product/2019)
18+
19+
## About This Project
20+
21+
### Background
22+
23+
This project relies on the geolocation feature of the Sigfox network.
24+
25+
The location computation is based on the data from the Sigfox infrastructure, coming from several replicas of the same messages sent by a device and received by different base stations. The method used is not based on flight time or signal Doppler shift, but on the signal strength (RSSI - Received Signal Stren- gth Indicator) using a probability model (the location with the highest probability is selected). The Sigfox geolocation service will evolve in 2017 to increase its accuracy by using machine learning technology.
26+
27+
### Accelerometer
28+
29+
Another key technology is the micromachined accelerometer inside the MMA8451 device: an I2C interfaced sensor that our project uses to detect movements and trigger the communication with the Sigfox network. Thanks to the low power modes of SAMD21 and Sigfox technology, expect this project to run for several months on a pair of AA Alkaline batteries.
30+
31+
### Components
32+
33+
![The hardware.](assets/img_0186_LNagrJd3Br.JPG)
34+
35+
### Build It
36+
37+
Connect the 3 axis to the MKR FOX 1200 as shown:
38+
39+
![Connect the accelerometer.](assets/img_0187_ahiTIvQTm8.JPG)
40+
41+
![Done!](assets/img_0188_Bk1ic7SkYi.JPG)
42+
43+
Connect a jumper between pin 14 and pin 0:
44+
45+
![](assets/img_0190_OKMcSlGMMp.JPG)
46+
47+
Put in a nice box:
48+
49+
![Put the components in a box.](assets/img_0191_LoOvn21wF7.JPG)
50+
51+
![Your setup is now hidden!](assets/img_0192_efNkd6uk5S.JPG)
52+
53+
Place the box inside the car:
54+
55+
![The box in the car.](assets/img_0193_38n9JqwBeV.JPG)
56+
57+
58+
## Code
59+
60+
<iframe src='https://create.arduino.cc/editor/Arduino_Genuino/3bcf9f25-65cf-4f91-ae15-64436bbd5bde/preview?embed&snippet' style='height:510px;width:100%;margin:10px 0' frameborder='0'></iframe>
61+
62+
63+
### How It Works
64+
65+
Once the movement sensor triggers, the MKR FOX will send an alert message with the coordinates taken from the network.
66+
67+
### Software
68+
69+
On software side, if you haven't done yet, register your MKR FOX 1200 by following the example [here](https://www.arduino.cc/en/Tutorial/SigFoxFirstConfiguration).
70+
71+
Then go to the [Sigfox backend](https://backend.sigfox.com/) and configure the callback as follows:
72+
73+
![Sigfox Backend.](assets/2017-07-10-102532_1589x339_scrot_rZLYCKniB0.png)
74+
75+
76+
![Change the recipient with your email address.](assets/2017-07-10-102547_721x597_scrot_YyrFIJ2FbV.png)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
title: "MKR FOX 1200 Weather Monitor"
3+
description: "Turn your MKR FOX 1200 into a battery-powered weather monitor that you can deploy EVERYWHERE. "
4+
coverImage: "assets/socials_mkrfox1200_bVlDZFCxco.jpg"
5+
tags: [radio, weather]
6+
author: "Arduino_Genuino"
7+
difficulty: advanced
8+
source: "https://create.arduino.cc/projecthub/Arduino_Genuino/mkr-fox-1200-weather-monitor-6a94e2"
9+
---
10+
11+
## Components and Supplies
12+
13+
- [Arduino MKR Fox 1200](https://store.arduino.cc/arduino-mkrfox1200)
14+
- [SparkFun Atmospheric Sensor Breakout - BME280](https://www.sparkfun.com/products/13676)
15+
- [TSL2561 digital luminosity light sensor](https://store.arduino.cc/tsl2561-digital-luminosity-light-sensor)
16+
- [HTU 1D](https://www.sparkfun.com/products/retired/12064)
17+
18+
## Apps and Online Services
19+
20+
- [Arduino Web Editor](https://create.arduino.cc/editor)
21+
- [ThingSpeak API](https://github.com/iobridge/ThingSpeak)
22+
- [Sigfox](http://makers.sigfox.com/)
23+
24+
## About This Project
25+
26+
This project shows how to turn a **MKR FOX 1200** and a bunch of I2C sensors into a simple, battery-powered weather station.
27+
28+
We will use:
29+
30+
* the onboard temperature sensor (low precision, ± 1 °C)
31+
* HTU21D I2C sensor to get humidity level
32+
* Bosch BMP280 to get the barometric pressure and precise temperature
33+
* TSL2561 light sensor to get luminosity
34+
35+
### Hardware Setup
36+
37+
The hardware connections for this project are quite simple: all the sensors use I2C interfaces and run at 3.3V.
38+
39+
They need four wires from the MKR FOX 1200: GND, 3.3V, SDA on Pin 11 and SCL on Pin 12. The same four connections can be shared in parallel with the three sensors because each of them has a specific I2C address and therefore the relevant libraries and functions will take care of discriminating each of them.
40+
41+
The whole project can be powered by two AA or AAA alkaline batteries connected in series to generate 3V and wired to the screw connection terminal block on the board.
42+
43+
### Sigfox Messages
44+
45+
Since the Sigfox network can send a maximum of 140 messages per day, we'll optimize the readings and send data in compact binary format.
46+
47+
Data packing is important because the maximum size of a message you can send is 12 bytes. A float occupies 4 bytes, so we'll need to pack our readings into some smaller representation.
48+
49+
The float format is very wide (you can represent numbers as big as 3.402823e+38 (!) ) and we don't need the whole data space; we can then decide safe limits (based on where we are going to deploy the station) and restore the original representation in the backend.
50+
51+
### Configuration of the Cloud Services
52+
53+
We'll use two Cloud services:
54+
55+
* [Sigfox backend](http://backend.sigfox.com/)
56+
* [Thingspeak](https://thingspeak.com/)
57+
58+
Register your board on Sigfox backend using PAC and ID provided by [FirstConfiguration example](https://www.arduino.cc/en/Tutorial/SigFoxFirstConfiguration) (can be skipped if you already did that for a previous project).
59+
60+
Both need to be configured to talk each other and interpret the data in the right format. Register to both and create a couple of *channels* on Thingspeak. The configuration is reported in the image below.
61+
62+
The first channel we configure will be the one which receives the raw data (`readChannelID`), while the second one will collect the re-scaled data (`writeChannelID`).
63+
64+
![Channel settings.](assets/2017-03-27-181233_547x732_scrot_B6IpPZo7FW.png)
65+
66+
It's about time to upload the sketch using Arduino Create Editor. The default sketch lets you test extensively all the infrastructure before deploying on the field.
67+
68+
Remember to declare:
69+
70+
```arduino
71+
oneshot = false
72+
```
73+
74+
when you are confident that all the backend infrastructure setup is correct. The sketch waits for the serial port, so we won't launch it now. Instead, open the [SigFox backend](http://backend.sigfox.com/) and configure a callback:
75+
76+
77+
![Click on **Device type** -> **List** -> right click on your board and click on **Edit.**](assets/2_edit_GTyVPD287A.png)
78+
79+
80+
![Click on **CALLBACKS** on the left side menu](assets/3_callbacks_7EhCtULJvp.png)
81+
82+
You will see a windows like this:
83+
84+
85+
![Click on **New** button on the upper right of the window.](assets/4_callbacks_3vY6hHeVX5.png)
86+
87+
![Select **Custom callback**](assets/5_callbacks_BfT0WriuOm.png)
88+
89+
![New callback.](assets/6_new_callback_1nmdMMud2F.png)
90+
91+
The relevant configurations are reported below. Make sure the callback is setup as:
92+
93+
* TYPE: `DATA/UPLINK`
94+
* Channel: `URL`
95+
* Http method: `GET`
96+
97+
As Custom Payload, set:
98+
99+
```arduino
100+
status::uint:8 temp1::int:16:little-endian temp2::int:16:little-endian press::uint:16:little-endian hum::uint:16:little-endian light::uint:16:little-endian lastMsg::uint:8
101+
```
102+
103+
This represents the structure we packed in the sketch. We are assigning a variable to each field, so we can reference them in the HTTP callback.
104+
105+
As URL Pattern, set:
106+
107+
```arduino
108+
https://api.thingspeak.com/update?api_key=XXXXXXXXXXXX&field1={customData#temp1}&field2={customData#press}&field3={customData#temp2}&field4={customData#hum}&field5={customData#light}&field6={customData#status}&field7={customData#lastMsg}
109+
```
110+
111+
Once configured, your windows should be like this:
112+
113+
![Callback on SigFox backend (use your API key!)](assets/2017-03-27-181130_1319x555_scrot_xIFbqIRrwJ.png)
114+
115+
116+
117+
Remember to change the API key `api_key`with the one provided by Thingspeak as `Write API Key`for `Channel1`.
118+
119+
![Generate API key.](assets/2017-03-27-181800_589x361_scrot_KZ9gpPSaaH.png)
120+
121+
Save and exit. We can now open the serial port and observe the first message being sent. Hooray!
122+
123+
### From Raw to Graphics
124+
125+
The setup we configured will route our data to the Thingspeak backend, but they are still in raw format; to reconvert them, let's use [Thingspeak analysis tool ](https://thingspeak.com/apps/matlab_analyses)with this snippet
126+
127+
```arduino
128+
% TODO - Replace the [] with channel ID to read data from:
129+
readChannelID = [];
130+
% TODO - Enter the Read API Key between the '' below:
131+
readAPIKey = 'T6UK7XO6A4H2AGT7';
132+
% TODO - Replace the [] with channel ID to write data to:
133+
writeChannelID = [];
134+
% TODO - Enter the Write API Key between the '' below:
135+
writeAPIKey = 'XU4TGY261P6B5USN';
136+
%% Read Data %%
137+
data = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey,'OutputFormat','table');
138+
analyzedData = data;
139+
%% Analyze Data %%
140+
INT16_t_MAX = 32767;
141+
UINT16_t_MAX = 65536;
142+
analyzedData.('Temperature1') = data.('Temperature1') / INT16_t_MAX * 120 ;
143+
analyzedData.('Temperature2') = data.('Temperature2') / INT16_t_MAX * 120 ;
144+
analyzedData.('Pressure') = data.('Pressure') / UINT16_t_MAX * 200000 ;
145+
analyzedData.('Light') = data.('Light') / UINT16_t_MAX * 100000 ;
146+
analyzedData.('Humidity') = data.('Humidity') / UINT16_t_MAX * 110 ;
147+
%% Write Data %%
148+
thingSpeakWrite(writeChannelID, analyzedData, 'WriteKey', writeAPIKey);
149+
%% Schedule action: React -> every 10 minutes
150+
```
151+
152+
By replacing the **channel IDs** with our own we can finally convert back the raw data into actual values. Remember to schedule the analysis action every 10 minutes using **React** or it will never be executed!
153+
154+
![Convert raw data.](assets/2017-03-27-181450_1097x788_scrot_PRlvnPeNfZ.png)
155+
156+
![Schedule the analysis action every ten minutes.](assets/2017-03-27-181503_779x384_scrot_EQdWfi5cZN.png)
157+
158+
![Setup React.](assets/2017-03-27-181523_596x797_scrot_YBbBPFdpON.png)
159+
160+
161+
![We finally have our wonderful graphs.](assets/1_Hq8YszSW57.png)
162+
163+
![Did someone turn the heat on at 11.30? ](assets/2_k6P30hcsDg.png)
164+
165+
166+
167+
## Complete Sketch
168+
169+
<iframe src='https://create.arduino.cc/editor/Arduino_Genuino/f025cb10-c6a7-41d5-911a-0ecad82bbcbb/preview?embed&snippet' style='height:510px;width:100%;margin:10px 0' frameborder='0'></iframe>

0 commit comments

Comments
 (0)