Blynk + Temboo + Arduino YUN

Hi, there

I am working on my IoT project. As title,I want to combine Blynk + Temboo + Arduino YUN. I’ve already done the Blynk+ Arduino YUN one and the Temboo + Arduino YUN (spreadsheet choreo & gmail choreo) one. They both work well “separately”. I open my temboo sketch which is the combination of gmail choreo & spreadsheet choreo, and as long as I include the < B l y n k S i m p l e Y u n . h > thing (just one line ----> #include< B l y n k S i m p l e Y u n . h >) it can’t work! :sob: I mean, it can compile and upload to my YUN board. But the email and data can’t send to my mailbox and spreadsheet. I have no idea why it can’t work, please help me.:cry:

PS, I’m not a native speaker so if there was something wrong please forgive me.

  1. Check if Blynk Yun example sketch works for you.
  2. Temboo questions should go to Temboo forum

Always start simple, then combine. Also post your sketch

Hi, Pavel, here’s my sketch and the Blynk Yun exemple do works for me.
I am wondering if there is any conflict between the Blynk sketch and the Temboo ones.
Thanks for replying. I will post it to the Temboo forum too.

#include < Ultrasonic.h >
#include < OneWire.h >
#include < DallasTemperature.h >
#include < Bridge.h >
#include < Temboo.h >
#include “TembooAccount.h”
#include < Servo.h >
#include < Process.h >
#include < BlynkSimpleYun.h >
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
Process date;
#define ONE_WIRE_BUS 7
const int PinIN1 = 8;
const int PinIN2 = 9;
const int PinIN3 = 10;
const int PinIN4 = 11;
#define TRIGPIN 12
#define ECHOPIN 13
//----------------------------------------------------------------------------
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
Ultrasonic ultrasonic(TRIGPIN, ECHOPIN);
Servo myservo;
//------------------------------------------------------------------------------
const unsigned long RUN_INTERVAL_MILLIS = 60000;
unsigned long lastRun = (unsigned long) - RUN_INTERVAL_MILLIS;
//-------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
sensors.begin();
pinMode(PinIN1, OUTPUT);
pinMode(PinIN2, OUTPUT);
pinMode(PinIN3, OUTPUT);
pinMode(PinIN4, OUTPUT);
pinMode(5, OUTPUT);
myservo.attach(6, 800, 2400);
char auth[] = “”;
Blynk.begin(auth);
while (Blynk.connect() == false) {} //wait until connected
delay(4000);
while (!Serial);
Bridge.begin();
}

void loop()
{
// ---------------------------------------------------------------------
sensors.requestTemperatures();
float temperature = sensors.getTempCByIndex(0);
if (temperature > 29) //如果溫度大於 29 度,啟動風扇
{
digitalWrite(8, LOW);
digitalWrite(11, HIGH);
}
else
{
digitalWrite(8, HIGH);
digitalWrite(11, LOW);
}
// --------------------------------------------------------------
float height = 15.75; // 水族箱高度
long microsec = ultrasonic.timing();
float cm = ultrasonic.convert(microsec, Ultrasonic::CM); // 感測到的距離,單位: 公分
float waterlevel = height - cm; // 計算水位高度
//------------------------------------------------------------------------
float brightness = analogRead(A0);
while (brightness <= 20) {
digitalWrite(9, HIGH);
delay(3000);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
delay(3000);
}
//--------------------------------------------------------------------------------
blynk (temperature, waterlevel);

unsigned long now = millis();
if (now - lastRun >= RUN_INTERVAL_MILLIS) {
lastRun = now;
Feed();
saveData( temperature, waterlevel, brightness );
}
}
//----------------------------------------------------------------------------------
void Feed() {
for (int i = 2400; i >= 800; i -= 300) {
myservo.writeMicroseconds(i);
delay(300);
}
for (int i = 800; i <= 2400; i += 300) {
myservo.writeMicroseconds(i);
delay(300);
}
//---------------------------------------------------------------------------
Serial.println(“Running SendAnEmail…”);
TembooChoreo SendEmailChoreo;
SendEmailChoreo.begin();
const String GMAIL_USER_NAME = "k55466909@gmail.com";
const String GMAIL_PASSWORD = “”;
const String TO_EMAIL_ADDRESS = "k55466909@gmail.com";
SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);
SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");
SendEmailChoreo.addInput(“Username”, GMAIL_USER_NAME);
SendEmailChoreo.addInput(“Password”, GMAIL_PASSWORD);
SendEmailChoreo.addInput(“ToAddress”, TO_EMAIL_ADDRESS);
SendEmailChoreo.addInput(“Subject”, “自動化養殖”);
SendEmailChoreo.addInput(“MessageBody”, “自動餵食機剛剛餵食了一次”);
if (SendEmailChoreo.run() == 0) {
Serial.println(“Success! Email sent!”);
} else {
while (SendEmailChoreo.available()) {
char c = SendEmailChoreo.read();
Serial.print©;
}
}
SendEmailChoreo.close();
}
//------------------------------------------------------------------------------------------
void saveData(float temperature, float waterlevel, float brightness) {
//Get date-------------------------------------------------------------------------
date.begin("/bin/date");
date.addParameter("+%d/%m/%Y %T");
date.run();
//String------------------------------------------------------------------------------
String rowData;
rowData += String(date.readString()) + “,” + String(temperature) + “,” + String(brightness) + “,” + String(waterlevel);
//------------------------------------------------------------------------------------
Serial.println(“Appending value to spreadsheet…”);
TembooChoreo AppendRowChoreo;
AppendRowChoreo.begin();
const String CLIENT_ID = “430501448281-jama7h23kbj3dba2hvtlkehhf1oo2nc1.apps.googleusercontent.com”;
const String CLIENT_SECRET = “”;
const String REFRESH_TOKEN = “”;
const String SPREADSHEET_TITLE = “chloe”;
AppendRowChoreo.setAccountName(TEMBOO_ACCOUNT);
AppendRowChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
AppendRowChoreo.setAppKey(TEMBOO_APP_KEY);
AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow");
AppendRowChoreo.addInput(“ClientID”, CLIENT_ID);
AppendRowChoreo.addInput(“ClientSecret”, CLIENT_SECRET);
AppendRowChoreo.addInput(“RefreshToken”, REFRESH_TOKEN);
AppendRowChoreo.addInput(“SpreadsheetTitle”, SPREADSHEET_TITLE);
AppendRowChoreo.addInput(“RowData”, rowData );
if (AppendRowChoreo.run() == 0) {
Serial.println(“Success! Appended " + rowData);
Serial.println(”");
} else {
while (AppendRowChoreo.available()) {
char c = AppendRowChoreo.read();
Serial.print©;
}
}
AppendRowChoreo.close();
}
//------------------------------------------------------------------------------------------

void blynk (float temperature, float waterlevel) {
Blynk.virtualWrite(V0, temperature);
Blynk.virtualWrite(V1, waterlevel);
}

1. Did you follow my recommendations? [quote=“Pavel, post:2, topic:8291”]
Check if Blynk Yun example sketch works for you.
[/quote]

2. Code snippets should be formatted. Edit your post

Wrap the code by adding 3 Backtick: ``` symbols:

Example:

 ``` cpp <--put 3 backticks BEFORE your code starts  (cpp means C++ language) 

   //Put your code here
   //..................
   //..................

 ``` <--insert 3 backticks AFTER your code

**This makes your code readable and with highlighted syntax, like this:**
//comment goes here 
void helloWorld() { 
   String message =  "hello" + "world"; 
}
1 Like