//This Program was made with help from templates provided by the nesscery libaries that where needed for the sensors and for the wifi to work. These templates are
//Thingspeaks libaries and the write mutiple fields template
//Adafruit BME280 Libery and the BME280test template
//And Finally hp_BH1750 Libary and the bare minimum example
//With these libaries I've been able to make a function program that works with my sensors
//Whilst I understand the code may look simmilar this is because there are many options as sensors have unique liberys meaning that there are specific ways to intalise and use them meaning there is little room for customisation
//Also the header file for BME280 sensor had to be editied to change the address it was looking for to 76 instead of 77
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10
Adafruit_BME280bme;
#include <hp_BH1750.h>
hp_BH1750BH1750;
#include <WiFiNINA.h>
#include "secrets.h"
#include "ThingSpeak.h" // always include thingspeak header file after other header files and custom macros
charssid[]=SECRET_SSID;// your network SSID (name)
charpass[]=SECRET_PASS;// your network password
WiFiClientclient;
unsignedlongChannelNumber=SECRET_CH_ID;
constchar*WriteAPIKey=SECRET_WRITE_APIKEY;
// Initialize our values
//String myStatus = "";
voidsetup(){
Serial.begin(115200);// Initialize serial
boolavail=BH1750.begin(BH1750_TO_GROUND);// init the sensor with address pin connetcted to ground
while(!Serial){
;// wait for serial port to connect. Needed for Leonardo native USB port only
}
Serial.println(F("BME280 test"));
unsignedstatus;
status=bme.begin();
if(!status){
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");