Thank you all for your help thus far, especially UKHeliBob!
PaulS: For your leasure reading: Pulitzer Prize Winning Article
We have now integrated our IR Sensor:
Here is our code:
#include <Wire.h>
#include "WireExt.h"
int ignition_LED = 12 ; // Ignition/weight LED connected to digital pin
int weight_LED = 11; // Ignition/weight
int ignition_input = 7; // Ignition/weight pushbutton connected to digital pin 7
int weight_input = 2; // Ignition/weight
int ignition_val = 0; // Ignition/weight variable to store the read value
int weight_val = 0; // Ignition/weight
int i; //IR Sensor
#define D6T_addr 0x0A // Address of OMRON D6T is 0x0A in hex //IR Sensor
#define D6T_cmd 0x4C // Standard command is 4C in hex //IR Sensor
int rbuf[35]; // Actual raw data is coming in as 35 bytes. Hence the needed for WireExt so that we can handle more than 32 bytes //IR Sensor
int tdata[16]; // The data comming from the sensor is 16 elements, in a 16x1 array //IR Sensor
float t_PTAT; //IR Sensor
void setup()
{
pinMode(ignition_LED, OUTPUT); // Ignition/weight sets the digital pin 13 as output
pinMode(weight_LED,OUTPUT); // Ignition/weight
pinMode(ignition_input, INPUT); // Ignition/weight sets the digital pin 7 as input
pinMode(weight_input, INPUT); // Ignition/weight
Wire.begin(); //IR Sensor
pinMode(13, OUTPUT); //IR Sensor
Serial.begin(9600);
}
void loop()
{
if (digitalRead(ignition_input) == HIGH) // Ignition/weight
{
Serial.println("Ignition Off");// Ignition/weight
}
else // Ignition/weight
{
Serial.println("Ignition On");// Ignition/weight
}
if (digitalRead(weight_input) == HIGH) // Ignition/weight
{
Serial.println("Adult Present");// Ignition/weight
}
else // Ignition/weight
{
Serial.println("Adult Not Present"); // Ignition/weight
delay(1000);// Ignition/weight
}
if ((digitalRead(ignition_input) == HIGH) && (digitalRead(weight_input) == LOW)) // Ignition/weight
{
Serial.println("Initialize Sensing"); // Ignition/weight
}
else // Ignition/weight
{
Serial.println("Do Not Sense"); // Ignition/weight
delay(4000); // Ignition/weight
}
Wire.beginTransmission(D6T_addr);//IR Sensor
Wire.write(D6T_cmd);//IR Sensor
Wire.endTransmission();//IR Sensor
if (WireExt.beginReception(D6T_addr) >= 0)//IR Sensor
{
i = 0;//IR Sensor
for (i = 0; i < 35; i++) //IR Sensor
{
rbuf = WireExt.get_byte();//IR Sensor
- }*
- WireExt.endReception();//IR Sensor*
t_PTAT = (rbuf[0] + (rbuf[1] << 8)) * 0.1; // Unclear what this is used for. It's not called elsewhere
- for (i = 0; i < 16; i++)//IR Sensor*
- {*
tdata = (rbuf[(i * 2 + 2)] + (rbuf[(i * 2 + 3)] << 8)) * 0.1; //IR Sensor
* }*
* }*
* // Data is captured into tdata. This should be a 16x1 data. For now we can output as a csv string which we can import to Matlab to sequence*
* for (i = 0; i < 4; i++) //IR Sensor*
* {*
_ Serial.print(tdata*); //IR Sensor*
* Serial.print(",");//IR Sensor*
* }
Serial.print("\n"); //IR Sensor*
* // Data is captured into tdata. This should be a 4x1 data. For now we can output as a csv string which we can import to Matlab to sequence*
* for (i = 4; i < 8; i++) //IR Sensor*
* {
Serial.print(tdata);//IR Sensor*
* Serial.print(",");//IR Sensor*
* }
Serial.print("\n");//IR Sensor*
* // Data is captured into tdata. This should be a 4x1 data. For now we can output as a csv string which we can import to Matlab to sequence*
* for (i = 8; i < 12; i++) //IR Sensor*
* {
Serial.print(tdata);//IR Sensor*
* Serial.print(",");//IR Sensor*
* }
Serial.print("\n");
// Data is captured into tdata. This should be a 4x1 data. For now we can output as a csv string which we can import to Matlab to sequence*
* for (i = 12; i < 16; i++) //IR Sensor*
* {
Serial.print(tdata);//IR Sensor*
* Serial.print(",");//IR Sensor*
* }
Serial.print("\n");//IR Sensor*
* Serial.print("\n");//IR Sensor*
* int CurrentLowestTemp = 999;//IR Sensor*
* int CurrentHighestTemp = 0;//IR Sensor*
* for (int i = 0; i < 16; i++) //IR Sensor*
* {
if (tdata < CurrentLowestTemp) //IR Sensor
{
CurrentLowestTemp = tdata;//IR Sensor*
* }
}
Serial.print("CurrentLowest: ");//IR Sensor*
* Serial.println(CurrentLowestTemp);//IR Sensor*_
* for (int i = 0; i < 16; i++)//IR Sensor*
* {*
_ if (tdata > CurrentHighestTemp)//IR Sensor
* {
CurrentHighestTemp = tdata;//IR Sensor*
* }
}
Serial.print("CurrentHighest: ");//IR Sensor*
* Serial.println(CurrentHighestTemp);//IR Sensor*_
// ("TempDiff")
* int TempDiff = CurrentHighestTemp - CurrentLowestTemp;*
* Serial.print("TempDiff: ");*
* Serial.print(TempDiff);*
* Serial.println();*
* if (TempDiff > 0 && TempDiff < 4) {*
* Serial.print("Baby Not Present");*
* } else if (TempDiff >= 4) {*
* Serial.print("Baby Present");*
* Serial.println();*
* if ((digitalRead(ignition_input) == HIGH) && (digitalRead(weight_input) == LOW) && (digitalread() // Ignition/weight*
* {*
* Serial.println("Initialize Sensing"); // Ignition/weight*
* }*
* else // Ignition/weight*
* {*
* Serial.println("Do Not Sense"); // Ignition/weight*
* delay(4000); // Ignition/weight*
* }*
* delay(4000);*
}
*Now we are attempting to add our SMS Text Portion: *
If: Ignition is off
and: Adult Not Present
and: Baby Present
then send SMS.
Here is our code for the SMS, that we had working independently on another computer, but now for some reason, we can't get it working again. This code is for the SMS alone. We can't get it to work now, and we are trying to get it to work before we add it to the other code.
#include <Ciao.h>
/*
This example show the interaction between the Ciao Library and the Thingspeak Cloud.
To run the example you need to register an account on thingspeak.com and create a
new channel by clicking "Channels" section in the website (Channels -> My Channels -> New Channel).
In the new channel you need to add two fields. The first one refers to the humidity data and the second one to the temperature value.
After that, replace the "XXXXXXXXX" value of APIKEY_THINGSPEAK with "Write API key" value reported in the API Keys section of the channel.
*/
#include <Wire.h>
#include <Ciao.h>// if you are using the Arduino IDE 1.8.x then: //
#include <UnoWiFiDevEd.h>
#define CONNECTOR "rest"
#define SERVER_ADDR "api.thingspeak.com"
#define APIKEY_THINGSPEAK "H1Z9583M8FUCQBWO" //Insert your API Key
void setup() {
* Serial.begin(9600);*
* Ciao.begin(); // CIAO INIT*
* String uri = "/apps/thinghttp/send_request?api_key=";
uri += APIKEY_THINGSPEAK;*
* delay(20000); // Thinkspeak policy*
* Serial.println( "about to send: " + uri + to SERVER_ADDR);
_ Ciao.println("Send data on ThingSpeak Channel");*_
* CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);*
* if (data.isEmpty()){*
* Serial.println("Got no data");*
* } else {*
* Serial.println("Got data");*
* }*
* Serial.println( "Sent" );*
}
void loop() {
}
* And here are the error codes we are getting: *
In file included from C:\Users\Manager\Desktop\SMS_Code_Test\SMS_Code_Test.ino:1:0:
C:\Users\Manager\Documents\Arduino\libraries\arduino-library-ciao-master\src/Ciao.h:42:2: error: #error CPU not yet supported
#error CPU not yet supported
* ^*
exit status 1
Error compiling for board Arduino Uno WiFi.
*We googled it, and added Caio Library and Caio Core but we are finding some information on how to the "rest" to work and can't seem to understand what to do. *
Can you help?