I've been working to learn more about the Arduino MKR GSM 1400 for a while and this is my attempt to set up a sketch that will publish data to the Thingspeak API in JSON format.
The sketch can be extended to monitor anything you like really. In its default format as presented, it will write sensor data and your location (latitude and longitude, as well as altitude and the accuracy of your location) through to a ThingSpeak channel.
This sketch was built from the basic GPRS SSL sketch by adding additional items and output to the serial monitor output such as the current phone network signal strength, etc.
It takes that basic sketch further by adding the Arduino JSON library and feeding the sensor and location data into a JSON array/object, which can be published directly to ThingSpeak.
Once connected, it will attempt to read the result of the connection to confirm it has successfully read or written to ThingSpeak via an HTTP status code, i.e. 200 or 202 (accepted).
In the second Iteration, it will publish the previous result code and the number of times the button has been pressed since the Arduino MKR GSM 1400 was powered on...
You may wish to eliminate the button altogether and just make it loop around every few seconds, so that if you did place the unit inside your fridge, you'd instantly know via your thingspeak graphs that the fridge light went out :)
To use this project:
1. Download the code.
2. Set up your project as shown in the Fritzing diagram.
3. Set up an account with ThingSpeak.
4. Modify the arduino_secrets.h file with your channel ID, and write API key as a minimum.
5. Compile the code and upload it to your MKR GSM 1400.
6. Monitor the output via serial.
7. Press the button.
8. Log in to the ThingSpeak website and look at your channel data to see if it changed.