Laurence Daxes
Published © MIT

Connecting LinkIt ONE to Cayenne

Cayenne don't have native support for LinkIt ONE, but as It use Blynk Libraries, Blynk have support, then is possible able for Cayenne.

IntermediateFull instructions provided1 hour292
Connecting LinkIt ONE to Cayenne

Things used in this project

Hardware components

LinkIt ONE
MediaTek Labs LinkIt ONE
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Cayenne
myDevices Cayenne

Story

Read more

Custom parts and enclosures

LinkIt ONE Pinout

Schematics

LinkIt ONE Pinout

Code

CayenneLWiFi.h

Arduino
Add this file
/*
The MIT License(MIT)

Cayenne Arduino Client Library
Copyright © 2016 myDevices

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files(the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This software uses open source blynk-library - see blynk-library/LICENSE
*/

#ifndef _CAYENNELWIFI_h
#define _CAYENNELWIFI_h

#include "CayenneDefines.h"
// Fix for connection issues caused by sending too much data for WiFi Shield R3
#define BLYNK_SEND_CHUNK 80
#define SEND_IN_CHUNKS
#include "BlynkSimpleLinkItONE.h"
#include "CayenneWiFiClient.h"

#endif

CayenneWiFiClient.h

Arduino
Modify this file
/*
The MIT License(MIT)

Cayenne Arduino Client Library
Copyright © 2016 myDevices

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files(the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This software uses open source blynk-library - see blynk-library/LICENSE
*/

#ifndef _CAYENNEWIFICLIENT_h
#define _CAYENNEWIFICLIENT_h

#include "CayenneClient.h"

int WiFiAuth;

class CayenneWiFiClient : public CayenneClient
{
public:
	/**
	* Begins Cayenne session
	* @param token Authentication token from Cayenne site
	* @param ssid WiFi network id
	* @param pass WiFi network password
	*/
	void begin(const char* token, const char* ssid, const char* pass)
	{
		Blynk.begin(token, ssid, pass,WiFiAuth, CAYENNE_DOMAIN, CAYENNE_PORT);
	}
};

CayenneWiFiClient Cayenne;

#endif

BlynkSimpleLinkItONE.h

Arduino
Modify this file
/**
 * @file       BlynkSimpleLinkItONE.h
 * @author     Volodymyr Shymanskyy
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 Volodymyr Shymanskyy
 * @date       Jul 2015
 * @brief
 *
 */

#ifndef BlynkSimpleLinkItONE_h
#define BlynkSimpleLinkItONE_h

#ifndef BLYNK_INFO_DEVICE
#define BLYNK_INFO_DEVICE  "LinkIt ONE"
#endif

// cause this causes crashes...
#define BLYNK_NO_YIELD

#include <BlynkApiArduino.h>
#include <Blynk/BlynkProtocol.h>
#include <Adapters/BlynkArduinoClient.h>
#include <LWiFi.h>
#include <LWiFiClient.h>

class BlynkLinkItOneWifi
    : public BlynkProtocol<BlynkArduinoClient>
{
    typedef BlynkProtocol<BlynkArduinoClient> Base;
public:
    BlynkLinkItOneWifi(BlynkArduinoClient& transp)
        : Base(transp)
    {}

    void connectWiFi(const char* ssid, const char* pass, int wifi_auth)
    {
        BLYNK_LOG("Connecting to %s ...", ssid);
        LWiFi.begin();
        //while(!LWiFi.connect(ssid, LWiFiLoginInfo((LWiFiEncryption)wifi_auth, pass))){
        while( !LWiFi.connectWPA(ssid,pass) ){
            ::delay(1000);        
        }
    }

    void config(const char* auth,
                const char* domain = BLYNK_DEFAULT_DOMAIN,
                uint16_t    port   = BLYNK_DEFAULT_PORT)
    {
        Base::begin(auth);
        this->conn.begin(domain, port);
    }

    void config(const char* auth,
            	IPAddress   ip,
                uint16_t    port   = BLYNK_DEFAULT_PORT)
    {
    	Base::begin(auth);
    	this->conn.begin(ip, port);
    }

    void begin(const char* auth,
               const char* ssid,
               const char* pass,
               int         wifi_auth,
               const char* domain = BLYNK_DEFAULT_DOMAIN,
               uint16_t port      = BLYNK_DEFAULT_PORT)
    {
        connectWiFi(ssid, pass, wifi_auth);
        config(auth, domain, port);
    }

    void begin(const char* auth,
               const char* ssid,
               const char* pass,
			   int         wifi_auth,
               IPAddress   ip,
               uint16_t    port = BLYNK_DEFAULT_PORT)
    {
        connectWiFi(ssid, pass, wifi_auth);
    	config(auth, ip, port);
    }

};


static LWiFiClient _blynkWifiClient;
static BlynkArduinoClient _blynkTransport(_blynkWifiClient);
BlynkLinkItOneWifi Blynk(_blynkTransport);

#include <BlynkWidgets.h>

#endif

Credits

Laurence Daxes

Laurence Daxes

5 projects • 25 followers
Systems Engineer Bachellor, I Love technology, and IoT World https://youtube.com/c/DaxesHacks

Comments

Add projectSign up / Login