Things used in this project

Hardware components:
Pi 3 02
Raspberry Pi 3 Model B
×1
Esp01
Everything ESP ESP8266 ESP-01
×1
Esp12e
Everything ESP ESP8266 ESP-12E
×1
00114 05
SparkFun Breadboard Power Supply 5V/3.3V
×1
Relay
Relay Module for Tessel
×1
Aiy projects 4 bgsoumwo5r
Google AIY Projects Kit
Mic and Speaker
×1
11026 02
Jumper wires (generic)
×1
Software apps and online services:
Google sheets
Google Sheets
Ide web
Arduino IDE
Logo things yummo7uv2y
Google Android Things
220px tensorflowlogo
TensorFlow
PushingBox
Hand tools and fabrication machines:
09507 01
Soldering iron (generic)

Custom parts and enclosures

Custom Google assistant
google_assistant__BImoeDZ5hs.zip
Tenser flow codes
tensor_flow_code_9o6ApGuLPD.rar

Schematics

Circuit Diagrams
Programing esp8266 with arduino p2apopudtc 5gqr0yh0gd
Esp8266 01 circuit
Capturemain eywjinlaaa

Code

Esp8266-01.inoArduino
#include <SoftwareSerial.h>
#define DEBUG true
 String readString3;
SoftwareSerial esp8266(3,2); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
                             // This means that you need to connect the TX line from the esp to the Arduino's pin 2

                             // and the RX line from the esp to the Arduino's pin 3
     int connectionId;
    String sendData(String command, const int timeout, boolean debug)
{
    String response = "";
    
    esp8266.print(command); // send the read character to the esp8266
    
    long int time1 = millis();
    
    while( (time1+timeout) > millis())
    {
      while(esp8266.available())
      {
        
        // The esp has data so display its output to the serial window 
        char c = esp8266.read(); // read the next character.
        response+=c;
      }  
    }
    
    if(debug)
    {
      Serial.print(response);
    }
    
    return response;
}

void setup()
{
  Serial.begin(115200);
  esp8266.begin(115200); // your esp's baud rate might be different
  sendData("AT+RST\r\n",2000,DEBUG); // reset module
  sendData("AT+CWMODE=2\r\n",1000,DEBUG); // configure as access point
  sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address
  sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections
  sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); 
  // turn on server on port 80
} 
void loop()
{

 
  if(esp8266.available()) // check if the esp is sending a message 
  {
         delay(60);
          if(esp8266.find("+IPD,"))
          {
                   delay(1000); // wait for the serial buffer to fill up (read all the serial data)
                   // get the connection id so that we can then disconnect
                   connectionId = esp8266.read()-48; // subtract 48 because the read() function returns 
                    
                                                         // the ASCII decimal value and 0 (the first decimal number) starts at 48
                     while(esp8266.available())
                        {
                            
                        char c = esp8266.read();
                        readString1 += c;
                         }
                       
                         
                   String closeCommand = "AT+CIPCLOSE="; 
                   closeCommand+=connectionId; // append connection id
                   closeCommand+="\r\n";
                   
                   sendData(closeCommand,1000,DEBUG); // close connection
       }
       if(readString1.length()>0)
     {   
           Serial.print(readString1);                                               //This is where you need to show your skills , 
       if (readString1.indexOf("/on")<1000&&readString1.indexOf("/on")!=-1)    // if the data send contails /on then the below commant will be exicuited 
      {                                                    
           digitalWrite(Light,HIGH); //Turn on the light 
      }                                                                               // if the data send contails /off then the below commant will be exicuited 
      else if(readString1.indexOf("/off")<1000&&readString1.indexOf("/off")!=-1)
                         {
                             digitalWrite(Light,LOW); //Turn off the light 
                          }               
                         

      }
                            
                                      
                                      
}  

  }
  
   
 
Google Script Java
//-----------------------------------------------
//Originally published by Mogsdad@Stackoverflow
//Modified for jarkomdityaz.appspot.com
//Modified for Hackster.io by Stephen Borsay
//-----------------------------------------------
/*

GET request query:

https://script.google.com/macros/s/<gscript id>/exec?celData=data_here
----------------------------------------------------------------------

GScript, PushingBox and Arduino/ESP8266 Variables in order:

humidityDat
celData
fehrData
hicData
hifData
----------------------------------------------------
*/


/* Using spreadsheet API */

function doGet(e) { 
  Logger.log( JSON.stringify(e) );  // view parameters

  var result = 'Ok'; // assume success

  if (e.parameter == undefined) {
    result = 'No Parameters';
  }
  else {
    var id = '<YOUR_SPREADSHEET_URL_HERE';//docs.google.com/spreadsheetURL/d
    var sheet = SpreadsheetApp.openById(id).getActiveSheet();
    var newRow = sheet.getLastRow() + 1;
    var rowData = [];
    //var waktu = new Date();
    rowData[0] = new Date(); // Timestamp in column A
    
    for (var param in e.parameter) {
      Logger.log('In for loop, param='+param);
      var value = stripQuotes(e.parameter[param]);
      //Logger.log(param + ':' + e.parameter[param]);
      switch (param) {
        case 'humidityData': //Parameter
          rowData[1] = value; //Value in column B
          break;
        case 'celData':
          rowData[2] = value;
          break;
        case 'fehrData':
          rowData[3] = value;
          break;
        case 'hicData':
          rowData[4] = value;
          break;
        case 'hifData':
          rowData[5] = value;
          break;
        default:
          result = "unsupported parameter";
      }
    }
    Logger.log(JSON.stringify(rowData));

    // Write new row below
    var newRange = sheet.getRange(newRow, 1, 1, rowData.length);
    newRange.setValues([rowData]);
  }

  // Return result of operation
  return ContentService.createTextOutput(result);
}

