IoT Toaster (LoRa)

by Prevas in Circuits > Wireless

4657 Views, 12 Favorites, 0 Comments

IoT Toaster (LoRa)

Prevas IoT Toaster.png
Prevas IoT Toaster Demo

IoT Toaster

A toaster that can be both monitored and controlled through an custom made Android application.

The toaster is equipped with an SODAQ ExpLoRer card that has a 32-Bit ARM Cortex M0+ and a integrated LoRa module and antenna. This LoRa modules provides for the communication between the mobile and the toaster via a gateway. The LoRa communication operates on the ISM band at 868Mhz and are typically used in IoT applications due to its low energy and long range performance (+ free of charge to operate on the 868Mhz band). Read more about LoRa here: http://www.semtech.com/wireless-rf/internet-of-things/what-is-lora/

An Andorid application has been developed that are able to wirelessly control the toaster by means of lowering down the breads in the toaster and turn the heater element on for a specifed amount of time. Three different ”toaster” levels can be chosen by the user(rare,medium,well done). At the same time it will monitor the outside temeperature of the toaster. All communication is directed through the LoRa gateway and further processed by PubNub that makes it possible for the Android application to subscribe and publish data form the gateway through a channel.

Hardware Parts

1. Toaster (any toaster with similar lifting mechanism will work) :
https://www.nfcd.hk/en/product/black-glass-toaster...

2. Stepper Motor – Linear Stepper motor:
https://prototypes.haydonkerk.com/ecatalog/can-sta...

4. Stepper Motor Driver:
https://www.pololu.com/product/1182

3. Sodaq One Explorer – LoRa:
http://support.sodaq.com/sodaq-one/explorer/

4. Battery holder – 12V:
https://www.ebay.com/itm/1-pc-8X1-5V-AA-2A-CELL-Pl...

5. Switch (any 12V switch will work):
https://www.ebay.com/itm/Heavy-Duty-ON-OFF-Small-S...

6. Aluminium Profiles:
https://www.ebay.co.uk/itm/2mm-Hole-3-5mm-Pitch-1m...

7. Cables,Screws and Batteries

Material

DSC_0653.JPG
DSC_0654.JPG
DSC_0655.JPG
DSC_0656.JPG
aluminium plate.png

2.1 - Measure the each of the sides on the toaster and cut out the aluminium part of that. In this case, the aluminium plate's dimension is 33,5 x 13,5 cm (picture). Make four holes that match the frontpanel holes of the toaster. In this case they are placed in each corner of a rectangle with diemension of 31,5 x 12,5 cm.

2.2 - Make two holes (location is up to you). The first hole needs to be 11 x 5,5 cm in order for the SODAQ card to fit. The second hole needs to be as large as your switch are. Make a plexiglass with the same dimensions as in the picture. Drill two holes to support for the SODAQ card.

2.3 - Take the aluminium profiles and cut into two pieces. The length should be equal to the side of the aluminium plate.

Mount the Stepper Motor

DSC_0660.JPG
DSC_0662.JPG
DSC_0665.JPG
DSC_0666.JPG
DSC_0667.JPG

WARNING! Modifications on electrical products may cause svere damgage if not handled correctly!

3.1. Remove the nessecary srews that holds the shell onto the heater element and it's structure.

3.2 Remove the rod that holds the toaster levler in vertical position.

3.3. Use a screwdriver to make a hole right below where this rod should have been placed. Make sure you are not drilling into any electronics!

3.4. Replace the orignial rod with the linear motor and fasten the plastic mount on top of the plastic structure with three srews (picture). This will now act as the new motorized rod, which we will able to control!

Connecting Hardware

hardware diagram_bb.png
Microchip-1-768x434.jpg
DSC_0654.JPG
DSC_0658.JPG
DSC_0643.JPG
DSC_0650.JPG
DSC_0668.JPG
DSC_0669.JPG
DSC_0672.JPG

4.1. After the motor have been mounted onto the toaster, connect it as in the above circuit diagram (picture). I used an experiment board to solder the nessecary connections between the signals and used three headers to be able to mount it on the SODAQ card.

4.2 Put it all togheter and take some adhesive tape to mount the battery holder on the back of the aluminium plate(picture). Use the screws to mount the plate on the toaster.

Software Design

traffic_overview.png

1. SODAQ Node – The node that controls the toaster and sends motor commands to the motor driver that controls the stepper motor. The stepper motor will lower or raise the toast depending on which command that has been given by the user.

2. Multiconnect Conduit – The gateway which the SODAQ node connects to over LoRa once powered up. The gateway provides a channel which data are transferred to talkpool.

3. Talkpool – Is the server provider that makes it possible to interface to the different IoT platforms via the integrated protocols. Protocols availabe to use is: MQTT, PubNub, IBM Bluemix. (In this project we are going to use PubNub)

4. PubNub – IoT platform that act as a central hub where the traffic are sent thorugh channels. Subscribe/Publish structure. Different SDK provides for different platforms to be used (In this project we are using the SDK for Android)

