[error] arduino yun + temboo + DS18B20 sensor

Hello everybody,

I’ve made a code to send some data to google spreadsheet via temboo. I’m using 2 DHT21 and it works nice, but when adding a DS18B20 thermometer to this code, I get a temboo error report.

I found that the problem begins when this lines are added:

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

It runs, but temboo does not send data to google spreadsheet.

I’m not a experienced programmer, any help is welcome!!

Here is the working code:

// Include required libraries
#include <Bridge.h>
#include <Temboo.h>
#include <Process.h>
#include <Console.h>
#include <Wire.h>

const unsigned long RUN_INTERVAL_MILLIS = 60000*10; // how often to run the Choreo (in milliseconds)

// the last time we ran the Choreo
// (initialized to 60 seconds ago so the
// Choreo is run immediately when we start up)
unsigned long lastRun = (unsigned long)-60000*10;

// Contains Temboo account information
#include “TembooAccount.h”

// Variables

float h_in;
float t_in;
float h_out;
float t_out;
unsigned long time;

float temperature_limit; // IN

// Process to get the measurement time
Process date;

// Your Google Docs data
const String GOOGLE_USERNAME = “xxxxxxxxx@gmail.com”;
const String GOOGLE_PASSWORD = “xxxxxxxxxxxxxxx”;
const String SPREADSHEET_TITLE = “xxxxx”;
const String TO_EMAIL_ADDRESS = “xxxxxxxxx@gmail.com”;

// Include required libraries
#include “DHT.h”

// DHT11 sensor pins
#define DHT1PIN 2 //IN
#define DHT2PIN 3 // OUT
#define DHT1TYPE DHT21
#define DHT2TYPE DHT21

int Mist_Maker = 11;

DHT dht1(DHT1PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT2TYPE);

// Debug mode ?
boolean debug_mode = false;

void setup() {

// Start Serial
if (debug_mode == true){
Serial.begin(9600);
Console.begin();
pinMode(Mist_Maker, OUTPUT);
digitalWrite(Mist_Maker, HIGH);
delay(4000);
while(!Serial);
while(!Console);
}

// Initialize DHT sensor
dht1.begin();
dht2.begin();

// Set temperature limit
temperature_limit = 33.0;

// Start bridge
Bridge.begin();

// Start date process
time = millis();
if (!date.running()) {
date.begin(“date”);
date.addParameter("+%D-%T");
date.run();
}

if (debug_mode == true){
Serial.println(“Setup complete. Waiting for sensor input…\n”);
}

}

void loop() {

// Measure the humidity & temperature
h_in = dht1.readHumidity();
t_in = dht1.readTemperature();
h_out = dht2.readHumidity();
t_out = dht2.readTemperature();

Console.print(t_in);
Console.print(" C / “);
Console.print(h_in);
Console.println(” %\t");

if(h_in < 50){

digitalWrite(Mist_Maker, LOW);} // liga desumidificador

if (h_in > 70){

digitalWrite(Mist_Maker, HIGH);} // desliga desumidificador

unsigned long now = millis();

if (debug_mode == true){
Serial.println("\nCalling the /Library/Google/Spreadsheets/AppendRow Choreo…");
}

if (now - lastRun >= RUN_INTERVAL_MILLIS) {

// remember ‘now’ as the last time we ran the choreo
lastRun = now;

// Append data to Google Docs sheet
runAppendRow(h_in, t_in, h_out, t_out);}

// Send email alert ?
if (t_in > temperature_limit) {
if (debug_mode == true){Serial.println(“Sending alert”);}
sendTempAlert(“Temperature is too High!”);

}

}

// Function to add data to Google Docs
void runAppendRow(float h_in, float t_in, float h_out, float t_out) {
TembooChoreo AppendRowChoreo;

// Invoke the Temboo client
AppendRowChoreo.begin();

// Set Temboo account credentials
AppendRowChoreo.setAccountName(TEMBOO_ACCOUNT);
AppendRowChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
AppendRowChoreo.setAppKey(TEMBOO_APP_KEY);

// Identify the Choreo to run
AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow");

// your Google username (usually your email address)
AppendRowChoreo.addInput(“Username”, GOOGLE_USERNAME);

// your Google account password
AppendRowChoreo.addInput(“Password”, GOOGLE_PASSWORD);

// the title of the spreadsheet you want to append to
AppendRowChoreo.addInput(“SpreadsheetTitle”, SPREADSHEET_TITLE);

// Restart the date process:
if (!date.running()) {
date.begin(“date”);
date.addParameter("+%D-%T");
date.run();
}

// Get date
String timeString = date.readString();

// Format data
String data = “”;
data = data + timeString + “,” + String(h_in) + “,” + String(t_in) + “,” + String(h_out) + “,” + String(t_out);

// Set Choreo inputs
AppendRowChoreo.addInput(“RowData”, data);

// Run the Choreo
unsigned int returnCode = AppendRowChoreo.run();

// A return code of zero means everything worked
if (returnCode == 0) {
if (debug_mode == true){
Serial.println(“Completed execution of the /Library/Google/Spreadsheets/AppendRow Choreo.\n”);
}
} else {
// A non-zero return code means there was an error
// Read and print the error message
while (AppendRowChoreo.available()) {
char c = AppendRowChoreo.read();
if (debug_mode == true){ Serial.print(c); }
}
if (debug_mode == true){ Serial.println(); }
}
AppendRowChoreo.close();

}

// Send email alert
void sendTempAlert(String message) {

if (debug_mode == true){ Serial.println(“Running SendAnEmail…”);}

TembooChoreo SendEmailChoreo;

SendEmailChoreo.begin();

// set Temboo account credentials
SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);

// identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");

// set the required choreo inputs
// see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/
// for complete details about the inputs for this Choreo

// the first input is your Gmail email address
SendEmailChoreo.addInput(“Username”, GOOGLE_USERNAME);
// next is your Gmail password.
SendEmailChoreo.addInput(“Password”, GOOGLE_PASSWORD);
// who to send the email to
SendEmailChoreo.addInput(“ToAddress”, TO_EMAIL_ADDRESS);
// then a subject line
SendEmailChoreo.addInput(“Subject”, “ALERT: Home Temperature”);

// next comes the message body, the main content of the email
SendEmailChoreo.addInput(“MessageBody”, message);

// tell the Choreo to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// was able to send our request to the Temboo servers
unsigned int returnCode = SendEmailChoreo.run();

// a return code of zero (0) means everything worked
if (returnCode == 0) {
if (debug_mode == true){Serial.println(“Success! Email sent!”);}
} else {
// a non-zero return code means there was an error
// read and print the error message
while (SendEmailChoreo.available()) {
char c = SendEmailChoreo.read();
if (debug_mode == true){Serial.print(c);}
}
}
SendEmailChoreo.close();
}

Solved!

Deleting the email notification part.

thanks to Andrew_Maryland

Hi there, I work for Temboo.

If you run into any other memory issues, you could look at using a profile for your credentials. A profile allows you to simply reference your credentials from your sketch without including all of the String data that consumes memory. You can learn more about that approach here:

You can also free up some memory by putting the inputs that don't change (your Temboo credentials, your Google credentials, your output filter specifications, the Choreo to run) into a settings file on a micro SD card, as described here:

If you have any questions, feel free to contact us via email (support AT temboo.com) - we're always happy to help.