Sign in to follow this  
Followers 0
eelcor

ESP8266 - IoT on the cheap ;)

21 posts in this topic

Hi everybody,

 

People might have read the hackaday post describing the ESP8266. The ESP8266 is a really low price Wifi chip, which uses serial communication (just like the Wifly etc.) to connect to wifi. Although the CC3100 and CC3200 are the better chips, the ESP8266 main differentiating point is its ridiculous low price. I've ordered 8 for $3.50 each (aliexpress). It doesn't seem to support IPv6 out of the box, but there is an SDK, which might open future possibilities.

 

I was thinking to make a library for energia to support the ESP8266. Anyone interested? Are there specific starting points to make this library usable?

 

I am looking at two scenario's:

- MQTT client - Relaying sensor data or control.

- Web service - Returning a JSON object with sensor data.

 

It would be nice to use the hooks of an ethernet library and only need to process strings/arrays of bytes. 

 

Edit: As this wifi dongle uses an UART, how do I create two UARTS on a G2553?

 

Kind regards,

 

Eelco Rouw

Automate and yosh like this

Share this post


Link to post
Share on other sites

I am interested in a lib, even if it cant use the current ethernet interface/framework it could be a good fit for dumb sensors that just send/recieve some data.

Share this post


Link to post
Share on other sites

I'm interested too.

This module could be a perfect companion for a 2553 in low powermode, sending datas time to time.

 

For second UART look at  SoftwareUart exemple. (hard Uart + soft Uart)

Share this post


Link to post
Share on other sites

So this device has a low power 32 bit CPU in it.  What is the point of an MSP430 connected to it?

(i.e., if you add the G2553, e.g., as a peripheral to this device, what does the MSP430 bring to the setup.)

Share this post


Link to post
Share on other sites

Adding some MSP gives :

-Energia for application programming (very important for some of us  !!)

-some proven I/O : GPIO , ADC, UART...

-great MSP low powering modes

 

Off course standalone ESP8266 is very interesting too !!!

Share this post


Link to post
Share on other sites

So this device has a low power 32 bit CPU in it.  What is the point of an MSP430 connected to it?

(i.e., if you add the G2553, e.g., as a peripheral to this device, what does the MSP430 bring to the setup.)

 Most boards for the esp only have 2 gpio broken out, lack of technical data, sdk, etc.

Share this post


Link to post
Share on other sites

A small ti/avr/arduino board and just using the ESP as a network module is probaly a lot easyier, and not that much more expensive.

Share this post


Link to post
Share on other sites

Hi everybody,

 

The modules are quite easy to connect and configure. Although the wifi dongle has its own microcontroller, I want to use it with the launchpad. I am not looking to tweak the modules themselves but create simple connected devices. The combination of a value line controller and the ESP8266 yields cheap smart switches and smart objects. 

 

Still pondering how the library should be structured...

 

Kind regards, 

 

Eelco

Share this post


Link to post
Share on other sites

Another alternative - EMW3162.

Uses Cortex M3 (STM32F205RG) (for those put off by the less common CPU of the ESP8266).
 
Looks like it could be a less expensive ($8.50), more powerful (120MHz, 1M byte of Flash, 128k bytes) alternative to the CC3200.
No desire to hijack this thread, but would be curious about comparison between the three platforms.

I started a thread on this on stellarisiti, but it seems to be slow showing up.

Share this post


Link to post
Share on other sites

