Springen naar inhoud


Arduino

Mega+Wifi R3 Atmega2560+Esp8266, Flash 32Mb, Usb-Ttl Ch340G, Micro-Usb



  • Log in a.u.b. om te beantwoorden
Geen reacties in dit onderwerp

#1 barremans

barremans

    Professional Developer

  • Leden
  • PipPipPipPip
  • 269 berichten
    Laatst bezocht 04 nov 2019 13:53
  • LocatieKortrijk

Geplaatst op 12 oktober 2019 - 16:41

Haidi,

Ik heb een
MEGA+WiFi R3 ATmega2560+ESP8266, flash 32MB, USB-TTL CH340G, Micro-USB

https://robotdyn.com...-micro-usb.html

Ik krijg dit ding maar niet aan de praat.
Met mijn wemos D1 R2 krijg ik werkt mijn code.

omdat de uno beperkt in analoge inputs heb ik besloten om een ATmega te gebruiken.

dit is de code die ik momenteel gebruik

Code:
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include "Adafruit_SI1145.h"
#include "Adafruit_Si7021.h"

Adafruit_BMP280 bme; // I2C
Adafruit_Si7021 sensor = Adafruit_Si7021();
Adafruit_SI1145 uv = Adafruit_SI1145();
//SSID of your network
const char* ssid  = "************"; //SSID of your Wi-Fi router
const char* password = "***********";  //Password of your Wi-Fi router
const char* host = "z***********";
int LDRsensor = A0;
void setup()
{
  Serial.begin(115200);
	// Connect WiFi
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.hostname("Name");
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
	delay(500);
	Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Print the IP address
  Serial.print("IP address: ");
  Serial.print(WiFi.localIP());
  Serial.print('\n');
delay(500);

Serial.println("BMP280 and SI7021 (GY-21p) test");
  Serial.print('\n');
Serial.println("Adafruit SI1145 test");

if (!bme.begin())
{
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
   if (! uv.begin()) {
	Serial.println("Didn't find Si1145");
	while (1);
  }


}

void loop()
{
  Serial.print('\n');
  Serial.print("connecting to ");
  Serial.println(host);
 
  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
	Serial.println("connection failed");
	return;
  }
 
Serial.println("BMP280 results");
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure()/100);
Serial.println(" HPa");
Serial.print("Approx altitude = ");
Serial.print(bme.readAltitude(1013.27)); // 1013.25this should be adjusted to your local forcase
Serial.println(" m");
Serial.println();
Serial.println("===================");
Serial.println("SI7021 results");
Serial.print("Humidity: ");
Serial.println(sensor.readHumidity(), 2);
Serial.print("Temperature: ");
Serial.println(sensor.readTemperature(), 2);
Serial.println();
  Serial.println("===================");
  Serial.print("Vis: "); Serial.println(uv.readVisible());
  Serial.print("IR: "); Serial.println(uv.readIR());
 
  // Uncomment if you have an IR LED attached to LED pin!
  //Serial.print("Prox: "); Serial.println(uv.readProx());
  float UVindex = uv.readUV();
  // the index is multiplied by 100 so to get the
  // integer index, divide by 100!
  UVindex /= 100.0;
  // the index is multiplied by 100 so to get the
  // integer index, divide by 100!
  Serial.print("UV: ");  Serial.println(UVindex);
  Serial.println();
  Serial.println("===================");
  double gamma = log(sensor.readHumidity()/ 100) + ((17.62 * sensor.readTemperature()) / (243.5 + sensor.readTemperature()));
  double dp = 243.5 * gamma / (17.62 - gamma);
	Serial.print("Dew point = ");
  Serial.print(dp);
  Serial.print(" *Celcius ");
  Serial.println();
	Serial.println("===================");
	Serial.print("Lux = ");
  Serial.print(analogRead(LDRsensor));
  Serial.print(" Lux ");
  Serial.println();
	Serial.println("===================");
   
// float data
int locid = 1;
int sensid = 1;
float t1 = sensor.readTemperature();
float h1 = sensor.readHumidity();
float p1 = bme.readPressure() / 100;
float at1 = bme.readAltitude(1013.27);
float dew1 = dp;
float vis1 = uv.readVisible();
float ir1 = uv.readIR();
float lux = (analogRead(LDRsensor)); // read the value from the sensor
//float soil1 =
// float lux1 =
  // We now create a URI for the request
String url = "/Temp/addV3.php";
url +="?locid=";
url += 1;
url +="&sensid=";
url += 1;
url +="&temp1=";
url += t1;
url += "&hum1=";
url += h1; 
url += "&press1=";
url += p1;
url += "&at1=";
url += at1;
url += "&dew1=";
url += dew1;
url += "&vis1=";
url += vis1;
url += "&ir1=";
url += ir1;
url += "&lux1=";
url += lux;
url += "&uv1=";
url += UVindex;			  
Serial.print("Requesting URL: ");
Serial.println(url);
  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
			   "Host: " + host + "\r\n" +
			   "Connection: close\r\n\r\n");
   delay(10);
 
  // Read all the lines of the reply from server and print them to Serial
  while(client.available()){
	String line = client.readStringUntil('\r');
	Serial.print(line);
  }
 
  Serial.println();
  Serial.println("closing connection");
delay(900000); //900 000 15min
}


Heeft er iemand ervaring met dit bord? of hoe arduino met een ESP werkt?

grtz
Barre





Ook met taq Arduino voorzien

0 gebruiker(s) lezen dit onderwerp

0 lid(leden), 0 bezoeker(s), 0 anonieme gebruikers

Inloggen


[Arduino] Untitled 1

Met dank aan J├╝rgen voor de jarenlange inzet van visualbasic.be (anno dec 2000)
Met dank aan Mike en Ronneke voor de jarenlange inzet van vbib.be (anno dec 2010)
Met dank aan PascalBianca voor de jarenlange inzet van vbib.be (anno dec 2016)