/**
* Remove leading and trailing single or double quotes
*/
function stripQuotes( value ) {
  return value.replace(/^["']|['"]$/g, "");
}
Arduino script for google sheetsArduino
//-----------------------------------------------
//This sketch is combined from Adafruit DHT sensor and tdicola
//for dht.h library
//Along with some  esp8266 NodeMCU specifics from teos009    
// https://learn.adafruit.com/dht/overview
// https://gist.github.com/teos0009/acad7d1e54b97f4b2a88
//other Authors Arduino and associated Google Script:
//Aditya Riska Putra
//Ahmed Reza Rafsanzani
//Ryan Eko Saputro
//See Also
//http://jarkomdityaz.appspot.com/
//
//ELINS UGM
//
//Modified for Hackster.io project to the ESP8266 from
//a Ethernet Sheild project
//by Stephen Borsay
//Since Arduino can't handle https, we need to use Pushingbox API
//(uses http)to run 
//the Google Script (uses https).


#include "ESP8266WiFi.h"


char sbuffer[30], ch;
unsigned char pos;
unsigned char sysbp, diabp, heartbeat;

const char WEBSITE[] = "api.pushingbox.com"; //pushingbox API server
const String devid = "<YOUR_Devid_HERE>"; //device ID from Pushingbox 

const char* MY_SSID = "<YOUR_WIFI_NAME_HERE";
const char* MY_PWD =  "<YOUR_WIFI_PASSWORD_HERE>";

char mygetchar(void)
{
	char c;
	while(!RI);
	RI =0;
	c = SBUF;
	return SBUF;
}
void setup()
{
  Serial.begin(115200);
  dht.begin();
  Serial.print("Connecting to "+*MY_SSID);
  WiFi.begin(MY_SSID, MY_PWD);
  Serial.println("going into wl connect");

  while (WiFi.status() != WL_CONNECTED) //not connected,..waiting to connect
    {
      delay(1000);
      Serial.print(".");
    }
  Serial.println("wl connected");
  Serial.println("");
  Serial.println("Credentials accepted! Connected to wifi\n ");
  Serial.println("");
  // -=-=- Intialize variables -=-=-=
	pos = 0;
		
	// -=-=- Intialise Serial Port -=-=-=
	//Sets up MCU to use 9600 bps @ 11.059 MHz Crystal
	SCON = 0x52; // 8-bit UART mode
	TMOD = 0x20; // timer 1 mode 2 auto reload
	TH1= 0xfd; // 9600 8-n-1
	TR1 = 1; // run timer1
}


void loop()
{
  
  //Wait between measurements longer then normal to slow donwn
  //google sheet populate, as We dont want to exceed free service quota
  delay(10000); //10 seconds, (sampling rate vs. service call quota)

  	ch = mygetchar(); //loop till character received
				if(ch==0x0A) // if received character is <LF>, 0x0A, 10 then process buffer
				{
					pos = 0; // buffer position reset for next reading
					
					// extract data from serial buffer to 8 bit integer value
					// convert data from ASCII to decimal
                    sysbp = ((sbuffer[1]-'0')*100) + ((sbuffer[2]-'0')*10) +(sbuffer[3]-'0');
                    diabp = ((sbuffer[6]-'0')*100) + ((sbuffer[7]-'0')*10) +(sbuffer[8]-'0');
                    heartbeat = ((sbuffer[11]-'0')*100) + ((sbuffer[12]-'0')*10) +(sbuffer[13]-'0');
					
					// Do whatever you wish to do with this sensor integer variables
					// Show on LCD or Do some action as per your application
					// Value of variables will be between 0-255
										
				} else { //store serial data to buffer
					sbuffer[pos] = ch;
					pos++;
				}
    
  WiFiClient client;  //Instantiate WiFi object

    //Start or API service using our WiFi Client through PushingBox
    if (client.connect(WEBSITE, 80))
      { 
        client.print("GET /pushingbox?devid=" + devid
       + "&BpTime=" + (String) BpTime
       + "&sysbp="  + (String) sysbp
       + "&diabp="  + (String) diabp
       + "&hbtime=" + (String) hbtime
       + "&heartbeat="+ (String) heartbeat
         );

      client.println(" HTTP/1.1"); 
      client.print("Host: ");
      client.println(WEBSITE);
      client.println("User-Agent: ESP8266/1.0");
      client.println("Connection: close");
      client.println();
      }
}

Credits

01bdcca554a75b61f460b0be98fda394
Jerin
0 projects • 4 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login