after fighting with the terrible string handling of msp430-g++ I finally got ESP8266 to work with MSP430 G2553 and upload telemetry data to ubidots. This is a REAL working code, no BS. Thanks to all who suggested using standard c str instead of the "String" object. 

       
        
        #define SSID        "xxxx"
        #define PASS        "xxxxx"
        #define DST_IP      "things.ubidots.com"
        #define idvariable  "xxxxxxxx"   // replace with your Ubidots Variable ID
        #define token       "xxxxxxxxxxxxx"  // replace with your Ubidots token
        int len;
        
        void setup()
        {
          // Open serial communications and wait for port to open:
          char cmd[254];
          Serial.begin(115200);
          Serial.setTimeout(5000);
          //test if the module is ready
          Serial.println("AT+RST");
          delay(1000);
          if (Serial.find("ready"))
          {
            //dbgSerial.println("Module is ready");
          }
          else
          {
            //dbgSerial.println("Module have no response.");
            while (1);
          }
          delay (1000);
          //connect to the wifi
          boolean connected = false;
          for (int i = 0; i < 5; i++)
          {
            if (connectWiFi())
            {
              connected = true;
              break;
            }
          }
          if (!connected) {
            while (1);
          }
          delay(5000);
          Serial.println("AT+CIPMUX=0");
          }
        
        void loop()
        {
          int value = analogRead(A0);                          //you can change ir to another pin
          int num=0;
          String var = "{\"value\":"+ String(value) + "}";
          num = var.length();
          String cmd = "AT+CIPSTART=\"TCP\",\"";
          cmd += DST_IP;
          cmd += "\",80";
          Serial.println(cmd);
          if (Serial.find("Error")) return;
          
          len=strlen ("POST /api/v1.6/datasources/");
          len=len+strlen (idvariable);
          len=len+strlen ("/values HTTP/1.1\nContent-Type: application/json\nContent-Length: ");
          char numlenght[4]; // this will hold the length of num which is the length of the JSON element
          sprintf(numlenght, "%d", num); // saw this clever code off the net; works yay
          len=len+strlen (numlenght);
          len=len + num; //fixed length of the string that will print as Content-Length: in the POST
          len=len+strlen ("\nX-Auth-Token: ");
          len=len+strlen (token);
          len=len+strlen ("\nHost: things.ubidots.com\n\n");
          len=len+strlen ("\n\n");
          Serial.print("AT+CIPSEND=");
          Serial.println (len); //lenght of the entire data POST for the CIPSEND command of ESP2866
          //Serial.println(cmd.length());
          if (Serial.find(">"))
          {
            //Serial.print(">");
          } else
          {
            Serial.println("AT+CIPCLOSE");
            delay(1000);
            return;
          }
          Serial.print ("POST /api/v1.6/variables/");
          Serial.print (idvariable);
          Serial.print ("/values HTTP/1.1\nContent-Type: application/json\nContent-Length: ");
          Serial.print (num);
          Serial.print ("\nX-Auth-Token: ");
          Serial.print (token);
          Serial.print ("\nHost: things.ubidots.com\n\n");
          Serial.print (var);
          Serial.println ("\n\n");
          delay(9000);
          //Serial.find("+IPD"); clear the input buffer after the web site responds to the POST
          while (Serial.available())
          {
            char c = Serial.read();
          }
          delay(1000);
        }
        boolean connectWiFi()
        {
          Serial.println("AT+CWMODE=1");
          String cmd = "AT+CWJAP=\"";
          cmd += SSID;
          cmd += "\",\"";
          cmd += PASS;
          cmd += "\"";
          Serial.println(cmd);
          delay(2000);
          if (Serial.find("OK"))
          {
          return true;
          } else
          {
           return false;
          }
        } 
        
roadrunner84 likes this

Share this post


Link to post
Share on other sites

@@bubba198 You do see that you're still using String instead of c-style strings?

 

Also, you're using Serial.print() while also using '\n', though sometimes you use println().

//This code
          Serial.print ("POST /api/v1.6/variables/");
          Serial.print (idvariable);
          Serial.print ("/values HTTP/1.1\nContent-Type: application/json\nContent-Length: ");
          Serial.print (num);
          Serial.print ("\nX-Auth-Token: ");
          Serial.print (token);
          Serial.print ("\nHost: things.ubidots.com\n\n");
          Serial.print (var);
          Serial.println ("\n\n");

// Could also be this code
          Serial.print  ("POST /api/v1.6/variables/");
          Serial.print  (idvariable);
          Serial.println("/values HTTP/1.1");
          Serial.println("Content-Type: application/json");
          Serial.print  ("Content-Length: ");
          Serial.println(num);
          Serial.print  ("X-Auth-Token: ");
          Serial.println(token);
          Serial.println("Host: things.ubidots.com");
          Serial.println("");
          Serial.print  (var);
          Serial.println("");
          Serial.println("");

Although the second looks a bit more messy, you're splitting the headerlines in a crisp fashion. It's just style, I just like the second one better.

Share this post


Link to post
Share on other sites

Wow,

 

The thread has been hijacked, but with a very good reason! I have been looking into the ESP8266 as a standalone controller and with the arduino fork it works like a charm.

 

All the options to have cheap wifi start to dazzle me! I am currently also working on a back end with python, MongoDB and Flask.

 

My original plans with an internet controlled greenhouse keep on changing ;)

Share this post


Link to post
Share on other sites

Does anyone know about the performance of this puppy? I want to do streaming video, but this might very well be too big a bone for this tiny beast...

Share this post


Link to post
Share on other sites

The default AT commands mode communication speed the modules come with is 57600/115200 bps, maybe if you run the code directly on the micro you can get a better speed.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0