5. Android Application – With the PubNub Android SDK, the application provides a graphical interface to the user that shows the temperature of the toaster (subscribe channel). Moreover, it is also possible to control the toaster via buttons in the application (publish channel).

For further reading and tutorial:
https://www.pubnub.com/docs/android-java/pubnub-ja...

Register Device on Talkpool

mt_multiconnects_conduit_mcard_animated.gif
Talkpool.PNG
talkpool2.png
talkpool3.png
talkpool4.png
talkpool5.png
talkpool6.png

There are several of LoRa gateways on the market, the MultiConnect® Conduit is just one of many.
For example, a cheaper solution would be Wirnet iFemtoCell by Kerlink, LG01-P LoRa Gateway from Dragino or The Things Gateway.

Talkpool is our local server provider in Sweden but there also exist other ones, for example LORIOT or The Things Network. Depending on which server provider that is used there will be different configuration methods.

After configuring the gateway via Talkpool we proceed by logging in and register our device.

6.1. Press the plus sign to add a device (picture), the hit "Generate An Application EUI" (picture), then type in a unique name for the device.
6.2. Go the tab "Customer Servers" and then press the plus sign (picture)
6.3. Press the "Protocol type drop down menu and select PUBNUB.
6.4. Add your PUBNUB publish key and subscribe key.(picture) (How to add these channels and get the keys will be covered in the next step)

Creating a PUBNUB App

PubNub.png
PubNub2.png
PubNub3.png

7.1. Create an account at PUBNUB (pubnub.com)
7.2. Press on the red button "Create New App" - (picture)
7.3. Name the app and press ok.
7.4. Press on the newly generated app card with your name.
7.5. Now you can see your Publish Key and Subscribe Key(picture). Copy those and type them in the Talkpool device fields for the PUBNUB settings (previous step). Do also type them in the Android Project (in step 9)

Source Code - Sodaq Explorer

device EUI- Sodaq Card.PNG

The source code is written and downloaded to the SODAQ card using the Arduino IDE. Make sure to add the requried libraries before deploying the code:
"Install the required libraries from the Arduino library manager.Sketch -> Include library -> Manage libraries…Install “Sodaq_RN2483” and “Sodaq_wdt”
More info here: http://support.sodaq.com/sodaq-one/1191-2/

To get your DevEUI, follow this tutorial here: http://support.sodaq.com/sodaq-one/lorawan/

The AppEUI is the one you generated on Talkpool (step 2).

Remember to change the following paramters in the SODAQ_Source_Code:
const uint8_t DevEUI[8] =
{
//Type in your DevEUI key below in HEX format
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

const uint8_t AppEUI[8] =
{
//Type in your AppEUI key below in HEX format
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

const uint8_t AppKey[16] =
{
// Type in your app key below in HEX format
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

Other important paramters to consider:
// Depending on your stepper motor, type in the number of steps for one revolution
const int stepsPerRevolution = 200;

// Type in your own times for the three different levels (in milliseconds)
int rareTime = 30000;
int mediumTime = 60000;
int wellDoneTime = 100000;

Source Code - Android Application

Device EUI.PNG
Screenshot_20171203-192018.png
Screenshot_20171203-192025.png

Remember to change the following parameter inside the MainActivity
(
The subscription and publish keys is the ones generated in step 7.5 and the deviceEUI in step 6.1):

private static String pubNubSubscriptionKey="sub-x-x-x-x-x-x";
private static String pubNubPublishKey="pub-x-x-x-x-x-x";
private static String deviceEui = "xx-xx-xx-xx-xx-xx-xx-xx";

Downloads

Debug Communication

PubNub Channel Setup.png
PubNub Incoming Data.png
Arduino data transmission.PNG
Talkpool network activity.png
Test Communication From Android Application.png
Test Communication From Android Application-2.png
Screenshot_20171207-190753.png
Screenshot_20171207-190800.png

To ensure that the bidirectional communication is working from the SODAQ card all the way to the Android App we brake it down in smaller pieces to make it easier to debug.

10.1 - First of all we check that the SODAQ card is able to connect to the gateway. We can do this by either looking on the leds on the SODAQ card, or simply by connecting the SODAQ card to the computer with a micro USB and read the serial line on baudrate 57000.
SODAQ Serial monitor picture

10.2 - Make sure that the gateway receives the packages that are sent from the SODAQ card by logging in to the server provider (in this case Talkpool).
Talkpool communication picture

10.3 - Make sure that the data packages are recevied in PubNub respective channels (sent from talkpool) by logging in and view the previously created channels. Check the "Incoming" channel for the data packages sent from Talkpool.
PubNub communication picture

10.4 - Open Android application to ensure that the "Latest update" is recevied with a timestamp (this ensures that data are received all the way from the SODAQ card to the Android Application). If the communcation work "upstreams", then try send a message to the SODAQ card by selecting a toaster level and press "Toast my bread". Then you can debug the other way around to make sure the communication works "downstreams" as well. The SODAQ card will print out on the serial lines when it receives a package and what action it will do.

Android communication picture

Android communication picture

Demo

Prevas IoT Toaster Demo