MySensors WiFi Gateway with Arduino UNO and CC3000



  • I have a few WiFi LinkSprite CC3000 but I can't find any sketch with MySensors WiFi gateway and CC3000.

    Anyone tried this WiFi shield as an WiFi gateway?

    Link to CC3000 http://linksprite.com/wiki/index.php5?title=CC3000_WiFi_Shield_for_Arduino





  • Hi @flopp

    I've tried my CC3000 shield again with no luck, it just does not initialize.

    However at the time I got another board with just the CC3000 and it does work, I was able to connect it to my Wifi and ping a server.

    Also did some investigation on what it would take to have this module working with MySensors on 1.6

    This would imply changes on the core libraries, something I don't feel comfortable without support from the MySensors folks.

    But let me explain my rationale:

    We should be able to create a CC3000 gateway similar to WL5100 or even ESP8266 and from there we could go to the MQTT client.

    At the core we have the ethernet transport library:
    Here is a snippet:

    #if defined(MY_GATEWAY_ESP8266)
    	// Some re-defines to make code more readable below
    	#define EthernetServer WiFiServer
    	#define EthernetClient WiFiClient
    	#define EthernetUDP WiFiUDP
    
    	#if defined(MY_IP_ADDRESS)
    		IPAddress gateway(MY_IP_GATEWAY_ADDRESS);
    		IPAddress subnet(MY_IP_SUBNET_ADDRESS);
    	#endif
    	static bool clientsConnected[MY_GATEWAY_MAX_CLIENTS];
    

    It should be possible to so something like:

    #if defined(MY_GATEWAY_CC3000)
    	// Some re-defines to make code more readable below
    	#define EthernetServer Adafruit_CC3000_Server
    	#define EthernetClient Adafruit_CC3000_Client
    	//#define EthernetUDP WiFiUDP
    
    	#if defined(MY_IP_ADDRESS)
    		IPAddress gateway(MY_IP_GATEWAY_ADDRESS);
    		IPAddress subnet(MY_IP_SUBNET_ADDRESS);
    	#endif
    	static bool clientsConnected[MY_GATEWAY_MAX_CLIENTS];
    

    Of course we would need to port whatever methods are called from those EthernetClient/Server to the Adafruit_CC3000_Client/Server.

    However later in the code we have a "mysterious" WiFi object that I just cant find where is it coming from...

    bool gatewayTransportInit() {
    	_w5100_spi_en(true);
    	#if defined(MY_GATEWAY_ESP8266)
    		(void)WiFi.begin(MY_ESP8266_SSID, MY_ESP8266_PASSWORD);
    		#ifdef MY_IP_ADDRESS
    			WiFi.config(_ethernetGatewayIP, gateway, subnet);
    		#endif
    		while (WiFi.status() != WL_CONNECTED)
    		{
    			delay(500);
    			MY_SERIALDEVICE.print(".");
    			yield();
    		}
    		MY_SERIALDEVICE.print(F("IP: "));
    		MY_SERIALDEVICE.println(WiFi.localIP());
    

    I suppose this would be inside the ESP8266.h or similar.
    I do have the Adafruit_CC3000 library and for this to work we have to declare and instantiate a CC3000 object, something like

    Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                             SPI_CLOCK_DIV2); // you can change this clock speed but DI
    

    And the we could call

    cc3000.begin()
    ...
    cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)
    ...
    etc
    

    But where to do this?

    On a lib under drivers, included when we define a MY_GATEWAY_CC3000 like the NRF drivers?

    #if defined(MY_RADIO_NRF24)
    		#if defined(MY_RF24_ENABLE_ENCRYPTION)
    			#include "drivers/AES/AES.cpp"
    		#endif
    		#include "drivers/RF24/RF24.cpp"
    		#include "core/MyTransportNRF24.cpp"
    

    Or maybe a MyHwCC3000 ?

    Perhaps @hek and the other folks can point us in the right direction

    Cheers



  • @flopp

    If you're not using 1.6 i think @Connor-Rigby has what you need

    Check this out http://forum.mysensors.org/topic/2727/adafruit-cc33000-wifigateway



  • If you are using the shield version it might be difficult. You need to change the pin locations for CE and cs on the radio. You can do this in either myconfig.h or in your gateway code. It shouldn't need any code modification in the core libraries but do note it won't fit onto am UNO.



  • I got it to work, yeah.

    Thanks to @Connor-Rigby and @barduino

    I am using a Ardino MEGA 2560 and a LinkSprite CC3000 Shield wo SD-card with Adafruit CC3000 Library.

    I am using the code as Connor -Rigby linked to in his topic http://forum.mysensors.org/topic/2727/adafruit-cc33000-wifigateway

    I had to do some modifications

    1. I had to add, since LinkSprite CC3000 seems not sharing MOSI/MISO/SCK
    #include <DigitalIO.h>     // This include can be removed when using UIPEthernet module
    
    1. enabled SOFTSPI by removing // at #define SOFTSPI, in MyConfig.h, since LinkSprite CC3000 seems not sharing MOSI/MISO/SCK
    2. change SOFTSPI pins, since a MEGA doesn't use same pins as UNO.
    const uint8_t SOFT_SPI_MISO_PIN = 56;
    const uint8_t SOFT_SPI_MOSI_PIN = 55;
    const uint8_t SOFT_SPI_SCK_PIN = 54;
    
    1. Changed VBAT to 5 instead of 4, according to https://learn.adafruit.com/adafruit-cc3000-wifi/connections. Tested with 4 but not working.
    #define ADAFRUIT_CC3000_VBAT  5
    

    This is same pin as Radio_CE(see code) but it is working, i think because we never sleep NRF

    #define RADIO_CE_PIN        5  // radio chip enable
    

    So now I will run it and see if it works for a long period



  • It has been running now for 3 days but today Domoticz failed to communicate with it.
    I restarted gateway, let's see for how long it will work this time.



  • Stopped after just 1,5 hours.

    This time I tried to only restart Domoticz, didn't help so I power-off power-on gateway and it start to work.



  • Stopped again.
    I will stop using/testing this setup right now.
    I will start to use UNO with W5100.



  • Hi @flopp

    I think cc3000 disconnects from the Wifi and as @Connor-Rigby mentioned in his post there is some work to be done on that area.



  • @barduino @flopp sorry guys i fixed this last week but forgot to tell anyone. it shou;d be on my github


Log in to reply
 

Suggested Topics

  • 1
  • 10
  • 3
  • 1
  • 2
  • 6

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts